Debian Codegraph @

hmmer/easel/miniapps/esl-alimerge.itest.pl

raw
1 #! /usr/bin/perl
2
3 # Integrated test of esl-alimerge miniapp.
4 #
5 # Usage: ./esl-alimerge.itest.pl <esl-alimerge binary> <tmpfile prefix>
6 # Example: ./esl-alimerge.itest.pl ./esl-alimerge foo
7 #
8 # EPN, Wed Nov 25 11:23:55 2009
9
10 $eslalimerge = shift;
11 $tmppfx = shift;
12
13 if (! -x "$eslalimerge") { die "FAIL: didn't find esl-alimerge binary $eslalimerge"; }
14
15 open(ALIFILE, ">$tmppfx.1") || die "FAIL: couldn't open $tmppfx.1 for writing alifile";
16 print ALIFILE << "EOF";
17 # STOCKHOLM 1.0
18 seq1 aaAAAA.AAAA...Cc.cCCCCCC.C..GGGGGgggg
19 seq2 ..AAAAaAAAAaacCcccCCCCCCcCccGGGGG....
20 #=GC RF ..AAAA.AAAA...C...CCCCCC.c..GGGGG....
21 //
22 EOF
23 close ALIFILE;
24
25 open(ALIFILE, ">$tmppfx.2") || die "FAIL: couldn't open $tmppfx.2 for writing alifile";
26 print ALIFILE << "EOF";
27 # STOCKHOLM 1.0
28 #=GS seq3 DE sequence 3 is the best!
29 seq3 AAAAA..AAA.....CCC..CCCC....c..G..GG..GG.
30 seq4 AAAAAaaAAAaccccC-CccCCCCccccccgGggGGggGGg
31 #=GC RF AAAAA..AAA.....CCC..CCCC~...c..G..GG..GG.
32 //
33 EOF
34 close ALIFILE;
35
36 open(ALIFILE, ">$tmppfx.3") || die "FAIL: couldn't open $tmppfx.3 for writing alifile";
37 print ALIFILE << "EOF";
38 # STOCKHOLM 1.0
39 #=GS seq5 DE kachow
40 seq5 AAAAA..AAA.....CCC..CCCC....c..G..GG..GG.
41 seq6 AAAAAaaAAAaccccC-CccCCCCccccccgGggGGggGGg
42 #=GC RF AAAAA..AAA.....CCC..CCCC~~..c..G..GG..GG.
43 //
44 EOF
45 close ALIFILE;
46
47 open(ALIFILE, ">$tmppfx.4") || die "FAIL: couldn't open $tmppfx.4 for writing alifile";
48 print ALIFILE << "EOF";
49 # STOCKHOLM 1.0
50 #=GS seq5 DE kachow
51 seq5 ~~~AAAAA..AAA.....CCC..CCCC....c..G..GG..GG~~~~
52 seq6 ...AAAAAaaAAAaccccC-CccCCCCccccccgGggGGggGGgggg
53 #=GC RF ...AAAAA..AAA.....CCC..CCCC~~..c..G..GG..GG....
54 //
55 EOF
56 close ALIFILE;
57
58 open(ALIFILE, ">$tmppfx.5") || die "FAIL: couldn't open $tmppfx.5 for writing alifile";
59 print ALIFILE << "EOF";
60 # STOCKHOLM 1.0
61 seq7 ~CAAAA..AAA.....CCC..CCCC....c..G..GG..GC~
62 seq8 .CAAAAaaAAAaccccC-CccCCCCccccccgGggGGggGGg
63 #=GC RF .AAAAA..AAA.....CCC..CCCC~~..c..G..GG..GG.
64 //
65 EOF
66 close ALIFILE;
67
68 # $tmppfx.6 and $tmppfx.7 tests that SS_cons only gets transferred if
69 # both alignments follow rule that all RF gaps are also gaps in
70 # SS_cons, this is crucial for merging, otherwise resulting SS_cons in
71 # merged alignment could be order-dependent.
72 open(ALIFILE, ">$tmppfx.6") || die "FAIL: couldn't open $tmppfx.6 for writing alifile";
73 print ALIFILE << "EOF";
74 # STOCKHOLM 1.0
75 seq7 CAAAAAAACCCCCCC.cGGGGC
76 #=GC RF AAAAAAAACCCCCCC.cGGGGG
77 #=GC SS_cons :::::::::::<<<<:<>>>>>
78 //
79 EOF
80 close ALIFILE;
81
82 open(ALIFILE, ">$tmppfx.7") || die "FAIL: couldn't open $tmppfx.7 for writing alifile";
83 print ALIFILE << "EOF";
84 # STOCKHOLM 1.0
85 seq8 .CAAAAaaAAAaccccC-CccCCCCccccccgGggGGggGGg
86 #=GC RF .AAAAA..AAA.....CCC..CCCC....c..G..GG..GG.
87 #=GC SS_cons .:::::..:::..........<<<<....<..>..>>..>>.
88 //
89 EOF
90 close ALIFILE;
91
92 open(LISTFILE, ">$tmppfx.list") || die "FAIL: couldn't open $tmppfx.list for writing list file";
93 print LISTFILE "$tmppfx.2\n";
94 print LISTFILE "$tmppfx.1\n";
95 print LISTFILE "$tmppfx.3\n";
96 close LISTFILE;
97
98 $output = `$eslalimerge -h`;
99 if ($? != 0) { die "FAIL: esl-alimerge failed unexpectedly"; }
100 if ($output !~ /Usage: esl-alimerge/) { die "FAIL: help output not right"; }
101
102 $output = `$eslalimerge --rna $tmppfx.1 $tmppfx.2 2>&1`;
103 if ($? != 0) { die "FAIL: esl-alimerge failed unexpectedly"; }
104 if ($output !~ /sequence 3 is the best/) { die "FAIL: alignments merged incorrectly"; }
105 if ($output !~ /aaAAAA\.A\.\.AAA\.\.\.\.\.Cc\.cCC\.\.CCCC\.\.\.\.C\.\.G\.\.GG\.\.GGgggg/) { die "FAIL: alignments merged incorrectly"; }
106 if ($output !~ /\.\.AAAA\.AaaAAAaccccC\.\.\.\-CccCCCCccccccgGggGGggGGg\.\.\./) { die "FAIL: alignments merged incorrectly"; }
107
108 $output = `$eslalimerge --dna $tmppfx.1 $tmppfx.2 2>&1`;
109 if ($? != 0) { die "FAIL: esl-alimerge failed unexpectedly"; }
110 if ($output !~ /sequence 3 is the best/) { die "FAIL: alignments merged incorrectly"; }
111 if ($output !~ /aaAAAA\.A\.\.AAA\.\.\.\.\.Cc\.cCC\.\.CCCC\.\.\.\.C\.\.G\.\.GG\.\.GGgggg/) { die "FAIL: alignments merged incorrectly"; }
112 if ($output !~ /\.\.AAAA\.AaaAAAaccccC\.\.\.\-CccCCCCccccccgGggGGggGGg\.\.\./) { die "FAIL: alignments merged incorrectly"; }
113
114 $output = `$eslalimerge --amino $tmppfx.1 $tmppfx.2 2>&1`;
115 if ($? != 0) { die "FAIL: esl-alimerge failed unexpectedly"; }
116 if ($output !~ /sequence 3 is the best/) { die "FAIL: alignments merged incorrectly"; }
117 if ($output !~ /aaAAAA\.A\.\.AAA\.\.\.\.\.Cc\.cCC\.\.CCCC\.\.\.\.C\.\.G\.\.GG\.\.GGgggg/) { die "FAIL: alignments merged incorrectly"; }
118 if ($output !~ /\.\.AAAA\.AaaAAAaccccC\.\.\.\-CccCCCCccccccgGggGGggGGg\.\.\./) { die "FAIL: alignments merged incorrectly"; }
119
120 $output = `$eslalimerge --rna --list $tmppfx.list 2>&1`;
121 if ($? != 0) { die "FAIL: esl-alimerge failed unexpectedly"; }
122 if ($output !~ /sequence 3 is the best/) { die "FAIL: alignments merged incorrectly"; }
123 if ($output !~ /aaAAAA\.A\.\.AAA\.\.\.\.\.Cc\.cCC\.\.CCCC\.\.\.\.\.C\.\.G\.\.GG\.\.GGgggg/) { die "FAIL: alignments merged incorrectly"; }
124 if ($output !~ /\.\.AAAA\.AaaAAAaccccC\.\.\.\-CccCCCCccc\.cccgGggGGggGGg\.\.\./) { die "FAIL: alignments merged incorrectly"; }
125 system("$eslalimerge --rna -o $tmppfx.out $tmppfx.1 $tmppfx.2 > /dev/null");
126 if ($? != 0) { die "FAIL: esl-alimerge failed unexpectedly"; }
127 $output = `cat $tmppfx.out`;
128 if ($output !~ /sequence 3 is the best/) { die "FAIL: alignments merged incorrectly"; }
129 if ($output !~ /aaAAAA\.A\.\.AAA\.\.\.\.\.Cc\.cCC\.\.CCCC\.\.\.\.C\.\.G\.\.GG\.\.GGgggg/) { die "FAIL: alignments merged incorrectly"; }
130 if ($output !~ /\.\.AAAA\.AaaAAAaccccC\.\.\.\-CccCCCCccccccgGggGGggGGg\.\.\./) { die "FAIL: alignments merged incorrectly"; }
131
132 system("$eslalimerge --rna -v -o $tmppfx.out $tmppfx.1 $tmppfx.2 > /dev/null");
133 if ($? != 0) { die "FAIL: esl-alimerge failed unexpectedly"; }
134 # don't worry about checking verbose output printed to stdout
135 $output = `cat $tmppfx.out`;
136 if ($output !~ /sequence 3 is the best/) { die "FAIL: alignments merged incorrectly"; }
137 if ($output !~ /aaAAAA\.A\.\.AAA\.\.\.\.\.Cc\.cCC\.\.CCCC\.\.\.\.C\.\.G\.\.GG\.\.GGgggg/) { die "FAIL: alignments merged incorrectly"; }
138 if ($output !~ /\.\.AAAA\.AaaAAAaccccC\.\.\.\-CccCCCCccccccgGggGGggGGg\.\.\./) { die "FAIL: alignments merged incorrectly"; }
139 $output = `cat $tmppfx.out`;
140
141 $output = `$eslalimerge --rna --outformat pfam $tmppfx.1 $tmppfx.2 2>&1`;
142 if ($? != 0) { die "FAIL: esl-alimerge failed unexpectedly"; }
143 if ($output !~ /sequence 3 is the best/) { die "FAIL: alignments merged incorrectly"; }
144 if ($output !~ /aaAAAA\.A\.\.AAA\.\.\.\.\.Cc\.cCC\.\.CCCC\.\.\.\.C\.\.G\.\.GG\.\.GGgggg/) { die "FAIL: alignments merged incorrectly"; }
145 if ($output !~ /\.\.AAAA\.AaaAAAaccccC\.\.\.\-CccCCCCccccccgGggGGggGGg\.\.\./) { die "FAIL: alignments merged incorrectly"; }
146
147 $output = `$eslalimerge --rna --outformat a2m $tmppfx.1 $tmppfx.2 2>&1`;
148 if ($? != 0) { die "FAIL: esl-alimerge failed unexpectedly"; }
149 if ($output !~ /aaAAAAAAAACccCCCCCCCGGGGGgggg/) { die "FAIL: alignments merged incorrectly"; }
150 if ($output !~ /AAAAAaaAAAaccccC-CccCCCCccccCcgGggGGggGGg/) { die "FAIL: alignments merged incorrectly"; }
151
152 $output = `$eslalimerge --rna --outformat psiblast $tmppfx.1 $tmppfx.2 2>&1`;
153 if ($? != 0) { die "FAIL: esl-alimerge failed unexpectedly"; }
154 if ($output !~ /aaAAAA-A--AAA-----Cc-cCC--CCCC----C--G--GG--GGgggg/) { die "FAIL: alignments merged incorrectly"; }
155 if ($output !~ /--AAAA-AaaAAAaccccC----CccCCCCccccCcgGggGGggGGg---/) { die "FAIL: alignments merged incorrectly"; }
156
157 $output = `$eslalimerge --rna --outformat afa $tmppfx.1 $tmppfx.2 2>&1`;
158 if ($? != 0) { die "FAIL: esl-alimerge failed unexpectedly"; }
159 if ($output !~ /aaAAAA\.A\.\.AAA\.\.\.\.\.Cc\.cCC\.\.CCCC\.\.\.\.C\.\.G\.\.GG\.\.GGgggg/) { die "FAIL: alignments merged incorrectly"; }
160 if ($output !~ /\.\.AAAA\.AaaAAAaccccC\.\.\.\-CccCCCCccccccgGggGGggGGg\.\.\./) { die "FAIL: alignments merged incorrectly"; }
161
162 $output = `$eslalimerge --rna --rfonly $tmppfx.1 $tmppfx.2 2>&1`;
163 if ($? != 0) { die "FAIL: esl-alimerge failed unexpectedly"; }
164 if ($output !~ /sequence 3 is the best/) { die "FAIL: alignments merged incorrectly"; }
165 if ($output !~ /AAAAAAAACCCCCCCCGGGGG/) { die "FAIL: alignments merged incorrectly"; }
166 if ($output !~ /AAAAAAAAC\-CCCCCcGGGGG/) { die "FAIL: alignments merged incorrectly"; }
167
168 # test that hmmer3 fragment annotation is correctly handled (this WILL NOT WORK currently with --small!)
169 $output = `$eslalimerge --rna $tmppfx.4 $tmppfx.5 2>&1`;
170 if ($? != 0) { die "FAIL: esl-alimerge failed unexpectedly"; }
171 if ($output !~ /~~~CAAAA..AAA.....CCC..CCCC....c..G..GG..GC~~~/) { die "FAIL: alignments merged incorrectly"; }
172
173 # repeat all the same tests (except a2m and psiblast output) but now in small memory mode
174 $output = `$eslalimerge --small --rna $tmppfx.1 $tmppfx.2 2>&1`;
175 if ($? != 0) { die "FAIL: esl-alimerge failed unexpectedly"; }
176 if ($output !~ /sequence 3 is the best/) { die "FAIL: alignments merged incorrectly"; }
177 if ($output !~ /aaAAAA\.A\.\.AAA\.\.\.\.\.Cc\.cCC\.\.CCCC\.\.\.\.C\.\.G\.\.GG\.\.GGgggg/) { die "FAIL: alignments merged incorrectly"; }
178 if ($output !~ /\.\.AAAA\.AaaAAAaccccC\.\.\.\-CccCCCCccccccgGggGGggGGg\.\.\./) { die "FAIL: alignments merged incorrectly"; }
179
180 $output = `$eslalimerge --small --dna $tmppfx.1 $tmppfx.2 2>&1`;
181 if ($? != 0) { die "FAIL: esl-alimerge failed unexpectedly"; }
182 if ($output !~ /sequence 3 is the best/) { die "FAIL: alignments merged incorrectly"; }
183 if ($output !~ /aaAAAA\.A\.\.AAA\.\.\.\.\.Cc\.cCC\.\.CCCC\.\.\.\.C\.\.G\.\.GG\.\.GGgggg/) { die "FAIL: alignments merged incorrectly"; }
184 if ($output !~ /\.\.AAAA\.AaaAAAaccccC\.\.\.\-CccCCCCccccccgGggGGggGGg\.\.\./) { die "FAIL: alignments merged incorrectly"; }
185
186 $output = `$eslalimerge --small --amino $tmppfx.1 $tmppfx.2 2>&1`;
187 if ($? != 0) { die "FAIL: esl-alimerge failed unexpectedly"; }
188 if ($output !~ /sequence 3 is the best/) { die "FAIL: alignments merged incorrectly"; }
189 if ($output !~ /aaAAAA\.A\.\.AAA\.\.\.\.\.Cc\.cCC\.\.CCCC\.\.\.\.C\.\.G\.\.GG\.\.GGgggg/) { die "FAIL: alignments merged incorrectly"; }
190 if ($output !~ /\.\.AAAA\.AaaAAAaccccC\.\.\.\-CccCCCCccccccgGggGGggGGg\.\.\./) { die "FAIL: alignments merged incorrectly"; }
191
192 $output = `$eslalimerge --small --rna --list $tmppfx.list 2>&1`;
193 if ($? != 0) { die "FAIL: esl-alimerge failed unexpectedly"; }
194 if ($output !~ /sequence 3 is the best/) { die "FAIL: alignments merged incorrectly"; }
195 if ($output !~ /aaAAAA\.A\.\.AAA\.\.\.\.\.Cc\.cCC\.\.CCCC\.\.\.\.\.C\.\.G\.\.GG\.\.GGgggg/) { die "FAIL: alignments merged incorrectly"; }
196 if ($output !~ /\.\.AAAA\.AaaAAAaccccC\.\.\.\-CccCCCCccc\.cccgGggGGggGGg\.\.\./) { die "FAIL: alignments merged incorrectly"; }
197
198 system("$eslalimerge --small --rna -o $tmppfx.out $tmppfx.1 $tmppfx.2 > /dev/null");
199 if ($? != 0) { die "FAIL: esl-alimerge failed unexpectedly"; }
200 $output = `cat $tmppfx.out`;
201 if ($output !~ /sequence 3 is the best/) { die "FAIL: alignments merged incorrectly"; }
202 if ($output !~ /aaAAAA\.A\.\.AAA\.\.\.\.\.Cc\.cCC\.\.CCCC\.\.\.\.C\.\.G\.\.GG\.\.GGgggg/) { die "FAIL: alignments merged incorrectly"; }
203 if ($output !~ /\.\.AAAA\.AaaAAAaccccC\.\.\.\-CccCCCCccccccgGggGGggGGg\.\.\./) { die "FAIL: alignments merged incorrectly"; }
204
205 system("$eslalimerge --small --rna -v -o $tmppfx.out $tmppfx.1 $tmppfx.2 > /dev/null");
206 if ($? != 0) { die "FAIL: esl-alimerge failed unexpectedly"; }
207 # don't worry about checking verbose output printed to stdout
208 $output = `cat $tmppfx.out`;
209 if ($output !~ /sequence 3 is the best/) { die "FAIL: alignments merged incorrectly"; }
210 if ($output !~ /aaAAAA\.A\.\.AAA\.\.\.\.\.Cc\.cCC\.\.CCCC\.\.\.\.C\.\.G\.\.GG\.\.GGgggg/) { die "FAIL: alignments merged incorrectly"; }
211 if ($output !~ /\.\.AAAA\.AaaAAAaccccC\.\.\.\-CccCCCCccccccgGggGGggGGg\.\.\./) { die "FAIL: alignments merged incorrectly"; }
212 $output = `cat $tmppfx.out`;
213
214 $output = `$eslalimerge --small --rna --outformat pfam $tmppfx.1 $tmppfx.2 2>&1`;
215 if ($? != 0) { die "FAIL: esl-alimerge failed unexpectedly"; }
216 if ($output !~ /sequence 3 is the best/) { die "FAIL: alignments merged incorrectly"; }
217 if ($output !~ /aaAAAA\.A\.\.AAA\.\.\.\.\.Cc\.cCC\.\.CCCC\.\.\.\.C\.\.G\.\.GG\.\.GGgggg/) { die "FAIL: alignments merged incorrectly"; }
218 if ($output !~ /\.\.AAAA\.AaaAAAaccccC\.\.\.\-CccCCCCccccccgGggGGggGGg\.\.\./) { die "FAIL: alignments merged incorrectly"; }
219
220 $output = `$eslalimerge --small --rna --rfonly $tmppfx.1 $tmppfx.2 2>&1`;
221 if ($? != 0) { die "FAIL: esl-alimerge failed unexpectedly"; }
222 if ($output !~ /sequence 3 is the best/) { die "FAIL: alignments merged incorrectly"; }
223 if ($output !~ /AAAAAAAACCCCCCCCGGGGG/) { die "FAIL: alignments merged incorrectly"; }
224 if ($output !~ /AAAAAAAAC\-CCCCCcGGGGG/) { die "FAIL: alignments merged incorrectly"; }
225
226 # test that versions 0.48 and earlier failed this by keeping SS_cons
227 $output = `$eslalimerge $tmppfx.6 $tmppfx.7 2>&1`;
228 if ($? != 0) { die "FAIL: esl-alimerge failed unexpectedly"; }
229 if ($output =~ /SS_cons/) { die "FAIL: SS_cons included unexpectedly"; }
230
231 $output = `$eslalimerge $tmppfx.7 $tmppfx.6 2>&1`;
232 if ($? != 0) { die "FAIL: esl-alimerge failed unexpectedly"; }
233 if ($output =~ /SS_cons/) { die "FAIL: SS_cons included unexpectedly"; }
234
235
236 print "ok\n";
237 unlink "$tmppfx.1";
238 unlink "$tmppfx.2";
239 unlink "$tmppfx.3";
240 unlink "$tmppfx.4";
241 unlink "$tmppfx.5";
242 unlink "$tmppfx.6";
243 unlink "$tmppfx.7";
244 unlink "$tmppfx.list";
245 unlink "$tmppfx.out";
246 exit 0;