-
Notifications
You must be signed in to change notification settings - Fork 0
/
rank2.perl
56 lines (49 loc) · 899 Bytes
/
rank2.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
53
54
55
56
use warnings;
use strict;
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);
while(<STDIN>){
chop();
my ($cl, $scr) = split(/;/);
push @rank, $scr;
$cluster{$cl}{$off}++;
$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){
my %fs = ();
for my $f (keys %{$v}){
#print STDERR "$k;$f;$num2f[$f]\n";
$fs{$num2f[$f]} = $rank[$f];
}
#print STDERR "$k\n";
output (\%fs);
}
sub output {
my $cl = $_[0];
my %ps;
for my $p (keys %{$cl}){
if ($p =~ /^PRJ_/){
$ps{$p}++;
}
}
my @fs = sort { $cl->{$b} <=> $cl->{$a} } (keys %ps);
for my $i (0 .. $#fs){
print "$fs[$i]\;$fs[0];$cl->{$fs[0]}\n";
}
}