Ejemplo n.º 1
0
def cli_main():
    """
    Enable mdstudio_cli as a command line tool

    Main entry point function called from the mdstudio-cli command line tool
    created by Python setuptools upon package installation.
    """

    # Override txaio logger to print result to stdout
    lg = logging.getLogger('clilogger')
    lg.setLevel(logging.INFO)
    lg.addHandler(logging.StreamHandler(sys.stdout))

    # Parse command line arguments
    config = mdstudio_cli_parser()

    main(CliWampApi,
         auto_reconnect=False,
         log_level=config['log_level'],
         extra=config,
         daily_log=False)
Ejemplo n.º 2
0
from mdstudio.runner import main
from mdstudio_amber.wamp_services import AmberWampApi

if __name__ == '__main__':
    main(AmberWampApi)
Ejemplo n.º 3
0
from mdstudio.runner import main
from lie_ti.ti_endpoints import Gromacs_ti_wamp_api

if __name__ == '__main__':
    main(Gromacs_ti_wamp_api)
Ejemplo n.º 4
0
            })
        print("promised job: ", data)

        print("running sequential version")

        output = yield self.call(
            "mdgroup.mdstudio_gromacs.endpoint.gromacs_ligand", {
                "cerise_file": create_path_file_obj(cerise_file),
                "ligand_file": create_path_file_obj(ligand_file),
                "protein_file": None,
                "protein_top": create_path_file_obj(protein_top),
                "topology_file": create_path_file_obj(topology_file),
                "include": list(map(create_path_file_obj, include)),
                "workdir": workdir,
                "clean_remote_workdir": False,
                "parameters": {
                    "sim_time": 0.001,
                    "residues": residues
                }
            })

        print("output sequential: ", output)

        output2 = yield self.call(
            "mdgroup.mdstudio_gromacs.endpoint.query_gromacs_results", data)
        print("MD output async: ", output2)


if __name__ == "__main__":
    main(Run_md)
Ejemplo n.º 5
0
# -*- coding: utf-8 -*-

from mdstudio.runner import main
from mdstudio_workflow.wamp_services import WorkflowWampApi

if __name__ == '__main__':
    main(WorkflowWampApi)
Ejemplo n.º 6
0
    @chainable
    def on_run(self):

        # Convert SMILES string into 1D mol2 file
        # Note: the SMILES string is defined as 'path_file' object
        mol = yield self.call('mdgroup.mdstudio_structures.endpoint.convert',
                              {"output_format": "mol2",
                               "mol": {"content": "O1[C@@H](CCC1=O)CCC",
                                       "extension": "smi",
                                       "path": None}
                               })

        # Convert 1D mol2 file into 3D PDB file
        # Note: the returned 'mol' path_file object is used as input for make3D
        pdb = yield self.call(
            'mdgroup.mdstudio_structures.endpoint.make3d',
            {'input_format': 'mol2',
             'output_format': 'pdb',
             'mol': mol['mol']})

        print(pdb['mol']['content'])

        # Disconnect from broker and stop reactor event loop
        self.disconnect()
        reactor.stop()


if __name__ == '__main__':
    main(PythonExample, daily_log=False)
Ejemplo n.º 7
0
            raise AssertionError('Structures are not the same')
        print('successful creation of a 3D structure for {}'.format(
            dict_convert['mol']))

        addh = yield self.call(
            'mdgroup.mdstudio_structures.endpoint.addh', dict_addh)
        if not compare_molecules(addh['mol']['content'], join(root, 'files/structureHs.mol2')):
            raise AssertionError('Structures are not the same')
        print('added hydrogens sucessfully!')

        info = yield self.call('mdgroup.mdstudio_structures.endpoint.info', dict_info)
        print('info', info)
        atts = info['attributes']
        if not all((atts['formula'] == 'C7H12O2', atts['exactmass'] - 128.083729624 < 1e-5)):
            raise AssertionError('Structures are not the same')
        print('attributes information successfully retrieved!')

        rotate = yield self.call('mdgroup.mdstudio_structures.endpoint.rotate', dict_rotate)
        if not compare_molecules(rotate['mol']['content'], join(root, 'files/rotations.mol2')):
            raise AssertionError('Structures are not the same')
        print('rotatation method succeeded!')

        similarity = yield self.call('mdgroup.mdstudio_structures.endpoint.chemical_similarity', dict_similarity)
        if not similarity['results']['idx_max_sim']['0'] == 20:
            raise AssertionError('Similarity not the same')
        print('Similarity method succeeded!')


if __name__ == '__main__':
    main(RunStructures)
Ejemplo n.º 8
0
from mdstudio.runner import main
from mdstudio_plants_docking.wamp_services import DockingWampApi


if __name__ == '__main__':
    main(DockingWampApi)
Ejemplo n.º 9
0
    init_time = None

    def authorize_request(self, uri, claims):
        return True

    def append(self, result, number):

        result = result['number']
        print('Result {0} for {1} after {2} seconds'.format(result, number, int(time.time()) - self.init_time))

    @chainable
    def on_run(self):

        # Register start time
        self.init_time = int(time.time())

        # Run a few numbers through the roundrobin endpoint.
        # These are async calls, we process the results in a separate 'callback'
        # function.
        # - Use 'parallel' endpoint to speed things up by round robin load
        #   balancing over multiple instances of the roundrobin microservice.
        # - Use 'sequential' endpoint to run the code sequential.
        for number in range(4):
            response = self.call('mdgroup.roundrobin.endpoint.sequential', {"number": number})
            response.addCallback(self.append, number)


if __name__ == '__main__':
    main(UserSession, daily_log=False)
Ejemplo n.º 10
0
# -*- coding: utf-8 -*

import os
import sys

modulepath = os.path.abspath(os.path.join(os.path.dirname(__file__), '../'))
sys.path.insert(0, modulepath)

from mdstudio.runner import main
from roundrobin.application import RoundrobinComponent

if __name__ == '__main__':
    main(RoundrobinComponent, daily_log=False)
Ejemplo n.º 11
0
                          uri='mdgroup.lie_pylie.endpoint.adan_residue_decomp',
                          inline_files=False)
        t23.set_input(model_pkl=modelpicklefile,
                      decompose_files=decompose_files)
        wf.connect_task(t18.nid, t23.nid)

        # Applicability domain: 3. deltaG energy range
        t24 = wf.add_task('AD3 dene yrange',
                          task_type='WampTask',
                          uri='mdgroup.lie_pylie.endpoint.adan_dene_yrange')
        t24.set_input(ymin=modelfile['AD']['Yrange']['min'],
                      ymax=modelfile['AD']['Yrange']['max'])
        wf.connect_task(t21.nid, t24.nid, 'liedeltag_file', liedeltag_file='dataframe')

        # Applicability domain: 4. deltaG energy distribution
        t25 = wf.add_task('AD4 dene distribution',
                          task_type='WampTask',
                          uri='mdgroup.lie_pylie.endpoint.adan_dene')
        t25.set_input(model_pkl=modelpicklefile,
                      center=list(modelfile['AD']['Dene']['Xmean']),
                      ci_cutoff=modelfile['AD']['Dene']['Maxdist'])
        wf.connect_task(t21.nid, t25.nid, 'liedeltag_file', liedeltag_file='dataframe')

        wf.run()
        while wf.is_running:
            yield sleep(1)


if __name__ == "__main__":
    main(LIEPredictionWorkflow)
Ejemplo n.º 12
0
import os

workdir = "/tmp/mdstudio_amber"
structure_path = os.path.join(os.getcwd(), "input.mol2")
with open(structure_path, 'r') as f:
    amber_input = f.read()

structure = {
    "path": structure_path,
    "content": amber_input,
    "extension": "mol2"
}


class Run_acpype(ComponentSession):
    def authorize_request(self, uri, claims):
        return True

    @chainable
    def on_run(self):
        result = yield self.call("mdgroup.mdstudio_amber.endpoint.acpype", {
            "structure": structure,
            "workdir": workdir
        })
        print(result)
        # assert all(os.path.isfile(p) or os.path.isdir(p) for p in result.values())


if __name__ == "__main__":
    main(Run_acpype)
Ejemplo n.º 13
0
    def on_run(self):

        result = yield self.call(
            u"mdgroup.mdstudio_plants_docking.endpoint.docking", {
                u"protein_file":
                protein_file,
                u"ligand_file":
                ligand_file,
                u"min_rmsd_tolerance":
                3.0,
                u"cluster_structures":
                100,
                u"bindingsite_radius":
                12.0,
                u"bindingsite_center":
                [4.926394772324452, 19.079624537618873, 21.98915631296689],
                u"workdir":
                workdir
            })

        if result['status'] != 'completed':
            raise AssertionError('Docking failed, status: {0}'.format(
                result['status']))
        if not all('path' in val for _, val in result['output'].items()):
            raise AssertionError('Not all expected output files created')
        print("Docking finished successfully!")


if __name__ == "__main__":
    main(Run_docking)
Ejemplo n.º 14
0

def copy_to_workdir(file_path, workdir):
    # shutil.copy(file_path, workdir)
    base = os.path.basename(file_path)
    return os.path.join(workdir, base)


workdir = "/tmp/mdstudio/mdstudio_haddock"
project_file = copy_to_workdir(
    os.path.join(os.getcwd(), "easy_run_server_ref.web"), workdir)


class Run_haddock(ComponentSession):
    def authorize_request(self, uri, claims):
        return True

    @chainable
    def on_run(self):
        result = yield self.call(
            "mdgroup.mdstudio_haddock.endpoint.submit_project", {
                "project_id": project_file,
                "haddock_username": "",
                "haddock_password": ""
            })
        print(result['project_id'])


if __name__ == "__main__":
    main(Run_haddock)
Ejemplo n.º 15
0
        result_average = yield self.call(
            "mdgroup.mdstudio_pylie.endpoint.calculate_lie_average",
            dict_average)
        assert compare_csv_files(result_average["averaged"]['content'],
                                 dict_deltag["dataframe"]['content'])
        print("method calculate_lie_average succeeded!")

        result_liedeltag = yield self.call(
            "mdgroup.mdstudio_pylie.endpoint.liedeltag", dict_deltag)
        assert compare_csv_files(result_liedeltag["liedeltag_file"]['content'],
                                 dict_adan_yrange["dataframe"]['content'])
        print("method liedeltag succeeded!")

        result_adan_yrange = yield self.call(
            "mdgroup.mdstudio_pylie.endpoint.adan_dene_yrange",
            dict_adan_yrange)
        assert compare_dictionaries(result_adan_yrange["decomp"],
                                    expected_adan_yrange_results)
        print("method adan_dene_yrange succeeded!")

        result_adan_dene = yield self.call(
            "mdgroup.mdstudio_pylie.endpoint.adan_dene", dict_adan_dene)
        assert compare_dictionaries(result_adan_dene["decomp"],
                                    expected_adan_results)
        print("method adan_dene succeeded!")


if __name__ == "__main__":
    main(Run_pylie)
Ejemplo n.º 16
0
# -*- coding: utf-8 -*-

import os
import sys

from mdstudio.runner import main

# Try import package
try:
    from mdstudio_gromacs.wamp_services import MDWampApi

except ImportError:

    # Add modules in package to path
    modulepath = os.path.abspath(os.path.join(os.path.dirname(__file__),
                                              '../'))
    if modulepath not in sys.path:
        sys.path.insert(0, modulepath)

    from mdstudio_gromacs.wamp_services import MDWampApi

if __name__ == '__main__':
    main(MDWampApi)
Ejemplo n.º 17
0
from mdstudio.deferred.chainable import chainable
from mdstudio.component.session import ComponentSession
from mdstudio.runner import main
import os
import shutil

workdir = "/tmp/propka"
if os.path.exists(workdir):
    shutil.rmtree(workdir)


class Run_propka(ComponentSession):
    def authorize_request(self, uri, claims):
        return True

    @chainable
    def on_run(self):
        with self.group_context('mdgroup'):
            self.call('mdgroup.mdstudio_propka.endpoint.propka',
                      {"workdir": workdir})


if __name__ == "__main__":
    main(Run_propka)
Ejemplo n.º 18
0
        #         mol2 If 'output_format' is not specified it is deduced from
        #         the input wich is mol2 in this case. There are circumstances
        #         where conversion to 3D fails, retry upto 3 times.
        t4 = wf.add_task('Make_3D',
                         task_type='WampTask',
                         uri='mdgroup.mdstudio_structures.endpoint.make3d',
                         retry_count=3)
        wf.connect_task(t3.nid, t4.nid, 'mol')
        wf.connect_task(t1.nid, t4.nid, 'steps')

        # Task 5: Empty task that server as a collector for all results
        #         obtained during iteration.
        t5 = wf.add_task('Collector')
        wf.connect_task(t4.nid, t5.nid, 'mol')

        # Set the array of input SMILES string to task 1
        wf.input(t1.nid,
                 smiles=[
                     'O1[C@@H](CCC1=O)CCC',
                     'C[C@]12CC[C@H]3[C@@H](CC=C4CCCC[C@]34CO)[C@@H]1CCC2=O',
                     'CC12CCC3C(CC=C4C=CCCC34C)C1CCC2=O'
                 ])

        wf.run()
        while wf.is_running:
            yield sleep(1)


if __name__ == "__main__":
    main(LoopDemonstrationWorkflow, auto_reconnect=False, daily_log=False)
Ejemplo n.º 19
0
        wf.save('workflow_spec.jgf')

        # Lets run the workflow specification for a number of ligand SMILES
        # The current microservice instance (self) is passed as task_runner to the workflow
        # it will be used to make calls to other microservice endpoints when task_type equals WampTask.
        wf.task_runner = self

        currdir = os.getcwd()
        for i, ligand in enumerate([
                'O1[C@@H](CCC1=O)CCC',
                'C[C@]12CC[C@H]3[C@@H](CC=C4CCCC[C@]34CO)[C@@H]1CCC2=O',
                'CC12CCC3C(CC=C4C=CCCC34C)C1CCC2=O'
        ],
                                   start=1):
            wf.load('workflow_spec.jgf')
            wf.input(t1.nid,
                     mol={
                         'content': ligand,
                         'path': None,
                         'extension': ligand_format
                     })
            wf.run(project_dir='./ligand-{0}'.format(i))
            while wf.is_running:
                yield sleep(1)

            os.chdir(currdir)


if __name__ == "__main__":
    main(ExampleWorkflow, auto_reconnect=False, daily_log=False)
Ejemplo n.º 20
0
from mdstudio.runner import main
from mdstudio_propka.wamp_services import PropkaWampApi

if __name__ == '__main__':
    main(PropkaWampApi)
Ejemplo n.º 21
0
from mdstudio.runner import main
from mdstudio_atb.wamp_services import ATBWampApi

if __name__ == '__main__':
    main(ATBWampApi)
Ejemplo n.º 22
0
# -*- coding: utf-8 -*

import os
import sys

modulepath = os.path.abspath(os.path.join(os.path.dirname(__file__), '../'))
sys.path.insert(0, modulepath)

from mdstudio.runner import main
from hello_world.application import HelloWorldComponent

if __name__ == '__main__':
    main(HelloWorldComponent)
Ejemplo n.º 23
0
    if args.base_work_dir:

        # Set dynamic base_work_dir as environmental variable accessible from else where
        os.environ['BASE_WORK_DIR'] = args.base_work_dir

        # Start results cleanup event if 'base_work_dir' and 'result_storage_time' are set
        if args.result_storage_time > 0:
            p = PeriodicCleanup(args.base_work_dir, args.result_storage_time)
            p.start()

    # Start service REST or WAMP API
    if args.api_mode == 'wamp':
        logging.debug('Start {0} WAMP interface at {1}'.format(
            __module__, __package_path__))

        main(SmartCypWampApi)

    else:
        logging.debug('Start {0} REST interface at {1}'.format(
            __module__, __package_path__))

        app = connexion.App(__name__, specification_dir='./rest/')
        app.add_api('smartcyp_openapi.yaml',
                    arguments={'title': 'MDStudio SMARTCyp REST API'})
        CORS(app.app)

        # Serve app using production ready gevent WSGIServer
        http_server = WSGIServer(('', args.http_port), app)
        http_server.serve_forever()
Ejemplo n.º 24
0
# -*- coding: utf-8 -*-

import sys
import os

modulepath = os.path.abspath(os.path.join(os.path.dirname(__file__), '../'))
if modulepath not in sys.path:
    sys.path.insert(0, modulepath)

from mdstudio.runner import main
from common_resources.resources_endpoints import Common_resources

if __name__ == '__main__':
    main(Common_resources)
Ejemplo n.º 25
0
from mdstudio.deferred.chainable import chainable
from mdstudio.component.session import ComponentSession
from mdstudio.runner import main
import os

cwd = os.path.dirname(os.path.abspath(__file__))
path_test_file = os.path.join(cwd, "files/input.mol2")

with open(path_test_file, 'r') as f:
    content = f.read()

dict_path_file = {
    "content": content,
    "path": path_test_file,
    "extension": ".mol2"
}


class Run_test_resources(ComponentSession):
    def authorize_request(self, uri, claims):
        return True

    @chainable
    def on_run(self):
        yield self.call("mdgroup.common_resources.endpoint.call_path_file",
                        {"path_file": dict_path_file})


if __name__ == "__main__":
    main(Run_test_resources)
Ejemplo n.º 26
0
        t23.set_input(model_pkl=modelpicklefile)
        wf.connect_task(t17.nid, t23.nid, 'decomp_files')

        # Applicability domain: 3. deltaG energy range
        t24 = wf.add_task('AD3 dene yrange',
                          task_type='WampTask',
                          uri='mdgroup.lie_pylie.endpoint.adan_dene_yrange')
        t24.set_input(ymin=modelfile['AD']['Yrange']['min'],
                      ymax=modelfile['AD']['Yrange']['max'])
        wf.connect_task(t21.nid, t24.nid, liedeltag_file='dataframe')

        # Applicability domain: 4. deltaG energy distribution
        t25 = wf.add_task('AD4 dene distribution',
                          task_type='WampTask',
                          uri='mdgroup.lie_pylie.endpoint.adan_dene')
        t25.set_input(model_pkl=modelpicklefile,
                      center=list(modelfile['AD']['Dene']['Xmean']),
                      ci_cutoff=modelfile['AD']['Dene']['Maxdist'])
        wf.connect_task(t21.nid, t25.nid, liedeltag_file='dataframe')

        # Save the workflow specification
        wf.save('workflow_spec.jgf')

        wf.run()
        while wf.is_running:
            yield sleep(1)


if __name__ == "__main__":
    main(LIEWorkflow, auto_reconnect=False, daily_log=False)
Ejemplo n.º 27
0
            u'mdgroup.mdstudio_smartcyp.endpoint.docking_structures', {
                'paths': means,
                'create_ensemble': False
            })
        self.assertEqual(len(result['result']), len(means))

        print('Test SPORES get info endpoint')
        result = yield self.call(
            u'mdgroup.mdstudio_smartcyp.endpoint.spores_info', {})
        self.assertEqual(result['status'], 'completed')
        self.assertIsInstance(result['info'], dict)
        self.assertItemsEqual(result['info'].keys(),
                              (u'version', u'default_settings', u'citation'))

        print('Test SPORES run')
        request = {
            'mol': create_path_file_obj(os.path.join(root, "ligand.mol2")),
            'input_format': 'mol2'
        }
        result = yield self.call(u'mdgroup.mdstudio_smartcyp.endpoint.spores',
                                 request)
        self.assertEqual(result['status'], 'completed')
        self.assertIsInstance(result['result'], dict)
        self.assertEqual(result['result']['content'].startswith('@<TRIPOS>'),
                         True)


if __name__ == "__main__":

    main(MDStudioSMARTCypWAMPTests)
Ejemplo n.º 28
0
        # Applicability domain: 3. deltaG energy range
        t24 = wf.add_task('AD3 dene yrange',
                          task_type='WampTask',
                          uri='mdgroup.lie_pylie.endpoint.adan_dene_yrange')
        t24.set_input(ymin=modelfile['AD']['Yrange']['min'],
                      ymax=modelfile['AD']['Yrange']['max'])
        wf.connect_task(t21.nid,
                        t24.nid,
                        'liedeltag_file',
                        liedeltag_file='dataframe')

        # Applicability domain: 4. deltaG energy distribution
        t25 = wf.add_task('AD4 dene distribution',
                          task_type='WampTask',
                          uri='mdgroup.lie_pylie.endpoint.adan_dene')
        t25.set_input(model_pkl=modelpicklefile,
                      center=list(modelfile['AD']['Dene']['Xmean']),
                      ci_cutoff=modelfile['AD']['Dene']['Maxdist'])
        wf.connect_task(t21.nid,
                        t25.nid,
                        'liedeltag_file',
                        liedeltag_file='dataframe')

        wf.run()
        while wf.is_running:
            yield sleep(1)


if __name__ == "__main__":
    main(LIEPredictionWorkflow, auto_reconnect=False, daily_log=False)
Ejemplo n.º 29
0
from mdstudio.runner import main
from mdstudio_structures.wamp_services import StructuresWampApi

if __name__ == '__main__':
    main(StructuresWampApi)
Ejemplo n.º 30
0
from mdstudio.runner import main
from pylie.wamp_services import PylieWampApi


if __name__ == '__main__':
    main(PylieWampApi)