Exemplo n.º 1
0
    def setUpClass(cls):
        # init project and resource
        import tempfile
        cls.shared_path = tempfile.mkdtemp(prefix="adaptivemd")
        Project.delete('example-simple-1')
        cls.project = Project('example-simple-1')
        # ----------------------------------------------------------------------
        # CREATE THE RESOURCE
        #   the instance to know about the place where we run simulations
        # ----------------------------------------------------------------------
        cls.project.initialize({'shared_path': cls.shared_path})
        if os.getenv('CONDA_BUILD', False):
            # activate the conda build test environment for workers

            cls.f_base = 'examples/files/alanine/'
            prefix = os.getenv('PREFIX')
            assert os.path.exists(prefix)
            cls.project.configuration.wrapper.pre.insert(
                0, 'source activate {prefix}'.format(prefix=prefix))

            # TODO why does test_simple_wrapper not
            #      have a chdir to ci test environment?
            test_tmp = prefix + '/../test_tmp/'
            if os.getcwd() is not test_tmp:
                os.chdir(test_tmp)
        else:
            # set the path for the workers to the path of the test interpreter.
            import sys

            cls.f_base = '../../examples/files/alanine/'
            cls.project.configuration.wrapper.pre.insert(
                0, 'PATH={python_path}:$PATH'.format(
                    python_path=os.path.dirname(sys.executable)))

        return cls
Exemplo n.º 2
0
    def setUpClass(cls):
        '''
        Operations that configure the test environment
        ----------------------------------------------

            env :
                    determine if local or in integration environment

            pkg :
                    object imports and coordination

            cfg :
                    object instantiation and building
                    one-time operations that set up for test

        '''

        # init project and resource
        import tempfile
        cls.shared_path = tempfile.mkdtemp(prefix="adaptivemd")
        Project.delete('test-skeleton')
        cls.project = Project('test-skeleton')
        cls.project.initialize({'shared_path': cls.shared_path})
        # ----------------------------------------------------------------------
        # CREATE THE RESOURCE
        #   the instance to know about the place where we run simulations
        # ----------------------------------------------------------------------
        if os.getenv('CONDA_BUILD', False):

            # activate the conda build test environment
            cls.f_base = 'examples/files/alanine/'
            prefix = os.getenv('PREFIX')
            assert os.path.exists(prefix)

            cls.project.configuration.wrapper.pre.insert(
                0, 'source activate {prefix}'.format(prefix=prefix))

            # TODO why does test_simple_wrapped not
            #      have a chdir to ci test environment?
            # TODO this is dealing in relative paths
            #      --> should check cwd based on absolute path
            test_tmp = prefix + '/../test_tmp/'
            if os.getcwd() is not test_tmp:
                os.chdir(test_tmp)

        else:
            # set the path for the workers to the path of the test interpreter.
            import sys

            cls.f_base = '../../examples/files/alanine/'
            cls.project.configuration.wrapper.pre.insert(
                0, 'PATH={python_path}:$PATH'.format(
                    python_path=os.path.dirname(sys.executable)))

        return cls
Exemplo n.º 3
0
os.environ['RADICAL_PILOT_DBURL'] = path_to_db

# import adaptive components

from adaptivemd import Project
from adaptivemd import LocalResource

from adaptivemd import OpenMMEngine
from adaptivemd import PyEMMAAnalysis

from adaptivemd import File

if __name__ == '__main__':

    project = Project('testcase')

    # --------------------------------------------------------------------------
    # CREATE THE RESOURCE
    #   the instance to know about the place where we run simulations
    # --------------------------------------------------------------------------

    project.initialize(LocalResource('$HOME/miniconda2/bin'))

    # --------------------------------------------------------------------------
    # CREATE THE ENGINE
    #   the instance to create trajectories
    # --------------------------------------------------------------------------
    pdb_file = File('file://../files/alanine/alanine.pdb').named('initial_pdb')

    engine = OpenMMEngine(
Exemplo n.º 4
0
# import adaptive components
import time

from adaptivemd import Project, ExecutionPlan
from adaptivemd import AllegroCluster
from adaptivemd import ExecutionPlan

from adaptivemd.engine.openmm import OpenMMEngine
from adaptivemd.analysis.pyemma import PyEMMAAnalysis

from adaptivemd import File

if __name__ == '__main__':

    project = Project('testcaseallegro')

    # --------------------------------------------------------------------------
    # CREATE THE RESOURCE
    #   the instance to know about the place where we run simulations
    # --------------------------------------------------------------------------

    # resource_id = 'fub.allegro'
    project.initialize(AllegroCluster())

    # --------------------------------------------------------------------------
    # CREATE THE ENGINE
    #   the instance to create trajectories
    # --------------------------------------------------------------------------
    pdb_file = File('file://../files/alanine/alanine.pdb').named(
        'initial_pdb').load()
Exemplo n.º 5
0
def init_project(p_name,
                 sys_name=None,
                 m_freq=None,
                 p_freq=None,
                 platform=None,
                 reinitialize=False):  #, dblocation=None):
    #def init_project(p_name, **freq):

    from adaptivemd import Project

    #if p_name in Project.list():
    #    print("Deleting existing version of this test project")
    #    Project.delete(p_name)

    dburl = os.environ.get("ADMD_DBURL", 0)
    if dburl:
        logger.info("Set ADMD_DBURL to: " + dburl)
        Project.set_dburl(dburl)
# if dblocation is not None:

#     Project.set_dblocation(dblocation)

    if reinitialize:
        logger.info(
            "Project {0} exists, deleting it from database to reinialize".
            format(p_name))
        Project.delete(p_name)

    if p_name in Project.list():
        logger.info(
            "Project {0} exists, reading it from database".format(p_name))
        project = Project(p_name)

    elif not all([sys_name, m_freq, p_freq, platform]):
        raise ValueError(
            "Must define all parameters [{0}] to initialize new project\nHave: {1}"
            .format("sys_name,m_freq,p_freq,platform",
                    [sys_name, m_freq, p_freq, platform].__repr__()))

    else:

        project = Project(p_name)

        from adaptivemd import File, OpenMMEngine
        from adaptivemd.analysis.pyemma import PyEMMAAnalysis

        # Initialize w/ config file: 1 of multiple options
        # TODO add config filename argument
        configuration_file = 'configuration.cfg'
        project.initialize(configuration_file)

        f_name = '{0}.pdb'.format(sys_name)

        # FIXME add system specifications to configuration file
        f_base = 'file:///$ADMD_FILES/{0}/'.format(sys_name)

        f_structure = File(f_base + f_name).load()

        f_system_2 = File(f_base + 'system-2.xml').load()
        f_integrator_2 = File(f_base + 'integrator-2.xml').load()

        f_system_5 = File(f_base + 'system-5.xml').load()
        f_integrator_5 = File(f_base + 'integrator-5.xml').load()

        sim_args = '-r -p {0}'.format(platform)

        engine_2 = OpenMMEngine(f_system_2, f_integrator_2, f_structure,
                                sim_args).named('openmm-2')

        engine_5 = OpenMMEngine(f_system_5, f_integrator_5, f_structure,
                                sim_args).named('openmm-5')

        # FIXME this is dumb and hard for user to deal with
        # TODO engine selection by name
        m_freq_2 = m_freq
        p_freq_2 = p_freq
        m_freq_5 = m_freq * 2 / 5
        p_freq_5 = p_freq * 2 / 5

        engine_2.add_output_type('master', 'allatoms.dcd', stride=m_freq_2)
        engine_2.add_output_type('protein',
                                 'protein.dcd',
                                 stride=p_freq_2,
                                 selection='protein')

        engine_5.add_output_type('master', 'allatoms.dcd', stride=m_freq_5)
        engine_5.add_output_type('protein',
                                 'protein.dcd',
                                 stride=p_freq_5,
                                 selection='protein')

        ca_features = {'add_distances_ca': None}
        #features = {'add_inverse_distances': {'select_Backbone': None}}
        ca_modeller_2 = PyEMMAAnalysis(engine_2, 'protein',
                                       ca_features).named('pyemma-ca-2')

        ca_modeller_5 = PyEMMAAnalysis(engine_5, 'protein',
                                       ca_features).named('pyemma-ca-5')

        pos = [
            '(rescode K and mass > 13) ' + 'or (rescode R and mass > 13) ' +
            'or (rescode H and mass > 13)'
        ]
        neg = ['(rescode D and mass > 13) ' + 'or (rescode E and mass > 13)']

        ionic_features = {
            'add_distances': {
                'select': pos
            },
            'kwargs': {
                'indices2': {
                    'select': neg
                }
            }
        }

        all_features = [ca_features, ionic_features]

        inv_ca_features = {'add_inverse_distances': {'select_Ca': None}}

        #ok#ionic_modeller = {'add_distances': {'select':
        #ok#                                   ['rescode K or rescode R or rescode H']},
        #ok#                  'kwargs': {'indices2': {'select':
        #ok#                                   'rescode D or rescode E']}}}
        #contact_features = [ {'add_inverse_distances':
        #                         {'select_Backbone': None}},
        #                     {'add_residue_mindist': None,
        #                      'kwargs': {'threshold': 0.6}}
        #                   ]

        all_modeller_2 = PyEMMAAnalysis(engine_2, 'protein',
                                        all_features).named('pyemma-ionic-2')

        all_modeller_5 = PyEMMAAnalysis(engine_5, 'protein',
                                        all_features).named('pyemma-ionic-5')

        inv_modeller_2 = PyEMMAAnalysis(
            engine_2, 'protein', inv_ca_features).named('pyemma-invca-2')

        inv_modeller_5 = PyEMMAAnalysis(
            engine_5, 'protein', inv_ca_features).named('pyemma-invca-5')

        project.generators.add(ca_modeller_2)
        project.generators.add(all_modeller_2)
        project.generators.add(inv_modeller_2)
        project.generators.add(ca_modeller_5)
        project.generators.add(all_modeller_5)
        project.generators.add(inv_modeller_5)
        project.generators.add(engine_2)
        project.generators.add(engine_5)

        #[print(g) for g in project.generators]

    return project
Exemplo n.º 6
0
import os

from adaptivemd import Project

from adaptivemd import OpenMMEngine
from adaptivemd import PyEMMAAnalysis

from adaptivemd import File
from adaptivemd import WorkerScheduler

import mdtraj as md

if __name__ == '__main__':

    Project.delete('example-simple-1')
    project = Project('example-simple-1')

    # --------------------------------------------------------------------------
    # CREATE THE RESOURCE
    #   the instance to know about the place where we run simulations
    # --------------------------------------------------------------------------

    project.initialize({'shared_path': '$HOME'})

    # --------------------------------------------------------------------------
    # CREATE THE ENGINE
    #   the instance to create trajectories
    # --------------------------------------------------------------------------

    pdb_file = File('file://../../examples/files/alanine/alanine.pdb').named(
Exemplo n.º 7
0
#
# os.environ['RADICAL_PILOT_DBURL'] = path_to_db

# import adaptive components

from adaptivemd import Project
from adaptivemd import LocalResource, AllegroCluster

from adaptivemd import OpenMMEngine4CUDA
from adaptivemd import PyEMMAAnalysis

from adaptivemd import File

if __name__ == '__main__':

    project = Project('testcase')

    # --------------------------------------------------------------------------
    # CREATE THE RESOURCE
    #   the instance to know about the place where we run simulations
    # --------------------------------------------------------------------------

    resource_id = 'fub.allegro'

    if len(sys.argv) > 2:
        exit()
    elif len(sys.argv) == 2:
        resource_id = sys.argv[1]

    if resource_id == 'local.jhp':
        project.initialize(LocalResource())
Exemplo n.º 8
0
# os.environ['RADICAL_PILOT_DBURL'] = path_to_db

# import adaptive components

from adaptivemd import Project
from adaptivemd import LocalResource AllegroCluster

from adaptivemd import OpenMMEngine
from adaptivemd import PyEMMAAnalysis

from adaptivemd import File, Directory


if __name__ == '__main__':

    project = Project('testcase')

    # --------------------------------------------------------------------------
    # CREATE THE RESOURCE
    #   the instance to know about the place where we run simulations
    # --------------------------------------------------------------------------

    resource_id = 'local.jhp'

    if len(sys.argv) > 2:
        exit()
    elif len(sys.argv) == 2:
        resource_id = sys.argv[1]

    if resource_id == 'local.jhp':
        project.initialize(LocalJHP())
Exemplo n.º 9
0
#!/usr/bin/env python

import sys

# import adaptive components

from adaptivemd import Project
from adaptivemd import AllegroCluster

from adaptivemd import OpenMMEngine

from adaptivemd import File

if __name__ == '__main__':

    project = Project('testcase')

    # --------------------------------------------------------------------------
    # CREATE THE RESOURCE
    #   the instance to know about the place where we run simulations
    # --------------------------------------------------------------------------

    resource = AllegroCluster()

    project.initialize(resource)

    # --------------------------------------------------------------------------
    # CREATE THE ENGINE
    #   the instance to create trajectories
    # --------------------------------------------------------------------------
    pdb_file = File('file://../files/alanine/alanine.pdb').named('initial_pdb')
Exemplo n.º 10
0
             'to get less traffic on the DB')

    args = parser.parse_args()

    if args.allegro:
        db_path = "mongodb://ensembletk.imp.fu-berlin.de:27017/"
    elif args.sheep:
        db_path = "mongodb://sheep:27017/"
    elif args.local:
        db_path = "mongodb://localhost:27017/"
    else:
        db_path = args.mongo_db_path

    MongoDBStorage._db_url = db_path

    project = Project(args.project)

    print project.resource

    print project.trajectories

    # --------------------------------------------------------------------------
    # CREATE THE WORKER
    #   the instance that knows about the current state
    # --------------------------------------------------------------------------

    worker = Worker(
        walltime=args.walltime,
        generators=args.generators,
        sleep=args.sleep,
        heartbeat=10.0
Exemplo n.º 11
0
#
# os.environ['RADICAL_PILOT_DBURL'] = path_to_db

# import adaptive components

from adaptivemd import Project
from adaptivemd import AllegroCluster

from adaptivemd import OpenMMEngine4CUDA
from adaptivemd import PyEMMAAnalysis

from adaptivemd import File

if __name__ == '__main__':

    project = Project('testcase')

    # --------------------------------------------------------------------------
    # CREATE THE RESOURCE
    #   the instance to know about the place where we run simulations
    # --------------------------------------------------------------------------

    resource_id = 'fub.allegro'
    project.initialize(AllegroCluster())

    # --------------------------------------------------------------------------
    # CREATE THE ENGINE
    #   the instance to create trajectories
    # --------------------------------------------------------------------------
    pdb_file = File('file://../files/alanine/alanine.pdb').named('initial_pdb')
Exemplo n.º 12
0
# import adaptive components
import time

from adaptivemd import Project, ExecutionPlan
from adaptivemd import AllegroCluster
from adaptivemd import ExecutionPlan

from adaptivemd import OpenMMEngine
from adaptivemd import PyEMMAAnalysis

from adaptivemd import File

if __name__ == '__main__':

    project = Project('testcase-4')

    # --------------------------------------------------------------------------
    # CREATE THE RESOURCE
    #   the instance to know about the place where we run simulations
    # --------------------------------------------------------------------------

    resource_id = 'fub.allegro'
    project.initialize(AllegroCluster())

    # --------------------------------------------------------------------------
    # CREATE THE ENGINE
    #   the instance to create trajectories
    # --------------------------------------------------------------------------
    pdb_file = File('file://../files/alanine/alanine.pdb').named('initial_pdb')
Exemplo n.º 13
0
if __name__ == '__main__':

    # --------------------------------------------------------------------------
    # CREATE THE RESOURCE
    #   the instance to know about the place where we run simulations
    # --------------------------------------------------------------------------

    # use the resource specified as argument, fall back to localhost
    resource_id = 'local.jhp'

    if len(sys.argv) > 3:
        exit()

    project_id = sys.argv[1]
    project = Project(project_id)

    if len(sys.argv) == 3:
        resource_id = sys.argv[2]

        if resource_id == 'local.jhp':
            project.initialize(LocalJHP)
        elif resource_id == 'local.sheep':
            project.initialize(LocalSheep)
        elif resource_id == 'fub.allegro':
            project.initialize(AllegroCluster)

    # --------------------------------------------------------------------------
    # CREATE THE ENGINE
    #   the instance to create trajectories
    # --------------------------------------------------------------------------
Exemplo n.º 14
0
import os

from adaptivemd import Project
from adaptivemd import LocalResource

from adaptivemd import OpenMMEngine
from adaptivemd import PyEMMAAnalysis

from adaptivemd import File
from adaptivemd import WorkerScheduler

import mdtraj as md

if __name__ == '__main__':

    Project.delete('example-simple-1')
    project = Project('example-simple-1')

    # --------------------------------------------------------------------------
    # CREATE THE RESOURCE
    #   the instance to know about the place where we run simulations
    # --------------------------------------------------------------------------

    project.initialize(LocalResource())

    # --------------------------------------------------------------------------
    # CREATE THE ENGINE
    #   the instance to create trajectories
    # --------------------------------------------------------------------------

    pdb_file = File('file://../../examples/files/alanine/alanine.pdb').named(
os.environ['RADICAL_PILOT_DBURL'] = path_to_db

# import adaptive components

from adaptivemd import Project, ExecutionPlan
from adaptivemd import LocalJHP
from adaptivemd import ExecutionPlan

from adaptivemd import OpenMMEngine
from adaptivemd import PyEMMAAnalysis

from adaptivemd import File

if __name__ == '__main__':

    project = Project('testcase-worker')

    # --------------------------------------------------------------------------
    # CREATE THE RESOURCE
    #   the instance to know about the place where we run simulations
    # --------------------------------------------------------------------------

    # resource_id = 'fub.allegro'
    project.initialize(LocalJHP())

    # --------------------------------------------------------------------------
    # CREATE THE ENGINE
    #   the instance to create trajectories
    # --------------------------------------------------------------------------
    pdb_file = File('file://../files/alanine/alanine.pdb').named(
        'initial_pdb').load()
Exemplo n.º 16
0
if __name__ == '__main__':

    # --------------------------------------------------------------------------
    # CREATE THE RESOURCE
    #   the instance to know about the place where we run simulations
    # --------------------------------------------------------------------------

    # use the resource specified as argument, fall back to localhost
    resource_id = 'local.jhp'

    if len(sys.argv) > 3 or len(sys.argv) < 2:
        exit()

    project_name = sys.argv[1]

    project = Project(project_name)

    if len(sys.argv) == 3:

        if resource_id == 'local.jhp':
            project.initialize(LocalJHP)
        elif resource_id == 'local.sheep':
            project.initialize(LocalSheep)
        elif resource_id == 'fub.allegro':
            project.initialize(AllegroCluster)

    # --------------------------------------------------------------------------
    # CREATE THE ENGINE
    #   the instance to create trajectories
    # --------------------------------------------------------------------------
    pdb_file = File('file://files/input.pdb')
Exemplo n.º 17
0
def init_project(p_name,
                 sys_name=None,
                 m_freq=None,
                 p_freq=None,
                 platform=None,
                 dbhost=None,
                 w_threads=None):
    #def init_project(p_name, **freq):

    from adaptivemd import Project

    #if p_name in Project.list():
    #    print(project.name, "Deleting existing version of this test project")
    #    Project.delete(p_name)

    if dbhost is not None:
        Project.set_dbhost(dbhost)

    project = Project(p_name)

    if project.name in Project.list():
        print(
            project.name,
            "Project {0} exists, reading it from database".format(
                project.name))

    else:

        from adaptivemd import File, OpenMMEngine
        from adaptivemd.analysis.pyemma import PyEMMAAnalysis

        #####################################
        # NEW initialize sequence
        configuration_file = 'configuration.cfg'
        project.initialize(configuration_file)
        #
        # OLD initialize sequence
        #from adaptivemd import LocalResource
        #resource = LocalResource('/lustre/atlas/scratch/jrossyra/bip149/admd/')
        #project.initialize(resource)
        #####################################

        f_name = '{0}.pdb'.format(sys_name)

        # only works if filestructure is preserved as described in 'jro_ntl9.ipynb'
        # and something akin to job script in 'admd_workers.pbs' is used
        f_base = 'file:///$ADAPTIVEMD/examples/files/{0}/'.format(sys_name)

        f_structure = File(f_base + f_name).load()

        f_system_2 = File(f_base + 'system-2.xml').load()
        f_integrator_2 = File(f_base + 'integrator-2.xml').load()

        f_system_5 = File(f_base + 'system-5.xml').load()
        f_integrator_5 = File(f_base + 'integrator-5.xml').load()

        sim_args = '-r -p {0}'.format(platform)

        if platform == 'CPU':
            print(
                project.name,
                "Using CPU simulation platform with {0} threads per worker".
                format(w_threads))

            sim_args += ' --cpu-cpu-threads {0}'.format(w_threads)

        engine_2 = OpenMMEngine(f_system_2, f_integrator_2, f_structure,
                                sim_args).named('openmm-2')

        engine_5 = OpenMMEngine(f_system_5, f_integrator_5, f_structure,
                                sim_args).named('openmm-5')

        m_freq_2 = m_freq
        p_freq_2 = p_freq
        m_freq_5 = m_freq * 2 / 5
        p_freq_5 = p_freq * 2 / 5

        engine_2.add_output_type('master', 'allatoms.dcd', stride=m_freq_2)
        engine_2.add_output_type('protein',
                                 'protein.dcd',
                                 stride=p_freq_2,
                                 selection='protein')

        engine_5.add_output_type('master', 'allatoms.dcd', stride=m_freq_5)
        engine_5.add_output_type('protein',
                                 'protein.dcd',
                                 stride=p_freq_5,
                                 selection='protein')

        ca_features = {'add_distances_ca': None}
        #features = {'add_inverse_distances': {'select_Backbone': None}}
        ca_modeller_2 = PyEMMAAnalysis(engine_2, 'protein',
                                       ca_features).named('pyemma-ca-2')

        ca_modeller_5 = PyEMMAAnalysis(engine_5, 'protein',
                                       ca_features).named('pyemma-ca-5')

        pos = [
            '(rescode K and mass > 13) ' + 'or (rescode R and mass > 13) ' +
            'or (rescode H and mass > 13)'
        ]
        neg = ['(rescode D and mass > 13) ' + 'or (rescode E and mass > 13)']

        ionic_features = {
            'add_distances': {
                'select': pos
            },
            'kwargs': {
                'indices2': {
                    'select': neg
                }
            }
        }

        all_features = [ca_features, ionic_features]

        #ok#ionic_modeller = {'add_distances': {'select':
        #ok#                                   ['rescode K or rescode R or rescode H']},
        #ok#                  'kwargs': {'indices2': {'select':
        #ok#                                   'rescode D or rescode E']}}}
        #contact_features = [ {'add_inverse_distances':
        #                         {'select_Backbone': None}},
        #                     {'add_residue_mindist': None,
        #                      'kwargs': {'threshold': 0.6}}
        #                   ]

        all_modeller_2 = PyEMMAAnalysis(engine_2, 'protein',
                                        all_features).named('pyemma-ionic-2')

        all_modeller_5 = PyEMMAAnalysis(engine_5, 'protein',
                                        all_features).named('pyemma-ionic-5')

        project.generators.add(ca_modeller_2)
        project.generators.add(all_modeller_2)
        project.generators.add(ca_modeller_5)
        project.generators.add(all_modeller_5)
        project.generators.add(engine_2)
        project.generators.add(engine_5)

        [print(g) for g in project.generators]

    return project
Exemplo n.º 18
0
# import adaptive components
import time

from adaptivemd import Project, ExecutionPlan
from adaptivemd import AllegroCluster
from adaptivemd import ExecutionPlan

from adaptivemd import OpenMMEngine4CUDA
from adaptivemd import PyEMMAAnalysis

from adaptivemd import File

if __name__ == '__main__':

    project = Project('testcase-5')

    # --------------------------------------------------------------------------
    # CREATE THE RESOURCE
    #   the instance to know about the place where we run simulations
    # --------------------------------------------------------------------------

    resource_id = 'fub.allegro'
    project.initialize(AllegroCluster())

    # --------------------------------------------------------------------------
    # CREATE THE ENGINE
    #   the instance to create trajectories
    # --------------------------------------------------------------------------
    pdb_file = File('file://../files/alanine/alanine.pdb').named('initial_pdb')