Пример #1
0
    def save(self):
        "Save the trajs as a n MSMBuilder project"

        traj_dir = pjoin(self.project_dir, 'Trajectories')
        if not os.path.exists(traj_dir):
            os.makedirs(traj_dir)

        t = Trajectory.load_trajectory_file(self.conf_filename)

        traj_paths = []
        for i, xyz in enumerate(self.trajectories):
            t['IndexList'] = None  # bug in msmbuilder
            t['XYZList'] = xyz

            traj_paths.append(pjoin(traj_dir, 'trj%d.lh5' % i))
            t.save(traj_paths[-1])

        p = Project(
            {
                'conf_filename': os.path.abspath(self.conf_filename),
                'traj_lengths': self.n_frames * np.ones(self.n_trajs),
                'traj_paths': [os.path.abspath(e) for e in traj_paths],
                'traj_converted_from': [[] for i in range(self.n_trajs)],
                'traj_errors': [None for i in range(self.n_trajs)],
            },
            project_dir=self.project_dir,
            validate=True)
        p.save(pjoin(self.project_dir, 'Project.yaml'))

        # just check again
        p = Project.load_from(pjoin(self.project_dir, 'Project.yaml'))
        p._validate()
        assert np.all(
            (p.load_traj(0)['XYZList'] - self.trajectories[0])**2 < 1e-6)
Пример #2
0
    def save(self):
        "Save the trajs as a n MSMBuilder project"
        
        traj_dir = pjoin(self.project_dir, 'Trajectories')
        if not os.path.exists(traj_dir):
            os.makedirs(traj_dir)

        t = Trajectory.load_trajectory_file(self.conf_filename)

        traj_paths = []
        for i, xyz in enumerate(self.trajectories):
            t['IndexList'] = None # bug in msmbuilder
            t['XYZList'] = xyz

            traj_paths.append(pjoin(traj_dir, 'trj%d.lh5' % i))
            t.save(traj_paths[-1])

        p = Project({'conf_filename': os.path.abspath(self.conf_filename),
            'traj_lengths': self.n_frames*np.ones(self.n_trajs),
            'traj_paths': [os.path.abspath(e) for e in traj_paths],
            'traj_converted_from': [[] for i in range(self.n_trajs)],
            'traj_errors': [None for i in range(self.n_trajs)],
            }, project_dir=self.project_dir, validate=True)
        p.save(pjoin(self.project_dir,'Project.yaml'))

        # just check again
        p = Project.load_from(pjoin(self.project_dir,'Project.yaml'))
        p._validate()
        assert np.all((p.load_traj(0)['XYZList'] - self.trajectories[0])**2 < 1e-6)