Debian Codegraph @

hmmer/profmark/x-sam

raw
1 #! /usr/bin/perl -w
2
3 # Do a piece of a profmark benchmark, for SAM.
4 #
5 # This script is normally called by pmark_master.pl; its command line
6 # syntax is tied to pmark_master.pl.
7 #
8 # Usage: x-sam <top_builddir> <top_srcdir> <resultdir> <tblfile> <msafile> <fafile> <outfile>
9 # Example: ./x-sam ~/alien-src/sam-3.5/sam3.5.x86_64-linux ~/src/hmmer testdir test.tbl pmark.msa test.fa test.out
10 #
11 # SRE, Tue Apr 20 10:42:48 2010 [Janelia]
12 # SVN $Id$
13
14 BEGIN {
15 $top_builddir = shift;
16 $top_srcdir = shift;
17 $wrkdir = shift;
18 $tblfile = shift;
19 $msafile = shift;
20 $fafile = shift;
21 $outfile = shift;
22 }
23
24 $w05 = "$top_builddir/bin/w0.5";
25 $hmmscore = "$top_builddir/bin/hmmscore";
26
27 if (! -d $top_builddir) { die "didn't find directory $top_builddir"; }
28 if (! -d $top_srcdir) { die "didn't find directory $top_srcdir"; }
29 if (! -x $w05) { die "didn't find executable $w05"; }
30 if (! -x $hmmscore) { die "didn't find executable $hmmscore"; }
31 if (! -e $wrkdir) { die "$wrkdir doesn't exist"; }
32
33 open(OUTFILE,">$outfile") || die "failed to open $outfile";
34 open(TABLE, "$tblfile") || die "failed to open $tblfile";
35 while (<TABLE>)
36 {
37 ($msaname) = split;
38
39 # Fetch query MSA from benchmark's .sto file
40 $output = `esl-afetch -o $wrkdir/$msaname.sto $msafile $msaname`;
41 if ($? != 0) { die "FAILED: esl-afetch -o $wrkdir/$msaname.sto $msafile $msaname"; }
42
43 # Reformat to A2M format (.a2m file)
44 $output = `esl-reformat -o $wrkdir/$msaname.a2m a2m $wrkdir/$msaname.sto`;
45 if ($? != 0) { die "FAILED: esl-reformat"; }
46
47 # Build a model using UCSC's w0.5 script (.mod file)
48 `(cd $wrkdir; $w05 $msaname.a2m $msaname.mod &> /dev/null)`;
49 if ($? != 0) { die "FAILED: $w05"; }
50
51 # Calibrate the model (.mlib file)
52 `(cd $wrkdir; $hmmscore $msaname -i $msaname.mod -calibrate 1 &> /dev/null)`;
53 if ($? != 0) { die "FAILED: $hmmscore -calibrate"; }
54
55 # Run hmmscore, search the benchmark .fa file. The result (a .dist file) drops into the wd.
56 `(cd $wrkdir; $hmmscore $msaname -modellibrary $msaname.mlib -db ../$fafile -sw 2 &> /dev/null)`;
57 if ($? != 0) { die "FAILED: $hmmscore"; }
58
59 # The output is now in the intuitively named file (wait for it): <msaname>.1.<msaname>.mod.dist
60 open (SAMOUTPUT,"$wrkdir/$msaname.1.$msaname.mod.dist") || die "failed to open sam output";
61 while ($line = <SAMOUTPUT>)
62 {
63 if ($line =~ /^%/) { next; }
64 @fields = split(' ', $line);
65 $target = $fields[0];
66 $revnll = $fields[3];
67 $evalue = $fields[4];
68 if ($evalue > 100) { next; }
69 printf OUTFILE "%g %.1f %s %s\n", $evalue, $revnll, $target, $msaname;
70 }
71 close SAMOUTPUT;
72
73 unlink "$wrkdir/$msaname.1.$msaname.mod.dist";
74 unlink "$wrkdir/$msaname.dist";
75 unlink "$wrkdir/$msaname.mlib";
76 unlink "$wrkdir/$msaname.mod";
77 unlink "$wrkdir/$msaname.a2m";
78 unlink "$wrkdir/$msaname.sto";
79 }
80 close TABLE;
81 close OUTFILE;
82
83
84
85
86
87