find_SNPs2.pl
Note, I cheated and did not make this run under cgi-bin. Invoke the
program like this on the unix command line:
% cat TB.mum.out | find_SNPs2.pl TBCDC1551.ppt
#!/usr/local/perl
use strict;
my $insert_size = 1;
my (@list, %array);
open(F_IN, $ARGV[0]) || die "cant open: $ARGV[0]";
while(<F_IN>) {
if (/^\s*([0-9]+)\.\.([0-9]+)/) {
my $start = $1;
my $stop = $2;
my($i);
for($i=$start;$i<$stop+1;$i++) {
$array{$i} = "coding";
}
}
}
close(F_IN);
while(<STDIN>) {
if (!/>/) {
s/^\s*//;
my($x1, $x2, $l) = split(/\s+/);
push(@list, $x1 . " " . $x2 . " " . $l);
}
}
@list = sort numerically (@list);
my $first_time = 1;
my $old_pos;
foreach my $row (@list) {
my ($x1, $x2, $l) = split(/\s/,$row);
if ($first_time != 1) {
if (($x1 - $old_pos) == $insert_size) {
if ($array{$old_pos} eq "coding") {
print "Pos $old_pos was coding\n";
}
else {
print "Pos $old_pos was noncoding\n";
}
}
}
$first_time = 0;
$old_pos = $x1 + $l;
}
sub numerically {
$a <=> $b;
}