| 1 |
#! /usr/bin/perl |
| 2 |
|
| 3 |
# Integrated test of the esl-alistat miniapp. |
| 4 |
# |
| 5 |
# Usage: ./esl-alistat.itest.pl <esl-alistat binary> <tmpfile prefix> |
| 6 |
# Example: ./esl-alistat.itest.pl ./esl-alistat foo |
| 7 |
# |
| 8 |
# EPN, Tue Feb 2 13:19:44 2010 |
| 9 |
|
| 10 |
$eslalistat= shift; |
| 11 |
$tmppfx = shift; |
| 12 |
|
| 13 |
if (! -x "$eslalistat") { die "FAIL: didn't find esl-alistat binary $eslalistat"; } |
| 14 |
|
| 15 |
open(ALIFILE, ">$tmppfx.stk") || die "FAIL: couldn't open $tmppfx.stk for writing alifile"; |
| 16 |
print ALIFILE << "EOF"; |
| 17 |
# STOCKHOLM 1.0 |
| 18 |
seq1 aaAAAA..AAAA...Cc.cCCCCCC.C..GGGGGgggg |
| 19 |
#=GR seq1 PP 5789**..**88...*9.9****88.7..776543210 |
| 20 |
seq2 ..AAAAa.AAAAaacCcccCCCCCCcCccGGGGG.... |
| 21 |
#=GR seq2 PP ..********************************.... |
| 22 |
seq3 ..AAAA..AAAA...C...CCCCCC.C..GGGG-.... |
| 23 |
#=GR seq3 PP ..5555..4*44...3...888888.8..8899..... |
| 24 |
#=GC SS_cons ...............<...<<<<......>>>>>.... |
| 25 |
#=GC PP_cons ..789*..8877...8...****99.8..99998.... |
| 26 |
#=GC RF ..AAAA..AAAA...C...CCCCCC.c..GGGGG.... |
| 27 |
// |
| 28 |
EOF |
| 29 |
close ALIFILE; |
| 30 |
|
| 31 |
open(ALIFILE, ">$tmppfx.dbl.stk") || die "FAIL: couldn't open $tmppfx.stk for writing alifile"; |
| 32 |
print ALIFILE << "EOF"; |
| 33 |
# STOCKHOLM 1.0 |
| 34 |
#=GS seq1 WT 1.5 |
| 35 |
#=GS seq2 WT 1.0 |
| 36 |
#=GS seq3 WT 0.5 |
| 37 |
seq1 aaAAAA..AAAA...Cc.cCCCCCC.C..GGGGGgggg |
| 38 |
#=GR seq1 PP 5789**..**88...*9.9****88.7..776543210 |
| 39 |
seq2 ..AAAAa.AAAAaacCcccCCCCCCcCccGGGGG.... |
| 40 |
#=GR seq2 PP ..********************************.... |
| 41 |
seq3 ..AAAA..AAAA...C...CCCCCC.C..GGGG-.... |
| 42 |
#=GR seq3 PP ..5555..4*44...3...888888.8..8899..... |
| 43 |
#=GC SS_cons ...............<...<<<<......>>>>>.... |
| 44 |
#=GC PP_cons ..789*..8877...8...****99.8..99998.... |
| 45 |
#=GC RF ..AAAA..AAAA...C...CCCCCC.c..GGGGG.... |
| 46 |
// |
| 47 |
# STOCKHOLM 1.0 |
| 48 |
seq1 aaA |
| 49 |
#=GR seq1 PP 578 |
| 50 |
seq2 ..A |
| 51 |
#=GR seq2 PP ..* |
| 52 |
#=GC SS_cons ... |
| 53 |
#=GC RF ..A |
| 54 |
// |
| 55 |
EOF |
| 56 |
close ALIFILE; |
| 57 |
|
| 58 |
open(ALIFILE, ">$tmppfx.afa") || die "FAIL: couldn't open $tmppfx.afa for writing alifile"; |
| 59 |
print ALIFILE << "EOF"; |
| 60 |
>seq1 |
| 61 |
aaAAAA..AAAA...Cc.cCCCCCC.C..GGGGGgggg |
| 62 |
>seq2 |
| 63 |
..AAAAa.AAAAaacCcccCCCCCCcCccGGGGG.... |
| 64 |
>seq3 |
| 65 |
..AAAA..AAAA...C...CCCCCC.C..GGGG-.... |
| 66 |
EOF |
| 67 |
close ALIFILE; |
| 68 |
|
| 69 |
$output = `$eslalistat -h`; |
| 70 |
if ($? != 0) { die "FAIL: esl-alistat failed unexpectedly"; } |
| 71 |
if ($output !~ /Usage: esl-alistat/) { die "FAIL: help output not right"; } |
| 72 |
|
| 73 |
# We do 2 runs of most tests, with and without --small |
| 74 |
$smallA[0] = ""; |
| 75 |
$smallA[1] = "--small --informat pfam"; |
| 76 |
|
| 77 |
for($pass = 0; $pass < 2; $pass++) { |
| 78 |
$pass2write = $pass+1; |
| 79 |
|
| 80 |
$output = `$eslalistat $smallA[$pass] --rna $tmppfx.stk 2>&1`; |
| 81 |
if ($? != 0) { die "FAIL: esl-alistat failed unexpectedly";} |
| 82 |
if ($output !~ /Alignment length: 38/) { die "FAIL: alignment statistics calculated incorrectly on pass $pass2write"; } |
| 83 |
if ($output !~ /Average length: 26.7/) { die "FAIL: alignment statistics calculated incorrectly on pass $pass2write"; } |
| 84 |
if ($pass == 0) { |
| 85 |
if ($output !~ /Format: Stockholm/) { die "FAIL: alignment statistics calculated incorrectly on pass $pass2write"; } |
| 86 |
if ($output !~ /Average identity: 93\%/) { die "FAIL: alignment statistics calculated incorrectly on pass $pass2write"; } |
| 87 |
} |
| 88 |
else { |
| 89 |
if ($output !~ /Format: Pfam/) { die "FAIL: alignment statistics calculated incorrectly on pass $pass2write"; } |
| 90 |
} |
| 91 |
|
| 92 |
$output = `$eslalistat $smallA[$pass] --dna $tmppfx.stk 2>&1`; |
| 93 |
if ($? != 0) { die "FAIL: esl-alistat failed unexpectedly";} |
| 94 |
if ($output !~ /Alignment length: 38/) { die "FAIL: alignment statistics calculated incorrectly on pass $pass2write"; } |
| 95 |
if ($output !~ /Average length: 26.7/) { die "FAIL: alignment statistics calculated incorrectly on pass $pass2write"; } |
| 96 |
if ($pass == 0) { |
| 97 |
if ($output !~ /Format: Stockholm/) { die "FAIL: alignment statistics calculated incorrectly on pass $pass2write"; } |
| 98 |
if ($output !~ /Average identity: 93\%/) { die "FAIL: alignment statistics calculated incorrectly on pass $pass2write"; } |
| 99 |
} |
| 100 |
else { |
| 101 |
if ($output !~ /Format: Pfam/) { die "FAIL: alignment statistics calculated incorrectly on pass $pass2write"; } |
| 102 |
} |
| 103 |
|
| 104 |
$output = `$eslalistat $smallA[$pass] --amino $tmppfx.stk 2>&1`; |
| 105 |
if ($? != 0) { die "FAIL: esl-alistat failed unexpectedly";} |
| 106 |
if ($output !~ /Alignment length: 38/) { die "FAIL: alignment statistics calculated incorrectly on pass $pass2write"; } |
| 107 |
if ($output !~ /Average length: 26.7/) { die "FAIL: alignment statistics calculated incorrectly on pass $pass2write"; } |
| 108 |
if ($pass == 0) { |
| 109 |
if ($output !~ /Format: Stockholm/) { die "FAIL: alignment statistics calculated incorrectly on pass $pass2write"; } |
| 110 |
if ($output !~ /Average identity: 93\%/) { die "FAIL: alignment statistics calculated incorrectly on pass $pass2write"; } |
| 111 |
} |
| 112 |
else { |
| 113 |
if ($output !~ /Format: Pfam/) { die "FAIL: alignment statistics calculated incorrectly on pass $pass2write"; } |
| 114 |
} |
| 115 |
|
| 116 |
if($pass == 0) { |
| 117 |
$output = `$eslalistat $smallA[$pass] --informat afa --rna $tmppfx.afa 2>&1`; |
| 118 |
if ($? != 0) { die "FAIL: esl-alistat failed unexpectedly";} |
| 119 |
if ($output !~ /Format: aligned FASTA/) { die "FAIL: alignment statistics calculated incorrectly on pass $pass2write"; } |
| 120 |
if ($output !~ /Alignment length: 38/) { die "FAIL: alignment statistics calculated incorrectly on pass $pass2write"; } |
| 121 |
if ($output !~ /Average length: 26.7/) { die "FAIL: alignment statistics calculated incorrectly on pass $pass2write"; } |
| 122 |
if ($output !~ /Average identity: 93\%/) { die "FAIL: alignments compared incorrectly on pass $pass2write"; } |
| 123 |
} |
| 124 |
|
| 125 |
$output = `$eslalistat $smallA[$pass] -1 --rna $tmppfx.stk 2>&1`; |
| 126 |
if ($? != 0) { die "FAIL: esl-alistat failed unexpectedly";} |
| 127 |
if ($pass == 0) { |
| 128 |
if ($output !~ /Stockholm 3 38 80 20 31 26.7 93/) { die "FAIL: alignment statistics calculated incorrectly on pass $pass2write"; } |
| 129 |
} |
| 130 |
else { |
| 131 |
if ($output !~ /Pfam 3 38 80 26.7/) { die "FAIL: alignment statistics calculated incorrectly on pass $pass2write"; } |
| 132 |
} |
| 133 |
|
| 134 |
# test a file with 2 alignments |
| 135 |
$output = `$eslalistat $smallA[$pass] --rna $tmppfx.dbl.stk 2>&1`; |
| 136 |
if ($? != 0) { die "FAIL: esl-alistat failed unexpectedly";} |
| 137 |
if ($output !~ /Alignment length: 38/) { die "FAIL: alignment statistics calculated incorrectly on pass $pass2write"; } |
| 138 |
if ($output !~ /Average length: 26.7/) { die "FAIL: alignment statistics calculated incorrectly on pass $pass2write"; } |
| 139 |
if ($output !~ /Alignment number: 2/) { die "FAIL: alignment statistics calculated incorrectly on pass $pass2write"; } |
| 140 |
if ($output !~ /Average length: 2.0/) { die "FAIL: alignment statistics calculated incorrectly on pass $pass2write"; } |
| 141 |
if ($pass == 0) { |
| 142 |
if ($output !~ /Format: Stockholm/) { die "FAIL: alignment statistics calculated incorrectly on pass $pass2write"; } |
| 143 |
if ($output !~ /Average identity: 93\%/) { die "FAIL: alignment statistics calculated incorrectly on pass $pass2write"; } |
| 144 |
} |
| 145 |
else { |
| 146 |
if ($output !~ /Format: Pfam/) { die "FAIL: alignment statistics calculated incorrectly on pass $pass2write"; } |
| 147 |
} |
| 148 |
|
| 149 |
# test output file options |
| 150 |
system("$eslalistat --icinfo $tmppfx.ic $smallA[$pass] --rna $tmppfx.dbl.stk > /dev/null"); |
| 151 |
if ($? != 0) { die "FAIL: esl-alistat failed unexpectedly";} |
| 152 |
$output = `cat $tmppfx.ic`; |
| 153 |
if($output !~ /5 9 1.0\d+ 2.0\d+/) { die "FAIL: alignment statistics calculated incorrectly on pass $pass2write"; } |
| 154 |
if($output !~ /\# Alignment idx: 2/) { die "FAIL: alignment statistics calculated incorrectly on pass $pass2write"; } |
| 155 |
|
| 156 |
system("$eslalistat --rinfo $tmppfx.r $smallA[$pass] --rna $tmppfx.dbl.stk > /dev/null"); |
| 157 |
if ($? != 0) { die "FAIL: esl-alistat failed unexpectedly";} |
| 158 |
$output = `cat $tmppfx.r`; |
| 159 |
if($output !~ /21 34 2.0 0.66\d+ 1.0 0.33\d+/) { die "FAIL: alignment statistics calculated incorrectly on pass $pass2write"; } |
| 160 |
if($output !~ /\# Alignment idx: 2/) { die "FAIL: alignment statistics calculated incorrectly on pass $pass2write"; } |
| 161 |
|
| 162 |
system("$eslalistat --pcinfo $tmppfx.pc $smallA[$pass] --rna $tmppfx.dbl.stk > /dev/null"); |
| 163 |
if ($? != 0) { die "FAIL: esl-alistat failed unexpectedly";} |
| 164 |
$output = `cat $tmppfx.pc`; |
| 165 |
if($output !~ /31\s+18\s+3.0\s+0.0\s+0.0\s+0.0\s+0.0\s+0.0\s+0.0\s+0.0\s+1.0\s+1.0\s+0.0\s+1.0\s+0.0\s+0.82\d+/) { |
| 166 |
die "FAIL: alignment statistics calculated incorrectly on pass $pass2write"; |
| 167 |
} |
| 168 |
if($output !~ /\# Alignment idx: 2/) { die "FAIL: alignment statistics calculated incorrectly on pass $pass2write"; } |
| 169 |
|
| 170 |
system("$eslalistat --list $tmppfx.list $smallA[$pass] --rna $tmppfx.dbl.stk > /dev/null"); |
| 171 |
if ($? != 0) { die "FAIL: esl-alistat failed unexpectedly";} |
| 172 |
$output = `cat $tmppfx.list`; |
| 173 |
if($output !~ /seq2.+seq2/s) { die "FAIL: alignment lists created incorrectly on pass $pass2write"; } |
| 174 |
if($output !~ /seq3/) { die "FAIL: alignment lists created incorrectly on pass $pass2write"; } |
| 175 |
|
| 176 |
if($pass == 0) { # these are incompatible with --small |
| 177 |
system("$eslalistat --psinfo $tmppfx.ps $smallA[$pass] --rna $tmppfx.dbl.stk > /dev/null"); |
| 178 |
if ($? != 0) { die "FAIL: esl-alistat failed unexpectedly";} |
| 179 |
$output = `cat $tmppfx.ps`; |
| 180 |
if($output !~ /seq3 20 0 0 0 1 3 4 0 0 9 2 1 0.67\d+/) { |
| 181 |
die "FAIL: alignment statistics calculated incorrectly on pass $pass2write"; |
| 182 |
} |
| 183 |
if($output !~ /seq2 1 0 0 0 0 0 0 0 0 0 0 1 0.97\d+/) { |
| 184 |
die "FAIL: alignment statistics calculated incorrectly on pass $pass2write"; |
| 185 |
} |
| 186 |
|
| 187 |
system("$eslalistat --iinfo $tmppfx.i $smallA[$pass] --rna $tmppfx.dbl.stk > /dev/null"); |
| 188 |
if ($? != 0) { die "FAIL: esl-alistat failed unexpectedly";} |
| 189 |
$output = `cat $tmppfx.i`; |
| 190 |
if($output !~ /16\s+1.0\s+0.33\d+\s+2.0/) { die "FAIL: alignment statistics calculated incorrectly on pass $pass2write"; } |
| 191 |
if($output !~ /\# Alignment idx: 2/) { die "FAIL: alignment statistics calculated incorrectly on pass $pass2write"; } |
| 192 |
|
| 193 |
system("$eslalistat --cinfo $tmppfx.c --noambig $smallA[$pass] --rna $tmppfx.dbl.stk > /dev/null"); |
| 194 |
if ($? != 0) { die "FAIL: esl-alistat failed unexpectedly";} |
| 195 |
$output = `cat $tmppfx.c`; |
| 196 |
if($output !~ /3\s+3\.\d+\s+0\.\d+\s+0\.\d+\s+0/) { die "FAIL: alignment statistics calculated incorrectly on pass $pass2write"; } |
| 197 |
if($output !~ /\# Alignment idx: 2/) { die "FAIL: alignment statistics calculated incorrectly on pass $pass2write"; } |
| 198 |
|
| 199 |
system("$eslalistat --bpinfo $tmppfx.bp $smallA[$pass] --rna $tmppfx.dbl.stk > /dev/null"); |
| 200 |
if ($? != 0) { die "FAIL: esl-alistat failed unexpectedly";} |
| 201 |
$output = `cat $tmppfx.bp`; |
| 202 |
if($output !~ /16\s+34\s+0\s+0\s+0\s+0\s+0\s+0\s+2\s+0\s+0\s+0\s+0\s+0\s+0\s+0\s+0\s+0\s+/) { die "FAIL: alignment statistics calculated incorrectly on pass $pass2write"; } |
| 203 |
if($output !~ /\# Alignment idx: 2/) { die "FAIL: alignment statistics calculated incorrectly on pass $pass2write"; } |
| 204 |
|
| 205 |
system("$eslalistat --weight --cinfo $tmppfx.c $smallA[$pass] --rna $tmppfx.dbl.stk > /dev/null"); |
| 206 |
if ($? != 0) { die "FAIL: esl-alistat failed unexpectedly";} |
| 207 |
$output = `cat $tmppfx.c`; |
| 208 |
if($output !~ /2\s+1\.5\s+0\.\d+\s+0\.\d+\s+0/) { die "FAIL: alignment statistics calculated incorrectly on pass $pass2write"; } |
| 209 |
if($output !~ /\# Alignment idx: 2/) { die "FAIL: alignment statistics calculated incorrectly on pass $pass2write"; } |
| 210 |
} |
| 211 |
|
| 212 |
system("$eslalistat --cinfo $tmppfx.c $smallA[$pass] --rna $tmppfx.dbl.stk > /dev/null"); |
| 213 |
if ($? != 0) { die "FAIL: esl-alistat failed unexpectedly";} |
| 214 |
$output = `cat $tmppfx.c`; |
| 215 |
if($output !~ /3\s+3\.\d+\s+0\.\d+\s+0\.\d+\s+0/) { die "FAIL: alignment statistics calculated incorrectly on pass $pass2write"; } |
| 216 |
if($output !~ /\# Alignment idx: 2/) { die "FAIL: alignment statistics calculated incorrectly on pass $pass2write"; } |
| 217 |
|
| 218 |
} |
| 219 |
|
| 220 |
|
| 221 |
print "ok\n"; |
| 222 |
unlink "$tmppfx.stk"; |
| 223 |
unlink "$tmppfx.afa"; |
| 224 |
unlink "$tmppfx.dbl.stk"; |
| 225 |
unlink "$tmppfx.i"; |
| 226 |
unlink "$tmppfx.ic"; |
| 227 |
unlink "$tmppfx.list"; |
| 228 |
unlink "$tmppfx.pc"; |
| 229 |
unlink "$tmppfx.ps"; |
| 230 |
unlink "$tmppfx.r"; |
| 231 |
unlink "$tmppfx.c"; |
| 232 |
unlink "$tmppfx.bp"; |
| 233 |
exit 0; |