0
|
1 # -*- coding: utf-8 -*-
|
|
2 """
|
|
3 Glimmer --> glimmer3
|
|
4 version 0.2 (andrea.pinna@crs4.it)
|
|
5 """
|
|
6
|
|
7 import optparse
|
|
8 import shutil
|
|
9 import subprocess
|
|
10 import sys
|
|
11
|
|
12 def __main__():
|
|
13 # load arguments
|
|
14 print 'Parsing input options...'
|
|
15 parser = optparse.OptionParser()
|
|
16 parser.add_option('--glSequence', dest='sequence', help='')
|
|
17 parser.add_option('--glIcm', dest='icm', help='')
|
|
18 #parser.add_option('--glPrefix', dest='prefix', help='')
|
|
19 parser.add_option('--glStartCodons', dest='start_codons', help='')
|
|
20 parser.add_option('--glRbsPwm', dest='rbs_pwm', help='')
|
|
21 parser.add_option('--glGcPercent', dest='gc_percent', type='float', help='')
|
|
22 parser.add_option('--glEntropy', dest='entropy', help='')
|
|
23 parser.add_option('--glFirstCodon', action='store_true', dest='first_codon', help='')
|
|
24 parser.add_option('--glGeneLen', dest='gene_len', type='int', help='')
|
|
25 parser.add_option('--glIgnore', dest='ignore', help='')
|
|
26 parser.add_option('--glLinear', action='store_true', dest='linear', help='')
|
|
27 parser.add_option('--glOrfCoords', dest='orf_coords', help='')
|
|
28 parser.add_option('--glSeparateGenes', action='store_true', dest='separate_genes', help='')
|
|
29 parser.add_option('--glMaxOverlap', dest='max_olap', type='int', help='')
|
|
30 parser.add_option('--glStartProbs', dest='start_probs', help='')
|
|
31 parser.add_option('--glIgnoreScoreLen', dest='ignore_score_len', type='int', help='')
|
|
32 parser.add_option('--glNoIndep', action='store_true', dest='no_indep', help='')
|
|
33 parser.add_option('--glThreshold', dest='threshold', type='int', help='')
|
|
34 parser.add_option('--glExtend', action='store_true', dest='extend', help='')
|
|
35 parser.add_option('--glTransTable', dest='trans_table', type='int', help='')
|
|
36 parser.add_option('--glStopCodons', dest='stop_codons', help='')
|
|
37 parser.add_option('--glDetail', dest='detail', help='')
|
|
38 parser.add_option('--glPredict', dest='predict', help='')
|
|
39 parser.add_option('--logfile', dest='logfile', help='')
|
|
40 (options, args) = parser.parse_args()
|
|
41 if len(args) > 0:
|
|
42 parser.error('Wrong number of arguments')
|
|
43
|
|
44 # build Glimmer3 command to be executed
|
|
45 # sequence file
|
|
46 sequence = options.sequence
|
|
47 # icm file
|
|
48 icm = options.icm
|
|
49 # prefix (not needed)
|
|
50 prefix = 'prefix'
|
|
51 # start codons
|
|
52 if options.start_codons:
|
|
53 start_codons = '--start_codons %s' % (options.start_codons)
|
|
54 else:
|
|
55 start_codons = ''
|
|
56 # rbs_pwm
|
|
57 if options.rbs_pwm:
|
|
58 rbs_pwm = '--rbs_pwm %s' % (options.rbs_pwm)
|
|
59 else:
|
|
60 rbs_pwm = ''
|
|
61 # gc percentage
|
|
62 if options.gc_percent is not None:
|
|
63 gc_percent = '--gc_percent %s' % (options.gc_percent)
|
|
64 else:
|
|
65 gc_percent = ''
|
|
66 # entropy
|
|
67 if options.entropy:
|
|
68 entropy = "--entropy '%s'" % (options.entropy)
|
|
69 else:
|
|
70 entropy = ''
|
|
71 # first_codon
|
|
72 if options.first_codon:
|
|
73 first_codon = '--first_codon'
|
|
74 else:
|
|
75 first_codon = ''
|
|
76 # gene length
|
|
77 if options.gene_len is not None:
|
|
78 gene_len = '--gene_len %d' % (options.gene_len)
|
|
79 else:
|
|
80 gene_len = ''
|
|
81 # ignore
|
|
82 if options.ignore:
|
|
83 ignore = '--ignore %s' % (options.ignore)
|
|
84 else:
|
|
85 ignore = ''
|
|
86 # linear
|
|
87 if options.linear:
|
|
88 linear = '--linear'
|
|
89 else:
|
|
90 linear = ''
|
|
91 # orf_coords
|
|
92 if options.orf_coords:
|
|
93 orf_coords = '--orf_coords %s' % (options.orf_coords)
|
|
94 else:
|
|
95 orf_coords = ''
|
|
96 # separate genes
|
|
97 if options.separate_genes:
|
|
98 separate_genes = '--separate_genes'
|
|
99 else:
|
|
100 separate_genes = ''
|
|
101 # max overlap
|
|
102 if options.max_olap is not None:
|
|
103 max_olap = '--max_olap %d' % (options.max_olap)
|
|
104 else:
|
|
105 max_olap = ''
|
|
106 # start probs
|
|
107 if options.start_probs:
|
|
108 start_probs = '--start_probs %s' % (options.start_probs)
|
|
109 else:
|
|
110 start_probs = ''
|
|
111 # ignore score length
|
|
112 if options.ignore_score_len is not None:
|
|
113 ignore_score_len = '--ignore_score_len %d' % (options.ignore_score_len)
|
|
114 else:
|
|
115 ignore_score_len = ''
|
|
116 # no indep
|
|
117 if options.no_indep:
|
|
118 no_indep = '--no_indep'
|
|
119 else:
|
|
120 no_indep = ''
|
|
121 # threshold
|
|
122 if options.threshold is not None:
|
|
123 threshold = '--threshold %d' % (options.threshold)
|
|
124 else:
|
|
125 threshold = ''
|
|
126 # extend
|
|
127 if options.extend:
|
|
128 extend = '--extend'
|
|
129 else:
|
|
130 extend = ''
|
|
131 # trans table
|
|
132 if options.trans_table is not None:
|
|
133 trans_table = '--trans_table %d' % (options.trans_table)
|
|
134 else:
|
|
135 trans_table = ''
|
|
136 # stop codons
|
|
137 if options.stop_codons:
|
|
138 stop_codons = '--stop_codons %s' % (options.stop_codons)
|
|
139 else:
|
|
140 stop_codons = ''
|
|
141 logfile = options.logfile
|
|
142
|
|
143 # Build Glimmer3 command
|
|
144 cmd = 'glimmer3 %s %s %s %s %s %s %s %s %s %s %s %s %s %s %s %s %s %s %s %s %s' % (start_codons, rbs_pwm, gc_percent, entropy, first_codon, gene_len, ignore, linear, orf_coords, separate_genes, max_olap, start_probs, ignore_score_len, no_indep, threshold, extend, trans_table, stop_codons, sequence, icm, prefix)
|
|
145 print '\nGlimmer3 command to be executed: \n %s' % (cmd)
|
|
146
|
|
147 print 'Executing Glimmer3...'
|
|
148 if logfile:
|
|
149 log = open(logfile, 'w')
|
|
150 else:
|
|
151 log = sys.stdout
|
|
152 try:
|
|
153 subprocess.check_call(cmd, stdout=log, stderr=subprocess.STDOUT, shell=True)
|
|
154 finally:
|
|
155 if log != sys.stdout:
|
|
156 log.close()
|
|
157 print 'Glimmer3 executed!'
|
|
158
|
|
159 shutil.move(prefix + ".detail", options.detail)
|
|
160 shutil.move(prefix + ".predict", options.predict)
|
|
161
|
|
162
|
|
163 if __name__ == "__main__":
|
|
164 __main__()
|