You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Traceback (most recent call last):
File "/YYYYYYY", line 5, in <module>
pdb.PDBFile.read("1atp_charged.pdb").get_structure(
File "/XXXXXX/biotite/structure/io/pdb/file.py", line 400, in get_structure
"charge", np.where(charge == " ", "0", charge).astype(int)
ValueError: invalid literal for int() with base 10: '2+'
Root cause analysis
The PDB format specification explicitly state that Columns 79 - 80 indicate any charge on the atom, e.g., 2+, 1-. In most cases, these are blank..
Biotite consequently reverses the charge column before parsing in io/pdb/file.py:370:
charge_raw[i] =line[_charge][::-1]
Unfortunately, REFMAC (and possibly others?) seems to store charges as follows (notice the +2 instead of 2+, here):
This notation violates the PDB format specification and breaks parsing with biotite as the reversed charge columns 2+ cannot be converted to an integer, hence the stack trace above.
Possible mitigation and corresponding motivation
Adding support for non-standard PDB files might be beyond the scope of biotite. However, in this particular case, the fix should have no side effect and would allow biotite users to load their files.
Hi!
Thanks for your great work! Here's a small bug report:
Context
I have a problem parsing PDB files that were apparently written with REFMAC 5.8.0258.
Symptom
After this file is loaded (as
pdb_file
), a call to.get_structure(altloc="all", extra_fields=["charge"])
fails.Ie. the following code:
leads to the following error:
Root cause analysis
The PDB format specification explicitly state that
Columns 79 - 80 indicate any charge on the atom, e.g., 2+, 1-. In most cases, these are blank.
.Biotite consequently reverses the charge column before parsing in io/pdb/file.py:370:
Unfortunately, REFMAC (and possibly others?) seems to store charges as follows (notice the
+2
instead of2+
, here):This notation violates the PDB format specification and breaks parsing with biotite as the reversed charge columns
2+
cannot be converted to an integer, hence the stack trace above.Possible mitigation and corresponding motivation
Adding support for non-standard PDB files might be beyond the scope of biotite. However, in this particular case, the fix should have no side effect and would allow biotite users to load their files.
The line
io/pdb/file.py:370
Would have to be replaced by:
If you agree, I can make a PR?
The text was updated successfully, but these errors were encountered: