Esempio n. 1
0
    # --------------------------------------------------------------------------

    # 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')

    engine = OpenMMEngine(
        pdb_file=pdb_file,
        system_file=File('file://files/system.xml'),
        integrator_file=File('file://files/integrator.xml'),
Esempio n. 2
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
Esempio n. 3
0
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()

    engine = OpenMMEngine(
        pdb_file=pdb_file,
        system_file=File('file://../files/alanine/system.xml').load(),
        integrator_file=File('file://../files/alanine/integrator.xml').load(),
        args='-r --report-interval 10 --store-interval 1 -p CPU').named(
            'openmm')
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(
        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')

    # --------------------------------------------------------------------------
Esempio n. 5
0
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(
        'initial_pdb').load()

    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(),
Esempio n. 6
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
Esempio n. 7
0
    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())
    elif resource_id == 'local.sheep':
        project.initialize(LocalResource())
    elif 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')

    engine = OpenMMEngine4CUDA(
        pdb_file=pdb_file,
        system_file=File('file://../files/alanine/system.xml'),
        integrator_file=File('file://../files/alanine/integrator.xml'),
Esempio n. 8
0
    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())
    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/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'),
Esempio n. 9
0
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(
        'initial_pdb').load()

    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(),
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()

    engine = OpenMMEngine(
        pdb_file=pdb_file,
        system_file=File('file://../files/alanine/system.xml').load(),
        integrator_file=File('file://../files/alanine/integrator.xml').load(),
        args='-r --report-interval 10 --store-interval 1 -p CPU').named(
            'openmm')
Esempio n. 11
0
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')

    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 --store-interval 1 -p CUDA').named(
            'openmm')

    project.generators.add(engine)