Debian Codegraph @

hmmer/test-speed/x-psiblast+

raw
1 #! /usr/bin/perl
2
3 # We assume that an NCBI BLAST+ install tree is in $top_builddir
4 # $top_srcdir is unused: pass "." or $top_builddir
5 #
6 # Example:
7 # mkdir foo-test
8 # ./x-psiblast /usr/local/ncbi-blast-2.2.24+ . 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 $psiblast = "$top_builddir/bin/psiblast";
23 $blastopts = "-num_threads $nthreads -num_descriptions 9999 -num_alignments 0";
24
25 if (! -d $top_builddir) { die "didn't find BLAST+ directory $top_builddir"; }
26 if (! -x $psiblast) { die "didn't find psiblast+ executable $psiblast"; }
27 if ($top_srcdir ne "." && $top_srcdir ne $top_builddir) { die "$top_srcdir is unused. pass ."; }
28 if (! -e $resultdir) { die "$resultdir doesn't exist"; }
29
30 open(OUTFILE,">$outfile") || die "failed to open output $outfile";
31 open(TABLE, "$tblfile") || die "failed to open work unit list $tblfile";
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 from the benchmark (.sto file)
43 $output = `esl-afetch -o $resultdir/$msaname.sto $querydb $msaname`;
44 if ($?) { print "FAILED: esl-afetch on $msaname\n"; next MSA; }
45
46 # Reformat to psiblast format (.pbl file)
47 $output = `esl-reformat -o $resultdir/$msaname.pbl psiblast $resultdir/$msaname.sto`;
48 if ($?) { print "FAILED: esl-reformat on $msaname\n"; next MSA; }
49
50 # Warmup. (An untimed run, to encourage filesystem to cache the target database.)
51 if ($n == 1) {
52 $output = `$psiblast $blastopts -db $targetdb -in_msa $resultdir/$msaname.pbl 2>&1`;
53 }
54
55 # Run psi-blast against the benchmark
56 $t0 = Benchmark->new;
57 $output = `$psiblast $blastopts -db $targetdb -in_msa $resultdir/$msaname.pbl 2>&1`;
58 if ($?) { print "FAILED: $psiblast on $msaname\n"; next MSA; }
59 $t1 = Benchmark->new;
60
61 if ($output =~ /\nLength=(\S+)/) { $M = $1; $M =~ s/,//g; }
62 if ($output =~ /\n\s*Number of letters in database:\s*(\S+)/) { $L = $1; $L =~ s/,//g; }
63
64 # Get the wall clock time.
65 $td = timediff($t1, $t0);
66 $walltime = $td->real;
67
68 $mcs = $L / 1000000 / $walltime * $M;
69 printf OUTFILE "%-15s %5d %10.1f %12.2f\n", $msaname, $M, $mcs, $walltime;
70
71 # unlink "$resultdir/$msaname.sto";
72 # unlink "$resultdir/$msaname.pbl";
73 }
74 }
75 close TABLE;
76 close OUTFILE;