Mercurial > repos > xuebing > sharplabtool
comparison bowtie2bed.pl @ 14:76e1b1b21cce default tip
Deleted selected files
author | xuebing |
---|---|
date | Tue, 13 Mar 2012 19:05:10 -0400 |
parents | 292186c14b08 |
children |
comparison
equal
deleted
inserted
replaced
13:292186c14b08 | 14:76e1b1b21cce |
---|---|
1 #!/usr/bin/perl | |
2 | |
3 # write bowtie output to bed file | |
4 | |
5 # perl bowtie2bed.pl s_5_trimmed.map outputfile 200 | |
6 # input | |
7 # inputfile | |
8 # extension | |
9 | |
10 $inputfile = $ARGV[0]; | |
11 $extension = $ARGV[2]; | |
12 $outputfile = $ARGV[1];#$inputfile.".extended_$extension"."bp.bed"; | |
13 | |
14 print "input file: $inputfile\n"; | |
15 print "output file: $outputfile\n"; | |
16 print "track name: $outputfile\n"; | |
17 | |
18 open (IN,$inputfile) or die $!; | |
19 open (OUT,">$outputfile") or die $!; | |
20 | |
21 print OUT "track name=$outputfile itemRgb=On\n"; | |
22 | |
23 while(<IN>) | |
24 { | |
25 @flds = split/\t/; | |
26 $flds[0] =~ s/ /-/g;#substitute space to dash | |
27 | |
28 if ($flds[1] eq "+") | |
29 { | |
30 print OUT join("\t",$flds[2],$flds[3],$flds[3]+$extension+length($flds[4]),$flds[0],1,$flds[1],$flds[3],$flds[3]+length($flds[4]),"255,0,0","\n"); | |
31 } | |
32 else | |
33 { | |
34 | |
35 print OUT join("\t",$flds[2],max(0,$flds[3]-$extension),$flds[3]+length($flds[4]),$flds[0],1,$flds[1],$flds[3],$flds[3]+length($flds[4]),"0,255,0","\n"); | |
36 } | |
37 } | |
38 close(IN); | |
39 close(OUT); | |
40 | |
41 sub max() | |
42 { | |
43 ($a,$b) = @_; | |
44 return $a>$b?$a:$b; | |
45 } |