Debian Codegraph @

test-speed/x-hmmer2

raw
1 #! /usr/bin/perl
2
3 # We assume that a HMMER2 build tree is in $top_builddir
4 # $top_srcdir is unused: pass "." or $top_builddir
5 #
6 # Example:
7 # mkdir foo-test
8 # ./x-hmmer2 ~/releases/hmmer-2.3.2 . foo-test test.list 1 Pfam-A.seed uniprot/trembl-shuf-10k test.out
9 #
10
11 use Benchmark qw(:hireswallclock) ;
12
13 $top_builddir = shift;
14 $top_srcdir = shift;
15 $resultdir = shift;
16 $tblfile = shift;
17 $nthreads = shift;
18 $querydb = shift;
19 $targetdb = shift;
20 $outfile = shift;
21
22 $hmmbuild = "$top_builddir/src/hmmbuild";
23 $hmmsearch = "$top_builddir/src/hmmsearch";
24 $opts = "--cpu $nthreads";
25
26 if (! -d $top_builddir) { die "didn't find HMMER2 build directory $top_builddir"; }
27 if (! -x $hmmbuild) { die "didn't find hmmbuild executable $hmmbuild"; }
28 if (! -x $hmmsearch) { die "didn't find hmmsearch executable $hmmsearch"; }
29 if ($top_srcdir ne "." && $top_srcdir ne $top_builddir) { die "$top_srcdir is unused. pass ."; }
30 if (! -e $resultdir) { die "$resultdir doesn't exist"; }
31
32 open(OUTFILE,">$outfile") || die "failed to open output $outfile";
33 open(TABLE, "$tblfile") || die "failed to open work unit list $tblfile";
34
35 $output = `esl-seqstat $targetdb | grep "^Total"`;
36 if ($?) { die("esl-seqstat failed"); }
37 if ($output =~ /^Total \# residues:\s+(\d+)/) { $L = $1; }
38
39 $n = 0;
40 MSA:
41 while (<TABLE>)
42 {
43 if (/(\S+)/)
44 {
45 $n++;
46 $msaname = $1;
47
48 # Fetch the query MSA (.sto file)
49 $output = `esl-afetch -o $resultdir/$msaname.sto $querydb $msaname`;
50 if ($?) { print "FAILED: esl-afetch on $msaname\n"; next MSA; }
51
52 # Build an HMM in local mode (.hmm file)
53 $output = `$hmmbuild -F --amino $resultdir/$msaname.hmm $resultdir/$msaname.sto`;
54 if ($?) { print("FAILED: hmmbuild on $msaname\n"); next MSA;}
55
56 $output = `grep "^LENG" $resultdir/$msaname.hmm`;
57 if ($?) { print("FAILED: grep on $msaname\n"); next MSA;}
58 if ($output =~ /^LENG\s+(\d+)/) { $M = $1;}
59
60 # Warmup. (An untimed run, to encourage filesystem to cache the target database.)
61 if ($n == 1) { $output = `$hmmsearch $opts $resultdir/$msaname.hmm $targetdb 2>&1`; }
62
63 $t0 = Benchmark->new;
64 $output = `$hmmsearch $opts $resultdir/$msaname.hmm $targetdb 2>&1`;
65 if ($?) { print("FAILED: hmmsearch on $msaname\n"); next MSA; }
66 $t1 = Benchmark->new;
67
68 # Get the wall clock time.
69 $td = timediff($t1, $t0);
70 $walltime = $td->real;
71
72 $mcs = $L / 1000000 / $walltime * $M;
73 printf OUTFILE "%-15s %5d %10.1f %12.2f\n", $msaname, $M, $mcs, $walltime;
74
75 unlink "$resultdir/$msaname.sto";
76 unlink "$resultdir/$msaname.hmm";
77 }
78 }
79 close OUTFILE;
80 close TABLE;