douweschulte / pdbtbx

A library to open/edit/save (crystallographic) Protein Data Bank (PDB) and mmCIF files in Rust.
https://crates.io/crates/pdbtbx
MIT License
53 stars 16 forks source link

Minimum b-factor value #50

Closed DocKDE closed 3 years ago

DocKDE commented 3 years ago

Hi again! Your fix for the TER statements works fine but I realized that another issue cropped up: I use the occupancy and b-value columns to assign atom to regions in QM/MM calculations. As such, most of the values are necessarily zero. I realize that this is contrary to the intended use of the b-value column but this behavior breaks my use case. I'm not sure what a good solution might be here. Maybe b-values of 0.00 could be allowed (with warnings shown perhaps) with StrictnessLevel::Loose for open_pdb? I'm currently in the process of refactoring my code to use this crate and it would be a pity if this excluded the possibility.

douweschulte commented 3 years ago

I do not remember coding anything anywhere that would prevent B factors or occupancies to be 0.00. I ran some tests and you can totally use atom.set_b_factor() and atom.set_occupancy() to set those properties to 0.0. And the following very minimal PDB file was parsed and saved successfully:

ATOM      2  CA  HIS A 465      34.226 -11.294   7.140  1.00  0.00           C  
ATOM      3  C   HIS A 465      33.549 -10.658   8.347  1.00  0.01           C  
ATOM      8  CD2 HIS A 465      35.297  -8.322   5.762  0.00 49.56           C  
ATOM      8  CD2 HIS A 465      35.297  -8.322   5.762  0.01 49.56           C  

If you have any error messages you could share with me I will dive into it, but otherwise I do not see any problem. Besides that the B factor column is 'misused' quite often for other things then the b factor, so the library should totally support any logical numerical value.

DocKDE commented 3 years ago

I swear this issue was real... I just ran my code again and it ran through without issue. Sorry for bothering you about this, I think I should maybe stop for today.