def __init__(self, mol, seed, coords): UserList.UserList.__init__(self) self.seed = seed self.mol = mol self.seed_coords = coords self.ruler = RMSDCalculator(coords) self.min_energy = self.max_energy = mol.autodock_states[seed].e_binding ##### get seed energy HERE self.append(seed)
def getRMSD_subset(self, refCoords=None): """Return RMSD of this conformations subset relative to refCoords. If refCoords is not given, the original coordinates for the subset will be used as the reference. """ if not refCoords: refCoords = self.getCoords_subset() rmsd_calc = RMSDCalculator(refCoords) return rmsd_calc.computeRMSD(self.getCoords_subset())
def __init__(self, refCoords=None): """The constructor of the rigidfitBodyAligner takes one required argument: refCoords: cartesian coordinates of reference structure (3,n) (input) This method creates: self.superimposed: flag when set to 1 the transformation matrices to superimpose a mobile set of coordinates onto the reference coords have been computed. self.rmsdCalculator: instance of the RMSDCalculator class that computes the rmsd between two lists of coordinates. This object will be used by the rmsdAfterSuperimposition method. """ self.refCoords = refCoords self.superimposed = 0 self.rmsdCalculator = RMSDCalculator()
def getRMSD(self, refCoords=None, numCoords=None): """Return RMSD of this conformations relative to refCoords. If refCoords is not given, the original coordinates for the molecule will be used as the reference. """ if not refCoords: oldCoords = self.mol.allAtoms.coords[:] oldConf = self.mol.allAtoms[0].conformation self.mol.allAtoms.setConformation(0) refCoords = self.mol.allAtoms.coords[:] self.mol.allAtoms.updateCoords(oldCoords, oldConf) rmsd_calc = RMSDCalculator(refCoords) if numCoords: rmsd = rmsd_calc.computeRMSD(self.getCoords()[:numCoords]) else: rmsd = rmsd_calc.computeRMSD(self.getCoords()) return rmsd
def getRMSD_custom(self, refCoords=None): """Return the minimum of the regular RMSD and the computed RMSD after the coords have been rotated about the c2 axis which was aligned with the y-axis. """ normal_RMSD = self.getRMSD(refCoords) c2_coords = self.coords[:] # I know there's a clever way to use Numeric to do this... for c in c2_coords: c[0] = -1.0 * c[0] c[2] = -1.0 * c[2] if not refCoords: self.mol.allAtoms.setConformation(0) refCoords = self.mol.allAtoms.coords rmsd_calc = RMSDCalculator(refCoords) c2_RMSD = rmsd_calc.computeRMSD(self.getCoords()) return min(normal_RMSD, c2_RMSD)
for dlg in dlg_list: d.readDlg(dlg) #setup rmsd tool coords = d.ligMol.allAtoms.coords[:] refCoords = None if rms_reference is not None: file = directory + '/' + rms_reference ref = Read(file) if not len(ref): print("unable to read ", rms_reference) else: ref = ref[0] coords = ref.allAtoms.coords refCoords = coords[:] d.clusterer.rmsTool = RMSDCalculator(coords) d.clusterer.make_clustering(rms_tolerance) # for building hydrogen bonds or reporting energy breakdown # setup receptor: if build_hydrogen_bonds or report_energy_breakdown: d.ligMol.buildBondsByDistance() receptor_filename = directory + '/' + receptor_filename receptor = Read(receptor_filename)[0] receptor.buildBondsByDistance() if build_hydrogen_bonds: hbondBuilder = HydrogenBondBuilder() #do next two lines for each conf #d.ligMol.set_conformation(conf) #atDict = hbondBuilder.build(receptor.allAtoms, d.ligMol.allAtoms)
if verbose: print 'set outputfilename to ', a if o in ('-t', '--t'): rms_tolerance = float(a) if verbose: print 'set rms_tolerance to ', a if o in ('-v', '--v'): verbose = True if verbose: print 'set verbose to ', True if o in ('-h', '--'): usage() sys.exit() dlg_list = glob.glob('*.dlg') d = Docking() for dlg in dlg_list: d.readDlg(dlg) d.clusterer.rmsTool = RMSDCalculator(d.ligMol.allAtoms.coords[:]) d.clusterer.make_clustering(rms_tolerance) clustering = d.clusterer.clustering_dict[rms_tolerance] largest = clustering[0] for clust in clustering: if len(clust)>len(largest): largest = clust #update the coordinates with those of conf with lowest energy in this largest cluster d.ch.set_conformation(largest[0]) parser = d.ligMol.parser lines = [] #have to add newline character to lines read from dlg for l in parser.allLines: l+= '\n' lines.append(l) parser.allLines = lines
print 'compute_rms_between_conformations: second filename must be specified.' usage() sys.exit() #process docking in reference directory #read the molecules first = Read(first)[0] second = Read(second)[0] assert len(first.allAtoms) == len(second.allAtoms) first_ats = first.allAtoms second_ats = second.allAtoms if omit_hydrogens: first_ats = first.allAtoms.get(lambda x: x.element != 'H') second_ats = second.allAtoms.get(lambda x: x.element != 'H') #setup rmsd tool rmsTool = RMSDCalculator(first_ats.coords) need_to_open = not os.path.exists(outputfilename) if need_to_open: fptr = open(outputfilename, 'w') ostr = "reference filename test filename\t\trms \n" fptr.write(ostr) else: fptr = open(outputfilename, 'a') ostr = "% 10s,\t% 10s, % 10.4f\n" % ( first.parser.filename, second.parser.filename, rmsTool.computeRMSD(second_ats.coords)) fptr.write(ostr) fptr.close() # To execute this command type: