예제 #1
0
    # CREATE THE ENGINE
    #   the instance to create trajectories
    # --------------------------------------------------------------------------
    pdb_file = File('file://files/input.pdb')

    engine = OpenMMEngine(
        pdb_file=pdb_file,
        system_file=File('file://files/system.xml'),
        integrator_file=File('file://files/integrator.xml'),
        args='-r --report-interval 1 -p CPU --store-interval 1')

    # --------------------------------------------------------------------------
    # CREATE THE MODELLER
    #   the instance to create msm models
    # --------------------------------------------------------------------------
    modeller = PyEMMAAnalysis(pdb_file=pdb_file,
                              source_folder=File('../staging_area/ntl9/trajs'))

    # --------------------------------------------------------------------------
    # CREATE THE SESSION
    #   the instance that runs the simulations on the resource
    # --------------------------------------------------------------------------

    # add the task generating capabilities
    project.register(engine)
    project.register(modeller)

    project.open()

    scheduler = project.get_scheduler(cores=2)
    trajs = project.new_trajectory(pdb_file, 100, 4)
예제 #2
0
    # --------------------------------------------------------------------------
    # CREATE THE CLUSTER
    #   the instance that runs the simulations on the resource
    # --------------------------------------------------------------------------

    cluster = MDCluster(system='alanine', resource=resource, report=report)

    # add the path to CONDA if now already in the default
    cluster.add_path(os.environ.get('CONDA_BIN'))

    # --------------------------------------------------------------------------
    # CREATE AN ANALYZER
    #   the instance that knows how to compute a msm from the trajectories
    # --------------------------------------------------------------------------

    msmb = PyEMMAAnalysis(pdb_file, File('../staging_area/ntl9/trajs'))
    msmb.args = '-k 2 -l 1 -c 2'

    # --------------------------------------------------------------------------
    # CREATE THE BRAIN
    #   the instance that knows what to do which the cluster
    # --------------------------------------------------------------------------
    brain = Brain(msmb)

    with cluster:
        resource.add_shared(cluster)

        report.info('stage shared data from generators')
        cluster.stage_in(engine.stage_in)
        cluster.stage_in(msmb.stage_in)
예제 #3
0
    # --------------------------------------------------------------------------
    pdb_file = File('file://../files/alanine/alanine.pdb').named('initial_pdb')

    engine = OpenMMEngine(
        pdb_file=pdb_file,
        system_file=File('file://../files/alanine/system.xml'),
        integrator_file=File('file://../files/alanine/integrator.xml'),
        args='-r --report-interval 1 -p CPU --store-interval 1').named(
            'openmm')

    # --------------------------------------------------------------------------
    # CREATE AN ANALYZER
    #   the instance that knows how to compute a msm from the trajectories
    # --------------------------------------------------------------------------

    modeller = PyEMMAAnalysis(pdb_file=pdb_file).named('pyemma')

    project.generators.add(engine)
    project.generators.add(modeller)

    # --------------------------------------------------------------------------
    # CREATE THE CLUSTER
    #   the instance that runs the simulations on the resource
    # --------------------------------------------------------------------------

    scheduler = project.get_scheduler(cores=1)

    trajectory = project.new_trajectory(engine['pdb_file'], 100)
    task = engine.run(trajectory)

    scheduler(task)
예제 #4
0
    engine = OpenMMEngine(
        pdb_file=pdb_file,
        system_file=File(
            'file://../../examples/files/alanine/system.xml').load(),
        integrator_file=File(
            'file://../../examples/files/alanine/integrator.xml').load(),
        args='-r --report-interval 1 -p CPU --store-interval 1').named(
            'openmm')

    # --------------------------------------------------------------------------
    # CREATE AN ANALYZER
    #   the instance that knows how to compute a msm from the trajectories
    # --------------------------------------------------------------------------

    modeller = PyEMMAAnalysis(engine=engine).named('pyemma')

    project.generators.add(engine)
    project.generators.add(modeller)

    # --------------------------------------------------------------------------
    # CREATE THE CLUSTER
    #   the instance that runs the simulations on the resource
    # --------------------------------------------------------------------------

    trajectory = project.new_trajectory(engine['pdb_file'], 100, engine)
    task = engine.run(trajectory)

    # project.queue(task)

    pdb = md.load('../../examples/files/alanine/alanine.pdb')
예제 #5
0
    def test(self):
        # ----------------------------------------------------------------------
        # CREATE THE ENGINE
        #   the instance to create trajectories
        # ----------------------------------------------------------------------

        pdb_file = File('file://{0}alanine.pdb'.format(
            self.f_base)).named('initial_pdb').load()

        engine = OpenMMEngine(
            pdb_file=pdb_file,
            system_file=File('file://{0}system.xml'.format(
                self.f_base)).load(),
            integrator_file=File('file://{0}integrator.xml'.format(
                self.f_base)).load(),
            args='-r --report-interval 1 -p CPU --store-interval 1 -v').named(
                'openmm')

        # ----------------------------------------------------------------------
        # CREATE AN ANALYZER
        #   the instance that knows how to compute a msm from the trajectories
        # ----------------------------------------------------------------------

        modeller = PyEMMAAnalysis(engine=engine).named('pyemma')

        self.project.generators.add(engine)
        self.project.generators.add(modeller)

        def strategy(loops=1, trajs_per_loop=1, length=1):
            initial_traj = self.project.new_trajectory(frame=pdb_file,
                                                       length=length)
            task = engine.run(initial_traj)
            self.project.queue(task)
            yield task.is_done

            for loop in range(loops):
                # submit some trajectory tasks
                trajectories = self.project.new_ml_trajectory(
                    engine=engine, length=length, number=trajs_per_loop)
                tasks = tuple(map(engine.run, trajectories))
                self.project.queue(tasks)
                print("queued %s tasks" % len(tasks))

                # continue if ALL of the tasks are done (can be failed)
                yield [task.is_done for task in tasks]

                # submit a model job
                task = modeller.execute(list(self.project.trajectories))
                self.project.queue(task)
                print("queued modeller task")

                # when it is done do next loop
                yield task.is_done

        # TODO worker/MD running in subprocess thread horribly slow
        #      - can it be made to run a bit faster?
        n_loops = 1
        trajs_per_loop = 1
        self.project.add_event(
            strategy(loops=n_loops, trajs_per_loop=trajs_per_loop))
        self.project.run()
        self.project.wait_until(self.project.on_ntraj(n_loops *
                                                      trajs_per_loop))

        self.assertEqual(len(list(self.project.trajectories)),
                         n_loops * trajs_per_loop)
        self.project.close()
예제 #6
0
    def test(self):
        # ----------------------------------------------------------------------
        # CREATE THE ENGINE
        #   the instance to create trajectories
        # ----------------------------------------------------------------------

        pdb_file = File('file://{0}alanine.pdb'.format(
            self.f_base)).named('initial_pdb').load()

        engine = OpenMMEngine(
            pdb_file=pdb_file,
            system_file=File('file://{0}system.xml'.format(
                self.f_base)).load(),
            integrator_file=File('file://{0}integrator.xml'.format(
                self.f_base)).load(),
            args='-r --report-interval 1 -p CPU --store-interval 1').named(
                'openmm')

        # ----------------------------------------------------------------------
        # CREATE AN ANALYZER
        #   the instance that knows how to compute a msm from the trajectories
        # ----------------------------------------------------------------------

        modeller = PyEMMAAnalysis(engine=engine).named('pyemma')

        self.project.generators.add(engine)
        self.project.generators.add(modeller)

        # ----------------------------------------------------------------------
        # CREATE THE CLUSTER
        #   the instance that runs the simulations on the resource
        # ----------------------------------------------------------------------
        traj_len = 1
        trajectory = self.project.new_trajectory(engine['pdb_file'], traj_len,
                                                 engine)
        task = engine.run(trajectory)

        # self.project.queue(task)

        pdb = md.load('{0}alanine.pdb'.format(self.f_base))

        # this part fakes a running worker without starting the worker process
        worker = WorkerScheduler(self.project.configuration, verbose=True)
        worker.enter(self.project)

        worker.submit(task)

        self.assertEqual(len(self.project.trajectories), 0)

        while not task.is_done():
            worker.advance()

        try:
            assert (len(self.project.trajectories) == 1)
        except AssertionError:
            print("stderr from worker task: \n%s" % task.stderr)
            print("stdout from worker task: \n%s" % task.stdout)
            raise
        print("stdout of worker:\n%s" % task.stdout)

        # FIXME: the worker space is cleared, so the trajectory paths are not valid anymore.
        # traj_path = os.path.join(
        #     worker.path,
        #     'workers',
        #     'worker.' + hex(task.__uuid__),
        #     worker.replace_prefix(self.project.trajectories.one.url)
        # )
        # this is a workaround, but assumes that sandbox:// lives on the same fs.
        traj_path = os.path.join(self.shared_path,
                                 self.project.trajectories.one.dirname[1:],
                                 'output.dcd')

        assert (os.path.exists(traj_path)), traj_path

        # go back to the place where we ran the test
        traj = md.load(traj_path, top=pdb)

        assert (len(traj) == traj_len + 1), len(traj)

        # well, we have a 100 step trajectory which matches the size of the initial PDB
        # that is a good sign

        # extend the trajectory by 10
        task2 = task.extend(10)

        worker.submit(task2)

        while not task2.is_done():
            worker.advance()

        # should still be one, since we have the same trajectory
        assert (len(self.project.trajectories) == 1)

        traj = md.load(traj_path, top=pdb)

        self.assertEqual(len(traj), traj_len + 10 + 1)

        # after extension it is traj_len + 10 frames. Excellent

        self.project.close()
예제 #7
0
    #   the instance to create trajectories
    # --------------------------------------------------------------------------
    pdb_file = File('file://../files/alanine/alanine.pdb').named('initial_pdb')

    engine = OpenMMEngine4CUDA(
        pdb_file=pdb_file,
        system_file=File('file://../files/alanine/system.xml'),
        integrator_file=File('file://../files/alanine/integrator.xml'),
        args='-r --report-interval 10 --store-interval 10').named('openmm')

    # --------------------------------------------------------------------------
    # CREATE AN ANALYZER
    #   the instance that knows how to compute a msm from the trajectories
    # --------------------------------------------------------------------------

    modeller = PyEMMAAnalysis(pdb_file=pdb_file).named('pyemma')

    project.generators.add(engine)
    project.generators.add(modeller)

    # --------------------------------------------------------------------------
    # CREATE THE CLUSTER
    #   the instance that runs the simulations on the resource
    # --------------------------------------------------------------------------

    scheduler = project.get_scheduler('gpu', cores=1, runtime=4 * 24 * 60)

    # create 4 blocks a 4 trajectories
    trajectories = [
        project.new_trajectory(engine['pdb_file'], 100, 4) for _ in range(4)
    ]