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
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.
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.'
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()