Debian Codegraph @

profmark/x-iterate-jackhmmer

raw
1 #! /usr/bin/perl
2
3 $n_iterations = 1;
4 # $n_iterations = 2; # uncomment as needed for -n2, -n3 tests...
5 # $n_iterations = 3;
6
7
8 $top_builddir = shift;
9 $top_srcdir = shift;
10 $wrkdir = shift;
11 $tblfile = shift;
12 $msafile = shift;
13 $fafile = shift;
14 $outfile = shift;
15
16 $jackhmmer = "$top_builddir/src/jackhmmer";
17 $hmmbuild = "$top_builddir/src/hmmbuild";
18 $hmmsearch = "$top_builddir/src/hmmsearch";
19 $iteropts = "-N $n_iterations --cpu 1";
20 $searchopts = "-E 200 --cpu 1";
21
22 if (! -d $top_builddir) { die "didn't find build directory $top_builddir"; }
23 if (! -d $top_srcdir) { die "didn't find source directory $top_srcdir"; }
24 if (! -x $jackhmmer) { die "didn't find executable $jackhmmer"; }
25 if (! -x $hmmbuild) { die "didn't find executable $hmmbuild"; }
26 if (! -x $hmmsearch) { die "didn't find executable $hmmsearch"; }
27 if (! -e $wrkdir) { die "$wrkdir doesn't exist"; }
28 if (! -e "$fafile.iter") { die "iteration db $fafile.iter doesn't exist"; }
29
30
31 open(OUTFILE,">$outfile") || die "failed to open $outfile";
32 open(TABLE, "$tblfile") || die "failed to open $tblfile";
33 MSA:
34 while (<TABLE>)
35 {
36 ($msaname) = split;
37
38 $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
39 $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
40 @qnames = split(/^/,$output);
41 chop (@qnames);
42 $qname = $qnames[0];
43 $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
44
45 $cmd = "$jackhmmer $iteropts -A $wrkdir/$msaname.jck $wrkdir/$msaname.query $fafile.iter > /dev/null"; `$cmd`; if ($?) { print "FAILED: $cmd\n"; next MSA; } # Iterate n times on the .iter intermediate database (NR, whatever); alignment to tmp .jck file
46 $cmd = "$hmmbuild --hand $wrkdir/$msaname.hmm $wrkdir/$msaname.jck > /dev/null`"; `$cmd`; if ($?) { print "FAILED: $cmd\n"; next MSA; } # Build a model from .jck, using the same architecture (--hand)
47 $cmd = "$hmmsearch $searchopts --tblout $wrkdir/$msaname.tmp $wrkdir/$msaname.hmm $fafile > /dev/null"; `$cmd`; if ($?) { print "FAILED: $cmd\n"; next MSA; } # Search against benchmark .fa file; results to tmp .tmp tbl file
48
49 if (! open(OUTPUT, "$wrkdir/$msaname.tmp")) { print "FAILED: to open $wrkdir/$msaname.tmp"; next MSA; }
50 while (<OUTPUT>)
51 {
52 if (/^\#/) { next; }
53 @fields = split(' ', $_, 7);
54 $target = $fields[0];
55 $pval = $fields[4];
56 $bitscore = $fields[5];
57 printf OUTFILE "%g %.1f %s %s\n", $pval, $bitscore, $target, $msaname;
58 }
59 close OUTPUT;
60 unlink "$wrkdir/$msaname.tmp";
61 unlink "$wrkdir/$msaname.hmm";
62 unlink "$wrkdir/$msaname.jck";
63 unlink "$wrkdir/$msaname.query";
64 unlink "$wrkdir/$msaname.sto";
65 }
66 close TABLE;
67 close OUTFILE;