douweschulte / pdbtbx

A library to open/edit/save (crystallographic) Protein Data Bank (PDB) and mmCIF files in Rust.

Home Page:https://crates.io/crates/pdbtbx

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Panic while parsing

bddap opened this issue · comments

While parsing the pdb file from https://www.rcsb.org/structure/2BTV

thread 'main' panicked at 'The given remark-type-number is not valid, see wwPDB v3.30 for valid remark-type-numbers', ~/.cargo/registry/src/github.com-1ecc6299db9ec823/pdbtbx-0.9.2/src/structs/pdb.rs:114:9
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

To reproduce:

pdbtbx::open_pdb_raw(
    std::io::BufReader::new(std::io::Cursor::new(include_bytes!("2btv.pdb"))),
    pdbtbx::Context::None,
    pdbtbx::StrictnessLevel::Loose,
);

assert!(reference_tables::valid_remark_type_number(remark_type), "The given remark-type-number is not valid, see wwPDB v3.30 for valid remark-type-numbers");

Thanks for raising the issue. I see that I missed the number 400 as a valid remark type number somehow. In the process I made the error message better in the future errors like this will look different and are printed with all other errors:

StrictWarning: Remark type number invalid
    ╷
446 │ REMARK 400 MOLECULE 2 HAS SEGID 2201, VP7Q MOLECULE 3 HAS SEGID 2301,
    ·        ───
    ╵
The remark-type-number is not valid, see wwPDB v3.30 for all valid numbers.

I also verified that there are no other issues with parsing this file. So you will be able to use this file for your work.

Awesome! The change both removes the panic and fixes parsing of that specific file. Thanks for getting to this so quickly.