forked from rbouckaert/benchmark
-
Notifications
You must be signed in to change notification settings - Fork 0
/
processWin.pl
executable file
·163 lines (144 loc) · 4.03 KB
/
processWin.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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
#Window7
`md generated`;
$chainLength="1000000";
$beagle_order="1";
foreach $f (glob("data/*.nex")) {
$n = 0;
print STDERR "Processing $f\n";
open(FIN, $f) or die "cannot open $f";
while (($s = <FIN>) && ($s !~ /matrix/)) {}
while (($s = <FIN>) && ($s !~ /^\s*$/)) {
@s = split('\s+', $s);
if ($#s != 2) {
print STDERR "Expected two words, not $#s $s[1]\n";
}
$taxon[$n] = $s[1];
$seq[$n] = $s[2];
$n++;
}
$f =~ s/data\///;
$f =~ s/testHKY(.*).nex/$1/;
generate1();
generate2();
close FIN;
}
open(FOUT,">generated/_experiment.bat");
print FOUT "\@ECHO OFF\n";
print FOUT "md singleThread\n";
print FOUT "cd singleThread\n";
print FOUT "md test_xml\n";
doWith(1);
print FOUT "cd ..\n";
print FOUT "md doubleThread\n";
print FOUT "cd doubleThread\n";
print FOUT "md test_xml\n";
doWith(2);
print FOUT "cd ..\n";
print FOUT "md fourThread\n";
print FOUT "cd fourThread\n";
print FOUT "md test_xml\n";
doWith(4);
print FOUT "cd ..\n";
print FOUT "md GPU\n";
print FOUT "cd GPU\n";
print FOUT "md test_xml\n";
doGPU();
print FOUT "cd ..\n";
close FOUT;
sub doWith {
$threads = shift;
print FOUT "echo. >screen1.dat\n";
print FOUT "echo. >screen2.dat\n";
foreach $f (sort(glob("generated/*_1_*.xml"))) {
print FOUT "echo \"$f\" >> time.txt\n";
# using thread pool
print FOUT "call ..\\beast1time -overwrite -beagle_instances $threads -threads $threads ../$f >> screen1.dat 2>>time.txt\n";
print FOUT "echo. >> time.txt\n";
if ($threads=="1") {
print FOUT "echo \"$f -threads 0\" >> time.txt\n";
# stop to use thread pool
print FOUT "call ..\\beast1time -overwrite -beagle_instances $threads -threads 0 ../$f >> screen1.dat 2>>time.txt\n";
print FOUT "echo. >> time.txt\n";
}
$f =~ s/_1_/_2_/;
print FOUT "echo \"$f\" >> time.txt\n";
print FOUT "call ..\\beast2time -overwrite -instances $threads -threads $threads ../$f >> screen2.dat 2>>time.txt\n";
print FOUT "echo. >> time.txt\n";
}
}
sub doGPU {
$threads = shift;
print FOUT "echo \"\" >screen1.dat\n";
print FOUT "echo \"\" >screen2.dat\n";
foreach $f (sort(glob("generated/*_1_*.xml"))) {
print FOUT "echo \"$f\" >> time.txt\n";
print FOUT "call ..\\beast1time -overwrite -beagle_GPU -beagle_order $beagle_order ../$f >> screen1.dat 2>>time.txt\n";
print FOUT "echo. >> time.txt\n";
$f =~ s/_1_/_2_/;
print FOUT "echo \"$f\" >> time.txt\n";
print FOUT "call ..\\beast2time -overwrite -beagle_GPU ../$f >> screen2.dat 2>>time.txt\n";
print FOUT "echo. >> time.txt\n";
}
}
sub generate1 {
merge1("xml/GTR_1.xml");
merge1("xml/GTRI_1.xml");
merge1("xml/GTRG_1.xml");
merge1("xml/GTRGI_1.xml");
}
sub merge1 {
$src = shift;
$type_ = $src;
$type_ =~ s/.xml/_/;
$target = $src;
$target =~ s/xml\///;
$target =~ s/.xml/_$f.xml/;
open (FIN, $src) or die "cannot open file $src" or die "cannot read $src";
open (FOUT, ">generated/_$target") or die "Cannot write generated/_$target" ;
$taxa = '';
$seqs = '';
for ($i = 0; $i < $n; $i++) {
$taxa .= "<taxon id=\"$taxon[$i]\"/>\n";
$seqs .= "<sequence>\n<taxon idref=\"$taxon[$i]\"/>\n$seq[$i]\n</sequence>\n";
}
while ($s = <FIN>) {
$s =~ s/fileName="test/fileName="test_$type_$f/;
$s =~ s/#taxa#/$taxa/;
$s =~ s/#seqs"/$seqs/;
$s =~ s/chainLength="1000000"/chainLength="$chainLength"/;
print FOUT $s;
}
close FOUT;
close FIN;
}
sub generate2 {
merge2("xml/GTR_2.xml");
merge2("xml/GTRI_2.xml");
merge2("xml/GTRG_2.xml");
merge2("xml/GTRGI_2.xml");
}
sub merge2 {
$src = shift;
$type_ = $src;
$type_ =~ s/.xml/_/;
$target = $src;
$target =~ s/.xml/_$f.xml/;
$target =~ s/xml\///;
open (FIN, $src) or die "cannot open file $src";
open (FOUT, ">generated/_$target");
$s = <FIN>;
print FOUT $s;
print FOUT " <data id=\"test\" name=\"alignment\"\n";
for ($i = 0; $i < $n; $i++) {
print FOUT " $taxon[$i]=\"$seq[$i]\"\n";
}
print FOUT "/>\n";
while ($s = <FIN>) {
$s =~ s/fileName="test/fileName="test_$type_$f/;
$s =~ s/fileName="tree/fileName="test_$type_$f/;
$s =~ s/chainLength="1000000"/chainLength="$chainLength"/;
print FOUT $s;
}
close FOUT;
close FIN;
}