Debian Codegraph @

hmmer/test-speed/x-fasta

raw
1 #! /usr/bin/perl
2
3 # We assume that a FASTA install tree is in $top_builddir
4 # $top_srcdir is unused: pass "." or $top_builddir
5 #
6 # Example:
7 # mkdir foo-test
8 # ./x-fasta /usr/local/fasta-36.3.3 . foo-test test.list 1 Pfam-A.seed uniprot/trembl-shuf-100k 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 if ($nthreads > 1) { $fasta = "$top_builddir/bin/fasta36_t"; $fasta_opts = "-q -T $nthreads";}
23 else { $fasta = "$top_builddir/bin/fasta36"; $fasta_opts = "-q"; }
24
25
26 if (! -d $top_builddir) { die "didn't find FASTA directory $top_builddir"; }
27 if (! -x $fasta) { die "didn't find ssearch executable $fasta"; }
28 if ($top_srcdir ne "." && $top_srcdir ne $top_builddir) { die "$top_srcdir is unused. pass ."; }
29 if (! -e $resultdir) { die "$resultdir doesn't exist"; }
30
31 open(OUTFILE,">$outfile") || die "failed to open output $outfile";
32 open(TABLE, "$tblfile") || die "failed to open work unit list $tblfile";
33
34 $n=0;
35 MSA:
36 while (<TABLE>)
37 {
38 if (/(\S+)/)
39 {
40 $n++;
41 $msaname = $1;
42
43 # Fetch the query MSA (.sto file)
44 $output = `esl-afetch -o $resultdir/$msaname.sto $querydb $msaname`;
45 if ($? != 0) { print "FAILED: esl-afetch on $msaname\n"; next MSA; }
46
47 # Select median length single sequence as the query (.query.fa file)
48 $output = `esl-seqstat -a $resultdir/$msaname.sto | grep "^=" | sort -n -k2 | awk '{print \$2}'`;
49 if ($?) { print "FAILED: esl-seqstat on $msaname\n"; next MSA; }
50 @qnames = split(/^/,$output);
51 chop (@qnames);
52 $qname = $qnames[ int(($#qnames+1) / 2)];
53 $output = `esl-sfetch -o $resultdir/$msaname.query.fa $resultdir/$msaname.sto $qname`;
54 if ($?) { print "FAILED: esl-sfetch on $msaname\n"; next MSA; }
55
56 # Warmup. (An untimed run, to encourage filesystem to cache the target database.)
57 if ($n == 1) { $output = `$fasta $fasta_opts $resultdir/$msaname.query.fa $targetdb 2>&1`; }
58
59 # FASTA and capture timing
60 $t0 = Benchmark->new;
61 $output = `$fasta $fasta_opts $resultdir/$msaname.query.fa $targetdb 2>&1`;
62 if ($? != 0) { print "FAILED: fasta on $msaname\n"; next MSA; }
63 $t1 = Benchmark->new;
64
65 if ($output =~ />>>\S+.+- (\d+) aa/) { $M = $1; }
66 if ($output =~ /(\d+) residues in \d+ sequences/) { $L = $1; }
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.query.fa";
77 }
78 }
79 close TABLE;
80 close OUTFILE;