|
110 | 110 | if ($se eq "false"){ |
111 | 111 | $total_u = int($total_u / 2); |
112 | 112 | } |
113 | | - else{ |
114 | | - $total_u--; |
115 | | - } |
116 | 113 | } |
117 | 114 | else{ |
118 | 115 | die "cannot find file '$filter_u'\n"; |
|
140 | 137 | if ($se eq "false"){ |
141 | 138 | $total_u_a = int($total_u_a/ 2); |
142 | 139 | } |
143 | | - else{ |
144 | | - $total_u_a--; |
145 | | - } |
146 | 140 | } |
147 | 141 | else{ |
148 | 142 | die "cannot find file '$filter_u_a'\n"; |
|
172 | 166 | if ($se eq "false"){ |
173 | 167 | $total_nu = int($total_nu/ 2); |
174 | 168 | } |
175 | | - else{ |
176 | | - $total_nu--; |
177 | | - } |
178 | 169 | } |
179 | 170 | else{ |
180 | 171 | die "cannot find file '$filter_nu'\n"; |
|
202 | 193 | if ($se eq "false"){ |
203 | 194 | $total_nu_a = int($total_nu_a/ 2); |
204 | 195 | } |
205 | | - else{ |
206 | | - $total_nu_a--; |
207 | | - } |
208 | 196 | } |
209 | 197 | else{ |
210 | 198 | die "cannot find file '$filter_nu_a'\n"; |
|
227 | 215 | } |
228 | 216 |
|
229 | 217 | if($U eq "true"){ |
230 | | - open(IN_U, $temp_u); |
231 | | - open(OUT, ">$outfile"); |
232 | | - open(OUT2, ">$highfile"); |
233 | | - print OUT "ensGene\t%gene\tgeneSymbol\tgeneCoordinates\n"; |
234 | | - print OUT2 "ensGene\t%gene\tgeneSymbol\tgeneCoordinates\n"; |
235 | | - while(my $line_U = <IN_U>){ |
236 | | - chomp($line_U); |
237 | | - my @au = split(/\t/, $line_U); |
238 | | - my $geneu = $au[0]; |
239 | | - my $quantu = $au[1]; |
240 | | - my $sym = $au[3]; |
241 | | - my $coord = $au[4]; |
242 | | - my $percent_u = int(($quantu / $total_u)* 10000 ) / 100; |
243 | | - $percent_u = sprintf("%.2f", $percent_u); |
244 | | - print OUT "$geneu\t$percent_u\t$sym\t$coord\n"; |
245 | | - if ($percent_u >= $cutoff){ |
246 | | - print OUT2 "$geneu\t$percent_u\t$sym\t$coord\n"; |
247 | | - } |
248 | | - } |
249 | | - close(IN_U); |
250 | | - close(OUT); |
251 | | - close(OUT2); |
252 | | - `rm $temp_u`; |
253 | | - if ($stranded eq "true"){ |
254 | | - open(IN_U_A, $temp_u_a); |
255 | | - open(OUT, ">$outfile_a"); |
256 | | - open(OUT2, ">$highfile_a"); |
| 218 | + open(IN_U, $temp_u); |
| 219 | + open(OUT, ">$outfile"); |
| 220 | + open(OUT2, ">$highfile"); |
257 | 221 | print OUT "ensGene\t%gene\tgeneSymbol\tgeneCoordinates\n"; |
258 | 222 | print OUT2 "ensGene\t%gene\tgeneSymbol\tgeneCoordinates\n"; |
259 | | - while(my $line_U_A = <IN_U_A>){ |
260 | | - chomp($line_U_A); |
261 | | - my @au = split(/\t/, $line_U_A); |
| 223 | + while(my $line_U = <IN_U>){ |
| 224 | + chomp($line_U); |
| 225 | + my @au = split(/\t/, $line_U); |
262 | 226 | my $geneu = $au[0]; |
263 | 227 | my $quantu = $au[1]; |
264 | 228 | my $sym = $au[3]; |
265 | 229 | my $coord = $au[4]; |
266 | | - my $percent_u = int(($quantu / $total_u_a)* 10000 ) / 100; |
| 230 | + my $percent_u = 0; |
| 231 | + #Prevents divide-by-zero error if there are no Unique (sense) reads. |
| 232 | + if($total_u > 0) { |
| 233 | + $percent_u = int(($quantu / $total_u)* 10000 ) / 100; |
| 234 | + } |
267 | 235 | $percent_u = sprintf("%.2f", $percent_u); |
268 | 236 | print OUT "$geneu\t$percent_u\t$sym\t$coord\n"; |
269 | 237 | if ($percent_u >= $cutoff){ |
270 | | - print OUT2 "$geneu\t$percent_u\t$sym\t$coord\n"; |
| 238 | + print OUT2 "$geneu\t$percent_u\t$sym\t$coord\n"; |
271 | 239 | } |
272 | 240 | } |
273 | | - close(IN_U_A); |
| 241 | + close(IN_U); |
274 | 242 | close(OUT); |
275 | 243 | close(OUT2); |
276 | | - `rm $temp_u_a`; |
277 | | - } |
| 244 | + `rm $temp_u`; |
| 245 | + if ($stranded eq "true"){ |
| 246 | + open(IN_U_A, $temp_u_a); |
| 247 | + open(OUT, ">$outfile_a"); |
| 248 | + open(OUT2, ">$highfile_a"); |
| 249 | + print OUT "ensGene\t%gene\tgeneSymbol\tgeneCoordinates\n"; |
| 250 | + print OUT2 "ensGene\t%gene\tgeneSymbol\tgeneCoordinates\n"; |
| 251 | + while(my $line_U_A = <IN_U_A>){ |
| 252 | + chomp($line_U_A); |
| 253 | + my @au = split(/\t/, $line_U_A); |
| 254 | + my $geneu = $au[0]; |
| 255 | + my $quantu = $au[1]; |
| 256 | + my $sym = $au[3]; |
| 257 | + my $coord = $au[4]; |
| 258 | + my $percent_u = 0; |
| 259 | + #Prevents divide-by-zero error if there are no Unique antisense reads. |
| 260 | + if($total_u_a > 0) { |
| 261 | + $percent_u = int(($quantu / $total_u_a)* 10000 ) / 100; |
| 262 | + } |
| 263 | + $percent_u = sprintf("%.2f", $percent_u); |
| 264 | + print OUT "$geneu\t$percent_u\t$sym\t$coord\n"; |
| 265 | + if ($percent_u >= $cutoff){ |
| 266 | + print OUT2 "$geneu\t$percent_u\t$sym\t$coord\n"; |
| 267 | + } |
| 268 | + } |
| 269 | + close(IN_U_A); |
| 270 | + close(OUT); |
| 271 | + close(OUT2); |
| 272 | + `rm $temp_u_a`; |
| 273 | + } |
278 | 274 | } |
279 | 275 | if($NU eq "true"){ |
280 | | - open(IN_NU, $temp_nu); |
281 | | - open(OUT, ">$outfile"); |
282 | | - #open(OUT2, ">$highfile"); |
283 | | - print OUT "ensGene\t%gene\tgeneSymbol\tgeneCoordinates\n"; |
284 | | - #print OUT2 "ensGene\t%max\tgeneSymbol\tgeneCoordinates\n"; |
285 | | - while(my $line_NU = <IN_NU>){ |
286 | | - chomp($line_NU); |
287 | | - my @anu = split(/\t/, $line_NU); |
288 | | - my $genenu = $anu[0]; |
289 | | - my $quantnu = $anu[2]; |
290 | | - my $sym = $anu[3]; |
291 | | - my $coord = $anu[4]; |
292 | | - my $percent_nu = int(($quantnu / $total_nu)* 10000 ) / 100; |
293 | | - $percent_nu = sprintf("%.2f", $percent_nu); |
294 | | - print OUT "$genenu\t$percent_nu\t$sym\t$coord\n"; |
295 | | - #if ($percent_nu >= $cutoff){ |
296 | | - # print OUT2 "$genenu\t$percent_nu\t$sym\t$coord\n"; |
297 | | - #} |
298 | | - } |
299 | | - close(IN_NU); |
300 | | - close(OUT); |
301 | | - #close(OUT2); |
302 | | - `rm $temp_nu`; |
303 | | - if ($stranded eq "true"){ |
304 | | - open(IN_NU_A, $temp_nu_a); |
305 | | - open(OUT, ">$outfile_a"); |
306 | | - #open(OUT2, ">$highfile_a"); |
307 | | - print OUT "ensGene\t%max\tgeneSymbol\tgeneCoordinates\n"; |
| 276 | + open(IN_NU, $temp_nu); |
| 277 | + open(OUT, ">$outfile"); |
| 278 | + #open(OUT2, ">$highfile"); |
| 279 | + print OUT "ensGene\t%gene\tgeneSymbol\tgeneCoordinates\n"; |
308 | 280 | #print OUT2 "ensGene\t%max\tgeneSymbol\tgeneCoordinates\n"; |
309 | | - while(my $line_NU_A = <IN_NU_A>){ |
310 | | - chomp($line_NU_A); |
311 | | - my @anu = split(/\t/, $line_NU_A); |
| 281 | + while(my $line_NU = <IN_NU>){ |
| 282 | + chomp($line_NU); |
| 283 | + my @anu = split(/\t/, $line_NU); |
312 | 284 | my $genenu = $anu[0]; |
313 | 285 | my $quantnu = $anu[2]; |
314 | 286 | my $sym = $anu[3]; |
315 | 287 | my $coord = $anu[4]; |
316 | | - my $percent_nu = int(($quantnu / $total_nu_a)* 10000 ) / 100; |
| 288 | + my $percent_nu = 0; |
| 289 | + #Prevents divide-by-zero error if there are no NU (sense) reads. |
| 290 | + if($total_nu > 0) { |
| 291 | + $percent_nu = int(($quantnu / $total_nu)* 10000 ) / 100; |
| 292 | + } |
317 | 293 | $percent_nu = sprintf("%.2f", $percent_nu); |
318 | 294 | print OUT "$genenu\t$percent_nu\t$sym\t$coord\n"; |
319 | 295 | #if ($percent_nu >= $cutoff){ |
320 | | - #print OUT2 "$genenu\t$percent_nu\t$sym\t$coord\n"; |
| 296 | + # print OUT2 "$genenu\t$percent_nu\t$sym\t$coord\n"; |
321 | 297 | #} |
322 | 298 | } |
323 | | - close(IN_NU_A); |
| 299 | + close(IN_NU); |
324 | 300 | close(OUT); |
325 | 301 | #close(OUT2); |
326 | | - `rm $temp_nu_a`; |
327 | | - } |
| 302 | + `rm $temp_nu`; |
| 303 | + if ($stranded eq "true"){ |
| 304 | + open(IN_NU_A, $temp_nu_a); |
| 305 | + open(OUT, ">$outfile_a"); |
| 306 | + #open(OUT2, ">$highfile_a"); |
| 307 | + print OUT "ensGene\t%max\tgeneSymbol\tgeneCoordinates\n"; |
| 308 | + #print OUT2 "ensGene\t%max\tgeneSymbol\tgeneCoordinates\n"; |
| 309 | + while(my $line_NU_A = <IN_NU_A>){ |
| 310 | + chomp($line_NU_A); |
| 311 | + my @anu = split(/\t/, $line_NU_A); |
| 312 | + my $genenu = $anu[0]; |
| 313 | + my $quantnu = $anu[2]; |
| 314 | + my $sym = $anu[3]; |
| 315 | + my $coord = $anu[4]; |
| 316 | + my $percent_nu = 0; |
| 317 | + #Prevents divide-by-zero error if there are no NU antisense reads. |
| 318 | + if($total_nu_a > 0) { |
| 319 | + $percent_nu = int(($quantnu / $total_nu_a)* 10000 ) / 100; |
| 320 | + } |
| 321 | + $percent_nu = sprintf("%.2f", $percent_nu); |
| 322 | + print OUT "$genenu\t$percent_nu\t$sym\t$coord\n"; |
| 323 | + #if ($percent_nu >= $cutoff){ |
| 324 | + #print OUT2 "$genenu\t$percent_nu\t$sym\t$coord\n"; |
| 325 | + #} |
| 326 | + } |
| 327 | + close(IN_NU_A); |
| 328 | + close(OUT); |
| 329 | + #close(OUT2); |
| 330 | + `rm $temp_nu_a`; |
| 331 | + } |
328 | 332 | } |
329 | 333 |
|
330 | 334 | print "got here\n"; |
0 commit comments