annotate 2.4/src/reduce_redundancy.pl @ 16:8eb7d93f7e58 draft

Uploaded
author plus91-technologies-pvt-ltd
date Sat, 31 May 2014 11:23:36 -0400
parents e3609c8714fb
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
13
e3609c8714fb Uploaded
plus91-technologies-pvt-ltd
parents:
diff changeset
1 open(BUFF,"$ARGV[0]") or die "no input file found\n";
e3609c8714fb Uploaded
plus91-technologies-pvt-ltd
parents:
diff changeset
2 $range="$ARGV[1]";
e3609c8714fb Uploaded
plus91-technologies-pvt-ltd
parents:
diff changeset
3 my %hash;
e3609c8714fb Uploaded
plus91-technologies-pvt-ltd
parents:
diff changeset
4 my %store;
e3609c8714fb Uploaded
plus91-technologies-pvt-ltd
parents:
diff changeset
5 $prev_chr="";
e3609c8714fb Uploaded
plus91-technologies-pvt-ltd
parents:
diff changeset
6 $next=0;
e3609c8714fb Uploaded
plus91-technologies-pvt-ltd
parents:
diff changeset
7 while(<BUFF>)
e3609c8714fb Uploaded
plus91-technologies-pvt-ltd
parents:
diff changeset
8 {
e3609c8714fb Uploaded
plus91-technologies-pvt-ltd
parents:
diff changeset
9 chomp($_);
e3609c8714fb Uploaded
plus91-technologies-pvt-ltd
parents:
diff changeset
10 #print "$.\n";
e3609c8714fb Uploaded
plus91-technologies-pvt-ltd
parents:
diff changeset
11 if($_ !~ m/^#/)
e3609c8714fb Uploaded
plus91-technologies-pvt-ltd
parents:
diff changeset
12 {
e3609c8714fb Uploaded
plus91-technologies-pvt-ltd
parents:
diff changeset
13 @array=split("\t",$_);
e3609c8714fb Uploaded
plus91-technologies-pvt-ltd
parents:
diff changeset
14 $chr=$array[0];
e3609c8714fb Uploaded
plus91-technologies-pvt-ltd
parents:
diff changeset
15 $pos=$array[1];
e3609c8714fb Uploaded
plus91-technologies-pvt-ltd
parents:
diff changeset
16 $value=$array[@array-1];
e3609c8714fb Uploaded
plus91-technologies-pvt-ltd
parents:
diff changeset
17 if($prev_chr ne $chr )
e3609c8714fb Uploaded
plus91-technologies-pvt-ltd
parents:
diff changeset
18 {
e3609c8714fb Uploaded
plus91-technologies-pvt-ltd
parents:
diff changeset
19 if($prev_chr ne "")
e3609c8714fb Uploaded
plus91-technologies-pvt-ltd
parents:
diff changeset
20 {
e3609c8714fb Uploaded
plus91-technologies-pvt-ltd
parents:
diff changeset
21 foreach $key (sort {$hash{$b} <=> $hash{$a} } keys %hash)
e3609c8714fb Uploaded
plus91-technologies-pvt-ltd
parents:
diff changeset
22 {
e3609c8714fb Uploaded
plus91-technologies-pvt-ltd
parents:
diff changeset
23 print "$store{$key}\n";
e3609c8714fb Uploaded
plus91-technologies-pvt-ltd
parents:
diff changeset
24 last;
e3609c8714fb Uploaded
plus91-technologies-pvt-ltd
parents:
diff changeset
25 }
e3609c8714fb Uploaded
plus91-technologies-pvt-ltd
parents:
diff changeset
26
e3609c8714fb Uploaded
plus91-technologies-pvt-ltd
parents:
diff changeset
27 }
e3609c8714fb Uploaded
plus91-technologies-pvt-ltd
parents:
diff changeset
28 $next = $pos+$range;
e3609c8714fb Uploaded
plus91-technologies-pvt-ltd
parents:
diff changeset
29 undef(%hash);
e3609c8714fb Uploaded
plus91-technologies-pvt-ltd
parents:
diff changeset
30 undef(%store);
e3609c8714fb Uploaded
plus91-technologies-pvt-ltd
parents:
diff changeset
31 }
e3609c8714fb Uploaded
plus91-technologies-pvt-ltd
parents:
diff changeset
32 if($next< $pos)
e3609c8714fb Uploaded
plus91-technologies-pvt-ltd
parents:
diff changeset
33 {
e3609c8714fb Uploaded
plus91-technologies-pvt-ltd
parents:
diff changeset
34 foreach $key (sort {$hash{$b} <=> $hash{$a} } keys %hash)
e3609c8714fb Uploaded
plus91-technologies-pvt-ltd
parents:
diff changeset
35 {
e3609c8714fb Uploaded
plus91-technologies-pvt-ltd
parents:
diff changeset
36 print "$store{$key}\n";
e3609c8714fb Uploaded
plus91-technologies-pvt-ltd
parents:
diff changeset
37 last;
e3609c8714fb Uploaded
plus91-technologies-pvt-ltd
parents:
diff changeset
38 }
e3609c8714fb Uploaded
plus91-technologies-pvt-ltd
parents:
diff changeset
39 $next = $pos+$range;
e3609c8714fb Uploaded
plus91-technologies-pvt-ltd
parents:
diff changeset
40 undef(%hash);
e3609c8714fb Uploaded
plus91-technologies-pvt-ltd
parents:
diff changeset
41 undef(%store);
e3609c8714fb Uploaded
plus91-technologies-pvt-ltd
parents:
diff changeset
42
e3609c8714fb Uploaded
plus91-technologies-pvt-ltd
parents:
diff changeset
43 }
e3609c8714fb Uploaded
plus91-technologies-pvt-ltd
parents:
diff changeset
44 if($value eq "NA")
e3609c8714fb Uploaded
plus91-technologies-pvt-ltd
parents:
diff changeset
45 {
e3609c8714fb Uploaded
plus91-technologies-pvt-ltd
parents:
diff changeset
46 $hash{$chr." ".$pos." ".$.}=0;
e3609c8714fb Uploaded
plus91-technologies-pvt-ltd
parents:
diff changeset
47 }
e3609c8714fb Uploaded
plus91-technologies-pvt-ltd
parents:
diff changeset
48 else
e3609c8714fb Uploaded
plus91-technologies-pvt-ltd
parents:
diff changeset
49 {
e3609c8714fb Uploaded
plus91-technologies-pvt-ltd
parents:
diff changeset
50 $hash{$chr." ".$pos." ".$.}=$value;
e3609c8714fb Uploaded
plus91-technologies-pvt-ltd
parents:
diff changeset
51 }
e3609c8714fb Uploaded
plus91-technologies-pvt-ltd
parents:
diff changeset
52 $store{$chr." ".$pos." ".$.}=$_;
e3609c8714fb Uploaded
plus91-technologies-pvt-ltd
parents:
diff changeset
53 }
e3609c8714fb Uploaded
plus91-technologies-pvt-ltd
parents:
diff changeset
54 else
e3609c8714fb Uploaded
plus91-technologies-pvt-ltd
parents:
diff changeset
55 {
e3609c8714fb Uploaded
plus91-technologies-pvt-ltd
parents:
diff changeset
56 print $_."\n";
e3609c8714fb Uploaded
plus91-technologies-pvt-ltd
parents:
diff changeset
57 }
e3609c8714fb Uploaded
plus91-technologies-pvt-ltd
parents:
diff changeset
58 $prev_chr = $chr;
e3609c8714fb Uploaded
plus91-technologies-pvt-ltd
parents:
diff changeset
59 }
e3609c8714fb Uploaded
plus91-technologies-pvt-ltd
parents:
diff changeset
60 foreach $key (sort {$hash{$b} <=> $hash{$a} } keys %hash)
e3609c8714fb Uploaded
plus91-technologies-pvt-ltd
parents:
diff changeset
61 {
e3609c8714fb Uploaded
plus91-technologies-pvt-ltd
parents:
diff changeset
62 print "$store{$key}\n";
e3609c8714fb Uploaded
plus91-technologies-pvt-ltd
parents:
diff changeset
63 last;
e3609c8714fb Uploaded
plus91-technologies-pvt-ltd
parents:
diff changeset
64 }
e3609c8714fb Uploaded
plus91-technologies-pvt-ltd
parents:
diff changeset
65