[project @ Download Cfg, Use genome mapper, configure, run and monitor pipeline!...
authorBrandon King <kingb@caltech.edu>
Sat, 17 Nov 2007 03:13:07 +0000 (03:13 +0000)
committerBrandon King <kingb@caltech.edu>
Sat, 17 Nov 2007 03:13:07 +0000 (03:13 +0000)
 * 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.

bin/config_pipeline2.py
bin/retrieve_eland_config.py

index ddc5c42deb58fa710e09e8f1a5804c1ff09ea6fa..8e9e81da6b574f8572188f1f79596b59f3c07574 100644 (file)
@@ -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.'
 
index 228aec9a7fcc9252f9e2a28332b4ec306b7fc136..f9acb5216da34a5860440e3bd3473f2777a0f600 100644 (file)
@@ -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()