| 1 |
#! /usr/bin/perl |
| 2 |
|
| 3 |
# We assume that a HMMER3 build tree is in $top_builddir, with binaries in src/ subdir of it |
| 4 |
# $top_srcdir is unused: pass "." or $top_builddir |
| 5 |
# |
| 6 |
# Example: |
| 7 |
# mkdir foo-test |
| 8 |
# ./x-hmmsearch ~/src/hmmer/trunk/build-icc-mpi . foo-test test.list 1 Pfam-A.seed uniprot/trembl-shuf-1M 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 |
$esl_afetch = "$top_builddir/easel/miniapps/esl-afetch"; |
| 23 |
$hmmbuild = "$top_builddir/src/hmmbuild"; |
| 24 |
$hmmsearch = "$top_builddir/src/hmmsearch"; |
| 25 |
|
| 26 |
open(OUTFILE,">$outfile") || die "failed to open $outfile"; |
| 27 |
open(TABLE, "$tblfile") || die "failed to open $tblfile"; |
| 28 |
|
| 29 |
$output = `esl-seqstat $targetdb | grep "^Total"`; |
| 30 |
if ($?) { die("esl-seqstat failed"); } |
| 31 |
if ($output =~ /^Total \# residues:\s+(\d+)/) { $L = $1; } |
| 32 |
|
| 33 |
$n=0; |
| 34 |
MSA: |
| 35 |
while (<TABLE>) |
| 36 |
{ |
| 37 |
if (/(\S+)/) |
| 38 |
{ |
| 39 |
$n++; |
| 40 |
$msaname = $1; |
| 41 |
|
| 42 |
# Fetch the query MSA (.sto file) |
| 43 |
`$esl_afetch -o $resultdir/$msaname.sto $querydb $msaname > /dev/null`; |
| 44 |
if ($? != 0) { print "FAILED: $esl_afetch on $msaname\n"; next MSA; } |
| 45 |
|
| 46 |
# Build a model (.hmm file) |
| 47 |
$output = `$hmmbuild $resultdir/$msaname.hmm $resultdir/$msaname.sto`; |
| 48 |
if ($?) { print("FAILED: $hmmbuild on $msaname\n"); next MSA; } |
| 49 |
|
| 50 |
# We need model length, to calculate normalized Mc/s units |
| 51 |
if ($output =~ /^\d+\s+\S+\s+\d+\s+\d+\s+(\d+)/m) { $M = $1; } |
| 52 |
|
| 53 |
# Warmup. (An untimed run, to encourage filesystem to cache the target database.) |
| 54 |
if ($n==1) { `$hmmsearch --cpu $nthreads $resultdir/$msaname.hmm $targetdb > /dev/null`; } |
| 55 |
|
| 56 |
# Time hmmsearch (running the requested number of threads) |
| 57 |
$t0 = Benchmark->new; |
| 58 |
`$hmmsearch --cpu $nthreads $resultdir/$msaname.hmm $targetdb > /dev/null`; |
| 59 |
if ($?) { print("FAILED: $hmmsearch on $msaname\n"); next MSA; } |
| 60 |
$t1 = Benchmark->new; |
| 61 |
|
| 62 |
# Get the wall clock time. |
| 63 |
$td = timediff($t1, $t0); |
| 64 |
$walltime = $td->real; |
| 65 |
|
| 66 |
$mcs = $L / 1000000 / $walltime * $M; |
| 67 |
printf OUTFILE "%-15s %5d %10.1f %12.2f\n", $msaname, $M, $mcs, $walltime; |
| 68 |
|
| 69 |
unlink "$resultdir/$msaname.sto"; |
| 70 |
unlink "$resultdir/$msaname.hmm"; |
| 71 |
} |
| 72 |
} |
| 73 |
close TABLE; |
| 74 |
close OUTFILE; |