-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrankNew.perl
52 lines (46 loc) · 1.01 KB
/
rankNew.perl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
use warnings;
use strict;
my $excludeMr = 1;
$excludeMr = $ARGV[1] if defined $ARGV[1];
open A, "gunzip -c $ARGV[0].names|";
my (@num2f);
while(<A>){
chop();
my $n = $_;
push @num2f, $n;
}
close (A);
my $cn = "";
my %cluster = ();
my $off = 0;
my (@rank, %tr, %best);
while(<STDIN>){
chop();
my ($cl, $scr) = split(/;/);
push @rank, $scr;
my $cln = $num2f[$cl];
if (! defined $tr{$cln}){
$tr{$cln} = -1
}
my $offn = $num2f[$off];
# print STDERR "$cl $off $cln $offn\n" if $offn =~ /^cl[0-9]+$/;
if ($offn !~ /^cl[0-9]+$/ || ! $excludeMr){
$cluster{$cln}{$offn}++;
if ($tr{$cln} < $scr || ($tr{$cln} == $scr && defined $best{$cln} && length($best{$cln}) > length($offn))){
$tr{$cln} = $scr;
$best{$cln} = $offn;
}
}
$off++;
}
close (A);
if ($off != $#num2f +1){
print STDERR "wrong length: $off vs ".($#num2f +1)."\n";
exit (-1);
}
print STDERR "length: $off\n";
while (my ($k, $v) = each %cluster){
for my $p (keys %{$v}){
print "$p;$best{$k};$tr{$k}\n";
}
}