2 # See the NOTICE file distributed with this work for additional information
3 # regarding copyright ownership.
5 # Licensed under the Apache License, Version 2.0 (the "License");
6 # you may not use this file except in compliance with the License.
7 # You may obtain a copy of the License at
9 # http://www.apache.org/licenses/LICENSE-2.0
11 # Unless required by applicable law or agreed to in writing, software
12 # distributed under the License is distributed on an "AS IS" BASIS,
13 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 # See the License for the specific language governing permissions and
15 # limitations under the License.
27 --basedir=PATH base directory of ID mapping results
31 --conffile, --conf=FILE read parameters from FILE
32 (
default: conf/Conversion.ini)
34 --logfile, --log=FILE log to FILE (
default: *STDOUT)
35 --logpath=PATH write logfile to PATH (
default: .)
36 --logappend, --log_append append to logfile (
default: truncate)
37 --loglevel=LEVEL define log level (
default: INFO)
39 -i, --interactive=0|1
run script interactively (
default:
true)
40 -h, --help, -? print help (
this message)
48 Patrick Meidl <meidl@ebi.ac.uk>, Ensembl core API team
52 Please post comments/questions to the Ensembl development list
59 no warnings
'uninitialized';
67 # parse configuration and commandline arguments
69 -SERVERROOT =>
"$Bin/../../../..",
70 -DEFAULT_CONF =>
"$Bin/default.conf"
80 unless ($conf->param(
'logpath')) {
81 $conf->param(
'logpath', path_append($conf->param(
'basedir'),
'log'));
84 # get log filehandle and print heading and parameters to logfile
86 -LOGFILE => $conf->param(
'logfile'),
87 -LOGAUTO => $conf->param(
'logauto'),
88 -LOGAUTOBASE =>
'compare_scores',
89 -LOGAUTOID => $conf->param(
'logautoid'),
90 -LOGPATH => $conf->param(
'logpath'),
91 -LOGAPPEND => $conf->param(
'logappend'),
92 -LOGLEVEL => $conf->param(
'loglevel'),
96 $logger->init_log($conf->list_param_values);
100 foreach my $type (@types) {
115 # read scores from file
116 $logger->info(
"Reading $type scores...\n", 0,
'stamped');
118 my $scores1 = &
parse_file($conf->param(
'path1').
"/${type}_scores.txt");
119 my $scores2 = &
parse_file($conf->param(
'path2').
"/${type}_scores.txt");
121 $logger->info(
"Done.\n\n", 0,
'stamped');
123 # look for pairs with scores in both result sets
129 foreach my $key (keys %$scores1) {
130 if ($scores2->{$key}) {
137 foreach my $key (keys %$scores2) {
138 unless ($scores1->{$key}) {
143 $stats{
'TOT1'} = keys %$scores1;
144 $stats{
'TOT2'} = keys %$scores2;
145 $stats{
'BOTH'} = @both;
146 $stats{
'ONLY1'} = @only1;
147 $stats{
'ONLY2'} = @only2;
149 $logger->info(
"Only in set 1 (first 10 shown):\n");
151 foreach my $key (sort @only1) {
152 $logger->info(sprintf(
"%-20s%-10s\n", $key, $scores1->{$key}), 1);
153 last
if ($i++ == 10);
156 $logger->info(
"\nOnly in set 2 (first 10 shown):\n");
158 foreach my $key (sort @only2) {
159 $logger->info(sprintf(
"%-20s%-10s\n", $key, $scores2->{$key}), 1);
160 last
if ($j++ == 10);
163 # compare scores which are present in both result sets
164 $logger->info(
"\nScores different (first 10 shown):\n");
166 foreach my $key (@both) {
168 my $s1 = $scores1->{$key};
169 my $s2 = $scores2->{$key};
170 my $diff = $s1 - $s2;
171 $diff = -$diff
if ($diff < 0);
173 unless ($diff < 0.000002) {
174 $stats{
'BOTH_DIFF'}++;
175 if ($stats{
'BOTH_DIFF'} <= 10) {
176 $logger->info(sprintf(
"%-20s%-10s%-10s\n", $key, $s1, $s2), 1);
181 $logger->info(
"\nStats:\n");
182 foreach my $t (qw(TOT1 TOT2 BOTH ONLY1 ONLY2 BOTH_DIFF)) {
183 $logger->info(sprintf(
"%-10s%8d\n", $t, $stats{$t}), 1);
191 open(my $fh,
'<', $file) or
192 throw(
"Unable to open $file for reading: $!");
196 while (my $line = <$fh>) {
198 my ($old_id, $new_id, $score) = split(/\s+/, $line);
199 $scores{
"$old_id:$new_id"} = sprintf(
"%.6f", $score);