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

b-value out of bounds

DocKDE opened this issue · comments

I think I have reported this earlier and misinterpreted this somewhat.
I noticed that when validate_pdb() is called on a sample PDB of mine and the resulting vec printed out, a lot of warnings are shown that say:

LooseWarning: Atom b factor out of bounds

Atom 24628 has a b factor which is out of bounds, max is 999.99 min is 0.00.

However, none of my b factors are actually below 0.00 or above 999.99.

Can you show the B value for this specific atom? Just so that I can verify what value it actually has?

It should only print that message if the value is < 0.01 (but not 0.00) or > 999.99. This lower bound is because the PDB file format can only have 2 decimal places, but since your last issue I added the part where it can be equal to 0.00 and not give this message. So I think I should change the message to something more descriptive for the lower bounds.

As tested in the code just pushed the following PDB file parses just fine and gives zero errors for normal and PDB validation. Also the full values are parsed correctly, so that should not introduce any problems.

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      3  C   HIS A 465      33.549 -10.658   8.347  1.00999.99           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  
ATOM      8  CD2 HIS A 465      35.297  -8.322   5.762999.99 49.56           C  

I look forward to receiving the values you use in your script so that we can find the root cause of this error. Keep in mind that if you change these factors anywhere in your program that could be a place where this error starts. Also as the error message has only a strictness level of 'Loose' it should not stall the execution of your program, there should be another error message somewhere that has a higher strictness level.

The b value for all atoms (as far as I can tell) where this happens is 0.00. I'm attaching the file I'm using so you can verify yourself.
myfile.zip
Also the validation happens just after opening the pdb file so no editing or other manipulation has happened at that point. You're correct, this is no breaking issue for me but it seemed to be unintended behaviour to me so I wanted to report it :)

Okay, had to figure out how to make use of a local crate but I just checked with the commits you made and now no warnings are displayed when validating the pdb. Thanks for fixing it so prompty!

It works in the newest version of my code (see below, this passes). But I think I found the problem, I added the new validations only after the most recent version increase (to be precise in c362874). So that makes it logical that you got the errors while for me it worked. I will upload a new version with this fix ASAP.

use pdbtbx::*;
use std::env;
use std::path::Path;

#[test]
fn verify_56() {
    let filename = env::current_dir()
        .unwrap()
        .as_path()
        .join(Path::new("example-pdbs"))
        .join(Path::new("myfile.pdb"))
        .into_os_string()
        .into_string()
        .unwrap();

    let (pdb, errors) = pdbtbx::open(&filename, StrictnessLevel::Strict).unwrap();
    let pdb_errors = validate_pdb(&pdb);
    println!("{:?}", errors);
    println!("{:?}", pdb_errors);
    assert_eq!(errors.len(), 0);
    assert_eq!(pdb_errors.len(), 0);
}

The new version should be up by now. And thanks for raising the issue!