def setup(self):
        if not HAS_MDTRAJ:
            pytest.skip("Unable to import MDTraj")
        pytest.importorskip('simtk.unit')

        self.mdt = md.load(data_filename("ala_small_traj.pdb"))
        top = MDTrajTopology(self.mdt.topology)
        self.traj = ops_omm.tools.trajectory_from_mdtraj(self.mdt)
        self.cv = MDTrajFunctionCV(md.compute_distances, top,
                                   atom_pairs=[[0, 1]])
 def setup(self):
     self.ad_pdb = data_filename("ala_small_traj.pdb")
     self.yml = "\n".join([
         "name: phi",
         "type: mdtraj",
         "topology: " + self.ad_pdb,
         "period_min: -np.pi",
         "period_max: np.pi",
         "func: {func}",
         "kwargs:",
         "  {kwargs}",
     ])
     self.kwargs = "indices: [[4, 6, 8, 14]]"
    def setup(self):
        # PES is one-dimensional zero function (y(x) = 0)
        pes = toys.LinearSlope(m=[0.0], c=[0.0])
        topology = toys.Topology(n_spatial=1, masses=[1.0], pes=pes)
        integrator = toys.LeapfrogVerletIntegrator(0.02)
        options = {
            'integ' : integrator,
            'n_frames_max' : 1000,
            'n_steps_per_frame' : 1
        }
        self.engine = toys.Engine(options=options, topology=topology)
        # test uses snapshots with different velocities
        self.initial_snapshots = [toys.Snapshot(
                                      coordinates=np.array([[0.0]]),
                                      velocities=np.array([[1.0]]),
                                      engine=self.engine),
                                  toys.Snapshot(
                                      coordinates=np.array([[0.1]]),
                                      velocities=np.array([[-1.0]]),
                                      engine=self.engine),
                                  toys.Snapshot(
                                      coordinates=np.array([[-0.2]]),
                                      velocities=np.array([[2.0]]),
                                      engine=self.engine)]
        # trajectory length is set to 100 steps
        self.l = 100
        # reaction coordinate is just x coordinate
        rc = paths.FunctionCV("Id", lambda snap : snap.coordinates[0][0])
        # state S: [-0.5, 0.5]
        self.state_S = paths.CVDefinedVolume(rc, -0.5, 0.5)
        # define state labels
        self.state_labels = {
            "S" : self.state_S,
            "NotS" :~self.state_S}
        # velocities are not randomized
        randomizer = paths.NoModification()

        self.filename = data_filename("sshooting_test.nc")
        self.storage = paths.Storage(self.filename, mode="w")
        self.storage.save(self.initial_snapshots)

        self.simulation = SShootingSimulation(
            storage=self.storage,
            engine=self.engine,
            state_S=self.state_S,
            randomizer=randomizer,
            initial_snapshots=self.initial_snapshots,
            trajectory_length=self.l
        )
        self.simulation.output_stream = open(os.devnull, 'w')
    def _make_gromacs_snap(self):
        # gromacs-specific
        test_dir = data_filename("gromacs_engine")
        engine = paths.engines.gromacs.Engine(
            gro="conf.gro",
            mdp="md.mdp",
            top="topol.top",
            options={},
            base_dir=test_dir,
            prefix="proj"
        )
        snap_file = os.path.join(test_dir, "project_trr", "0000000.trr")

        snap = paths.engines.gromacs.ExternalMDSnapshot(
            file_name=snap_file,
            file_position=2,
            engine=engine
        )
        return snap
 def test_build_topology_file(self):
     ad_pdb = data_filename("ala_small_traj.pdb")
     topology = build_topology(ad_pdb)
     assert topology.n_spatial == 3
     assert topology.n_atoms == 1651
Exemple #6
0
    def setup(self):
        if not HAS_MDTRAJ:
            pytest.skip()

        self.filename = data_filename('ala_small_traj.pdb')
 def _make_openmm_snap(self):
     mm = pytest.importorskip('simtk.openmm')
     traj_file = data_filename('ala_small_traj.pdb')
     traj = paths.engines.openmm.tools.ops_load_trajectory(traj_file)
     snap = traj[0]
     return snap
Exemple #8
0
    def setup(self):
        # PES is one-dimensional negative slope (y(x) = -x)
        pes = toys.LinearSlope(m=[-1.0], c=[0.0])
        topology = toys.Topology(n_spatial=1, masses=[1.0], pes=pes)
        integrator = toys.LeapfrogVerletIntegrator(0.02)
        options = {
            'integ': integrator,
            'n_frames_max': 1000,
            'n_steps_per_frame': 1
        }
        self.engine = toys.Engine(options=options, topology=topology)
        # test uses snapshots with different velocities
        # (1) does not ever reach A
        # (2) goes form A to S to B
        # (3) goes from B to S to A
        self.initial_snapshots = [
            toys.Snapshot(coordinates=np.array([[0.0]]),
                          velocities=np.array([[1.0]]),
                          engine=self.engine),
            toys.Snapshot(coordinates=np.array([[0.1]]),
                          velocities=np.array([[2.0]]),
                          engine=self.engine),
            toys.Snapshot(coordinates=np.array([[-0.2]]),
                          velocities=np.array([[-2.0]]),
                          engine=self.engine)
        ]
        # trajectory length is set to 100 steps
        self.l = 100
        # reaction coordinate is just x coordinate
        rc = paths.FunctionCV("Id", lambda snap: snap.coordinates[0][0])
        # state A: [-inf, -1]
        self.state_A = paths.CVDefinedVolume(rc, float("-inf"), -1.0)
        # state B: [1, inf]
        self.state_B = paths.CVDefinedVolume(rc, 1.0, float("inf"))
        # state S: [-0.5, 0.5]
        self.state_S = paths.CVDefinedVolume(rc, -0.5, 0.5)
        # define state labels
        self.state_labels = {
            "A": self.state_A,
            "B": self.state_B,
            "S": self.state_S,
            "None": ~(self.state_A | self.state_B | self.state_S)
        }
        # velocities are not randomized
        randomizer = paths.NoModification()

        self.filename = data_filename("sshooting_test.nc")
        self.storage = paths.Storage(self.filename, mode="w")
        self.storage.save(self.initial_snapshots)

        self.simulation = SShootingSimulation(
            storage=self.storage,
            engine=self.engine,
            state_S=self.state_S,
            randomizer=randomizer,
            initial_snapshots=self.initial_snapshots,
            trajectory_length=self.l)
        self.simulation.output_stream = open(os.devnull, 'w')
        self.simulation.run(n_per_snapshot=1)
        self.analysis = SShootingAnalysis(
            steps=self.storage.steps,
            states=[self.state_A, self.state_B, self.state_S])