Debian Codegraph @

hmmer/profmark/x-single-ncbiblast

raw
1 #! /usr/bin/perl -w
2
3 BEGIN {
4 $top_builddir = shift;
5 $top_srcdir = shift;
6 $wrkdir = shift;
7 $tblfile = shift;
8 $msafile = shift;
9 $fafile = shift;
10 $outfile = shift;
11 }
12 use lib "${top_srcdir}/easel/demotic";
13 use demotic_blast;
14
15 $blastp = "${top_builddir}/bin/blastall";
16 $blastopts = "-p blastp -a 1 -v 9999 -b 0";
17 # -a 1 : 1 cpu
18 # -v 9999 : long hit list, well into noise
19 # -b 0 : suppress alignment output, benchmark doesn't use it
20
21 if (! -d $top_builddir) { die "didn't find BLAST build directory $top_builddir"; }
22 if (! -d $top_srcdir) { die "didn't find H3 source directory $top_srcdir"; }
23 if (! -x $blastp) { die "didn't find executable $blastp"; }
24 if (! -e $wrkdir) { die "$wrkdir doesn't exist"; }
25
26 open(OUTFILE,">$outfile") || die "failed to open $outfile";
27 open(TABLE, "$tblfile") || die "failed to open $tblfile";
28 MSA:
29 while (<TABLE>)
30 {
31 ($msaname) = split;
32
33 $cmd = "esl-afetch -o $wrkdir/$msaname.sto $msafile $msaname"; $output = `$cmd`; if ($?) { print "FAILED: $cmd\n"; next MSA; } # Fetch the query MSA from the benchmark; tmp .sto file here
34 $cmd = "esl-seqstat --amino -a $wrkdir/$msaname.sto | grep "^=" | awk '{print \$2}'"; $output = `$cmd`; if ($?) { print "FAILED: $cmd\n", next MSA; } # Extract list of indiv seq names. --amino for robustness, some msa's v. small
35 @qnames = split(/^/,$output);
36 chop (@qnames);
37 $qname = $qnames[0];
38 $cmd = "esl-sfetch -o $wrkdir/$msaname.query $wrkdir/$msaname.sto $qname > /dev/null"; `$cmd`; if ($?) { print "FAILED: $cmd\n"; next MSA; } # Pick a single seq (first one) to tmp file; tmp .query file here
39
40 $cmd = "$blastp -d $fafile -i $wrkdir/$msaname.query $blastopts |"; if (! open(BLASTP, "$cmd")) { print "FAILED: $cmd\n"; next MSA; }
41
42 if (! demotic_blast::parse(\*BLASTP)) { print "FAILED: demotic blastp parser on $msaname\n"; next MSA; }
43
44 for ($i = 0; $i < $demotic_blast::nhits; $i++)
45 {
46 $target = $demotic_blast::hit_target[$i];
47 $pval = $demotic_blast::hit_Eval[$i];
48 $bitscore = $demotic_blast::hit_bitscore[$i];
49 printf OUTFILE "%g %.1f %s %s\n", $pval, $bitscore, $target, $msaname;
50 }
51
52 close BLASTP;
53 unlink "$wrkdir/$msaname.sto";
54 unlink "$wrkdir/$msaname.query";
55 }
56 close TABLE;
57 close OUTFILE;