def symop(self, matrixA, matrixB, title=""): a = SVD.SVDSuperimposer() a.set(matrixA[1], matrixB[1]) x = [] x.append(matrixA[0]) x.append(matrixB[0]) COM = self.get_center_of_mass(x) print "COMPARISON " + title print "Centroid: " print COM a.run() R = np.transpose(a.get_rot()) print "Rotation Matrix:" print R print title + " Rotation Angle: " + self.getangle(R) angle = self.getangle(R) print title + " RMSD: " + a.get_rms() print '-----'
def main(self, filetype): self.set = 1 for pdb in self.pdbs: print "Autoloading detected PDB file: %s" % pdb print ", ".join([str(x) for x in pdb.list_chains()]) commonAA = pdb.commonAA( 123, 531 ) #Only use amino acids 123-531 for superimposing and computing RMSD. f = open('input.txt', 'r') l = [] matrices = [] matrices.append([]) for line in f: if line.strip() == "": matrices.append(l) l = [] else: l.append(map(float, line.split(' '))) flag = 1 while flag: towrite1 = [] matrix_static = [] matrix_moving = [] towrite2 = [] counter1 = 1 counter2 = 1 input2 = question("What subunit is the static reference? (eg 5A)") input2 = input2.strip() matrixID2 = int(re.findall(r'\d+', input2)[0]) chainID2 = re.findall(r'\D+', input2)[0].upper() input2 = input2.upper() input1 = question("What subunit is moving? (eg 1A)") input1 = input1.strip() matrixID1 = int(re.findall(r'\d+', input1)[0]) chainID1 = re.findall(r'\D+', input1)[0].upper() input1 = input1.upper() for pdb in self.pdbs: for atom in pdb.backbone: if atom['chain'] == chainID1 and atom[ 'res num'] in commonAA: a = matrices[matrixID1] * np.transpose(atom.coord()) temp = Patom(str(atom), 1) temp['x'] = float(a[0]) temp['y'] = float(a[1]) temp['z'] = float(a[2]) temp['line num'] = counter1 counter1 += 1 towrite1.append(temp) if atom['chain'] == chainID2 and atom[ 'res num'] in commonAA: a = matrices[matrixID2] * np.transpose(atom.coord()) temp = Patom(str(atom), 1) temp['x'] = float(a[0]) temp['y'] = float(a[1]) temp['z'] = float(a[2]) temp['line num'] = counter2 counter2 += 1 towrite2.append(temp) file = open("output/%s%s.pdb" % (filetype, input1), 'w') for i in towrite1: file.write(str(i) + '\n') file.close() file = open("output/%s%s.pdb" % (filetype, input2), 'w') for i in towrite2: file.write(str(i) + '\n') file.close() matrix_static = self.coordmatrix(towrite1) matrix_moving = self.coordmatrix(towrite2) a = SVD.SVDSuperimposer() static = [towrite1, matrix_static] moving = [towrite2, matrix_moving] self.symop(static, moving, "%s-to-%s" % (input1, input2)) continue_check = question("Continue? (Y/n)", ['', 'y', 'Y', 'n', 'N']) if continue_check not in ['', 'y', 'Y']: flag = 0