1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45
|
"""
Tests for the PDBML parser in the PDB package.
These tests rely on the principle that the structure returned by the PDBML parser should be the same as the structure
returned by the mmCIF parser for any PDB structure.
"""
import unittest
import warnings
from Bio.PDB import MMCIFParser
from Bio.PDB import PDBMLParser
from Bio.PDB.PDBExceptions import PDBConstructionWarning
class TestPDBMLParser(unittest.TestCase):
def test_get_structure(self):
mmcif_parser = MMCIFParser()
pdbml_parser = PDBMLParser()
with warnings.catch_warnings():
warnings.simplefilter("ignore", PDBConstructionWarning)
for entry in ["1GBT", "6WG6", "3JQH"]:
mmcif_structure = mmcif_parser.get_structure(entry, f"PDB/{entry}.cif")
pdbml_structure = pdbml_parser.get_structure(f"PDB/{entry}.xml")
self.assertEqual(mmcif_structure, pdbml_structure)
def test_get_structure_filehandle(self):
mmcif_parser = MMCIFParser()
pdbml_parser = PDBMLParser()
with warnings.catch_warnings():
warnings.simplefilter("ignore", PDBConstructionWarning)
for entry in ["1GBT"]:
with (
open(f"PDB/{entry}.cif") as mmcif_file,
open(f"PDB/{entry}.xml") as pdbml_file,
):
mmcif_structure = mmcif_parser.get_structure(entry, mmcif_file)
pdbml_structure = pdbml_parser.get_structure(pdbml_file)
self.assertEqual(mmcif_structure, pdbml_structure)
if __name__ == "__main__":
unittest.main()
|