Created
February 21, 2015 19:42
-
-
Save phonyphonecall/416495433ce3d9fa1617 to your computer and use it in GitHub Desktop.
Generates the area percentage increase data from input file.
This file contains 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 characters
#!/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 $maxArea = -1; | |
my $minArea = 9223372036854775806; | |
my $max = -1; | |
my $count = -1; | |
while(<$fd>) { | |
$count++; | |
next if $count == 0; | |
my @line = split("\t", $_); | |
if ($max < $line[1]) { | |
$max = $line[1]; | |
} | |
if ($maxArea < $line[4]) { | |
$maxArea = $line[4]; | |
} | |
if ($minArea > $line[4]) { | |
$minArea = $line[4]; | |
} | |
} | |
print "max temp: $max\n"; | |
print "max area: $maxArea\n"; | |
print "min area: $minArea\n"; | |
seek($fd, 0, 0); | |
my @binmax = (-1, -1, -1, -1, -1); | |
my @binmin = (9223372036854775806, 9223372036854775806, 9223372036854775806, 9223372036854775806, 9223372036854775806); | |
$count = 0; | |
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) { | |
if($binmax[0] < $temp) { | |
$binmax[0] = $temp; | |
} elsif($binmin[0] > $temp) { | |
$binmin[0] = $temp; | |
} | |
} elsif($temp > 0.01 * $max and $temp <= 0.1 * $max) { | |
if($binmax[1] < $temp) { | |
$binmax[1] = $temp; | |
} elsif($binmin[1] > $temp) { | |
$binmin[1] = $temp; | |
} | |
} elsif($temp > 0.001 * $max and $temp <= 0.01 * $max) { | |
if($binmax[2] < $temp) { | |
$binmax[2] = $temp; | |
} elsif($binmin[2] > $temp) { | |
$binmin[2] = $temp; | |
} | |
} elsif($temp > 0.0001 * $max and $temp <= 0.001 * $max) { | |
if($binmax[3] < $temp) { | |
$binmax[3] = $temp; | |
} elsif($binmin[3] > $temp) { | |
$binmin[3] = $temp; | |
} | |
} elsif($temp <= 0.0001 * $max) { | |
if($binmax[4] < $temp) { | |
$binmax[4] = $temp; | |
} elsif($binmin[4] > $temp) { | |
$binmin[4] = $temp; | |
} | |
} else { | |
warn "bad temp: $temp\n"; | |
} | |
} | |
close($fd); | |
#convert to percentage improvement | |
$binmax[0] = ($binmax[0] - $binmin[0]) / ($maxArea - $minArea) * 100; | |
$binmax[1] = ($binmax[1] - $binmin[1]) / ($maxArea - $minArea) * 100; | |
$binmax[2] = ($binmax[2] - $binmin[2]) / ($maxArea - $minArea) * 100; | |
$binmax[3] = ($binmax[3] - $binmin[3]) / ($maxArea - $minArea) * 100; | |
$binmax[4] = ($binmax[4] - $binmin[4]) / ($maxArea - $minArea) * 100; | |
print "bin0: $binmax[0]%\n"; | |
print "bin1: $binmax[1]%\n"; | |
print "bin2: $binmax[2]%\n"; | |
print "bin3: $binmax[3]%\n"; | |
print "bin4: $binmax[4]%\n"; | |
print "done\n"; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Usage
chmod 755 {script_name}
./{script_name} {path_to_sa_log}