print(line1, '!=', line2) print(lineCount, matchCount, diffCount) if args.rama: if pdb_input: pdb_structure.atom_to_internal_coordinates() for r in pdb_structure.get_residues(): # print(r.internal_coord.get_dihedral('N:CA:C:O')) if r.internal_coord: print(r, r.internal_coord.get_angle('psi'), r.internal_coord.get_angle('phi'), r.internal_coord.get_angle( 'omg'), r.internal_coord.get_angle('chi2'), r.internal_coord.get_length('0C:1N')) if args.ws: if args.flex: for r in pdb_structure.get_residues(): r.internal_coord.set_flexible() if args.hb: for r in pdb_structure.get_residues(): r.internal_coord.set_hbond() write_SCAD(pdb_structure, outfile + '.scad', scale_val, pdbid=prot_id, backboneOnly=args.backbone, includeCode=scadCode_val) fileNo += 1 print('normal termination')
def test_write_SCAD(self): """Check SCAD output plus MaxPeptideBond and Gly CB. SCAD tests: scaling, transform mtx, extra bond created (allBonds) """ sf = StringIO() write_SCAD( self.cif_4CUP2, sf, 10.0, pdbid="4cup", backboneOnly=True, includeCode=False, ) sf.seek(0) next_one = False with as_handle(sf, mode="r") as handle: for aline in handle.readlines(): if "// (1856_S_CB, 1856_S_CA, 1856_S_C)" in aline: m = re.search(r"\[\s+(\d+\.\d+)\,", aline) if m: # test correctly scaled atom bond length self.assertAlmostEqual(float(m.group(1)), 15.30582, places=3) else: self.fail("scaled atom bond length not found") elif '[ 1, "1857M",' in aline: next_one = True elif next_one: next_one = False # test last residue transform looks roughly correct # some differences due to sorting issues on different # python versions target = [-12.413, -3.303, 35.771, 1.0] ms = re.findall( # last column of each row r"\s+(-?\d+\.\d+)\s+\]", aline ) if ms: for i in range(0, 3): self.assertAlmostEqual(float(ms[i]), target[i], places=0) else: self.fail("transform not found") sf.seek(0) IC_Residue.gly_Cbeta = True IC_Chain.MaxPeptideBond = 100.0 chn = self.pdb_2XHE2[0]["A"] chn.atom_to_internal_coordinates() rt0 = chn.internal_coord.ordered_aa_ic_list[12] rt1 = chn.internal_coord.ordered_aa_ic_list[16] rt0.set_flexible() rt1.set_hbond() write_SCAD( self.pdb_2XHE2[0]["A"], sf, 10.0, pdbid="2xhe", # maxPeptideBond=100.0, includeCode=False, start=10, fin=570, ) sf.seek(0) allBondsPass = False maxPeptideBondPass = False glyCbetaFound = False startPass = True finPass = True flexPass = False hbPass = False with as_handle(sf, mode="r") as handle: for aline in handle.readlines(): # test extra bond created in TRP (allBonds is True) if '"Cres", 0, 0, 1, 0, StdBond, "W", 24, "CD2CE3CZ3"' in aline: allBondsPass = True # test 509_K-561_E long bond created if "509_K" in aline and "561_E" in aline: maxPeptideBondPass = True if "(21_G_CB, 21_G_CA, 21_G_C)" in aline: glyCbetaFound = True target = [15.33630, 110.17513, 15.13861] ms = re.findall(r"\s+(-?\d+\.\d+)", aline) if ms: for i in range(0, 3): self.assertAlmostEqual(float(ms[i]), target[i], places=0) else: self.fail("Cbeta internal coords not found") if "8_K_CA" in aline: startPass = False if "572_N_CA" in aline: finPass = False if 'FemaleJoinBond, FemaleJoinBond, "N", 13, "NCAC"' in aline: flexPass = True if 'HBond, "R", 16, "CACO"' in aline: hbPass = True self.assertTrue(allBondsPass, msg="missing extra ring close bonds") self.assertTrue(glyCbetaFound, msg="gly CB not created") self.assertTrue(maxPeptideBondPass, msg="ignored maxPeptideBond setting") self.assertTrue(startPass, msg="writeSCAD wrote residue before start") self.assertTrue(finPass, msg="writeSCAD wrote residue past fin") self.assertTrue(flexPass, msg="writeSCAD residue 12 not flexible") self.assertTrue(hbPass, msg="writeSCAD residue 16 no hbond")
def test_write_SCAD(self): """Check SCAD output plus MaxPeptideBond and Gly CB. SCAD tests: scaling, transform mtx, extra bond created (allBonds) """ sf = StringIO() write_SCAD(self.cif_4CUP, sf, 10.0, pdbid="4cup", backboneOnly=True, includeCode=False) sf.seek(0) next_one = False with as_handle(sf, mode="r") as handle: for aline in handle.readlines(): if "// (1856_S_CB, 1856_S_CA, 1856_S_C)" in aline: m = re.search(r"\[\s+(\d+\.\d+)\,", aline) if m: # test correctly scaled atom bond length self.assertAlmostEqual(float(m.group(1)), 15.30582, places=3) else: self.fail("scaled atom bond length not found") elif '[ 1, "1857M",' in aline: next_one = True elif next_one: next_one = False # test last residue transform looks roughly correct # some differences due to sorting issues on different python # versions target = [-12.413, -3.303, 35.771, 1.0] ms = re.findall( # last column of each row r"\s+(-?\d+\.\d+)\s+\]", aline) if ms: for i in range(0, 3): self.assertAlmostEqual(float(ms[i]), target[i], places=0) else: self.fail("transform not found") sf.seek(0) IC_Residue.gly_Cbeta = True write_SCAD( self.pdb_2XHE[0]["A"], sf, 10.0, pdbid="2xhe", maxPeptideBond=100.0, includeCode=False, ) sf.seek(0) allBondsPass = False maxPeptideBondPass = False glyCbetaFound = False with as_handle(sf, mode="r") as handle: for aline in handle.readlines(): # test extra bond created in TRP (allBonds is True) if '"Cres", 0, 0, 1, 0, StdBond, "W", 24, "CD2CE3CZ3"' in aline: allBondsPass = True # test 509_K-561_E long bond created if "509_K" in aline and "561_E" in aline: maxPeptideBondPass = True if "(21_G_CB, 21_G_CA, 21_G_C)" in aline: glyCbetaFound = True target = [15.33630, 110.17513, 15.13861] ms = re.findall(r"\s+(-?\d+\.\d+)", aline) if ms: for i in range(0, 3): self.assertAlmostEqual(float(ms[i]), target[i], places=0) else: self.fail("Cbeta internal coords not found") self.assertTrue(allBondsPass) self.assertTrue(glyCbetaFound) self.assertTrue(maxPeptideBondPass)