def calcDists(): """In a parallel method, calculate all of the distances for each frame. Returns a list of (frame, distance)""" global TOTALFRAMES os.chdir(OUTPATH) with open(OUTPATH + "/initial.pdb") as p: LIGANDATOM, PROTEINATOM, lAtomCoord, pAtomCoord, lCenter, pCenter = \ calcCenterAtoms(list(p)) log("Selected ligand center atom ID " + MAGENTA + "%i" % LIGANDATOM + END + " at (%.3f, %.3f, %.3f), " % (lAtomCoord[0], lAtomCoord[1], lAtomCoord[2]) + "closest to (%.3f, %.3f, %.3f).\n" % (lCenter[0], lCenter[1], lCenter[2])) log("Selected protein center atom ID " + MAGENTA + "%i" % PROTEINATOM + END + " at (%.3f, %.3f, %.3f), " % (pAtomCoord[0], pAtomCoord[1], pAtomCoord[2]) + "closest to (%.3f, %.3f, %.3f).\n" % (pCenter[0], pCenter[1], pCenter[2])) def calcDist(frame): """Calculate the distance for a certain frame. Returns (frame, distance).""" with open("frame_%i.pdb" % frame) as pdb: dist = atomDist(list(pdb), LIGANDATOM, PROTEINATOM) log("Frame %i has distance %.3f\n" % (frame, dist)) return frame, dist log("Calculating distances.\n") output = parMap(calcDist, range(1, TOTALFRAMES + 1), n=cpu_count() / 2) os.chdir(WORKDIR) return output
def determineRestraint(): """Determine the atom groups used for the center-of-mass restaints and sets them in the PROTEINATOM and LIGANDATOM lists.""" global PROTEINATOM global LIGANDATOM global PRMTOPPATH global COORDPATH with open(COORDPATH + "/initial.pdb") as p: LIGANDATOM, PROTEINATOM, ligandAtomCoord, proteinAtomCoord, ligandCenter, proteinCenter = \ calcCenterAtoms(list(p)) log("Selected ligand center atom ID " + MAGENTA + "%i" % LIGANDATOM + END + " at (%.3f, %.3f, %.3f), " % (ligandAtomCoord[0], ligandAtomCoord[1], ligandAtomCoord[2]) + "closest to (%.3f, %.3f, %.3f).\n" % (ligandCenter[0], ligandCenter[1], ligandCenter[2])) log("Selected protein center atom ID " + MAGENTA + "%i" % PROTEINATOM + END + " at (%.3f, %.3f, %.3f), " % (proteinAtomCoord[0], proteinAtomCoord[1], proteinAtomCoord[2]) + "closest to (%.3f, %.3f, %.3f).\n" % (proteinCenter[0], proteinCenter[1], proteinCenter[2]))