I have SNP data and gen list data. I am looking for the position of SNP cotain in the gen list data when I compare with gen list. For example:
The SNP data :
Pos_start pos_end 14185 14185 .... .....
The gen list data:
5"side(pos_start) 3"sile(pos_end) 1 1527 1920 1777 .... .....
the result: in the position 14185 of SNP contain at the 16185 position of the gen list.
Below is my code but it has some problem in sort the number.
#!/usr/bin/perl -w
open(POS1,"<posi1.txt"); (I collect two data and save with posi1.txt)
@posi1=<POS1>;
open(list,">list.txt");
@list1=@posi1;
@list2= sort num_last (@list1);
$list2 = join( '', @list2);
print $list2;
print list $list2."\n\n";
close(list);
sub num_last {
my ($num_a, $num_b);
$num_a=$a=~ /^[0-9]/;
$num_b=$b=~ /^[0-9]/;
if ($num_a && $num_b){
return $a<=>$b;
} elsif ($num_a){
return 1;
} elsif ($num_b){
return -1;
} else {
return $a cmp $b;
}
}
I would appreciate if you could give some pointers.