[project @ Monitor status implementation + config_pipeline cmdling args]
[htsworkflow.git] / scripts / configure_pipeline
1 #!/usr/bin/env python
2 import os
3 import sys
4 from gaworkflow.pipeline.configure_run import *
5 from gaworkflow.pipeline.monitors import startCmdLineStatusMonitor
6
7
8 def main(args=None):
9   ci = ConfigInfo()
10
11   #FIXME: make a better command line tool
12   skip_retrieve_config = False
13   if len(args) == 1:
14     cfg_filepath = os.path.abspath(args[0])
15     skip_retrieve_config = True
16   else:
17     cfg_filepath = os.path.abspath('config32auto.txt')
18
19   flowcell = 'FC12150'
20   genome_dir = '/home/king/trog_drive/'
21
22   if not skip_retrieve_config:
23     status_retrieve_cfg = retrieve_config(ci, flowcell, cfg_filepath, genome_dir)
24     if status_retrieve_cfg:
25       print "Retrieve config file successful"
26     else:
27       print "Failed to retrieve config file"
28   else:
29     print "Config file %s provided from command-line" % (cfg_filepath)
30     ci.config_filepath = cfg_filepath
31     status_retrieve_cfg = True
32   
33   if status_retrieve_cfg:
34     status = configure(ci)
35     if status:
36       print "Configure success"
37     else:
38       print "Configure failed"
39     
40     print 'Run Dir:', ci.run_path
41     print 'Bustard Dir:', ci.bustard_path
42     
43     if status:
44       # Setup status cmdline status monitor
45       startCmdLineStatusMonitor(ci)
46       
47       print 'Running pipeline now!'
48       run_status = run_pipeline(ci)
49       if run_status is True:
50         print 'Pipeline ran successfully.'
51         return 0
52       else:
53         print 'Pipeline run failed.'
54         return 1
55
56     return 2
57
58 if __name__ == "__main__":
59   sys.exit(main(sys.argv[1:]))