Replace some prints with logging.info messages and
[htsworkflow.git] / scripts / retrieve_config
index 56bd7c590edaedd8ef2834b94946d713eabb51a2..c765da941050076c4c8787c13d0499b80452a74a 100644 (file)
@@ -1,6 +1,13 @@
 #!/usr/bin/env python
+import logging
 import sys
-from gaworkflow.pipeline.retrieve_config import *
+from htsworkflow.pipelines.retrieve_config import *
+from htsworkflow.pipelines import retrieve_config
+from htsworkflow.pipelines.genome_mapper import getAvailableGenomes
+from htsworkflow.pipelines.genome_mapper import constructMapperDict
+
+#Turn on built-in command-line parsing.
+retrieve_config.DISABLE_CMDLINE = False
 
 def main(args=None):
   #Display help if no args are presented
@@ -18,13 +25,30 @@ def main(args=None):
   if options.url is None:
     msg_list.append("  URL argument required (-u <url> or --url=<url>), or entry\n" \
                     "    in /etc/ga_frontend/ga_frontend.conf or ~/.ga_frontend.conf")
+  if options.genome_dir is None:
+    msg_list.append("  genome_dir argument required (-g <genome_dir> or \n" \
+                    "    --genome_dir=<genome_dir>, or entry in \n" \
+                    "    /etc/ga_frontend/ga_frontend.conf or ~/.ga_frontend.conf")
     
   if len(msg_list) > 1:
     print '\n'.join(msg_list)
     return 1
   
   saveConfigFile(options.flowcell, options.url, options.output_filepath)
+
+  f = open(options.output_filepath, 'r')
+  data = f.read()
+  f.close()
+
+  genome_dict = getAvailableGenomes(options.genome_dir)
+  mapper_dict = constructMapperDict(genome_dict)
+
+  f = open(options.output_filepath, 'w')
+  f.write(data % (mapper_dict))
+  f.close()
+  
   return 0
   
 if __name__ == "__main__":
+  logging.basicConfig(level=logging.INFO)
   sys.exit(main(sys.argv[1:]))