| 1 |
#! /usr/bin/perl |
| 2 |
|
| 3 |
# Regression test of handling a nonresidue '*' character. By design, |
| 4 |
# '*' residues score 0 in insert states and N,C,J; and -inf in match |
| 5 |
# states. Test case verifies that an inserted * is handled within one |
| 6 |
# alignment, and a consensus * breaks an alignment in two. |
| 7 |
# Implemented as a regression test against specific scores (in domtbl |
| 8 |
# output) of a small manually checked example. |
| 9 |
# |
| 10 |
# Usage: ./i8-nonresidues.pl <builddir> <srcdir> <tmpfile prefix> |
| 11 |
# Example: ./i8-nonresidues.pl .. .. tmpfoo |
| 12 |
# |
| 13 |
# SRE, Thu Oct 29 08:38:09 2009 |
| 14 |
|
| 15 |
BEGIN { |
| 16 |
$builddir = shift; |
| 17 |
$srcdir = shift; |
| 18 |
$tmppfx = shift; |
| 19 |
} |
| 20 |
|
| 21 |
use lib "$srcdir/testsuite"; |
| 22 |
use h3; |
| 23 |
|
| 24 |
$hmmsearch = "$builddir/src/hmmsearch"; |
| 25 |
$hmm20aa = "$srcdir/testsuite/20aa.hmm"; |
| 26 |
|
| 27 |
# Two test sequences, to be aligned to 20aa.hmm |
| 28 |
# First one will get parsed into two domains (consensus L replaced by '*') |
| 29 |
# Second one will get parsed into one domain because '*' is an insertion; |
| 30 |
# this is a "feature" of insertions being scored as 0 regardless of |
| 31 |
# residue identity. |
| 32 |
# |
| 33 |
if (! open(FP1, ">$tmppfx.1")) { print "FAIL: couldn't open $tmppfx.1 for writing"; exit 1; } |
| 34 |
if (! open(FP2, ">$tmppfx.2")) { print "FAIL: couldn't open $tmppfx.2 for writing"; exit 1; } |
| 35 |
|
| 36 |
print FP1 <<"EOF"; |
| 37 |
>test1 |
| 38 |
ACDEFGHIK*MNPQRSTVWY |
| 39 |
EOF |
| 40 |
|
| 41 |
print FP2 <<"EOF"; |
| 42 |
>test2 |
| 43 |
ACDEFGHIKL*MNPQRSTVWY |
| 44 |
EOF |
| 45 |
|
| 46 |
system("$hmmsearch --domtblout $tmppfx.dom $hmm20aa $tmppfx.1 > $tmppfx.out 2>&1"); |
| 47 |
if ($? != 0) { die "FAIL: hmmsearch failed on first test sequence\n"; } |
| 48 |
&h3::ParseDomTbl("$tmppfx.dom"); |
| 49 |
|
| 50 |
# Verify. |
| 51 |
if ($h3::ndomtbl != 2) { printf("FAIL: expected two lines in domtbl; saw %d\n", $h3::ndomtbl); exit 1; } |
| 52 |
if ($h3::ndom[0] != 2) { printf("FAIL: expected two domains; saw %d\n", $h3::ndom[0]); exit 1; } |
| 53 |
if ($h3::seqsc[0] != "45.8") { printf("FAIL: expected seq score of 41.8; saw %s\n", $h3::seqsc[0]); exit 1; } |
| 54 |
if ($h3::seqbias[0] != "11.8") { printf("FAIL: expected seq bias of 11.8; saw %s\n", $h3::seqbias[0]); exit 1; } |
| 55 |
if ($h3::domsc[0] != "23.6") { printf("FAIL: expected domain 1 score of 23.6; saw %s\n", $h3::domsc[0]); exit 1; } |
| 56 |
if ($h3::domsc[1] != "28.2") { printf("FAIL: expected domain 1 score of 28.2; saw %s\n", $h3::domsc[1]); exit 1; } |
| 57 |
|
| 58 |
system("$hmmsearch --domtblout $tmppfx.dom $hmm20aa $tmppfx.2 > $tmppfx.out 2>&1"); |
| 59 |
if ($? != 0) { print "FAIL: hmmsearch failed on second test sequence"; } |
| 60 |
&h3::ParseDomTbl("$tmppfx.dom"); |
| 61 |
|
| 62 |
if ($h3::ndomtbl != 1) { printf("FAIL: expected one line in domtbl; saw %d\n", $h3::ndomtbl); exit 1; } |
| 63 |
if ($h3::ndom[0] != 1) { printf("FAIL: expected one domains; saw %d\n", $h3::ndom[0]); exit 1; } |
| 64 |
if ($h3::seqsc[0] != "64.6") { printf("FAIL: expected seq score of 64.6; saw %s\n", $h3::seqsc[0]); exit 1; } |
| 65 |
if ($h3::seqbias[0] != "0.1") { printf("FAIL: expected seq bias of 0.1; saw %s\n", $h3::seqbias[0]); exit 1; } |
| 66 |
if ($h3::domsc[0] != "64.5") { printf("FAIL: expected domain 1 score of 64.5; saw %s\n", $h3::domsc[0]); exit 1; } |
| 67 |
|
| 68 |
print "ok\n"; |
| 69 |
unlink "$tmppfx.1"; |
| 70 |
unlink "$tmppfx.2"; |
| 71 |
unlink "$tmppfx.dom"; |
| 72 |
unlink "$tmppfx.out"; |
| 73 |
exit 0; |
| 74 |
|