Debian Codegraph @

hmmer/profmark/x-phmmer-consensus

raw
1 #! /usr/bin/perl
2
3 # Do a piece of a profmark benchmark, for phmmer searches using a
4 # consensus sequence query.
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-phmmer-consensus <top_builddir> <top_srcdir> <resultdir> <tblfile> <msafile> <fafile> <outfile>
10 #
11 # SRE, Sun Feb 7 08:58:12 2010 [Case de Gatos]
12 # SVN $Id$
13 #
14
15 $top_builddir = shift;
16 $top_srcdir = shift;
17 $resultdir = shift;
18 $tblfile = shift;
19 $msafile = shift;
20 $fafile = shift;
21 $outfile = shift;
22
23 $phmmer = "$top_builddir/src/phmmer";
24 $esl_afetch = "$top_builddir/easel/miniapps/esl-afetch";
25 $hmmbuild = "$top_builddir/src/hmmbuild --wnone --enone --laplace"; # for building consensus seqs
26 $hmmemit = "$top_builddir/src/hmmemit -c";
27 $opts = "";
28
29 open(OUTFILE,">$outfile") || die "failed to open $outfile";
30 open(TABLE, "$tblfile") || die "failed to open $tblfile";
31 while (<TABLE>)
32 {
33 ($msaname) = split;
34
35 # Fetch the query MSA from the benchmark (.sto file)
36 $output = `$esl_afetch -o $resultdir/$msaname.sto $msafile $msaname`;
37 if ($? != 0) { die "FAILED: $esl_afetch -o $resultdir/$msaname.sto $msafile $msaname"; }
38
39 # Create a profile HMM from it (.hmm file; .query.fa file)
40 $output = `$hmmbuild $resultdir/$msaname.hmm $resultdir/$msaname.sto`;
41 if ($? != 0) { die "FAILED: $hmmbuild $resultdir/$msaname.hmm $resultdir/$msaname.sto"; }
42
43 $output = `$hmmemit -o $resultdir/$msaname.query.fa $resultdir/$msaname.hmm`;
44 if ($? != 0) { die "FAILED: hmmemit -o $resultdir/$msaname.query.fa $resultdir/$msaname.hmm"; }
45
46 # PHMMER it against the benchmark
47 $output = `$phmmer $opts --cpu 1 --tblout $resultdir/$msaname.tmp $resultdir/$msaname.query.fa $fafile > /dev/null`;
48 if ($? != 0) { die "FAILED: $phmmer --tblout $resultdir/$msaname.tmp $opts $resultdir/$msaname.query.fa $fafile"; }
49
50 open(OUTPUT, "$resultdir/$msaname.tmp") || die "FAILED: to open $resultdir/$msaname.tmp tabular output file";
51 while (<OUTPUT>)
52 {
53 if (/^\#/) { next; }
54 ($target, $tacc, $query, $qacc, $pval, $bitscore, $remainder) = split(' ', $_, 7);
55 printf OUTFILE "%g %.1f %s %s\n", $pval, $bitscore, $target, $msaname;
56 }
57
58 unlink "$resultdir/$msaname.tmp";
59 unlink "$resultdir/$msaname.query.fa";
60 unlink "$resultdir/$msaname.hmm";
61 unlink "$resultdir/$msaname.sto";
62 }
63 close TABLE;
64 close OUTFILE;