annotate short_reads_trim_seq.py @ 1:ece3c79e81ae draft default tip

planemo upload commit 33927a87ba2eee9bf0ecdd376a66241b17b3d734
author devteam
date Tue, 13 Oct 2015 12:31:41 -0400
parents 8c0b907e6e5b
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
8c0b907e6e5b Imported from capsule None
devteam
parents:
diff changeset
1 #!/usr/bin/env python
8c0b907e6e5b Imported from capsule None
devteam
parents:
diff changeset
2 """
8c0b907e6e5b Imported from capsule None
devteam
parents:
diff changeset
3 trim reads based on the quality scores
8c0b907e6e5b Imported from capsule None
devteam
parents:
diff changeset
4 input: read file and quality score file
8c0b907e6e5b Imported from capsule None
devteam
parents:
diff changeset
5 output: trimmed read file
8c0b907e6e5b Imported from capsule None
devteam
parents:
diff changeset
6 """
8c0b907e6e5b Imported from capsule None
devteam
parents:
diff changeset
7
8c0b907e6e5b Imported from capsule None
devteam
parents:
diff changeset
8 import os, sys, math, tempfile, re
8c0b907e6e5b Imported from capsule None
devteam
parents:
diff changeset
9
8c0b907e6e5b Imported from capsule None
devteam
parents:
diff changeset
10 assert sys.version_info[:2] >= ( 2, 4 )
8c0b907e6e5b Imported from capsule None
devteam
parents:
diff changeset
11
8c0b907e6e5b Imported from capsule None
devteam
parents:
diff changeset
12 def stop_err( msg ):
8c0b907e6e5b Imported from capsule None
devteam
parents:
diff changeset
13 sys.stderr.write( "%s\n" % msg )
8c0b907e6e5b Imported from capsule None
devteam
parents:
diff changeset
14 sys.exit()
8c0b907e6e5b Imported from capsule None
devteam
parents:
diff changeset
15
8c0b907e6e5b Imported from capsule None
devteam
parents:
diff changeset
16 def append_to_outfile( outfile_name, seq_title, segments ):
8c0b907e6e5b Imported from capsule None
devteam
parents:
diff changeset
17 segments = segments.split( ',' )
8c0b907e6e5b Imported from capsule None
devteam
parents:
diff changeset
18 if len( segments ) > 1:
8c0b907e6e5b Imported from capsule None
devteam
parents:
diff changeset
19 outfile = open( outfile_name, 'a' )
8c0b907e6e5b Imported from capsule None
devteam
parents:
diff changeset
20 for i in range( len( segments ) ):
8c0b907e6e5b Imported from capsule None
devteam
parents:
diff changeset
21 outfile.write( "%s_%d\n%s\n" % ( seq_title, i, segments[i] ) )
8c0b907e6e5b Imported from capsule None
devteam
parents:
diff changeset
22 outfile.close()
8c0b907e6e5b Imported from capsule None
devteam
parents:
diff changeset
23 elif segments[0]:
8c0b907e6e5b Imported from capsule None
devteam
parents:
diff changeset
24 outfile = open( outfile_name, 'a' )
8c0b907e6e5b Imported from capsule None
devteam
parents:
diff changeset
25 outfile.write( "%s\n%s\n" % ( seq_title, segments[0] ) )
8c0b907e6e5b Imported from capsule None
devteam
parents:
diff changeset
26 outfile.close()
8c0b907e6e5b Imported from capsule None
devteam
parents:
diff changeset
27
8c0b907e6e5b Imported from capsule None
devteam
parents:
diff changeset
28 def trim_seq( seq, score, arg, trim_score, threshold ):
8c0b907e6e5b Imported from capsule None
devteam
parents:
diff changeset
29 seq_method = '454'
8c0b907e6e5b Imported from capsule None
devteam
parents:
diff changeset
30 trim_pos = 0
8c0b907e6e5b Imported from capsule None
devteam
parents:
diff changeset
31 # trim after a certain position
8c0b907e6e5b Imported from capsule None
devteam
parents:
diff changeset
32 if arg.isdigit():
8c0b907e6e5b Imported from capsule None
devteam
parents:
diff changeset
33 keep_homopolymers = False
8c0b907e6e5b Imported from capsule None
devteam
parents:
diff changeset
34 trim_pos = int( arg )
8c0b907e6e5b Imported from capsule None
devteam
parents:
diff changeset
35 if trim_pos > 0 and trim_pos < len( seq ):
8c0b907e6e5b Imported from capsule None
devteam
parents:
diff changeset
36 seq = seq[0:trim_pos]
8c0b907e6e5b Imported from capsule None
devteam
parents:
diff changeset
37 else:
8c0b907e6e5b Imported from capsule None
devteam
parents:
diff changeset
38 keep_homopolymers = arg=='yes'
8c0b907e6e5b Imported from capsule None
devteam
parents:
diff changeset
39
8c0b907e6e5b Imported from capsule None
devteam
parents:
diff changeset
40 new_trim_seq = ''
8c0b907e6e5b Imported from capsule None
devteam
parents:
diff changeset
41 max_segment = 0
8c0b907e6e5b Imported from capsule None
devteam
parents:
diff changeset
42
8c0b907e6e5b Imported from capsule None
devteam
parents:
diff changeset
43 for i in range( len( seq ) ):
8c0b907e6e5b Imported from capsule None
devteam
parents:
diff changeset
44 if i >= len( score ):
8c0b907e6e5b Imported from capsule None
devteam
parents:
diff changeset
45 score.append(-1)
8c0b907e6e5b Imported from capsule None
devteam
parents:
diff changeset
46 if int( score[i] ) >= trim_score:
8c0b907e6e5b Imported from capsule None
devteam
parents:
diff changeset
47 pass_nuc = seq[ i:( i + 1 ) ]
8c0b907e6e5b Imported from capsule None
devteam
parents:
diff changeset
48 else:
8c0b907e6e5b Imported from capsule None
devteam
parents:
diff changeset
49 if keep_homopolymers and ( (i == 0 ) or ( seq[ i:( i + 1 ) ].lower() == seq[ ( i - 1 ):i ].lower() ) ):
8c0b907e6e5b Imported from capsule None
devteam
parents:
diff changeset
50 pass_nuc = seq[ i:( i + 1 ) ]
8c0b907e6e5b Imported from capsule None
devteam
parents:
diff changeset
51 else:
8c0b907e6e5b Imported from capsule None
devteam
parents:
diff changeset
52 pass_nuc = ' '
8c0b907e6e5b Imported from capsule None
devteam
parents:
diff changeset
53 new_trim_seq = '%s%s' % ( new_trim_seq, pass_nuc )
8c0b907e6e5b Imported from capsule None
devteam
parents:
diff changeset
54 # find the max substrings
8c0b907e6e5b Imported from capsule None
devteam
parents:
diff changeset
55 segments = new_trim_seq.split()
8c0b907e6e5b Imported from capsule None
devteam
parents:
diff changeset
56 max_segment = ''
8c0b907e6e5b Imported from capsule None
devteam
parents:
diff changeset
57 len_max_segment = 0
8c0b907e6e5b Imported from capsule None
devteam
parents:
diff changeset
58 if threshold == 0:
8c0b907e6e5b Imported from capsule None
devteam
parents:
diff changeset
59 for seg in segments:
8c0b907e6e5b Imported from capsule None
devteam
parents:
diff changeset
60 if len_max_segment < len( seg ):
8c0b907e6e5b Imported from capsule None
devteam
parents:
diff changeset
61 max_segment = '%s,' % seg
8c0b907e6e5b Imported from capsule None
devteam
parents:
diff changeset
62 len_max_segment = len( seg )
8c0b907e6e5b Imported from capsule None
devteam
parents:
diff changeset
63 elif len_max_segment == len( seg ):
8c0b907e6e5b Imported from capsule None
devteam
parents:
diff changeset
64 max_segment = '%s%s,' % ( max_segment, seg )
8c0b907e6e5b Imported from capsule None
devteam
parents:
diff changeset
65 else:
8c0b907e6e5b Imported from capsule None
devteam
parents:
diff changeset
66 for seg in segments:
8c0b907e6e5b Imported from capsule None
devteam
parents:
diff changeset
67 if len( seg ) >= threshold:
8c0b907e6e5b Imported from capsule None
devteam
parents:
diff changeset
68 max_segment = '%s%s,' % ( max_segment, seg )
8c0b907e6e5b Imported from capsule None
devteam
parents:
diff changeset
69 return max_segment[ 0:-1 ]
8c0b907e6e5b Imported from capsule None
devteam
parents:
diff changeset
70
8c0b907e6e5b Imported from capsule None
devteam
parents:
diff changeset
71 def __main__():
8c0b907e6e5b Imported from capsule None
devteam
parents:
diff changeset
72
8c0b907e6e5b Imported from capsule None
devteam
parents:
diff changeset
73 try:
8c0b907e6e5b Imported from capsule None
devteam
parents:
diff changeset
74 threshold_trim = int( sys.argv[1].strip() )
8c0b907e6e5b Imported from capsule None
devteam
parents:
diff changeset
75 except:
8c0b907e6e5b Imported from capsule None
devteam
parents:
diff changeset
76 stop_err( "Minimal quality score must be numeric." )
8c0b907e6e5b Imported from capsule None
devteam
parents:
diff changeset
77 try:
8c0b907e6e5b Imported from capsule None
devteam
parents:
diff changeset
78 threshold_report = int( sys.argv[2].strip() )
8c0b907e6e5b Imported from capsule None
devteam
parents:
diff changeset
79 except:
8c0b907e6e5b Imported from capsule None
devteam
parents:
diff changeset
80 stop_err( "Minimal length of trimmed reads must be numeric." )
8c0b907e6e5b Imported from capsule None
devteam
parents:
diff changeset
81 outfile_seq_name = sys.argv[3].strip()
8c0b907e6e5b Imported from capsule None
devteam
parents:
diff changeset
82 infile_seq_name = sys.argv[4].strip()
8c0b907e6e5b Imported from capsule None
devteam
parents:
diff changeset
83 infile_score_name = sys.argv[5].strip()
8c0b907e6e5b Imported from capsule None
devteam
parents:
diff changeset
84 arg = sys.argv[6].strip()
8c0b907e6e5b Imported from capsule None
devteam
parents:
diff changeset
85
8c0b907e6e5b Imported from capsule None
devteam
parents:
diff changeset
86 seq_infile_name = infile_seq_name
8c0b907e6e5b Imported from capsule None
devteam
parents:
diff changeset
87 score_infile_name = infile_score_name
8c0b907e6e5b Imported from capsule None
devteam
parents:
diff changeset
88
8c0b907e6e5b Imported from capsule None
devteam
parents:
diff changeset
89
8c0b907e6e5b Imported from capsule None
devteam
parents:
diff changeset
90 # Determine quailty score format: tabular or fasta format within the first 100 lines
8c0b907e6e5b Imported from capsule None
devteam
parents:
diff changeset
91 seq_method = None
8c0b907e6e5b Imported from capsule None
devteam
parents:
diff changeset
92 data_type = None
8c0b907e6e5b Imported from capsule None
devteam
parents:
diff changeset
93 for i, line in enumerate( file( score_infile_name ) ):
8c0b907e6e5b Imported from capsule None
devteam
parents:
diff changeset
94 line = line.rstrip( '\r\n' )
8c0b907e6e5b Imported from capsule None
devteam
parents:
diff changeset
95 if not line or line.startswith( '#' ):
8c0b907e6e5b Imported from capsule None
devteam
parents:
diff changeset
96 continue
8c0b907e6e5b Imported from capsule None
devteam
parents:
diff changeset
97 if data_type == None:
8c0b907e6e5b Imported from capsule None
devteam
parents:
diff changeset
98 if line.startswith( '>' ):
8c0b907e6e5b Imported from capsule None
devteam
parents:
diff changeset
99 data_type = 'fasta'
8c0b907e6e5b Imported from capsule None
devteam
parents:
diff changeset
100 continue
8c0b907e6e5b Imported from capsule None
devteam
parents:
diff changeset
101 elif len( line.split( '\t' ) ) > 0:
8c0b907e6e5b Imported from capsule None
devteam
parents:
diff changeset
102 fields = line.split()
8c0b907e6e5b Imported from capsule None
devteam
parents:
diff changeset
103 for score in fields:
8c0b907e6e5b Imported from capsule None
devteam
parents:
diff changeset
104 try:
8c0b907e6e5b Imported from capsule None
devteam
parents:
diff changeset
105 int( score )
8c0b907e6e5b Imported from capsule None
devteam
parents:
diff changeset
106 data_type = 'tabular'
8c0b907e6e5b Imported from capsule None
devteam
parents:
diff changeset
107 seq_method = 'solexa'
8c0b907e6e5b Imported from capsule None
devteam
parents:
diff changeset
108 break
8c0b907e6e5b Imported from capsule None
devteam
parents:
diff changeset
109 except:
8c0b907e6e5b Imported from capsule None
devteam
parents:
diff changeset
110 break
8c0b907e6e5b Imported from capsule None
devteam
parents:
diff changeset
111 elif data_type == 'fasta':
8c0b907e6e5b Imported from capsule None
devteam
parents:
diff changeset
112 fields = line.split()
8c0b907e6e5b Imported from capsule None
devteam
parents:
diff changeset
113 for score in fields:
8c0b907e6e5b Imported from capsule None
devteam
parents:
diff changeset
114 try:
8c0b907e6e5b Imported from capsule None
devteam
parents:
diff changeset
115 int( score )
8c0b907e6e5b Imported from capsule None
devteam
parents:
diff changeset
116 seq_method = '454'
8c0b907e6e5b Imported from capsule None
devteam
parents:
diff changeset
117 break
8c0b907e6e5b Imported from capsule None
devteam
parents:
diff changeset
118 except:
8c0b907e6e5b Imported from capsule None
devteam
parents:
diff changeset
119 break
8c0b907e6e5b Imported from capsule None
devteam
parents:
diff changeset
120 if i == 100:
8c0b907e6e5b Imported from capsule None
devteam
parents:
diff changeset
121 break
8c0b907e6e5b Imported from capsule None
devteam
parents:
diff changeset
122
8c0b907e6e5b Imported from capsule None
devteam
parents:
diff changeset
123 if data_type is None:
8c0b907e6e5b Imported from capsule None
devteam
parents:
diff changeset
124 stop_err( 'This tool can only use fasta data or tabular data.' )
8c0b907e6e5b Imported from capsule None
devteam
parents:
diff changeset
125 if seq_method is None:
8c0b907e6e5b Imported from capsule None
devteam
parents:
diff changeset
126 stop_err( 'Invalid data for fasta format.')
8c0b907e6e5b Imported from capsule None
devteam
parents:
diff changeset
127
8c0b907e6e5b Imported from capsule None
devteam
parents:
diff changeset
128 if os.path.exists( seq_infile_name ) and os.path.exists( score_infile_name ):
8c0b907e6e5b Imported from capsule None
devteam
parents:
diff changeset
129 seq = None
8c0b907e6e5b Imported from capsule None
devteam
parents:
diff changeset
130 score = None
8c0b907e6e5b Imported from capsule None
devteam
parents:
diff changeset
131 score_found = False
8c0b907e6e5b Imported from capsule None
devteam
parents:
diff changeset
132
8c0b907e6e5b Imported from capsule None
devteam
parents:
diff changeset
133 score_file = open( score_infile_name, 'r' )
8c0b907e6e5b Imported from capsule None
devteam
parents:
diff changeset
134
8c0b907e6e5b Imported from capsule None
devteam
parents:
diff changeset
135 for i, line in enumerate( open( seq_infile_name ) ):
8c0b907e6e5b Imported from capsule None
devteam
parents:
diff changeset
136 line = line.rstrip( '\r\n' )
8c0b907e6e5b Imported from capsule None
devteam
parents:
diff changeset
137 if not line or line.startswith( '#' ):
8c0b907e6e5b Imported from capsule None
devteam
parents:
diff changeset
138 continue
8c0b907e6e5b Imported from capsule None
devteam
parents:
diff changeset
139 if line.startswith( '>' ):
8c0b907e6e5b Imported from capsule None
devteam
parents:
diff changeset
140 if seq:
8c0b907e6e5b Imported from capsule None
devteam
parents:
diff changeset
141 scores = []
8c0b907e6e5b Imported from capsule None
devteam
parents:
diff changeset
142 if data_type == 'fasta':
8c0b907e6e5b Imported from capsule None
devteam
parents:
diff changeset
143 score = None
8c0b907e6e5b Imported from capsule None
devteam
parents:
diff changeset
144 score_found = False
8c0b907e6e5b Imported from capsule None
devteam
parents:
diff changeset
145 score_line = 'start'
8c0b907e6e5b Imported from capsule None
devteam
parents:
diff changeset
146 while not score_found and score_line:
8c0b907e6e5b Imported from capsule None
devteam
parents:
diff changeset
147 score_line = score_file.readline().rstrip( '\r\n' )
8c0b907e6e5b Imported from capsule None
devteam
parents:
diff changeset
148 if not score_line or score_line.startswith( '#' ):
8c0b907e6e5b Imported from capsule None
devteam
parents:
diff changeset
149 continue
8c0b907e6e5b Imported from capsule None
devteam
parents:
diff changeset
150 if score_line.startswith( '>' ):
8c0b907e6e5b Imported from capsule None
devteam
parents:
diff changeset
151 if score:
8c0b907e6e5b Imported from capsule None
devteam
parents:
diff changeset
152 scores = score.split()
8c0b907e6e5b Imported from capsule None
devteam
parents:
diff changeset
153 score_found = True
8c0b907e6e5b Imported from capsule None
devteam
parents:
diff changeset
154 score = None
8c0b907e6e5b Imported from capsule None
devteam
parents:
diff changeset
155 else:
8c0b907e6e5b Imported from capsule None
devteam
parents:
diff changeset
156 for val in score_line.split():
8c0b907e6e5b Imported from capsule None
devteam
parents:
diff changeset
157 try:
8c0b907e6e5b Imported from capsule None
devteam
parents:
diff changeset
158 int( val )
8c0b907e6e5b Imported from capsule None
devteam
parents:
diff changeset
159 except:
8c0b907e6e5b Imported from capsule None
devteam
parents:
diff changeset
160 score_file.close()
8c0b907e6e5b Imported from capsule None
devteam
parents:
diff changeset
161 stop_err( "Non-numerical value '%s' in score file." % val )
8c0b907e6e5b Imported from capsule None
devteam
parents:
diff changeset
162 if not score:
8c0b907e6e5b Imported from capsule None
devteam
parents:
diff changeset
163 score = score_line
8c0b907e6e5b Imported from capsule None
devteam
parents:
diff changeset
164 else:
8c0b907e6e5b Imported from capsule None
devteam
parents:
diff changeset
165 score = '%s %s' % ( score, score_line )
8c0b907e6e5b Imported from capsule None
devteam
parents:
diff changeset
166 elif data_type == 'tabular':
8c0b907e6e5b Imported from capsule None
devteam
parents:
diff changeset
167 score = score_file.readline().rstrip('\r\n')
8c0b907e6e5b Imported from capsule None
devteam
parents:
diff changeset
168 loc = score.split( '\t' )
8c0b907e6e5b Imported from capsule None
devteam
parents:
diff changeset
169 for base in loc:
8c0b907e6e5b Imported from capsule None
devteam
parents:
diff changeset
170 nuc_error = base.split()
8c0b907e6e5b Imported from capsule None
devteam
parents:
diff changeset
171 try:
8c0b907e6e5b Imported from capsule None
devteam
parents:
diff changeset
172 nuc_error[0] = int( nuc_error[0] )
8c0b907e6e5b Imported from capsule None
devteam
parents:
diff changeset
173 nuc_error[1] = int( nuc_error[1] )
8c0b907e6e5b Imported from capsule None
devteam
parents:
diff changeset
174 nuc_error[2] = int( nuc_error[2] )
8c0b907e6e5b Imported from capsule None
devteam
parents:
diff changeset
175 nuc_error[3] = int( nuc_error[3] )
8c0b907e6e5b Imported from capsule None
devteam
parents:
diff changeset
176 big = max( nuc_error )
8c0b907e6e5b Imported from capsule None
devteam
parents:
diff changeset
177 except:
8c0b907e6e5b Imported from capsule None
devteam
parents:
diff changeset
178 score_file.close()
8c0b907e6e5b Imported from capsule None
devteam
parents:
diff changeset
179 stop_err( "Invalid characters in line %d: '%s'" % ( i, line ) )
8c0b907e6e5b Imported from capsule None
devteam
parents:
diff changeset
180 scores.append( big )
8c0b907e6e5b Imported from capsule None
devteam
parents:
diff changeset
181 if scores:
8c0b907e6e5b Imported from capsule None
devteam
parents:
diff changeset
182 new_trim_seq_segments = trim_seq( seq, scores, arg, threshold_trim, threshold_report )
8c0b907e6e5b Imported from capsule None
devteam
parents:
diff changeset
183 append_to_outfile( outfile_seq_name, seq_title, new_trim_seq_segments )
8c0b907e6e5b Imported from capsule None
devteam
parents:
diff changeset
184
8c0b907e6e5b Imported from capsule None
devteam
parents:
diff changeset
185 seq_title = line
8c0b907e6e5b Imported from capsule None
devteam
parents:
diff changeset
186 seq = None
8c0b907e6e5b Imported from capsule None
devteam
parents:
diff changeset
187 else:
8c0b907e6e5b Imported from capsule None
devteam
parents:
diff changeset
188 if not seq:
8c0b907e6e5b Imported from capsule None
devteam
parents:
diff changeset
189 seq = line
8c0b907e6e5b Imported from capsule None
devteam
parents:
diff changeset
190 else:
8c0b907e6e5b Imported from capsule None
devteam
parents:
diff changeset
191 seq = "%s%s" % ( seq, line )
8c0b907e6e5b Imported from capsule None
devteam
parents:
diff changeset
192 if seq:
8c0b907e6e5b Imported from capsule None
devteam
parents:
diff changeset
193 scores = []
8c0b907e6e5b Imported from capsule None
devteam
parents:
diff changeset
194 if data_type == 'fasta':
8c0b907e6e5b Imported from capsule None
devteam
parents:
diff changeset
195 score = None
8c0b907e6e5b Imported from capsule None
devteam
parents:
diff changeset
196 while score_line:
8c0b907e6e5b Imported from capsule None
devteam
parents:
diff changeset
197 score_line = score_file.readline().rstrip( '\r\n' )
8c0b907e6e5b Imported from capsule None
devteam
parents:
diff changeset
198 if not score_line or score_line.startswith( '#' ) or score_line.startswith( '>' ):
8c0b907e6e5b Imported from capsule None
devteam
parents:
diff changeset
199 continue
8c0b907e6e5b Imported from capsule None
devteam
parents:
diff changeset
200 for val in score_line.split():
8c0b907e6e5b Imported from capsule None
devteam
parents:
diff changeset
201 try:
8c0b907e6e5b Imported from capsule None
devteam
parents:
diff changeset
202 int( val )
8c0b907e6e5b Imported from capsule None
devteam
parents:
diff changeset
203 except:
8c0b907e6e5b Imported from capsule None
devteam
parents:
diff changeset
204 score_file.close()
8c0b907e6e5b Imported from capsule None
devteam
parents:
diff changeset
205 stop_err( "Non-numerical value '%s' in score file." % val )
8c0b907e6e5b Imported from capsule None
devteam
parents:
diff changeset
206 if not score:
8c0b907e6e5b Imported from capsule None
devteam
parents:
diff changeset
207 score = score_line
8c0b907e6e5b Imported from capsule None
devteam
parents:
diff changeset
208 else:
8c0b907e6e5b Imported from capsule None
devteam
parents:
diff changeset
209 score = "%s %s" % ( score, score_line )
8c0b907e6e5b Imported from capsule None
devteam
parents:
diff changeset
210 if score:
8c0b907e6e5b Imported from capsule None
devteam
parents:
diff changeset
211 scores = score.split()
8c0b907e6e5b Imported from capsule None
devteam
parents:
diff changeset
212 elif data_type == 'tabular':
8c0b907e6e5b Imported from capsule None
devteam
parents:
diff changeset
213 score = score_file.readline().rstrip('\r\n')
8c0b907e6e5b Imported from capsule None
devteam
parents:
diff changeset
214 loc = score.split( '\t' )
8c0b907e6e5b Imported from capsule None
devteam
parents:
diff changeset
215 for base in loc:
8c0b907e6e5b Imported from capsule None
devteam
parents:
diff changeset
216 nuc_error = base.split()
8c0b907e6e5b Imported from capsule None
devteam
parents:
diff changeset
217 try:
8c0b907e6e5b Imported from capsule None
devteam
parents:
diff changeset
218 nuc_error[0] = int( nuc_error[0] )
8c0b907e6e5b Imported from capsule None
devteam
parents:
diff changeset
219 nuc_error[1] = int( nuc_error[1] )
8c0b907e6e5b Imported from capsule None
devteam
parents:
diff changeset
220 nuc_error[2] = int( nuc_error[2] )
8c0b907e6e5b Imported from capsule None
devteam
parents:
diff changeset
221 nuc_error[3] = int( nuc_error[3] )
8c0b907e6e5b Imported from capsule None
devteam
parents:
diff changeset
222 big = max( nuc_error )
8c0b907e6e5b Imported from capsule None
devteam
parents:
diff changeset
223 except:
8c0b907e6e5b Imported from capsule None
devteam
parents:
diff changeset
224 score_file.close()
8c0b907e6e5b Imported from capsule None
devteam
parents:
diff changeset
225 stop_err( "Invalid characters in line %d: '%s'" % ( i, line ) )
8c0b907e6e5b Imported from capsule None
devteam
parents:
diff changeset
226 scores.append( big )
8c0b907e6e5b Imported from capsule None
devteam
parents:
diff changeset
227 if scores:
8c0b907e6e5b Imported from capsule None
devteam
parents:
diff changeset
228 new_trim_seq_segments = trim_seq( seq, scores, arg, threshold_trim, threshold_report )
8c0b907e6e5b Imported from capsule None
devteam
parents:
diff changeset
229 append_to_outfile( outfile_seq_name, seq_title, new_trim_seq_segments )
8c0b907e6e5b Imported from capsule None
devteam
parents:
diff changeset
230 score_file.close()
8c0b907e6e5b Imported from capsule None
devteam
parents:
diff changeset
231 else:
8c0b907e6e5b Imported from capsule None
devteam
parents:
diff changeset
232 stop_err( "Cannot locate sequence file '%s'or score file '%s'." % ( seq_infile_name, score_infile_name ) )
8c0b907e6e5b Imported from capsule None
devteam
parents:
diff changeset
233
8c0b907e6e5b Imported from capsule None
devteam
parents:
diff changeset
234 if __name__ == "__main__": __main__()