From c6ad3af76120d3aa6c17c910a1700ecbcd262d1d Mon Sep 17 00:00:00 2001 From: Diane Trout Date: Tue, 20 Nov 2007 09:50:58 +0000 Subject: [PATCH] [project @ move brandon's pipeline handling code into gaworkflow.pipeline] the code that was in the if __name__ == "__main__" got moved into similary named scripts in the scripts directory. Those import everything from their corresponding gaworkfile.pipeline module. I still wish the names were shorter, and yet still descriptive. Other refactoring ideas, break configure_run up, make a single module to hold all the exceptions from all the varios parts of the pipeline. And: I (still) find our lack of tests disturbing. --- .../pipeline/configure_run.py | 39 ++--------------- {bin => gaworkflow/pipeline}/genome_mapper.py | 0 .../pipeline/retrieve_config.py | 23 ---------- scripts/configure_pipeline | 42 +++++++++++++++++++ scripts/retrieve_config | 30 +++++++++++++ setup.py | 5 ++- 6 files changed, 79 insertions(+), 60 deletions(-) rename bin/config_pipeline2.py => gaworkflow/pipeline/configure_run.py (93%) rename {bin => gaworkflow/pipeline}/genome_mapper.py (100%) rename bin/retrieve_eland_config.py => gaworkflow/pipeline/retrieve_config.py (82%) create mode 100644 scripts/configure_pipeline create mode 100644 scripts/retrieve_config diff --git a/bin/config_pipeline2.py b/gaworkflow/pipeline/configure_run.py similarity index 93% rename from bin/config_pipeline2.py rename to gaworkflow/pipeline/configure_run.py index 2739cce..f71bfc5 100644 --- a/bin/config_pipeline2.py +++ b/gaworkflow/pipeline/configure_run.py @@ -5,9 +5,9 @@ import time import re import os -from retrieve_eland_config import getCombinedOptions, saveConfigFile -from retrieve_eland_config import FlowCellNotFound, WebError404 -from genome_mapper import DuplicateGenome, getAvailableGenomes, constructMapperDict +from gaworkflow.pipeline.retrieve_config import getCombinedOptions, saveConfigFile +from gaworkflow.pipeline.retrieve_config import FlowCellNotFound, WebError404 +from gaworkflow.pipeline.genome_mapper import DuplicateGenome, getAvailableGenomes, constructMapperDict from pyinotify import WatchManager, ThreadedNotifier from pyinotify import EventsCodes, ProcessEvent @@ -516,36 +516,3 @@ def run_pipeline(conf_info): return status - -if __name__ == '__main__': - ci = ConfigInfo() - - flowcell = 'FC12150' - cfg_filepath = 'config32auto.txt' - genome_dir = '/home/king/trog_drive/' - - status_retrieve_cfg = retrieve_config(ci, flowcell, cfg_filepath, genome_dir) - if status_retrieve_cfg: - print "Retrieve config file successful" - else: - print "Failed to retrieve config file" - #ci.config_filepath = 'config32bk.txt' - - if status_retrieve_cfg: - status = configure(ci) - if status: - print "Configure success" - else: - print "Configure failed" - - print 'Run Dir:', ci.run_path - print 'Bustard Dir:', ci.bustard_path - - if status: - print 'Running pipeline now!' - run_status = run_pipeline(ci) - if run_status is True: - print 'Pipeline ran successfully.' - else: - print 'Pipeline run failed.' - diff --git a/bin/genome_mapper.py b/gaworkflow/pipeline/genome_mapper.py similarity index 100% rename from bin/genome_mapper.py rename to gaworkflow/pipeline/genome_mapper.py diff --git a/bin/retrieve_eland_config.py b/gaworkflow/pipeline/retrieve_config.py similarity index 82% rename from bin/retrieve_eland_config.py rename to gaworkflow/pipeline/retrieve_config.py index cb4fa84..322d5ab 100644 --- a/bin/retrieve_eland_config.py +++ b/gaworkflow/pipeline/retrieve_config.py @@ -144,27 +144,4 @@ def saveConfigFile(flowcell, base_host_url, output_filepath): f.close() print 'Wrote config file to %s' % (output_filepath) - -if __name__ == '__main__': - #Display help if no args are presented - if len(sys.argv) == 1: - sys.argv.append('-h') - - options = getCombinedOptions() - msg_list = ['ERROR MESSAGES:'] - if options.output_filepath is None: - msg_list.append(" Output filepath argument required. -o or --output=") - - if options.flowcell is None: - msg_list.append(" Flow cell argument required. -f or --flowcell=") - - if options.url is None: - msg_list.append(" URL argument required (-u or --url=), or entry\n" \ - " in /etc/elandifier/elandifer.conf or ~/.elandifier.conf") - - if len(msg_list) > 1: - print '\n'.join(msg_list) - sys.exit(0) - - saveConfigFile(options.flowcell, options.url, options.output_filepath) diff --git a/scripts/configure_pipeline b/scripts/configure_pipeline new file mode 100644 index 0000000..b491a38 --- /dev/null +++ b/scripts/configure_pipeline @@ -0,0 +1,42 @@ +#!/usr/bin/env python +import sys +from gaworkflow.pipeline.configure_run import * + +def main(args=None): + ci = ConfigInfo() + + flowcell = 'FC12150' + cfg_filepath = 'config32auto.txt' + genome_dir = '/home/king/trog_drive/' + + status_retrieve_cfg = retrieve_config(ci, flowcell, cfg_filepath, genome_dir) + if status_retrieve_cfg: + print "Retrieve config file successful" + else: + print "Failed to retrieve config file" + #ci.config_filepath = 'config32bk.txt' + + if status_retrieve_cfg: + status = configure(ci) + if status: + print "Configure success" + else: + print "Configure failed" + + print 'Run Dir:', ci.run_path + print 'Bustard Dir:', ci.bustard_path + + if status: + print 'Running pipeline now!' + run_status = run_pipeline(ci) + if run_status is True: + print 'Pipeline ran successfully.' + return 0 + else: + print 'Pipeline run failed.' + return 1 + + return 2 + +if __name__ == "__main__": + sys.exit(main(sys.argv[1:])) diff --git a/scripts/retrieve_config b/scripts/retrieve_config new file mode 100644 index 0000000..3056c16 --- /dev/null +++ b/scripts/retrieve_config @@ -0,0 +1,30 @@ +#!/usr/bin/env python +import sys +from gaworkflow.pipeline.retrieve_config import * + +def main(args=None): + #Display help if no args are presented + if len(sys.argv) == 1: + sys.argv.append('-h') + + options = getCombinedOptions() + msg_list = ['ERROR MESSAGES:'] + if options.output_filepath is None: + msg_list.append(" Output filepath argument required. -o or --output=") + + if options.flowcell is None: + msg_list.append(" Flow cell argument required. -f or --flowcell=") + + if options.url is None: + msg_list.append(" URL argument required (-u or --url=), or entry\n" \ + " in /etc/elandifier/elandifer.conf or ~/.elandifier.conf") + + if len(msg_list) > 1: + print '\n'.join(msg_list) + return 1 + + saveConfigFile(options.flowcell, options.url, options.output_filepath) + return 0 + +if __name__ == "__main__": + sys.exit(main(sys.argv[1:])) diff --git a/setup.py b/setup.py index eb4f676..0dc2dbf 100644 --- a/setup.py +++ b/setup.py @@ -6,5 +6,8 @@ setup( author="Diane Trout", author_email="diane@caltech.edu", packages=["uashelper"], - scripts=['scripts/spoolwatcher', 'scripts/copier'], + scripts=['scripts/spoolwatcher', + 'scripts/copier', + 'scripts/retreive_config', + 'scripts/configure_pipeline'], ) -- 2.30.2