| 1 |
#! /usr/bin/perl |
| 2 |
|
| 3 |
# Test that HMM naming in hmmbuild works as advertised. |
| 4 |
# Written to test for #h50. |
| 5 |
# SRE, Tue Apr 28 14:00:51 2009 |
| 6 |
# |
| 7 |
# Usage: ./i5-hmmbuild-naming.pl <builddir> <srcdir> <tmpfile prefix> |
| 8 |
# Example: ./i5-hmmbuild-naming.pl .. .. tmpfoo |
| 9 |
|
| 10 |
$builddir = shift; |
| 11 |
$srcdir = shift; |
| 12 |
$tmppfx = shift; |
| 13 |
|
| 14 |
|
| 15 |
if (! -x "$builddir/src/hmmbuild") { print "FAIL: didn't find hmmbuild binary $builddir/src/hmmbuild\n"; exit 1; } |
| 16 |
if (! -r "$srcdir/testsuite/20aa.sto") { print "FAIL: didn't find $srcdir/testsuite/20aa.sto\n"; exit 1; } |
| 17 |
if (! -r "$srcdir/tutorial/fn3.sto") { print "FAIL: didn't find $srcdir/tutorial/globins4.sto\n"; exit 1; } |
| 18 |
if (! -r "$srcdir/tutorial/globins4.sto") { print "FAIL: didn't find $srcdir/tutorial/globins4.sto\n"; exit 1; } |
| 19 |
|
| 20 |
system("$builddir/src/hmmbuild $tmppfx.hmm $srcdir/testsuite/20aa.sto > /dev/null"); |
| 21 |
if ($? != 0) { print "FAIL: hmmbuild failed unexpectedly\n"; exit 1; } |
| 22 |
$name = `cat $tmppfx.hmm | grep "^NAME"`; |
| 23 |
if ($name !~ /^NAME \s*test/) { print "FAIL: default naming by MSA name fails\n"; exit 1; } |
| 24 |
|
| 25 |
system("$builddir/src/hmmbuild $tmppfx.hmm $srcdir/tutorial/globins4.sto > /dev/null"); |
| 26 |
if ($? != 0) { print "FAIL: hmmbuild failed unexpectedly\n"; exit 1; } |
| 27 |
$name = `cat $tmppfx.hmm | grep "^NAME"`; |
| 28 |
if ($name !~ /^NAME \s*globins4/) { print "FAIL: naming using file name fails\n"; exit 1; } |
| 29 |
|
| 30 |
system("$builddir/src/hmmbuild -n myname $tmppfx.hmm $srcdir/tutorial/fn3.sto > /dev/null"); |
| 31 |
if ($? != 0) { print "FAIL: hmmbuild failed unexpectedly\n"; exit 1; } |
| 32 |
$name = `cat $tmppfx.hmm | grep "^NAME"`; |
| 33 |
if ($name !~ /^NAME \s*myname/) { print "FAIL: naming using -n fails\n"; exit 1; } |
| 34 |
|
| 35 |
# >1 alignment in file; both have MSA names. |
| 36 |
# default will work; -n will fail. |
| 37 |
# |
| 38 |
system("cat $srcdir/testsuite/20aa.sto $srcdir/tutorial/fn3.sto > $tmppfx.sto"); |
| 39 |
system("$builddir/src/hmmbuild $tmppfx.hmm $tmppfx.sto > /dev/null"); if ($? != 0) { print "FAIL: hmmbuild failed on multi MSA file\n"; exit 1; } |
| 40 |
system("$builddir/src/hmmbuild -n myname $tmppfx.hmm $tmppfx.sto > /dev/null 2>&1"); if ($? == 0) { print "FAIL: hmmbuild -n should have failed\n"; exit 1; } |
| 41 |
|
| 42 |
# >1 alignment in file; first or second one lacks MSA name. |
| 43 |
# default will fail. |
| 44 |
# |
| 45 |
system("cat $srcdir/testsuite/20aa.sto $srcdir/tutorial/globins4.sto > $tmppfx.sto"); |
| 46 |
system("$builddir/src/hmmbuild $tmppfx.hmm $tmppfx.sto > /dev/null 2>&1"); if ($? == 0) { print "FAIL: hmmbuild should have failed\n"; exit 1; } |
| 47 |
system("cat $srcdir/tutorial/globins4.sto $srcdir/testsuite/20aa.sto > $tmppfx.sto"); |
| 48 |
system("$builddir/src/hmmbuild $tmppfx.hmm $tmppfx.sto > /dev/null 2>&1"); if ($? == 0) { print "FAIL: hmmbuild should have failed\n"; exit 1; } |
| 49 |
|
| 50 |
|
| 51 |
print "ok\n"; |
| 52 |
unlink "$tmppfx.hmm"; |
| 53 |
unlink "$tmppfx.sto"; |
| 54 |
exit 0; |