-
Notifications
You must be signed in to change notification settings - Fork 2
/
splCl.perl
69 lines (59 loc) · 1.06 KB
/
splCl.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
57
58
59
60
61
62
63
64
65
66
use strict;
use warnings;
my (%a, %t);
my $n = 0;
open A, $ARGV[0];
while(<A>){
chop();
my ($i,$ba,$bt)=split(/\;/, $_ ,-1);
$a{$ba}{$i}++;
$n = $i;
}
print STDERR "read $n\n";
open A, $ARGV[1];
while(<A>){
chop();
my ($i,$bt)=split(/\;/, $_ ,-1);
$t{$bt}{$i}++;
$n = $i;
}
my (%la, %lt);
my $mx = 0;
my $cl = 0;
while (my ($ba,$v) = each %a){
my @vs = keys %{$v};
$mx =$#vs if $#vs > $mx;
$cl ++;
for my $i (0..$#vs){
for my $j (0..$#vs){
$la{"$vs[$i];$vs[$j]"}++;
}
}
}
print STDERR "created la: $cl clstrs with max $mx\n";
$mx = 0;
$cl = 0;
while (my ($ba,$v) = each %t){
my @vs = keys %{$v};
$mx =$#vs if $#vs > $mx;
$cl ++;
for my $i (0..$#vs){
for my $j (0..$#vs){
$lt{"$vs[$i];$vs[$j]"}++;
}
}
}
print STDERR "created lt: $cl clstrs with max $mx\n";
my ($tp, $fp, $fn) = (0, 0, 0);
while (my $i = each %lt){
if (defined $la{$i}){
$tp++;
}else{
$fp++;
}
}
print STDERR "tp=$tp fp=$fp\n";
while (my $i = each %la){
$fn ++ if !defined $lt{$i};
}
print "tp=$tp;fp=$fp;fn=$fn\n";