Debian Codegraph @

hmmer/profmark/x-iterate-psiblast

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 $n_iterations = 1;
16 $n_iterations +=1; # +1 because psi-blast stores checkpoint file from the PREVIOUS iteration.
17
18 $blastpgp = "${top_builddir}/bin/blastpgp";
19 $blastopts1 = "-a 1 -v 9999 -b 0 -F T -u 1 -j $n_iterations -J TRUE"; # opts for generating checkpoint file
20 $blastopts2 = "-a 1 -v 9999 -b 0 -F F -q 1 -t 1"; # opts for searching the benchmark
21 # explanation of options
22 # -a 1 : run a single thread/cpu (benchmark sends independent jobs to our cluster nodes, uses all cpus that way already)
23 # -v 9999 : show a large hit list, deep into noise (benchmark calculates its own false positive threshold)
24 # -b 0 : suppresses alignment output (benchmark only needs the top hits)
25 # -F T : filters query seq with SEG (can't use this option on -R restored checkpoint file)
26 # -j <n> : number of rounds to iterate in the iteration stage, on the iteration db. Minimum n=2, because the checkpoint file is for the *prev* round. (n=1 generates only a blastp output and no checkpoint)
27 # -u 1 : specifies checkpoint output file is in ASN.1 ASCII
28 # -q 1 : specifies checkpoint input file is in ASN.1 ASCII
29 # -J TRUE : "believe the query defline", but I don't recall why I needed this.
30 # -t 1 : blastpgp -R checkpoint restart only supports -t 1; otherwise it will bitch.
31 #
32 # also will add -i <query.fa> -d <database> ;
33 # and -C <checkpoint .asnt file> for the iteration stage
34 # and -R <checkpoint .asnt file> for the benchmark search.
35
36 if (! -d $top_builddir) { die "didn't find BLAST build directory $top_builddir"; }
37 if (! -d $top_srcdir) { die "didn't find H3 source directory $top_srcdir"; }
38 if (! -x $blastpgp) { die "didn't find executable $blastpgp"; }
39 if (! -e $wrkdir) { die "$wrkdir doesn't exist"; }
40
41 open(OUTFILE,">$outfile") || die "failed to open $outfile";
42 open(TABLE, "$tblfile") || die "failed to open $tblfile";
43 MSA:
44 while (<TABLE>)
45 {
46 ($msaname) = split;
47
48 $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
49 $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
50 @qnames = split(/^/,$output);
51 chop (@qnames);
52 $qname = $qnames[0];
53 $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
54
55 $cmd = "$blastpgp $blastopts1 -d $fafile.iter -i $wrkdir/$msaname.query -C $wrkdir/$msaname.asnt"; $output = `$cmd`; if ($?) { print "FAILED: $cmd\n"; next MSA; } # Iterate on the .iter database. tmp .asnt checkpoint file here.
56 $cmd = "$blastpgp $blastopts2 -d $fafile -R $wrkdir/$msaname.asnt 2>/dev/null |"; if (! open(PSIBLAST, "$cmd")) { print "FAILED: $cmd\n"; next MSA; } # Search the benchmark database
57
58 if (! demotic_blast::parse(\*PSIBLAST)) { print "FAILED: demotic psiblast parser on $msaname\n"; next MSA; }
59 for ($i = 0; $i < $demotic_blast::nhits; $i++)
60 {
61 printf OUTFILE ("%g\t%.1f\t%s\t%s\n",
62 $demotic_blast::hit_Eval[$i],
63 $demotic_blast::hit_bitscore[$i],
64 $demotic_blast::hit_target[$i],
65 $msaname);
66 }
67
68 close PSIBLAST;
69 unlink "$wrkdir/$msaname.query";
70 unlink "$wrkdir/$msaname.sto";
71 unlink "$wrkdir/$msaname.asnt";
72 }
73 close TABLE;
74 close OUTFILE;