diff 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
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/2.4/src/reduce_redundancy.pl	Sat May 31 11:23:36 2014 -0400
@@ -0,0 +1,65 @@
+open(BUFF,"$ARGV[0]") or die "no input file found\n";
+$range="$ARGV[1]";
+my %hash;
+my %store;
+$prev_chr="";
+$next=0;
+while(<BUFF>)
+{
+	chomp($_);
+	#print "$.\n";
+	if($_ !~ m/^#/)
+	{
+		@array=split("\t",$_);
+		$chr=$array[0];
+		$pos=$array[1];
+		$value=$array[@array-1];
+		if($prev_chr ne $chr )
+		{
+			if($prev_chr ne "")
+			{
+				foreach $key (sort {$hash{$b} <=> $hash{$a} } keys %hash)
+                        	{
+                                	print "$store{$key}\n";
+                                	last;
+                        	}
+
+			}
+			$next = $pos+$range;
+			undef(%hash);
+			undef(%store);
+		}
+		if($next< $pos)
+		{	
+			foreach $key (sort {$hash{$b} <=> $hash{$a} } keys %hash)
+			{
+     				print "$store{$key}\n";
+				last;
+			}
+			$next = $pos+$range;
+			undef(%hash);
+			undef(%store);
+			
+		}	
+		if($value eq "NA")
+                {
+                      $hash{$chr." ".$pos." ".$.}=0;
+                }
+                else
+                {
+                       $hash{$chr." ".$pos." ".$.}=$value;
+               	}
+                $store{$chr." ".$pos." ".$.}=$_;
+	}
+	else
+	{
+		print $_."\n";
+	}
+	$prev_chr = $chr;
+}
+foreach $key (sort {$hash{$b} <=> $hash{$a} } keys %hash)
+{
+       print "$store{$key}\n";
+       last;
+}
+