import sys from MMTK import * from Bio import PDB import numpy listnames = open(sys.argv[1],'r') listnames = listnames.readlines() def calc_atom_dist(atom_one, atom_two) : """Returns the C-alpha distance between two atoms""" diff_vector = atom_one.coord - atom_two.coord return numpy.sqrt(numpy.sum(diff_vector * diff_vector)) def check_bondlengths(pdbfile): """checks for bond lengths shorter than forcefield cutoff of 0.277908 nm""" parser = PDB.PDBParser() f = open(pdbfile,'r') o = parser.get_structure(pdbfile, f) f.close() out = open(pdbfile.replace(".pdb","_atombondlengths.txt"),"w") list_atoms=[] error=[] dist = [] for r in o.get_atoms(): list_atoms.append(r) for i in range(len(list_atoms)): for j in range(len(list_atoms)): dist = calc_atom_dist(list_atoms[i],list_atoms[j]) out.write(str((i,j))+"\t"+str(dist)+"\n") for l in listnames: l = l.rstrip() l = l.split("\t") filename=l[1]+"_allatom" #filename=l.split("/")[3].replace(".mode","") modes = load(l[0]) #should have the input modes file for the TIM barrel structure in question universe = modes.universe protein = universe.protein protein.normalizeConfiguration('Ir') protein.writeToFile(filename+"_modes.pdb") check_bondlengths(filename+"_modes.pdb")