def analysis(lUniverses, lTpr, lXtc, sSurface, lOutput, lTimeOffsets=[], sSaveAs='SASAResults'): makeIndex(lUniverses, sSurface, lOutput) lSASA = [] npSASA = np.array(lSASA) lOutputInts = [] for y in range(1, len(lOutput) + 1): lOutputInts.append(y) for x in range(len(lTpr)): cSASA = tools.G_sas(s=lTpr[x], f=lXtc[x], n='SASAIndex.ndx', o='SASA.xvg', surface=["0"], output=lOutputInts) cSASA.run() wSASA = wrap.XVG() wSASA.read(filename='SASA.xvg') npTempSASA = wSASA.array if x == 0: npSASA = deepcopy(npTempSASA) else: npSASA = np.concatenate((npSASA, npTempSASA), axis=1) dSASA = createDictionary(lUniverses, npSASA, sSurface, lOutput, lTimeOffsets) #save dictionary pickleMethods.save(dSASA, sSaveAs)
def analysis(lUniverses, lAtomSelections, lTimeOffsets=[], sSaveAs="DihedralResults"): npDihedral = [] for universe in lUniverses: lQuartets = [] for x in lAtomSelections: lQuartets.append(universe.select_atoms(x)) D = Dihedrals.Dihedral(lQuartets) D.run() npTempDihedral = D.angles.T if len(npDihedral) == 0: npDihedral = deepcopy(npTempDihedral) else: npDihedral = np.concatenate((npDihedral, npTempDihedral), axis=1) dDihedral = {} for x in range(len(lAtomSelections)): dDihedral[lAtomSelections[x]] = npDihedral[x] #Add time points iTimeStep = int(lUniverses[0].trajectory[1].time - lUniverses[0].trajectory[0].time) dDihedral['time'] = [] for y in range(len(lUniverses)): for x in range(0, len(lUniverses[y].trajectory) * iTimeStep, iTimeStep): if ((y - 1) == 0) | ((y - 1) > 0): dDihedral['time'].append(x + lTimeOffsets[y - 1]) else: dDihedral['time'].append(x) pickle.save(dDihedral, sSaveAs)
def analysis(lUniverses, lGroupSelection, lTimeOffsets=[], sSaveAs="GyrationResults"): Rgyr = [] u = 0 for universe in lUniverses: lGroups = [] for group in lGroupSelection: lGroups.append(universe.select_atoms(group)) for ts in universe.trajectory: tempRgyr = [] if u < 1: tempRgyr.append(universe.trajectory.time) else: tempRgyr.append(universe.trajectory.time + lTimeOffsets[u - 1]) for group in lGroups: tempRgyr.append(group.radius_of_gyration()) Rgyr.append(tempRgyr) u += 1 Rgyr = np.array(Rgyr).T dGyration = {} dGyration['time'] = Rgyr[0] for x in range(len(lGroupSelection)): dGyration[lGroupSelection[x]] = Rgyr[x + 1] pickle.save(dGyration, sSaveAs)
def analysis(lUniverses, uRef, sSelection, lGroups, sSaveAs="RMSDResults", lTimeOffsets=[]): lRMSD = [] for universe in lUniverses: R = MDAnalysis.analysis.rms.RMSD(universe, uRef, select=sSelection, groupselections=lGroups, filename="rmsd.dat") R.run() if len(lRMSD) < 1: lRMSD = R.rmsd.T else: lRMSD = np.concatenate((lRMSD.T, R.rmsd), axis=0).T if len(lTimeOffsets) > 0: for x in range(len(lTimeOffsets)): fBegIndex = 0 for i in range(x + 1): fBegIndex += len(lUniverses[i].trajectory) for y in range(fBegIndex, fBegIndex + len(lUniverses[x + 1].trajectory)): lRMSD[1][y] = lRMSD[1][y] + lTimeOffsets[x] dRMSD = {} dRMSD['frame'] = lRMSD[0] dRMSD['time'] = lRMSD[1] dRMSD[sSelection] = lRMSD[2] for x in range(len(lGroups)): dRMSD[lGroups[x]] = lRMSD[x + 3] pickle.save(dRMSD, sSaveAs)