Mercurial > repos > greg > resize_coordinate_window
comparison resize_coordinate_window.pl @ 0:d64206d13298 draft default tip
Uploaded
| author | greg |
|---|---|
| date | Wed, 06 Jan 2016 15:15:56 -0500 |
| parents | |
| children |
comparison
equal
deleted
inserted
replaced
| -1:000000000000 | 0:d64206d13298 |
|---|---|
| 1 #! /usr/bin/perl | |
| 2 | |
| 3 my($input, $SIZE) = @ARGV; | |
| 4 open(IN, "<$input") or die "Can't open $input for reading!\n"; | |
| 5 | |
| 6 #chr1 genetrack . 123950 123970 22 + . stddev=0.0 | |
| 7 #chr1 genetrack . 565745 565765 12 + . stddev=0.0 | |
| 8 #chr1 genetrack . 565793 565813 44 + . stddev=0.298065387468 | |
| 9 | |
| 10 $line = ""; | |
| 11 while($line = <IN>) { | |
| 12 chomp($line); | |
| 13 @array = split(/\t/, $line); | |
| 14 | |
| 15 $CENTER = int(($array[3] + $array[4]) / 2); | |
| 16 if(($array[4] - $array[3]) % 2 != 0 || $array[6] eq "-") { $CENTER++; } | |
| 17 $START = $CENTER - ($SIZE / 2); | |
| 18 $STOP = $CENTER + (($SIZE / 2) - 1); | |
| 19 | |
| 20 if($START < 1) { print STDERR "Error:\t$line\nRequested expansion places region beyond chromosome bounds!!!\n"; } | |
| 21 else { | |
| 22 print "$array[0]\t$array[1]\t$array[2]\t$START\t$STOP"; | |
| 23 for($x = 5; $x <= $#array; $x++) { print "\t$array[$x]"; } | |
| 24 print "\n"; | |
| 25 } | |
| 26 } | |
| 27 close IN; |
