def test_traj_split(self): traj1 = traj.TimeSeries(distraj=[1, 2, 3], dt=1.) traj2 = traj.TimeSeries(distraj=[3, 2, 1], dt=2.) trajs = [traj1, traj2] self.filepath = msm_lib.traj_split(data=trajs, lagt=10) self.assertIsInstance(self.filepath, str) self.assertTrue(os.path.exists(self.filepath)) os.remove(self.filepath) # clean temp file
def setUp(self): download_test_data() self.nstates = np.random.randint(3,100) distraj_1 = np.random.randint(1,self.nstates+1, size=1000).tolist() traj_1 = traj.TimeSeries(distraj= distraj_1, dt=1.) distraj_2 = np.random.randint(1,self.nstates+1, size=1000).tolist() traj_2 = traj.TimeSeries(distraj= distraj_2, dt=2.) self.data = np.array([ traj_1, traj_2 ]) self.lagt = 10 self.keys = [i for i in range(1,self.nstates+1)] msm_obj = msm.MSM(data=self.data, lagt=self.lagt, keys=self.keys, sym=True) self.msm = msm_obj
def setUp(self): download_test_data() self.tr = traj.TimeSeries(top='test/data/alaTB.gro', \ traj=['test/data/protein_only.xtc']) self.tr.discretize('rama', states=['A', 'E', 'O']) self.tr.find_keys() self.msm = msm.SuperMSM([self.tr])
def map_trajectory(self): """ Maps trajectory onto the PCCA clusters Returns ------- mappedtraj : str The mapped trajectory. """ print "\n Mapping trajectory onto macrostates..." mappedtraj = [] keep_states = self.parent.keep_states keep_keys = self.parent.keep_keys mt_states = [] for data in self.parent.data: for s in data.distraj: try: mt_states.append([k for k, v in self.macros.iteritems() \ if keep_keys.index(s) in v][0]) except ValueError: #print " not in keep_keys" try: prev = mt_states[-1] except IndexError: pass mt = traj.TimeSeries(distraj=mt_states, dt=data.dt) mappedtraj.append(mt) super(PCCA, self).__init__(mappedtraj, keys=range(self.N), lagt=self.parent.lagt)
def setUp(self): download_test_data() self.traj = md.load('test/data/protein_only.xtc', \ top='test/data/alaTB.gro') self.topfn = 'test/data/alaTB.gro' self.trajfn = 'test/data/protein_only.xtc' self.tr = traj.TimeSeries(top='test/data/alaTB.gro', \ traj=['test/data/protein_only.xtc'])
def test_merge_trajs(self): # create fake trajectory to merge traj2 = traj.TimeSeries(distraj=['L', 'L', 'L', 'A'], dt = 2.0) traj2.keys = ['L','A'] old_keys = self.msm.keys self.msm.data = [self.tr, traj2] new_keys = self.msm._merge_trajs() self.assertEqual(len(new_keys), len(old_keys) + 1) self.assertEqual(sorted(new_keys), ['A', 'E', 'L'])
def test_max_dt(self): traj2 = traj.TimeSeries(distraj=['L', 'L', 'L', 'A'], dt=2.0) old_dt = self.msm.dt self.msm.data = [self.tr, traj2] new_dt = self.msm._max_dt() self.assertEqual(new_dt, 2.0)
def setUp(self): self.tr = traj.TimeSeries(top='trajectory/tests/data/alaTB.gro', \ traj=['trajectory/tests/data/protein_only.xtc']) pass