def test_double_coordinates_identification(self): """Should remove RNA ligand when there is no ribose and phosphate group.""" st3 = ModernaStructure('file', PDB_WITH_DOUBLE_COORDINATES) pc3 = PdbController(st3) self.assertEqual(len(pc3.disordered), 3) pc3.clean_structure() self.assertEqual(len(pc3.disordered), 3)
def test_phosphate_detection_and_removal(self): """Should detect pfosphate group (P, OP1, OP2, O5') in 3FU2 (resi 12) and remove it.""" st5 = ModernaStructure('file', PDB_WITH_PHOSPHATE) pc5 = PdbController(st5) self.assertEqual(len(pc5.phosphate), 1) pc5.clean_structure() self.assertEqual(len(pc5.phosphate), 0)
def test_ligand_removal(self): """Should remove RNA ligand from 3FU2 when there is no ribose and phosphate group.""" st2 = ModernaStructure('file', PDB_WITH_LIGAND) pc2 = PdbController(st2) self.assertEqual(st2.get_sequence(), Sequence('AGAGGUUCUAG_._CACCCUCUAUAAAAAACUAA_x_._._._._._._._._._._._._.')) pc2.clean_structure() self.assertEqual(st2.get_sequence(), Sequence('AGAGGUUCUAG_CACCCUCUAUAAAAAACUAA'))
def test_missing_phosphates2(self): """Messy residues with missing phosphates are not delted.""" st2 = ModernaStructure('file', MISSING_PHOSPHATES2) pc = PdbController(st2) self.assertEqual(st2.get_sequence(), Sequence('C_C_G_A_C_C_U_U_C_G_G_C_C_A_C_C_U_G')) pc.clean_structure() self.assertEqual(st2.get_sequence(), Sequence('CCGACCUUCGGCCACC_UG'))
def test_AMP_detection_and_removal(self): """Should detect AMP in the structure and remove it while cleaning.""" st4 = ModernaStructure('file', PDB_WITH_AMP) self.assertEqual(st4.get_sequence(), Sequence('GGGAAGGGAAGAAACUGCGGCUUCGGCCGGCUUCCC_H')) pc4 = PdbController(st4) self.assertEqual(len(pc4.rna_ligand), 1) pc4.clean_structure() self.assertEqual(len(pc4.rna_ligand), 0) self.assertEqual(st4.get_sequence(), Sequence('GGGAAGGGAAGAAACUGCGGCUUCGGCCGGCUUCCC'))
def examine_structure(st, ex_log=None, verbose=True): """*examine_structure(structure)* Checks whether the given structure has any features that may cause any problems during the modeling process. The user needs to give a structure object, and optionally a name of the file the report is written to. :Arguments: * Stucture object * name of logfile (optional) """ struc = validate_structure(st) pc = PdbController(st) if ex_log: pc.write_log(ex_log) else: log.write_message(str(pc)) if verbose: print(pc) return pc
def test_missing_phosphates(self): """residues with missing phosphates are fixed.""" st2 = ModernaStructure('file', MISSING_PHOSPHATES) pc = PdbController(st2) self.assertEqual(len(pc.P_missing), 2) self.assertEqual(st2.get_sequence(), Sequence('GCG_GAUUUALCUCAG')) pc.clean_structure() self.assertEqual(st2.get_sequence(), Sequence('GCG_GAUUUALCUCAG')) pc = PdbController(st2) self.assertEqual(len(pc.P_missing), 0)
def clean_structure(st, write_structure=False): """*clean_structure(structure, write_structure=False)* Eliminates features that may cause problems during modeling from a template or model structure: * water molecules, ions, amino acids, and unidentified residues are deleted. * old atom names are replaced (C1* becomes C1', O1P becomes OP1). * missing phosphate groups are added (also adds the OP3 atom for these) * reports whether the chain is continuous. In case some feature cannot be fixed (e.g. chain discontinuity) this is written to the logfile. It is recommended to include such features in the alignment ('.' characters for strange residues, and '_' for backbone breaks). :Arguments: * Stucture object (RnaModel or Template) * True/False - whether structure should be written to a PDB file (optional) """ struc = validate_structure(st) pc = PdbController(st) pc.clean_structure() log.write_message(str(pc)) if write_structure: pc.write_structure('fixed_structure.pdb') return pc
def setUp(self): self.st = ModernaStructure('file', NASTY_PDB) self.pc = PdbController(self.st)
class CheckPdbTests(TestCase): def setUp(self): self.st = ModernaStructure('file', NASTY_PDB) self.pc = PdbController(self.st) def test_ions_detection(self): self.assertEqual(len(self.pc.ions), 9) def test_water_detection(self): self.assertEqual(len(self.pc.water), 160) def test_unidentifiedRNA_detection(self): self.assertEqual(len(self.pc.unidentified_rna), 1) def test_stars_detection(self): self.assertTrue(self.pc.stars) def test_O1P_detection(self): self.assertTrue(self.pc.OP) def test_clean_structure(self): self.pc.clean_structure() self.assertEqual(len(self.pc.ions), 0) self.assertEqual(len(self.pc.ions), 0) self.assertEqual(len(self.pc.unidentified_rna), 1) self.assertEqual(len(self.pc.P_missing), 0) def test_clean_structure_in_struc(self): self.assertEqual( self.st.get_sequence(), Sequence( 'G_C_GGAU.UALCUCAGDDGGGAGAGCRCCAGABU#AAYAP?UGGAG7UC?UGUGTPCG"UCCACAGAAUUCGCACCA_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._.' )) self.pc.clean_structure() self.assertEqual( self.st.get_sequence(), Sequence( 'GCGGAU.UALCUCAGDDGGGAGAGCRCCAGABU#AAYAP?UGGAG7UC?UGUGTPCG"UCCACAGAAUUCGCACCA' )) def test_add_missing_p(self): """Identifies residues with P missing""" self.assertEqual(len(self.pc.P_missing), 1) self.assertEqual(self.pc.P_missing[0].identifier, '1') def test_atom_names(self): """Names of O1P, C1* etc should be fixed properly.""" self.pc.clean_structure() at1 = self.st['2']["C1'"] self.assertEqual(at1.name, "C1'") self.assertEqual(at1.fullname, " C1'") at2 = self.st['4']["OP1"] self.assertEqual(at2.name, "OP1") self.assertEqual(at2.fullname, " OP1") at3 = self.st['2']["O5'"] self.assertEqual(at3.name, "O5'") self.assertEqual(at3.fullname, " O5'") def test_missing_phosphates(self): """residues with missing phosphates are fixed.""" st2 = ModernaStructure('file', MISSING_PHOSPHATES) pc = PdbController(st2) self.assertEqual(len(pc.P_missing), 2) self.assertEqual(st2.get_sequence(), Sequence('GCG_GAUUUALCUCAG')) pc.clean_structure() self.assertEqual(st2.get_sequence(), Sequence('GCG_GAUUUALCUCAG')) pc = PdbController(st2) self.assertEqual(len(pc.P_missing), 0) def test_missing_phosphates2(self): """Messy residues with missing phosphates are not delted.""" st2 = ModernaStructure('file', MISSING_PHOSPHATES2) pc = PdbController(st2) self.assertEqual(st2.get_sequence(), Sequence('C_C_G_A_C_C_U_U_C_G_G_C_C_A_C_C_U_G')) pc.clean_structure() self.assertEqual(st2.get_sequence(), Sequence('CCGACCUUCGGCCACC_UG')) def test_ligand_removal(self): """Should remove RNA ligand from 3FU2 when there is no ribose and phosphate group.""" st2 = ModernaStructure('file', PDB_WITH_LIGAND) pc2 = PdbController(st2) self.assertEqual( st2.get_sequence(), Sequence( 'AGAGGUUCUAG_._CACCCUCUAUAAAAAACUAA_x_._._._._._._._._._._._._.' )) pc2.clean_structure() self.assertEqual(st2.get_sequence(), Sequence('AGAGGUUCUAG_CACCCUCUAUAAAAAACUAA')) def test_double_coordinates_identification(self): """Should remove RNA ligand when there is no ribose and phosphate group.""" st3 = ModernaStructure('file', PDB_WITH_DOUBLE_COORDINATES) pc3 = PdbController(st3) self.assertEqual(len(pc3.disordered), 3) pc3.clean_structure() self.assertEqual(len(pc3.disordered), 3) def test_AMP_detection_and_removal(self): """Should detect AMP in the structure and remove it while cleaning.""" st4 = ModernaStructure('file', PDB_WITH_AMP) self.assertEqual(st4.get_sequence(), Sequence('GGGAAGGGAAGAAACUGCGGCUUCGGCCGGCUUCCC_H')) pc4 = PdbController(st4) self.assertEqual(len(pc4.rna_ligand), 1) pc4.clean_structure() self.assertEqual(len(pc4.rna_ligand), 0) self.assertEqual(st4.get_sequence(), Sequence('GGGAAGGGAAGAAACUGCGGCUUCGGCCGGCUUCCC')) def test_phosphate_detection_and_removal(self): """Should detect pfosphate group (P, OP1, OP2, O5') in 3FU2 (resi 12) and remove it.""" st5 = ModernaStructure('file', PDB_WITH_PHOSPHATE) pc5 = PdbController(st5) self.assertEqual(len(pc5.phosphate), 1) pc5.clean_structure() self.assertEqual(len(pc5.phosphate), 0) def test_double_coordinates(self): """Disordered residues should be recognized only when they have double coordinates.""" st6 = ModernaStructure('file', PDB_WITHOUT_DOUBLE_COORD) pc6 = PdbController(st6) self.assertEqual(len(pc6.disordered), 0)
def test_double_coordinates(self): """Disordered residues should be recognized only when they have double coordinates.""" st6 = ModernaStructure('file', PDB_WITHOUT_DOUBLE_COORD) pc6 = PdbController(st6) self.assertEqual(len(pc6.disordered), 0)