-
Notifications
You must be signed in to change notification settings - Fork 13
/
bartender_combiner_com
executable file
·62 lines (59 loc) · 2.04 KB
/
bartender_combiner_com
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
#!/usr/bin/env python
import os
import sys
import getopt
def usage():
print("\tthere are 3 parameters and all are required. For help -h or -help")
print("\t -c the cutoff that all clusters below this threshold will be removed from the result. ")
print("\t -o the output prefix")
print("\t -f the cluster results files from different time points. Only the cluster and quality files should be included. The files should be separated by comma")
def driver():
inputfile = ''
outprefix = ''
freq_cutoff = 1
cluster_files = ''
outprefix = ''
try:
opt,args = getopt.getopt(sys.argv[1:],"f:o:c:h",["help"])
except getopt.GetoptError as msg:
print(msg)
usage()
sys.exit(2)
for o,a in opt:
if o == '-f':
inputfile = a.strip().split(',')
if len(inputfile) % 2:
print("The number of input files are not correct!")
sys.exit(2)
for f in inputfile:
if not os.path.isfile(f):
print(f + " probably is not a valid file!\n")
sys.exit(2)
inputfile = ' '.join(inputfile)
elif o == '-o':
outprefix = a
if not outprefix:
print("No output file was specified!")
sys.exit(2)
elif o == '-c':
try:
freq_cutoff = int(a)
assert(freq_cutoff > 0)
except Exception as err:
print("Frequency cutoff " + a + " is not a valid input!\n")
sys.exit(2)
elif o in ("-h","--help"):
print(usage())
sys.exit(0)
if not inputfile:
print("There is no inputfile specified")
print(usage())
sys.exit(0)
if not outprefix:
print("There is no output file specified")
print(usage())
sys.exit(0)
os.system('bartender_combiner ' + str(freq_cutoff) + ' ' + outprefix + ' ' + inputfile)
if __name__=="__main__":
print('Running bartender_combiner')
driver()