-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbartender_single_com
executable file
·69 lines (67 loc) · 2.02 KB
/
bartender_single_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
62
63
64
65
66
67
68
#!/usr/bin/python
import os
import sys
import getopt
import pdb
'''
print("Current path is ")
p = os.getcwd()
print p
sys.path.append(p)
'''
def usage():
print "\tthere are 4 options, the first 2 is required, the remainings are optional,for help use -h or --help:"
print " \t -f the input fastq file "
print "\t -o the output prefix"
print "\t -c the frequency cutoff. All clusters with size less then this threshold will not included in the result."
print "\t -e the sequencing error. The default value is 0.01. Could be obtained by running the extraction components."
def driver():
inputfile = ''
outprefix = ''
freq_cutoff = 1
error_rate = 0.01
try:
opt,args = getopt.getopt(sys.argv[1:],"f:o:c:e:h",["help"])
except getopt.error,msg:
print("Invalid parameters!")
usage()
sys.exit(2)
for o,a in opt:
if o == '-f':
inputfile = a
if not os.path.isfile(inputfile):
print inputfile + " probably is not a valid file!\n"
sys.exit(2)
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 == '-e':
try:
error_rate = float(a)
assert(error_rate <= 1)
assert(error_rate >=0)
except Exception as err:
print("Invalid error rate specified!\n")
sys.exit(2)
elif o in ("-h","--help"):
print usage()
sys.exit(0)
if not inputfile:
print "There is no input sequence file specified"
sys.exit(0)
if not outprefix:
print "There is no output file specified"
sys.exit(0)
os.system('bartender_single ' + inputfile + ' ' + outprefix + ' ' + str(freq_cutoff) + ' ' + str(error_rate))
if __name__=="__main__":
print('Running bartender')
driver()