Mercurial > repos > shellac > guppy_basecaller
comparison env/lib/python3.7/site-packages/ephemeris/workflow_install.py @ 2:6af9afd405e9 draft
"planemo upload commit 0a63dd5f4d38a1f6944587f52a8cd79874177fc1"
| author | shellac |
|---|---|
| date | Thu, 14 May 2020 14:56:58 -0400 |
| parents | 26e78fe6e8c4 |
| children |
comparison
equal
deleted
inserted
replaced
| 1:75ca89e9b81c | 2:6af9afd405e9 |
|---|---|
| 1 #!/usr/bin/env python | |
| 2 '''Tool to install workflows on a Galaxy instance.''' | |
| 3 import argparse | |
| 4 import json | |
| 5 import os | |
| 6 | |
| 7 from . import get_galaxy_connection | |
| 8 from .common_parser import get_common_args | |
| 9 | |
| 10 | |
| 11 def import_workflow(gi, path, publish_wf=False): | |
| 12 """ | |
| 13 Given a connection to a Galaxy Instance (gi) and a path to a Galaxy workflow file, | |
| 14 this function will import the worklfow into Galaxy. | |
| 15 """ | |
| 16 with open(path, 'r') as wf_file: | |
| 17 import_uuid = json.load(wf_file).get('uuid') | |
| 18 existing_uuids = [d.get('latest_workflow_uuid') for d in gi.workflows.get_workflows()] | |
| 19 if import_uuid not in existing_uuids: | |
| 20 gi.workflows.import_workflow_from_local_path(path, publish=publish_wf) | |
| 21 | |
| 22 | |
| 23 def _parser(): | |
| 24 parent = get_common_args() | |
| 25 parser = argparse.ArgumentParser(parents=[parent]) | |
| 26 parser.add_argument("-w", "--workflow_path", | |
| 27 required=True, | |
| 28 help='Path to a workflow file or a directory with multiple workflow files ending with ".ga"') | |
| 29 parser.add_argument("--publish_workflows", | |
| 30 required=False, | |
| 31 action='store_true', | |
| 32 help='Flag to publish all imported workflows, so that they are viewable by other users') | |
| 33 return parser | |
| 34 | |
| 35 | |
| 36 def main(): | |
| 37 """ | |
| 38 This script uses bioblend to import .ga workflow files into a running instance of Galaxy | |
| 39 """ | |
| 40 args = _parser().parse_args() | |
| 41 gi = get_galaxy_connection(args) | |
| 42 | |
| 43 if os.path.isdir(args.workflow_path): | |
| 44 for file_path in os.listdir(args.workflow_path): | |
| 45 if file_path.endswith('.ga'): | |
| 46 import_workflow(gi, os.path.join(args.workflow_path, file_path), args.publish_workflows) | |
| 47 else: | |
| 48 import_workflow(gi, args.workflow_path, args.publish_workflows) | |
| 49 | |
| 50 | |
| 51 if __name__ == '__main__': | |
| 52 main() |
