From: Brandon King Date: Sat, 17 Nov 2007 03:13:07 +0000 (+0000) Subject: [project @ Download Cfg, Use genome mapper, configure, run and monitor pipeline!... X-Git-Tag: 0.1.0~60 X-Git-Url: http://woldlab.caltech.edu/gitweb/?p=htsworkflow.git;a=commitdiff_plain;h=d95c331b683def54d1b23281d8ada551a8187a36 [project @ Download Cfg, Use genome mapper, configure, run and monitor pipeline! (Proof of concept!)] * Now downloads config file from fctracker db * Requires ~/.ga_frontend.conf or /etc/ga_frontend/ga_frontend.conf to have [server_info]\nbase_host_url: http://host:port * FIXME: flowcell and genome dir are hard coded for testing * Uses genome mapper to update config file with local available genomes * Requires each genome dir to have a file called _metainfo_ with: * species|build * Then uses that config file to configure the pipeline * Runs the pipeline monitoring the status * TODOs: * Allow for specifying config file from commandline (skipping download config step). * Need non-hardcoded way of getting flowcell and genome base directory * Incorperate into run daemon that listens for copy complete command * Add feature to notify users of success and failures. --- diff --git a/bin/config_pipeline2.py b/bin/config_pipeline2.py index ddc5c42..8e9e81d 100644 --- a/bin/config_pipeline2.py +++ b/bin/config_pipeline2.py @@ -5,6 +5,10 @@ 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 pyinotify import WatchManager, ThreadedNotifier from pyinotify import EventsCodes, ProcessEvent @@ -284,6 +288,58 @@ def pipeline_stderr_handler(line, conf_info): return False +def retrieve_config(conf_info, flowcell, cfg_filepath, genome_dir): + """ + Gets the config file from server... + requires config file in: + /etc/ga_frontend/ga_frontend.conf + or + ~/.ga_frontend.conf + + with: + [server_info] + base_host_url: http://host:port + + return True if successful, False is failure + """ + options = getCombinedOptions() + + if options.url is None: + logging.error("~/.ga_frontend.conf or /etc/ga_frontend/ga_frontend.conf" \ + " missing base_host_url option") + return False + + try: + saveConfigFile(flowcell, options.url, cfg_filepath) + conf_info.config_filepath = cfg_filepath + except FlowCellNotFound, e: + logging.error(e) + return False + except WebError404, e: + logging.error(e) + return False + except IOError, e: + logging.error(e) + return False + except Exception, e: + logging.error(e) + return False + + f = open(cfg_filepath, 'r') + data = f.read() + f.close() + + genome_dict = getAvailableGenomes(genome_dir) + mapper_dict = constructMapperDict(genome_dict) + + f = open(cfg_filepath, 'w') + f.write(data % (mapper_dict)) + f.close() + + return True + + + def configure(conf_info): """ Attempts to configure the GA pipeline using goat. @@ -463,22 +519,33 @@ def run_pipeline(conf_info): if __name__ == '__main__': ci = ConfigInfo() - ci.config_filepath = 'config32bk.txt' - - status = configure(ci) - if status: - print "Configure success" + + 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 "Configure failed" + print "Failed to retrieve config file" + #ci.config_filepath = 'config32bk.txt' - 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.' + if status_retrieve_cfg: + status = configure(ci) + if status: + print "Configure success" else: - print 'Pipeline run failed.' + 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/retrieve_eland_config.py b/bin/retrieve_eland_config.py index 228aec9..f9acb52 100644 --- a/bin/retrieve_eland_config.py +++ b/bin/retrieve_eland_config.py @@ -114,19 +114,19 @@ def saveConfigFile(flowcell, base_host_url, output_filepath): url = base_host_url + '/eland_config/%s/' % (flowcell) f = open(output_filepath, 'w') - try: - web = urllib.urlopen(url) - except IOError, msg: - if str(msg).find("Connection refused") >= 0: - print 'Error: Connection refused for: %s' % (url) - f.close() - sys.exit(1) - elif str(msg).find("Name or service not known") >= 0: - print 'Error: Invalid domain or ip address for: %s' % (url) - f.close() - sys.exit(2) - else: - raise IOError, msg + #try: + web = urllib.urlopen(url) + #except IOError, msg: + # if str(msg).find("Connection refused") >= 0: + # print 'Error: Connection refused for: %s' % (url) + # f.close() + # sys.exit(1) + # elif str(msg).find("Name or service not known") >= 0: + # print 'Error: Invalid domain or ip address for: %s' % (url) + # f.close() + # sys.exit(2) + # else: + # raise IOError, msg data = web.read()