Last active
August 29, 2015 14:15
-
-
Save phonyphonecall/cdbe75255d863ffe0c25 to your computer and use it in GitHub Desktop.
Revisions
-
phonyphonecall revised this gist
Feb 23, 2015 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -25,7 +25,7 @@ my @binct = (0, 0, 0, 0, 0); $count = -1; #iterate over each line to count bins (and total) while(<$fd>) { $count++; -
phonyphonecall renamed this gist
Feb 21, 2015 . 1 changed file with 0 additions and 0 deletions.There are no files selected for viewing
File renamed without changes. -
phonyphonecall created this gist
Feb 21, 2015 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,70 @@ #!/usr/bin/perl use strict; use warnings; #get file in open(my $fd, "<", $ARGV[0]) or die "cannot open file $!"; #iterate over each line to find max my $max = -1; my $count = -1; while(<$fd>) { $count++; next if $count == 0; my @line = split("\t", $_); if ($max < $line[1]) { $max = $line[1]; } } print "max temp: $max\n"; seek($fd, 0, 0); my @binct = (0, 0, 0, 0, 0); $count = 0; #iterate over each line to count bins (and total) while(<$fd>) { $count++; next if $count == 0; my @line = split("\t", $_); no warnings 'numeric'; my $temp = $line[1] * 1.0000000; if($temp > 0.1 * $max and $temp <= $max) { $binct[0]++; } elsif($temp > 0.01 * $max and $temp <= 0.1 * $max) { $binct[1]++; } elsif($temp > 0.001 * $max and $temp <= 0.01 * $max) { $binct[2]++; } elsif($temp > 0.0001 * $max and $temp <= 0.001 * $max) { $binct[3]++; } elsif($temp <= 0.0001 * $max) { $binct[4]++; } else { warn "bad temp: $temp\n"; } } close($fd); #convert to percentage $binct[0] = ($binct[0] / $count) * 100; $binct[1] = ($binct[1] / $count) * 100; $binct[2] = ($binct[2] / $count) * 100; $binct[3] = ($binct[3] / $count) * 100; $binct[4] = ($binct[4] / $count) * 100; print "bin0: $binct[0]%\n"; print "bin1: $binct[1]%\n"; print "bin2: $binct[2]%\n"; print "bin3: $binct[3]%\n"; print "bin4: $binct[4]%\n"; print "done\n";