biotite-dev / biotite

A comprehensive library for computational molecular biology
https://www.biotite-python.org
BSD 3-Clause "New" or "Revised" License
582 stars 92 forks source link

Fail to load RCSB structure 1fs4 #522

Closed xvlaurent closed 5 months ago

xvlaurent commented 5 months ago

Hello!

When I tried to load RCSB structure 1fs4 the following error raise:

UserWarning: File contains invalid 'CRYST1' record, box is ignored
  warnings.warn(
Traceback (most recent call last):
  File "/home/ubuntu/3decision/master/dng-3dec-backend-core/test.py", line 6, in <module>
    pdbfile.get_structure(
  File "/home/ubuntu/.pyenv/versions/3.11.5/envs/dng-3dec-backend-core-master/lib/python3.11/site-packages/biotite/structure/io/pdb/file.py", line 519, in get_structure
    box[np.newaxis, ...], array.stack_depth(), axis=0
    ~~~^^^^^^^^^^^^^^^^^
TypeError: 'NoneType' object is not subscriptable

my exemple code:

from biotite.structure.io.pdb import PDBFile

pdbfile = PDBFile.read("1f4s.pdb")

pdbfile.get_structure(
            altloc="all", extra_fields=["atom_id", "b_factor", "occupancy", "charge"]
        )

Could someone check this please? Maybe a default box definition is misssing when CRYST1 keyword is empty?

Thanks by advance!

padix-key commented 5 months ago

Hi, thanks for finding and reporting this bug. Currently, invalid CRYST1 records are not handled correctly by Biotite and I created a fix for that. However, I still wonder how such CRYST1 record made it into the PDB in the first place, because it contradicts the PDB specification:

If the entry describes a structure determined by a technique other than X-ray crystallography, CRYST1 contains a = b = c = 1.0, alpha = beta = gamma = 90 degrees, space group = P 1, and Z = 1.