my $type = shift;
# read scores from file
$logger->info("Reading $type scores...\n", 0, 'stamped');
my $scores1 = &
parse_file($conf->param(
'path1').
"/${type}_scores.txt");
my $scores2 = &
parse_file($conf->param(
'path2').
"/${type}_scores.txt");
$logger->info("Done.\n\n", 0, 'stamped');
# look for pairs with scores in both result sets
my %stats;
my @both = ();
my @only1 = ();
my @only2 = ();
foreach my $key (keys %$scores1) {
if ($scores2->{$key}) {
push @both, $key;
} else {
push @only1, $key;
}
}
foreach my $key (keys %$scores2) {
unless ($scores1->{$key}) {
push @only2, $key;
}
}
$stats{'TOT1'} = keys %$scores1;
$stats{'TOT2'} = keys %$scores2;
$stats{'BOTH'} = @both;
$stats{'ONLY1'} = @only1;
$stats{'ONLY2'} = @only2;
$logger->info("Only in set 1 (first 10 shown):\n");
my $i;
foreach my $key (sort @only1) {
$logger->info(sprintf("%-20s%-10s\n", $key, $scores1->{$key}), 1);
last if ($i++ == 10);
}
$logger->info("\nOnly in set 2 (first 10 shown):\n");
my $j;
foreach my $key (sort @only2) {
$logger->info(sprintf("%-20s%-10s\n", $key, $scores2->{$key}), 1);
last if ($j++ == 10);
}
# compare scores which are present in both result sets
$logger->info("\nScores different (first 10 shown):\n");
foreach my $key (@both) {
my $s1 = $scores1->{$key};
my $s2 = $scores2->{$key};
my $diff = $s1 - $s2;
$diff = -$diff if ($diff < 0);
unless ($diff < 0.000002) {
$stats{'BOTH_DIFF'}++;
if ($stats{'BOTH_DIFF'} <= 10) {
$logger->info(sprintf("%-20s%-10s%-10s\n", $key, $s1, $s2), 1);
}
}
}
$logger->info("\nStats:\n");
foreach my $t (qw(TOT1 TOT2 BOTH ONLY1 ONLY2 BOTH_DIFF)) {
$logger->info(sprintf("%-10s%8d\n", $t, $stats{$t}), 1);
}
}