| 1 |
#! /usr/bin/perl |
| 2 |
|
| 3 |
# Tests hmmemit -c and hmmemit -C consensus-generating options. |
| 4 |
# |
| 5 |
# Usage: ./i14-hmmemit-consensus.pl <builddir> <srcdir> <tmpfile prefix> |
| 6 |
# Example: ./i14-hmmemit-consensus.pl .. .. tmpfoo |
| 7 |
# |
| 8 |
# SRE, Fri May 14 11:34:28 2010 [Janelia] |
| 9 |
|
| 10 |
|
| 11 |
BEGIN { |
| 12 |
$builddir = shift; |
| 13 |
$srcdir = shift; |
| 14 |
$tmppfx = shift; |
| 15 |
} |
| 16 |
|
| 17 |
# Verify that we have all the executables we need for the test. |
| 18 |
if (! -x "$builddir/src/hmmbuild") { die "FAIL: didn't find hmmbuild binary in $builddir/src\n"; } |
| 19 |
if (! -x "$builddir/src/hmmemit") { die "FAIL: didn't find hmmemit binary in $builddir/src\n"; } |
| 20 |
|
| 21 |
# Create a carefully constructed test alignment |
| 22 |
# |
| 23 |
if (! open(ALI1, ">$tmppfx.sto")) { die "FAIL: couldn't open $tmppfx.sto for write\n"; } |
| 24 |
print ALI1 << "EOF"; |
| 25 |
# STOCKHOLM 1.0 |
| 26 |
|
| 27 |
seq0 ACDEFHIKLMNPQRST |
| 28 |
seq1 ACDEFHIKLMNPQRSK |
| 29 |
seq2 ACDEFHIKLMNPQRII |
| 30 |
seq3 ACDEFHIKLMNPQEHH |
| 31 |
seq4 ACDEFHIKLMN-CDGG |
| 32 |
seq5 ACDEFAIKLM--CDFF |
| 33 |
seq6 ACDEAAIKL---CCEE |
| 34 |
seq7 ACDAAAIK----ACDD |
| 35 |
seq8 ACAAAAI-----AACC |
| 36 |
seq9 AAAAAA------AAAA |
| 37 |
// |
| 38 |
EOF |
| 39 |
close ALI1; |
| 40 |
|
| 41 |
# max c: A C D E F A I K L M N P Q R S A |
| 42 |
# max p: 1.0 0.9 0.8 0.7 0.6 0.5 1.0 1.0 1.0 1.0 1.0 1.0 0.4 0.3 0.2 0.1 |
| 43 |
# present if symfrac <= 1.0 1.0 1.0 1.0 1.0 1.0 0.9 0.8 0.7 0.6 0.5 0.4 1.0 1.0 1.0 1.0 |
| 44 |
# upper if minu <= 1.0 0.9 0.8 0.7 0.6 0.5 1.0 1.0 1.0 1.0 1.0 1.0 0.4 0.3 0.2 0.1 |
| 45 |
# else lower if minl <= 1.0 0.9 0.8 0.7 0.6 0.5 1.0 1.0 1.0 1.0 1.0 1.0 0.4 0.3 0.2 0.1 |
| 46 |
# else x. |
| 47 |
# |
| 48 |
# So: |
| 49 |
# symfrac minl minu => L sequence |
| 50 |
# 0.0 0.0 0.0 ACDEFAIKLMNPQRSA |
| 51 |
# 0.0 0.0 1.0 AcdefaIKLMNPqrsa |
| 52 |
# 0.0 1.0 1.0 AxxxxxIKLMNPxxxx |
| 53 |
# 0.0 0.5 0.8 ACDefaIKLMNPxxxx But, p_6(A) comes back 0.499999, so it'll be x |
| 54 |
# 0.6 0.5 0.8 ACDefaIKLM xxxx (ditto) |
| 55 |
|
| 56 |
@symfrac_choices = ( 0.0, 0.0, 0.0, 0.0, 0.6 ); |
| 57 |
@minl_choices = ( 0.0, 0.0, 1.0, 0.5, 0.5 ); |
| 58 |
@minu_choices = ( 0.0, 1.0, 1.0, 0.8, 0.8 ); |
| 59 |
@answers = ( "ACDEFAIKLMNPQRSA\n", |
| 60 |
"AcdefaIKLMNPqrsa\n", |
| 61 |
"AxxxxxIKLMNPxxxx\n", |
| 62 |
"ACDefxIKLMNPxxxx\n", |
| 63 |
"ACDefxIKLMxxxx\n"); |
| 64 |
|
| 65 |
for ($i = 0; $i < $#symfrac_choices; $i++) |
| 66 |
{ |
| 67 |
@output = `$builddir/src/hmmbuild --wnone --pnone --symfrac $symfrac_choices[$i] $tmppfx.hmm $tmppfx.sto 2>&1`; |
| 68 |
if ($? != 0) { die "FAIL: hmmbuild failed\n"; } |
| 69 |
|
| 70 |
@output = `$builddir/src/hmmemit -C --minl $minl_choices[$i] --minu $minu_choices[$i] $tmppfx.hmm 2>&1`; |
| 71 |
if ($? != 0) { die "FAIL: hmmemit failed\n"; } |
| 72 |
|
| 73 |
if ($output[1] ne $answers[$i]) { die "FAIL: hmmemit, expected $answers[$i]; saw $output[1]\n"; } |
| 74 |
} |
| 75 |
|
| 76 |
print "ok\n"; |
| 77 |
unlink "$tmppfx.sto"; |
| 78 |
unlink "$tmppfx.hmm"; |
| 79 |
exit 0; |
| 80 |
|
| 81 |
|