def test(self): from msmbuilder.scripts.SaveStructures import save project = get('ProjectInfo.yaml') assignments = get('Assignments.h5')['arr_0'] which_states = [0, 1, 2] list_of_trajs = project.get_random_confs_from_states(assignments, which_states, num_confs=2, replacement=True, random=np.random.RandomState(42)) assert isinstance(list_of_trajs, list) assert isinstance(list_of_trajs[0], Trajectory) eq(len(list_of_trajs), len(which_states)) for t in list_of_trajs: eq(len(t), 2) print list_of_trajs[0].keys() # sep, tps, one save(list_of_trajs, which_states, style='sep', format='lh5', outdir=self.td) save(list_of_trajs, which_states, style='tps', format='lh5', outdir=self.td) save(list_of_trajs, which_states, style='one', format='lh5', outdir=self.td) names = ['State0-0.lh5', 'State0-1.lh5', 'State0.lh5', 'State1-0.lh5', 'State1-1.lh5', 'State1.lh5', 'State2-0.lh5', 'State2-1.lh5', 'State2.lh5'] for name in names: t = Trajectory.load_trajectory_file(pjoin(self.td, name)) eq(t, get('save_structures/' + name))
def test(self): from msmbuilder.scripts.SaveStructures import save os.chdir(self.td) project = get('ProjectInfo.yaml') assignments = get('Assignments.h5')['arr_0'] which_states = [0, 1, 2] list_of_trajs = project.get_random_confs_from_states(assignments, which_states, num_confs=2, replacement=True, random=np.random.RandomState(42)) assert isinstance(list_of_trajs, list) assert isinstance(list_of_trajs[0], md.Trajectory) eq(len(list_of_trajs), len(which_states)) for t in list_of_trajs: eq(len(t), 2) # sep, tps, one save(list_of_trajs, which_states, style='sep', format='lh5', outdir=self.td) save(list_of_trajs, which_states, style='tps', format='lh5', outdir=self.td) save(list_of_trajs, which_states, style='one', format='lh5', outdir=self.td) names = ['State0-0.lh5', 'State0-1.lh5', 'State0.lh5', 'State1-0.lh5', 'State1-1.lh5', 'State1.lh5', 'State2-0.lh5', 'State2-1.lh5', 'State2.lh5'] for name in names: t = md.load(pjoin(self.td, name)) eq(t.xyz, get('save_structures/' + name).xyz) # Just checking coordinates because atom names / bonds in reference data are incompatible with MDTraj.