-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcombine.pl
executable file
·62 lines (54 loc) · 1.3 KB
/
combine.pl
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
#!/usr/bin/perl
# weights of three components
$w1=1;
$w2=1;
$w3=2;
if (exists $ARGV[0]){
$w1=$ARGV[0];
}
if (exists $ARGV[1]){
$w2=$ARGV[1];
}
if (exists $ARGV[2]){
$w3=$ARGV[2];
}
#print "$w1\t$w2\t$w3\n";
#die;
open OLD, "pred_count.txt" or die;
while ($line=<OLD>){
chomp $line;
@table=split ",", $line;
$ref_count{$table[0]}{$table[1]}=$table[2];
}
close OLD;
open OLD, "pred_ori_2.txt" or die;
while ($line=<OLD>){
chomp $line;
@table=split ",", $line;
$ref_2{$table[0]}{$table[1]}=$table[2];
}
close OLD;
open OLD, "pred_spread_2.txt" or die;
open NEW, ">prediction.csv" or die;
$line=<OLD>;
print NEW "$line";
while ($line=<OLD>){
chomp $line;
@table=split ",", $line;
# $val=($ref_count{$table[0]}{$table[1]}+$ref_1{$table[0]}{$table[1]}+$ref_2{$table[0]}{$table[1]}+$ref_only_1{$table[0]}{$table[1]}+$ref_only_2{$table[0]}{$table[1]}+$ref_spread{$table[0]}{$table[1]}+$table[2])/5;
$val=($w1*$ref_count{$table[0]}{$table[1]}+$w2*$ref_2{$table[0]}{$table[1]}+$w3*$table[2])/($w1+$w2+$w3);
print NEW "$table[0],$table[1],$val\n";
}
close NEW;
close OLD;
open OLD, "TEST_gs.txt" or die;
open NEW, ">tmp.txt" or die;
while ($line=<OLD>){
chomp $line;
@table=split ',', $line;
print NEW "$table[0],$table[1],$table[2]\n";
}
close OLD;
close NEW;
system "mv tmp.txt TEST_gs.txt";
system "rm *txt";