Debian Codegraph @

hmmer/profmark/x-fps-wublast

raw
1 #! /usr/bin/perl -w
2
3 # Do a piece of a profmark benchmark, for WU-BLAST searches by FPS
4 # (family-pairwise-search; best E-value of all individual queries).
5 #
6 # This script is normally called by pmark_master.pl; its command line
7 # syntax is tied to pmark_master.pl.
8 #
9 # Usage: x-wublast-fps <top_builddir> <top_srcdir> <resultdir> <tblfile> <msafile> <fafile> <outfile>
10 # Example: ./x-wublast-fps /usr/local/wublast ~/src/hmmer testdir test.tbl pmark.msa test.fa test.out
11 #
12 # SRE, Sat Apr 17 11:16:23 2010 [Janelia]
13 # SVN $Id$
14
15 BEGIN {
16 $top_builddir = shift;
17 $top_srcdir = shift;
18 $wrkdir = shift;
19 $tblfile = shift;
20 $msafile = shift;
21 $fafile = shift;
22 $outfile = shift;
23 }
24 use lib "${top_srcdir}/easel/demotic";
25 use demotic_blast;
26
27 $blastp = "${top_builddir}/blastp";
28 $blastopts = "cpus=1 V=9999 B=0 filter=seg filter=xnu";
29
30 if (! -d $top_builddir) { die "didn't find BLAST build directory $top_builddir"; }
31 if (! -d $top_srcdir) { die "didn't find H3 source directory $top_srcdir"; }
32 if (! -x $blastp) { die "didn't find executable $blastp"; }
33 if (! -e $wrkdir) { die "$wrkdir doesn't exist"; }
34
35 open(OUTFILE,">$outfile") || die "failed to open $outfile";
36 open(TABLE, "$tblfile") || die "failed to open $tblfile";
37 MSA:
38 while (<TABLE>)
39 {
40 ($msaname) = split;
41
42 %seen = ();
43 %best_pval = ();
44 %best_bitscore = ();
45
46 `esl-afetch -o $wrkdir/$msaname.sto $msafile $msaname`;
47 if ($?) { print "FAILED: esl-afetch -o $wrkdir/$msaname.sto $msafile $msaname\n"; next MSA; }
48
49 # Extract a list of individual sequence names from the multiple alignment.
50 $output = `esl-seqstat -a $wrkdir/$msaname.sto | grep "^=" | awk '{print \$2}'`;
51 if ($?) { print "FAILED: esl-seqstat -a $wrkdir/$msaname.sto\n"; next MSA; }
52
53 @qnames = split(/^/,$output);
54 chop (@qnames);
55
56 # Loop over each query; blast; accumulate best pval for each target
57 QUERY:
58 foreach $qname (@qnames)
59 {
60 $output = `esl-sfetch -o $wrkdir/$msaname.query.fa $wrkdir/$msaname.sto $qname`;
61 if ($?) { print "FAILED: esl-sfetch -o $wrkdir/$msaname.query.fa $wrkdir/$msaname.sto $qname\n"; next QUERY; }
62
63 if (! open(BLASTP, "$blastp $fafile $wrkdir/$msaname.query.fa $blastopts |")) {
64 print "FAILED: $blastp $fafile $wrkdir/$msaname.query.fa $blastopts |\n"; next QUERY;
65 }
66
67 if (! demotic_blast::parse(\*BLASTP)) {
68 print "FAILED: demotic parser for blastp output; query might be x'ed by filters; skipping this query\n"; next QUERY;
69 }
70
71 for ($i = 0; $i < $demotic_blast::nhits; $i++)
72 {
73 $target = $demotic_blast::hit_target[$i];
74 $pval = $demotic_blast::hit_Eval[$i];
75 $bitscore = $demotic_blast::hit_bitscore[$i];
76
77 if (! $seen{$target} || $pval < $best_pval{$target})
78 {
79 $seen{$target} = 1;
80 $best_pval{$target} = $pval;
81 $best_bitscore{$target} = $bitscore;
82 }
83 }
84 close BLASTP;
85 }
86
87 # Append to the outfile.
88 foreach $target (keys(%seen))
89 {
90 printf OUTFILE "%g %.1f %s %s\n", $best_pval{$target}, $best_bitscore{$target}, $target, $msaname;
91 }
92
93 unlink "$wrkdir/$msaname.sto";
94 unlink "$wrkdir/$msaname.query.fa";
95 }
96 close TABLE;
97 close OUTFILE;