def rel2sim(self, relFrames): """ Converts trajectory index-frame pairs into Sim-frame pairs Parameters ---------- relFrames : 2D np.ndarray An array containing in each row trajectory index and frame pairs Returns ------- frames : np.ndarray An array of :class:`Frame <htmd.simlist.Frame>` objects containing the simulation object, the trajectory piece ID and the frame index. Examples -------- >>> simframes = data.rel2sim([100, 56]) # 100th simulation frame 56 """ from htmd.simlist import Frame sims = [] frames = [] for i in range(np.size(relFrames, 0)): trajID = relFrames[i, 0] trajFrame = relFrames[i, 1] sims.append(self.simlist[trajID]) frames.append( Frame(self.simlist[trajID], self.ref[trajID][trajFrame, 0], self.ref[trajID][trajFrame, 1])) return np.array(frames)
def rel2sim(self, relFrames, simlist=None): """ Converts trajectory index-frame pairs into Sim-frame pairs Parameters ---------- relFrames : 2D np.ndarray An array containing in each row trajectory index and frame pairs simlist : numpy.ndarray of :class:`Sim <htmd.simlist.Sim>` objects Optionally pass a different (but matching, i.e. filtered) simlist for creating the Frames. Returns ------- frames : np.ndarray An array of :class:`Frame <htmd.simlist.Frame>` objects containing the simulation object, the trajectory piece ID and the frame index. Examples -------- >>> simframes = data.rel2sim([100, 56]) # 100th simulation frame 56 """ from htmd.simlist import Frame if simlist is None: simlist = self.simlist else: if len(simlist) != len(self.simlist): raise AttributeError( 'Provided simlist has different number of trajectories than the one used by this object.' ) relFrames = np.array(relFrames) if relFrames.ndim == 1: relFrames = relFrames[np.newaxis, :] sims = [] frames = [] for i in range(np.size(relFrames, 0)): trajID = relFrames[i, 0] trajFrame = relFrames[i, 1] sims.append(simlist[trajID]) ref = self.trajectories[trajID].reference frames.append( Frame(simlist[trajID], ref[trajFrame, 0], ref[trajFrame, 1])) return np.array(frames)
md.datapath = path.join(home(), 'data', 'adaptive', 'data') md.run() # Cleaning up inputodel = glob(path.join(home(), 'data', 'adaptive', 'input', 'e2*')) for i in inputodel: shutil.rmtree(i, ignore_errors=True, acemd='/shared/acemd/bin/acemd') os.remove(path.join(home(), 'data', 'adaptive', 'input', 'e2_writeinputs.log'))''' import htmd import os import shutil from htmd.queues.localqueue import LocalGPUQueue from htmd.simlist import Frame, simlist from htmd.util import tempname filedir = htmd.home.home() + '/data/adaptive/' sims = simlist(glob(os.path.join(filedir, 'data', '*', '')), glob(os.path.join(filedir, 'input', '*', '')), glob(os.path.join(filedir, 'input', '*', ''))) outf = tempname() os.makedirs(outf) f = Frame(sims[0], 0, 5) _writeInputsFunction(1, f, 2, outf, 'input.coor') mol = Molecule(sims[0]) mol.read(os.path.join(outf, 'e2s2_e1s1p0f5', 'input.coor')) shutil.rmtree(outf)