| 1 |
#! /usr/bin/perl |
| 2 |
|
| 3 |
# Testing the esl-afetch miniapp |
| 4 |
# |
| 5 |
# Usage: ./esl-afetch.itest.pl <esl-afetch binary> <tmpfile prefix> |
| 6 |
# Example: ./esl-afetch.itest.pl ./esl-afetch foo |
| 7 |
# |
| 8 |
# SRE, Fri Nov 11 09:16:49 2011 |
| 9 |
|
| 10 |
$esl_afetch = shift; |
| 11 |
$tmppfx = shift; |
| 12 |
|
| 13 |
if (! -x "$esl_afetch") { die "FAIL: didn't find esl-afetch binary $esl_afetch"; } |
| 14 |
|
| 15 |
# Existence of a previous .ssi index will screw up this test. |
| 16 |
if ( -e "$tmppfx.sto.ssi") { unlink "$tmppfx.sto.ssi"; } |
| 17 |
|
| 18 |
open(TESTALI, ">$tmppfx.sto") || die "FAIL: couldn't open $tmppfx.sto for writing test ali file"; |
| 19 |
print TESTALI << "EOF"; |
| 20 |
# STOCKHOLM 1.0 |
| 21 |
#=GF ID foo |
| 22 |
#=GF AC XX00001.1 |
| 23 |
seq1 AAAAAAAAAACCCCCCCCCC |
| 24 |
seq2 AAAAAAAAAACCCCCCCCCC |
| 25 |
// |
| 26 |
# STOCKHOLM 1.0 |
| 27 |
#=GF ID bar |
| 28 |
#=GF AC XX00002.2 |
| 29 |
seq3 DDDDDDDDDDEEEEEEEEEE |
| 30 |
seq4 DDDDDDDDDDEEEEEEEEEE |
| 31 |
// |
| 32 |
# STOCKHOLM 1.0 |
| 33 |
#=GF ID $tmppfx.name |
| 34 |
seq3 XXXXXXXXXXXXXXXXXXXX |
| 35 |
seq4 XXXXXXXXXXXXXXXXXXXX |
| 36 |
// |
| 37 |
# STOCKHOLM 1.0 |
| 38 |
#=GF ID baz |
| 39 |
#=GF AC XX00003.3 |
| 40 |
seq5 FFFFFFFFFFGGGGGGGGGG |
| 41 |
seq6 FFFFFFFFFFGGGGGGGGGG |
| 42 |
// |
| 43 |
EOF |
| 44 |
close TESTFILE; |
| 45 |
|
| 46 |
|
| 47 |
open(TESTLIST, ">$tmppfx.list") || die "FAIL: couldn't open $tmppfx.list for writing test name list"; |
| 48 |
print TESTLIST << "EOF"; |
| 49 |
baz |
| 50 |
foo |
| 51 |
EOF |
| 52 |
close TESTLIST; |
| 53 |
|
| 54 |
|
| 55 |
|
| 56 |
|
| 57 |
# First, test without an SSI index... |
| 58 |
# |
| 59 |
@output = `$esl_afetch $tmppfx.sto baz`; |
| 60 |
if ($? != 0) { die "FAIL: esl-afetch failed, returned nonzero"; } |
| 61 |
if ($output[1] !~ /^#=GF ID baz$/) { die "FAIL: esl-afetch fetched incorrectly"; } |
| 62 |
if ($output[6] !~ /^\/\/$/) { die "FAIL: esl-afetch fetched incorrectly"; } |
| 63 |
if ($#output != 6) { die "FAIL: esl-afetch fetched incorrectly"; } |
| 64 |
|
| 65 |
@output = `$esl_afetch $tmppfx.sto XX00003.3`; |
| 66 |
if ($? != 0) { die "FAIL: esl-afetch failed, returned nonzero"; } |
| 67 |
if ($output[1] !~ /^#=GF ID baz$/) { die "FAIL: esl-afetch fetched incorrectly"; } |
| 68 |
if ($output[6] !~ /^\/\/$/) { die "FAIL: esl-afetch fetched incorrectly"; } |
| 69 |
if ($#output != 6) { die "FAIL: esl-afetch fetched incorrectly"; } |
| 70 |
|
| 71 |
# Without SSI, when fetching from a list, MSAs are in order of .sto file, not .list file |
| 72 |
@output = `$esl_afetch -f $tmppfx.sto $tmppfx.list`; |
| 73 |
if ($? != 0) { die "FAIL: esl-afetch failed, returned nonzero"; } |
| 74 |
if ($output[1] !~ /^#=GF ID foo$/) { die "FAIL: esl-afetch fetched incorrectly"; } |
| 75 |
if ($output[8] !~ /^#=GF ID baz$/) { die "FAIL: esl-afetch fetched incorrectly"; } |
| 76 |
if ($#output != 13) { die "FAIL: esl-afetch fetched incorrectly"; } |
| 77 |
|
| 78 |
@output = `$esl_afetch -O $tmppfx.sto $tmppfx.name`; if ($? != 0) { die "FAIL: esl-afetch failed, returned nonzero"; } |
| 79 |
@output = `$esl_afetch $tmppfx.sto $tmppfx.name > $tmppfx.tmp`; if ($? != 0) { die "FAIL: esl-afetch failed, returned nonzero"; } |
| 80 |
system "diff $tmppfx.name $tmppfx.tmp > /dev/null 2>&1"; if ($? != 0) { die "FAIL: esl-afetch bad diff"; } |
| 81 |
|
| 82 |
@output = `$esl_afetch -f -o $tmppfx.tmp $tmppfx.sto $tmppfx.list`; if ($? != 0) { die "FAIL: esl-afetch failed, returned nonzero"; } |
| 83 |
@output = `$esl_afetch -f $tmppfx.sto $tmppfx.list > $tmppfx.tmp2`; if ($? != 0) { die "FAIL: esl-afetch failed, returned nonzero"; } |
| 84 |
system "diff $tmppfx.tmp $tmppfx.tmp2 > /dev/null 2>&1"; if ($? != 0) { die "FAIL: esl-afetch bad diff"; } |
| 85 |
|
| 86 |
@output = `$esl_afetch --informat stockholm $tmppfx.sto baz`; |
| 87 |
if ($? != 0) { die "FAIL: esl-afetch failed, returned nonzero"; } |
| 88 |
|
| 89 |
@output = `$esl_afetch --outformat clustal $tmppfx.sto XX00003.3`; |
| 90 |
if ($? != 0) { die "FAIL: esl-afetch failed, returned nonzero"; } |
| 91 |
if ($output[0] !~ /^CLUSTAL/) { die "FAIL: esl-afetch fetched incorrectly"; } |
| 92 |
|
| 93 |
|
| 94 |
# Now index it |
| 95 |
# |
| 96 |
@output = `$esl_afetch --index $tmppfx.sto`; |
| 97 |
if ($? != 0) { die "FAIL: esl-afetch indexing failed, returned nonzero"; } |
| 98 |
|
| 99 |
# Now repeat the tests. They'll use the SSI index now. |
| 100 |
# We have a couple of ways to tell that the SSI index is being used. |
| 101 |
# One is that with SSI and -f, MSAs come in order of list file, not sto file. |
| 102 |
# Another is that with SSI, the alignment is fetched verbatim (line spacing the same), |
| 103 |
# so the test alignments are fetched with no blank line between #=GF AC line and first seq. |
| 104 |
@output = `$esl_afetch $tmppfx.sto baz`; |
| 105 |
if ($? != 0) { die "FAIL: esl-afetch failed, returned nonzero"; } |
| 106 |
if ($output[1] !~ /^#=GF ID baz$/) { die "FAIL: esl-afetch fetched incorrectly"; } |
| 107 |
if ($output[5] !~ /^\/\/$/) { die "FAIL: esl-afetch fetched incorrectly"; } |
| 108 |
if ($#output != 5) { die "FAIL: esl-afetch fetched incorrectly"; } |
| 109 |
|
| 110 |
@output = `$esl_afetch $tmppfx.sto XX00003.3`; |
| 111 |
if ($? != 0) { die "FAIL: esl-afetch failed, returned nonzero"; } |
| 112 |
if ($output[1] !~ /^#=GF ID baz$/) { die "FAIL: esl-afetch fetched incorrectly"; } |
| 113 |
if ($output[5] !~ /^\/\/$/) { die "FAIL: esl-afetch fetched incorrectly"; } |
| 114 |
if ($#output != 5) { die "FAIL: esl-afetch fetched incorrectly"; } |
| 115 |
|
| 116 |
# With SSI, when fetching from a list, MSAs are in order of .list file, not .sto file |
| 117 |
@output = `$esl_afetch -f $tmppfx.sto $tmppfx.list`; |
| 118 |
if ($? != 0) { die "FAIL: esl-afetch failed, returned nonzero"; } |
| 119 |
if ($output[1] !~ /^#=GF ID baz$/) { die "FAIL: esl-afetch fetched incorrectly"; } |
| 120 |
if ($output[7] !~ /^#=GF ID foo$/) { die "FAIL: esl-afetch fetched incorrectly"; } |
| 121 |
if ($#output != 11) { die "FAIL: esl-afetch fetched incorrectly"; } |
| 122 |
|
| 123 |
@output = `$esl_afetch -O $tmppfx.sto $tmppfx.name`; if ($? != 0) { die "FAIL: esl-afetch failed, returned nonzero"; } |
| 124 |
@output = `$esl_afetch $tmppfx.sto $tmppfx.name > $tmppfx.tmp`; if ($? != 0) { die "FAIL: esl-afetch failed, returned nonzero"; } |
| 125 |
system "diff $tmppfx.name $tmppfx.tmp > /dev/null 2>&1"; if ($? != 0) { die "FAIL: esl-afetch bad diff"; } |
| 126 |
|
| 127 |
@output = `$esl_afetch -f -o $tmppfx.tmp $tmppfx.sto $tmppfx.list`; if ($? != 0) { die "FAIL: esl-afetch failed, returned nonzero"; } |
| 128 |
@output = `$esl_afetch -f $tmppfx.sto $tmppfx.list > $tmppfx.tmp2`; if ($? != 0) { die "FAIL: esl-afetch failed, returned nonzero"; } |
| 129 |
system "diff $tmppfx.tmp $tmppfx.tmp2 > /dev/null 2>&1"; if ($? != 0) { die "FAIL: esl-afetch bad diff"; } |
| 130 |
|
| 131 |
@output = `$esl_afetch --informat stockholm $tmppfx.sto baz`; |
| 132 |
if ($? != 0) { die "FAIL: esl-afetch failed, returned nonzero"; } |
| 133 |
|
| 134 |
@output = `$esl_afetch --outformat clustal $tmppfx.sto XX00003.3`; |
| 135 |
if ($? != 0) { die "FAIL: esl-afetch failed, returned nonzero"; } |
| 136 |
if ($output[0] !~ /^CLUSTAL/) { die "FAIL: esl-afetch fetched incorrectly"; } |
| 137 |
|
| 138 |
|
| 139 |
print "ok\n"; |
| 140 |
unlink "$tmppfx.sto"; |
| 141 |
unlink "$tmppfx.sto.ssi"; |
| 142 |
unlink "$tmppfx.tmp"; |
| 143 |
unlink "$tmppfx.tmp2"; |
| 144 |
unlink "$tmppfx.name"; |
| 145 |
unlink "$tmppfx.list"; |
| 146 |
exit 0; |