-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathrun-batch.pl
executable file
·62 lines (50 loc) · 1.25 KB
/
run-batch.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
#!/usr/bin/perl
use strict;
use warnings;
no warnings 'uninitialized';
use IPC::Open2;
use IO::Handle;
use POSIX qw(clock CLOCKS_PER_SEC);
my $in = new IO::Handle;
my $out = new IO::Handle;
my $data = new IO::Handle;
open $data, "batch0.tab";
die "Usage: $0 <command> <output-base>\n" unless @ARGV == 2;
my $command = $ARGV[0];
my $base = $ARGV[1];
open R, ">$base.res";
my $pid = open2($in, $out, "/usr/bin/time $command -a -S 2> $base.time");
print $out "!\n";
<$in>;
while (<$data>) {
chop;
my ($mis, $cor) = split /\t/;
die ":$mis: :$cor:" if $mis !~ /^[a-zA-Z\']+ ?[a-zA-Z\']+$/;
die ":$mis: :$cor:" if $cor !~ /^[a-zA-Z\']+ ?[a-zA-Z\']+$/;
print $out "$cor\n";
my $res = <$in>;
chop $res;
if ($res) {
print R "$mis\t$cor\t-1\t-1\n";
$res = <$in>;
} else {
print $out "$mis\n";
$res = <$in>;
chop $res;
if (!$res) {
print R "$mis\t$cor\t-1\t-1\n";
} else {
my ($info, $list) = split /: /, $res;
my ($key, undef, $num, undef) = split / /, $info;
my @list = split /, /, $list;
my $i;
for ($i = 0; $list[$i] && $list[$i] ne $cor; $i++) {}
if ($list[$i]) {$i++}
else {$i = 0;}
print R "$mis\t$cor\t$i\t$num\n";
$res = <$in>;
}
}
}
close $out;
close R;