Fix mmCIF parsing bug with underscores

* Allow underscore in non-first columns
* Add test case

Squashed commit of pull request #1349
This commit is contained in:
Joe Greener
2017-08-04 14:15:16 +01:00
committed by Peter Cock
parent 1fda0f6026
commit f2ab4d95d5
3 changed files with 22 additions and 1 deletions

View File

@ -38,7 +38,11 @@ class MMCIF2Dict(dict):
n = 0
continue
elif loop_flag:
if token.startswith("_"):
# The second condition checks we are in the first column
# Some mmCIF files (e.g. 4q9r) have values in later columns
# starting with an underscore and we don't want to read
# these as keys
if token.startswith("_") and (n == 0 or i % n == 0):
if i > 0:
loop_flag = False
else:

10
Tests/PDB/4Q9R_min.cif Normal file
View File

@ -0,0 +1,10 @@
data_4Q9R
loop_
_pdbx_audit_revision_item.ordinal
_pdbx_audit_revision_item.revision_ordinal
_pdbx_audit_revision_item.data_content_type
_pdbx_audit_revision_item.item
1 5 'Structure model' '_atom_site.B_iso_or_equiv'
2 5 'Structure model' '_atom_site.Cartn_x'
3 5 'Structure model' '_atom_site.Cartn_y'
4 5 'Structure model' '_atom_site.Cartn_z'

File diff suppressed because one or more lines are too long