Skip to content

Commit

Permalink
Fix auth_residues=False for MMCIFParser (biopython#4277)
Browse files Browse the repository at this point in the history
* fix warnings.warn calls
* add name to NEWS.rst
* tests for label res and chain in MMCIFParser
  • Loading branch information
jgreener64 committed Apr 5, 2023
1 parent a5b93f6 commit ca64586
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 6 deletions.
9 changes: 3 additions & 6 deletions Bio/PDB/MMCIFParser.py
Original file line number Diff line number Diff line change
Expand Up @@ -215,8 +215,7 @@ def _build_structure(self, structure_id):
except ValueError:
serial = atom_serial_list[i]
warnings.warn(
"PDBConstructionWarning: "
"Some atom serial numbers are not numerical",
"PDBConstructionWarning: Some atom serial numbers are not numerical",
PDBConstructionWarning,
)

Expand All @@ -239,8 +238,7 @@ def _build_structure(self, structure_id):
except (KeyError, IndexError):
msg = f"Non-existing residue ID in chain '{chainid}'"
warnings.warn(
"PDBConstructionWarning: ",
msg,
"PDBConstructionWarning: " + msg,
PDBConstructionWarning,
)
continue
Expand Down Expand Up @@ -530,8 +528,7 @@ def _build_structure(self, structure_id, filehandle):
except (KeyError, IndexError):
msg = f"Non-existing residue ID in chain '{chainid}'"
warnings.warn(
"PDBConstructionWarning: ",
msg,
"PDBConstructionWarning: " + msg,
PDBConstructionWarning,
)
continue
Expand Down
1 change: 1 addition & 0 deletions NEWS.rst
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ possible, especially the following contributors:
- Cam McMenamie
- Ricardas Ralys
- Vladislav Kuznetsov
- Joe Greener

12 February 2023: Biopython 1.81
===============================================
Expand Down
15 changes: 15 additions & 0 deletions Tests/test_PDB_MMCIFParser.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,21 @@ def test_parsers(self):
self.assertEqual(len(structure), 1)
self.assertEqual(len(f_structure), 1)

parser_lab_res = MMCIFParser(auth_residues=False, QUIET=True)
fast_parser_lab_res = FastMMCIFParser(auth_residues=False, QUIET=True)
parser_lab_chain = MMCIFParser(auth_chains=False, QUIET=True)
fast_parser_lab_chain = FastMMCIFParser(auth_chains=False, QUIET=True)

structure_lr = parser_lab_res.get_structure("example", "PDB/1A8O.cif")
f_structure_lr = fast_parser_lab_res.get_structure("example", "PDB/1A8O.cif")
structure_lc = parser_lab_chain.get_structure("example", "PDB/1A8O.cif")
f_structure_lc = fast_parser_lab_chain.get_structure("example", "PDB/1A8O.cif")

self.assertEqual(len(list(structure_lr.get_atoms())), 556)
self.assertEqual(len(list(f_structure_lr.get_atoms())), 556)
self.assertEqual(len(list(structure_lc.get_atoms())), 644)
self.assertEqual(len(list(f_structure_lc.get_atoms())), 644)

for ppbuild in [PPBuilder(), CaPPBuilder()]:
# ==========================================================
# Check that serial_num (model column) is stored properly
Expand Down

0 comments on commit ca64586

Please sign in to comment.