diff --git a/modules/atom/test/input/atomtype.cif b/modules/atom/test/input/atomtype.cif new file mode 100644 index 0000000000..ac52c80cd4 --- /dev/null +++ b/modules/atom/test/input/atomtype.cif @@ -0,0 +1,29 @@ +loop_ +_atom_site.group_PDB +_atom_site.id +_atom_site.type_symbol +_atom_site.label_atom_id +_atom_site.label_alt_id +_atom_site.label_comp_id +_atom_site.label_asym_id +_atom_site.label_entity_id +_atom_site.label_seq_id +_atom_site.pdbx_PDB_ins_code +_atom_site.Cartn_x +_atom_site.Cartn_y +_atom_site.Cartn_z +_atom_site.occupancy +_atom_site.B_iso_or_equiv +_atom_site.pdbx_formal_charge +_atom_site.auth_seq_id +_atom_site.auth_comp_id +_atom_site.auth_asym_id +_atom_site.auth_atom_id +_atom_site.pdbx_PDB_model_num +ATOM 1 C CA . ALA A 1 1 ? 953.312 704.510 700.259 1.00 84.31 ? 1 ALA A CA 1 +ATOM 2 C CB . GLN A 1 2 ? 862.521 620.909 612.377 1.00 10.00 ? 2 GLN A CA 1 +ATOM 3 C C . GLN A 1 3 ? 862.521 620.909 612.377 1.00 10.00 ? 3 GLN A CA 1 +ATOM 4 O O . ALA A 1 4 ? 953.312 704.510 700.259 1.00 84.31 ? 4 ALA A CA 1 +ATOM 5 N N . GLN A 1 5 ? 862.521 620.909 612.377 1.00 10.00 ? 5 GLN A CA 1 +ATOM 6 P P . DG B 2 1 ? 862.521 620.909 612.377 1.00 10.00 ? 6 DG B P 1 +HETATM 7 CA CA . CA C 3 . ? 862.521 620.909 612.377 1.00 10.00 ? 7 CA C CA 1 diff --git a/modules/atom/test/input/water.cif b/modules/atom/test/input/water.cif new file mode 100644 index 0000000000..4b42348da2 --- /dev/null +++ b/modules/atom/test/input/water.cif @@ -0,0 +1,26 @@ +loop_ +_atom_site.group_PDB +_atom_site.id +_atom_site.type_symbol +_atom_site.label_atom_id +_atom_site.label_alt_id +_atom_site.label_comp_id +_atom_site.label_asym_id +_atom_site.label_entity_id +_atom_site.label_seq_id +_atom_site.pdbx_PDB_ins_code +_atom_site.Cartn_x +_atom_site.Cartn_y +_atom_site.Cartn_z +_atom_site.occupancy +_atom_site.B_iso_or_equiv +_atom_site.pdbx_formal_charge +_atom_site.auth_seq_id +_atom_site.auth_comp_id +_atom_site.auth_asym_id +_atom_site.auth_atom_id +_atom_site.pdbx_PDB_model_num +ATOM 1 C CA . ALA A 1 1 ? 953.312 704.510 700.259 1.00 84.31 ? 1 ALA A CA 1 +ATOM 2 H HA . ALA A 1 2 ? 953.312 704.510 700.259 1.00 84.31 ? 2 ALA A HA 1 +HETATM 3 O O . HOH B 2 . ? 862.521 620.909 612.377 1.00 10.00 ? 3 HOH B O 1 +HETATM 4 O O . HOH B 2 . ? 862.521 620.909 612.377 1.00 10.00 ? 4 HOH B O 1 diff --git a/modules/atom/test/test_mmcif.py b/modules/atom/test/test_mmcif.py index 6f953064fd..17acfb64a2 100644 --- a/modules/atom/test/test_mmcif.py +++ b/modules/atom/test/test_mmcif.py @@ -200,6 +200,164 @@ def test_atom_selector(self): self.assertEqual([IMP.atom.Residue(x).get_index() for x in residues], [68, 287, 287, 287, 287]) + def test_calpha_selector(self): + """Check CAlphaPDBSelector when reading mmCIF files""" + m = IMP.Model() + + mp = IMP.atom.read_mmcif(self.get_input_file_name('atomtype.cif'), m, + IMP.atom.CAlphaPDBSelector()) + residues = IMP.atom.get_by_type(mp, IMP.atom.RESIDUE_TYPE) + # Only residue 1 contains a C-alpha (residue 6 is calcium, should + # be rejected) + self.assertEqual([IMP.atom.Residue(x).get_index() for x in residues], + [1]) + + def test_cbeta_selector(self): + """Check CBetaPDBSelector when reading mmCIF files""" + m = IMP.Model() + + mp = IMP.atom.read_mmcif(self.get_input_file_name('atomtype.cif'), m, + IMP.atom.CBetaPDBSelector()) + residues = IMP.atom.get_by_type(mp, IMP.atom.RESIDUE_TYPE) + # Only residue 2 contains a C-beta + self.assertEqual([IMP.atom.Residue(x).get_index() for x in residues], + [2]) + + def test_atom_type_selector(self): + """Check AtomTypePDBSelector when reading mmCIF files""" + m = IMP.Model() + + mp = IMP.atom.read_mmcif(self.get_input_file_name('atomtype.cif'), m, + IMP.atom.AtomTypePDBSelector(['CA', 'O'])) + residues = IMP.atom.get_by_type(mp, IMP.atom.RESIDUE_TYPE) + # Residue 1 is C-alpha; residue 4 is O; residue 7 is "CA" (calcium) + self.assertEqual([IMP.atom.Residue(x).get_index() for x in residues], + [1, 4, 7]) + + def test_residue_type_selector(self): + """Check ResidueTypePDBSelector when reading mmCIF files""" + m = IMP.Model() + + mp = IMP.atom.read_mmcif(self.get_input_file_name('atomtype.cif'), m, + IMP.atom.ResidueTypePDBSelector(['ALA'])) + residues = IMP.atom.get_by_type(mp, IMP.atom.RESIDUE_TYPE) + # Residues 1 and 4 are ALA + self.assertEqual([IMP.atom.Residue(x).get_index() for x in residues], + [1, 4]) + + def test_c_selector(self): + """Check CPDBSelector when reading mmCIF files""" + m = IMP.Model() + + mp = IMP.atom.read_mmcif(self.get_input_file_name('atomtype.cif'), m, + IMP.atom.CPDBSelector()) + residues = IMP.atom.get_by_type(mp, IMP.atom.RESIDUE_TYPE) + # Only residue 3 contains a C atom + self.assertEqual([IMP.atom.Residue(x).get_index() for x in residues], + [3]) + + def test_n_selector(self): + """Check NPDBSelector when reading mmCIF files""" + m = IMP.Model() + + mp = IMP.atom.read_mmcif(self.get_input_file_name('atomtype.cif'), m, + IMP.atom.NPDBSelector()) + residues = IMP.atom.get_by_type(mp, IMP.atom.RESIDUE_TYPE) + # Only residue 5 contains a N atom + self.assertEqual([IMP.atom.Residue(x).get_index() for x in residues], + [5]) + + def test_p_selector(self): + """Check PPDBSelector when reading mmCIF files""" + m = IMP.Model() + + mp = IMP.atom.read_mmcif(self.get_input_file_name('atomtype.cif'), m, + IMP.atom.PPDBSelector()) + residues = IMP.atom.get_by_type(mp, IMP.atom.RESIDUE_TYPE) + # Only residue 6 contains a P atom + self.assertEqual([IMP.atom.Residue(x).get_index() for x in residues], + [6]) + + def test_all_selector(self): + """Check AllPDBSelector when reading mmCIF files""" + m = IMP.Model() + + mp = IMP.atom.read_mmcif(self.get_input_file_name('nonalttest.cif'), m, + IMP.atom.AllPDBSelector()) + # All alternative locations should be selected + self.assertEqual(len(IMP.atom.get_leaves(mp)), 6) + + mp = IMP.atom.read_mmcif(self.get_input_file_name('atomtype.cif'), m, + IMP.atom.AllPDBSelector()) + # Both ATOM and HETATM records should be selected + self.assertEqual(len(IMP.atom.get_leaves(mp)), 7) + + def test_water_selector(self): + """Check WaterPDBSelector when reading mmCIF files""" + m = IMP.Model() + + mp = IMP.atom.read_mmcif(self.get_input_file_name('water.cif'), m, + IMP.atom.WaterPDBSelector()) + residues = IMP.atom.get_by_type(mp, IMP.atom.RESIDUE_TYPE) + # Residues 3, 4 are waters + self.assertEqual([IMP.atom.Residue(x).get_index() for x in residues], + [3, 4]) + + def test_hydrogen_selector(self): + """Check HydrogenPDBSelector when reading mmCIF files""" + m = IMP.Model() + + mp = IMP.atom.read_mmcif(self.get_input_file_name('water.cif'), m, + IMP.atom.HydrogenPDBSelector()) + residues = IMP.atom.get_by_type(mp, IMP.atom.RESIDUE_TYPE) + # Residue 2 only contains hydrogen + self.assertEqual([IMP.atom.Residue(x).get_index() for x in residues], + [2]) + + def test_non_water_non_hydrogen_selector(self): + """Check NonWaterNonHydrogenPDBSelector when reading mmCIF files""" + m = IMP.Model() + + mp = IMP.atom.read_mmcif(self.get_input_file_name('water.cif'), m, + IMP.atom.NonWaterNonHydrogenPDBSelector()) + residues = IMP.atom.get_by_type(mp, IMP.atom.RESIDUE_TYPE) + # Residue 1 contains CA (not water or hydrogen) + self.assertEqual([IMP.atom.Residue(x).get_index() for x in residues], + [1]) + + def test_non_hydrogen_selector(self): + """Check NonHydrogenPDBSelector when reading mmCIF files""" + m = IMP.Model() + + mp = IMP.atom.read_mmcif(self.get_input_file_name('water.cif'), m, + IMP.atom.NonHydrogenPDBSelector()) + residues = IMP.atom.get_by_type(mp, IMP.atom.RESIDUE_TYPE) + # Residue 1 contains CA, 3 and 4 are water oxygens + self.assertEqual([IMP.atom.Residue(x).get_index() for x in residues], + [1, 3, 4]) + + def test_non_water_selector(self): + """Check NonWaterPDBSelector when reading mmCIF files""" + m = IMP.Model() + + mp = IMP.atom.read_mmcif(self.get_input_file_name('water.cif'), m, + IMP.atom.NonWaterPDBSelector()) + residues = IMP.atom.get_by_type(mp, IMP.atom.RESIDUE_TYPE) + self.assertEqual([IMP.atom.Residue(x).get_index() for x in residues], + [1, 2]) + + def test_backbone_selector(self): + """Check BackbonePDBSelector when reading mmCIF files""" + m = IMP.Model() + + mp = IMP.atom.read_mmcif(self.get_input_file_name('atomtype.cif'), m, + IMP.atom.BackbonePDBSelector()) + residues = IMP.atom.get_by_type(mp, IMP.atom.RESIDUE_TYPE) + # Residue 2 is excluded because it only contains CB (non-backbone); + # residue 6 is excluded because its "CA" is calcium, not C-alpha + self.assertEqual([IMP.atom.Residue(x).get_index() for x in residues], + [1, 3, 4, 5]) + def test_chain_selector(self): """Check reading single chain from an mmCIF file""" m = IMP.Model()