-
Notifications
You must be signed in to change notification settings - Fork 1
/
main_script.py
99 lines (82 loc) · 2.84 KB
/
main_script.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
import time
from datetime import datetime
from sys import argv, exit
from libs.ngs_process import demux_illumina, merge_pair_libs
from libs.run_qiime import pick_otus, pick_rep_set, assign_taxonomy, \
make_otu_table, make_qiime_reports
from libs.reporting import log_start_run, log_end_run, save_parameters, \
make_final_report
from config import datasets
print "\n", \
"##################################################\n", \
"### RiboMatic v. 0.1 ###\n", \
"### Copyright 2011 Geraldine A. Van der Auwera ###\n", \
"##################################################\n", \
if len(argv) > 1 and argv[1] == '-h':
print "Basic usage: \n", \
"$ python main_script.py [run_id] [step#] [max_pairs]\n", \
"Note that these arguments are positional: order matters!\n"
exit()
if len(argv) > 1:
run_id = argv[1]
else:
run_id = str(int(time.time())) # use timestamp as unique run identifier
if len(argv) > 2:
max_pairs = int(argv[2])
else:
max_pairs = 1000000000 # insanely large number = no limit
if len(argv) > 3:
step = int(argv[3])
else:
step = 0
start_timestamp = str(datetime.now())
if step is 0:
print "\n###", step, ". Set up logging & reporting ###"
for dataset in datasets:
save_parameters(dataset, max_pairs, run_id, start_timestamp)
log_start_run(dataset, run_id, start_timestamp)
step +=1
if step is 1:
print "\n###", step, ". Demultiplex Illumina read sets ###"
for dataset in datasets:
demux_illumina(dataset, max_pairs, run_id)
step +=1
if step is 2:
print "\n###", step, ". Merge read pairs ###"
for dataset in datasets:
merge_pair_libs(dataset, run_id)
step +=1
if step is 3:
print "\n###", step, ". Cluster sequences into OTUs ###"
for dataset in datasets:
pick_otus(dataset, run_id)
step +=1
if step is 4:
print "\n###", step, ". Pick representative OTUs ###"
for dataset in datasets:
pick_rep_set(dataset, run_id)
step +=1
if step is 5:
print "\n###", step, ". Assign taxonomy to representative OTUs ###"
for dataset in datasets:
assign_taxonomy(dataset, run_id)
step +=1
if step is 6:
print "\n###", step, ". Make OTU table ###"
for dataset in datasets:
make_otu_table(dataset, run_id)
step +=1
if step is 7:
print "\n###", step, ". Generate community analysis reports ###"
for dataset in datasets:
make_qiime_reports(dataset, run_id)
step +=1
end_timestamp = str(datetime.now())
if step is 8:
print "\n###", step, ". Compile final report and log run completion ###"
for dataset in datasets:
make_final_report(dataset, run_id, start_timestamp, end_timestamp)
log_end_run(dataset, run_id, end_timestamp)
step +=1
if step > 7:
print "\n### Nothing more to do! ###\n"