Debian Codegraph @

easel/miniapps/esl-alimask.itest.pl

raw
1 #! /usr/bin/perl
2
3 # Integrated test of esl-alimask miniapp.
4 #
5 # Usage: ./esl-alimask.itest.pl <esl-alimask binary> <tmpfile prefix>
6 # Example: ./esl-alimask.itest.pl ./esl-alimask foo
7 #
8 # EPN, Wed Nov 25 11:23:55 2009
9
10 $eslalimask = shift;
11 $tmppfx = shift;
12
13 if (! -x "$eslalimask") { die "FAIL: didn't find esl-alimask binary $eslalimask"; }
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
19 seq1 aaAAAA..AAAA...Cc.cCCCCCC.C..GGGGGgggg
20 #=GR seq1 PP 5789**..**88...*9.9****88.7..776543210
21 seq2 ..AAAAa.AAAAaacCcccCCCCCCcCccGGGGG....
22 #=GR seq2 PP ..********************************....
23 seq3 ..AAAA..AAAA...C...CCCCCC.C..GGGG-....
24 #=GR seq3 PP ..5555..4*44...3...888888.8..8899.....
25 #=GC SS_cons ...............<...<<<<......>>>>>....
26 #=GC PP_cons ..789*..8877...8...****99.8..99998....
27 #=GC RF ..AAAA..AAAA...C...CCCCCC.c..GGGGG....
28 //
29 EOF
30 close ALIFILE;
31
32 open(NORFALIFILE, ">$tmppfx.norf.stk") || die "FAIL: couldn't open $tmppfx.stk for writing no RF alifile";
33 print NORFALIFILE << "EOF";
34 # STOCKHOLM 1.0
35
36 seq1 aaAAAA..AAAA...Cc.cCCCCCC.C..GGGGGgggg
37 #=GR seq1 PP 5789**..**88...*9.9****88.7..776543210
38 seq2 ..AAAAa.AAAAaacCcccCCCCCCcCccGGGGG....
39 #=GR seq2 PP ..********************************....
40 seq3 ..AAAA..AAAA...C...CCCCCC.C..GGGG-....
41 #=GR seq3 PP ..5555..4*44...3...888888.8..8899.....
42 //
43 EOF
44 close NORFALIFILE;
45
46 open(FULLMASKFILE, ">$tmppfx.fullmask") || die "FAIL: couldn't open $tmppfx.2 for writing full maskfile";
47 print FULLMASKFILE << "EOF";
48 #this is a full aln length mask file
49 1010111011
50 1110101101
51 #in the middle
52 1101101111
53 01101010
54 EOF
55 close FULLMASKFILE;
56
57 open(RFMASKFILE, ">$tmppfx.rfmask") || die "FAIL: couldn't open $tmppfx.rfmask for writing RF maskfile";
58 print RFMASKFILE << "EOF";
59 #this is an RF length mask file
60 001110101110110111101
61 EOF
62 close RFMASKFILE;
63
64 # Note: Not nearly all possible option combinations are tried, but each option is tested
65 # in at least one context, usually what I think to be the most common context.
66 #
67 # We do 4 runs of all tests, each pairwise combination of with and without RF annotation
68 # in alifile and with and without --small.
69
70 $afileA[0] = "$tmppfx.stk";
71 $afileA[1] = "$tmppfx.stk";
72 $afileA[2] = "$tmppfx.norf.stk";
73 $afileA[3] = "$tmppfx.norf.stk";
74
75 $smallA[0] = "";
76 $smallA[1] = "--small";
77 $smallA[2] = "";
78 $smallA[3] = "--small";
79
80 $have_rfA[0] = 1;
81 $have_rfA[1] = 1;
82 $have_rfA[2] = 0;
83 $have_rfA[3] = 0;
84
85 $output = `$eslalimask -h`;
86 if ($? != 0) { die "FAIL: esl-alimask failed unexpectedly"; }
87 if ($output !~ /Usage: esl-alimask/) { die "FAIL: help output not right"; }
88
89 for($pass = 0; $pass < 4; $pass++) {
90 $pass2write = $pass+1;
91
92 $output = `$eslalimask $smallA[$pass] --rna $afileA[$pass] $tmppfx.fullmask 2>&1`;
93 if ($? != 0) { die "FAIL: esl-alimask failed unexpectedly on pass $pass2write"; }
94 if ($output !~ /aAAA\.AAAA\.\.c\.CCCCCC\.\.GGGgg/) { die "FAIL: alignment masked incorrectly on pass $pass2write"; }
95 if ($output !~ /\.555\.4\*44\.\.\.\.888888\.\.899\.\./) { die "FAIL: alignment masked incorrectly on pass $pass2write"; }
96 if ($have_rfA[$pass]) {
97 if ($output !~ /:::::::::::::<<_______>>::/) { die "FAIL: alignment masked incorrectly on pass $pass2write"; }
98 }
99
100 if($have_rfA[$pass]) {
101 $output = `$eslalimask $smallA[$pass] --dna $afileA[$pass] $tmppfx.rfmask 2>&1`;
102 if ($? != 0) { die "FAIL: esl-alimask failed unexpectedly on pass $pass2write"; }
103 if ($output !~ /AAAACCCCCCGGGG/) { die "FAIL: alignment masked incorrectly"; }
104 if ($output !~ /5544388888889\./) { die "FAIL: alignment masked incorrectly"; }
105 if ($output !~ /::::<\-<<__>\->>/) { die "FAIL: alignment masked incorrectly"; }
106 }
107 system("$eslalimask $smallA[$pass] --amino -o $tmppfx.out $afileA[$pass] $tmppfx.fullmask > /dev/null");
108 $output = `cat $tmppfx.out`;
109 if ($? != 0) { die "FAIL: esl-alimask failed unexpectedly on pass $pass2write"; }
110 if ($output !~ /aAAA\.AAAA\.\.c\.CCCCCC\.\.GGGgg/) { die "FAIL: alignment masked incorrectly on pass $pass2write"; }
111 if ($output !~ /\.555\.4\*44\.\.\.\.888888\.\.899\.\./) { die "FAIL: alignment masked incorrectly on pass $pass2write"; }
112 if ($have_rfA[$pass]) {
113 if ($output !~ /.............<<<.....>>>../) { die "FAIL: alignment masked incorrectly on pass $pass2write"; }
114 }
115
116 system("$eslalimask $smallA[$pass] --rna -q -o $tmppfx.out $afileA[$pass] $tmppfx.fullmask > /dev/null");
117 $output = `cat $tmppfx.out`;
118 if ($? != 0) { die "FAIL: esl-alimask failed unexpectedly on pass $pass2write"; }
119 if ($output !~ /aAAA\.AAAA\.\.c\.CCCCCC\.\.GGGgg/) { die "FAIL: alignment masked incorrectly on pass $pass2write"; }
120 if ($output !~ /\.555\.4\*44\.\.\.\.888888\.\.899\.\./) { die "FAIL: alignment masked incorrectly on pass $pass2write"; }
121 if ($have_rfA[$pass]) {
122 if ($output !~ /:::::::::::::<<_______>>::/) { die "FAIL: alignment masked incorrectly on pass $pass2write"; }
123 }
124
125 $output = `$eslalimask $smallA[$pass] --amino --informat pfam $afileA[$pass] $tmppfx.fullmask 2>&1`;
126 if ($? != 0) { die "FAIL: esl-alimask failed unexpectedly on pass $pass2write"; }
127 if ($output !~ /aAAA\.AAAA\.\.c\.CCCCCC\.\.GGGgg/) { die "FAIL: alignment masked incorrectly on pass $pass2write"; }
128 if ($output !~ /\.555\.4\*44\.\.\.\.888888\.\.899\.\./) { die "FAIL: alignment masked incorrectly on pass $pass2write"; }
129 if ($have_rfA[$pass]) {
130 if ($output !~ /.............<<<.....>>>../) { die "FAIL: alignment masked incorrectly on pass $pass2write"; }
131 }
132
133 $output = `$eslalimask $smallA[$pass] --rna --outformat pfam $afileA[$pass] $tmppfx.fullmask 2>&1`;
134 if ($? != 0) { die "FAIL: esl-alimask failed unexpectedly on pass $pass2write"; }
135 if ($output !~ /aAAA\.AAAA\.\.c\.CCCCCC\.\.GGGgg/) { die "FAIL: alignment masked incorrectly on pass $pass2write"; }
136 if ($output !~ /\.555\.4\*44\.\.\.\.888888\.\.899\.\./) { die "FAIL: alignment masked incorrectly on pass $pass2write"; }
137 if ($have_rfA[$pass]) {
138 if ($output !~ /:::::::::::::<<_______>>::/) { die "FAIL: alignment masked incorrectly on pass $pass2write"; }
139 }
140
141 if($smallA[$pass] eq "") {
142 $output = `$eslalimask $smallA[$pass] --rna --outformat a2m $afileA[$pass] $tmppfx.fullmask 2>&1`;
143 if ($? != 0) { die "FAIL: esl-alimask failed unexpectedly on pass $pass2write"; }
144 if($have_rfA[$pass]) {
145 if ($output !~ /aAAAAAAAcCCCCCCGGGgg/) { die "FAIL: alignment masked incorrectly on pass $pass2write"; }
146 }
147 else {
148 if ($output !~ /AAAAAAAACCCCCCCGGGGG/) { die "FAIL: alignment masked incorrectly on pass $pass2write"; }
149 }
150
151 $output = `$eslalimask $smallA[$pass] --rna --outformat psiblast $afileA[$pass] $tmppfx.fullmask 2>&1`;
152 if ($? != 0) { die "FAIL: esl-alimask failed unexpectedly on pass $pass2write"; }
153 if($have_rfA[$pass]) {
154 if ($output !~ /aAAA\-AAAA\-\-c\-CCCCCC\-\-GGGgg/) { die "FAIL: alignment masked incorrectly on pass $pass2write"; }
155 }
156 else {
157 if ($output !~ /AAAA\-AAAA\-\-C\-CCCCCC\-\-GGGGG/) { die "FAIL: alignment masked incorrectly on pass $pass2write"; }
158 }
159
160 $output = `$eslalimask $smallA[$pass] --rna --outformat afa $afileA[$pass] $tmppfx.fullmask 2>&1`;
161 if ($? != 0) { die "FAIL: esl-alimask failed unexpectedly on pass $pass2write"; }
162 if ($output !~ /aAAA\.AAAA\.\.c\.CCCCCC\.\.GGGgg/) { die "FAIL: alignment masked incorrectly on pass $pass2write"; }
163 }
164
165 $output = `$eslalimask $smallA[$pass] --rna -t $afileA[$pass] 12-23 2>&1`;
166 if ($? != 0) { die "FAIL: esl-alimask failed unexpectedly on pass $pass2write"; }
167 if ($output !~ /A\.\.\.Cc\.cCCCC/) { die "FAIL: alignment masked incorrectly on pass $pass2write"; }
168 if ($output !~ /4\.\.\.3\.\.\.8888/) { die "FAIL: alignment masked incorrectly on pass $pass2write"; }
169 if ($have_rfA[$pass]) {
170 if ($output !~ /\s+::::::::::::\s+/) { die "FAIL: alignment masked incorrectly on pass $pass2write"; }
171 }
172
173 if ($have_rfA[$pass]) {
174 $output = `$eslalimask $smallA[$pass] --rna -t --t-rf $afileA[$pass] 18: 2>&1`;
175 if ($? != 0) { die "FAIL: esl-alimask failed unexpectedly on pass $pass2write"; }
176 if ($output !~ /GGGGgggg/) { die "FAIL: alignment masked incorrectly on pass $pass2write"; }
177 if ($output !~ /76543210/) { die "FAIL: alignment masked incorrectly on pass $pass2write"; }
178 if ($output !~ /\s+::::::::\s+/) { die "FAIL: alignment masked incorrectly on pass $pass2write"; }
179 }
180
181 if ($have_rfA[$pass]) {
182 $output = `$eslalimask $smallA[$pass] --rna -t --t-rmins --t-rf $afileA[$pass] 18: 2>&1`;
183 if ($? != 0) { die "FAIL: esl-alimask failed unexpectedly on pass $pass2write"; }
184 if ($output !~ /GGGG/) { die "FAIL: alignment masked incorrectly on pass $pass2write"; }
185 if ($output !~ /7654/) { die "FAIL: alignment masked incorrectly on pass $pass2write"; }
186 if ($output !~ /\s+::::\s+/) { die "FAIL: alignment masked incorrectly on pass $pass2write"; }
187 }
188
189 if ($have_rfA[$pass]) {
190 $output = `$eslalimask $smallA[$pass] --rna -t --t-rmins --t-rf $afileA[$pass] 18: 2>&1`;
191 if ($? != 0) { die "FAIL: esl-alimask failed unexpectedly on pass $pass2write"; }
192 if ($output !~ /GGGG/) { die "FAIL: alignment masked incorrectly on pass $pass2write"; }
193 if ($output !~ /7654/) { die "FAIL: alignment masked incorrectly on pass $pass2write"; }
194 if ($output !~ /\s+::::\s+/) { die "FAIL: alignment masked incorrectly on pass $pass2write"; }
195 }
196
197 $output = `$eslalimask $smallA[$pass] --rna -g $afileA[$pass] 2>&1`;
198 if ($? != 0) { die "FAIL: esl-alimask failed unexpectedly on pass $pass2write"; }
199 if ($have_rfA[$pass]) {
200 if ($output !~ /AAAAAAAACCCCCCCCGGGGG/) { die "FAIL: alignment masked incorrectly on pass $pass2write"; }
201 if ($output !~ /55554\*44388888888899\./) { die "FAIL: alignment masked incorrectly on pass $pass2write"; }
202 if ($output !~ /::::::::<<<<<___>>>>>/) { die "FAIL: alignment masked incorrectly on pass $pass2write"; }
203 }
204 else {
205 if ($output !~ /AAAAAAAAC\.\.CCCCCCCGGGG\-/) { die "FAIL: alignment masked incorrectly on pass $pass2write"; }
206 if ($output !~ /55554\*443\.\.88888888899\./) { die "FAIL: alignment masked incorrectly on pass $pass2write"; }
207 }
208
209 if ($have_rfA[$pass]) {
210 $output = `$eslalimask $smallA[$pass] --rna -g --keepins $afileA[$pass] 2>&1`;
211 if ($? != 0) { die "FAIL: esl-alimask failed unexpectedly on pass $pass2write"; }
212 if ($output !~ /AAAAAAAACccCCCCCCCGGGGG/) { die "FAIL: alignment masked incorrectly on pass $pass2write"; }
213 if ($output !~ /55554\*443..88888888899*/) { die "FAIL: alignment masked incorrectly on pass $pass2write"; }
214 if ($output !~ /::::::::<\-\-<<<<___>>>>>/) { die "FAIL: alignment masked incorrectly on pass $pass2write"; }
215 }
216
217 if ($have_rfA[$pass]) {
218 $output = `$eslalimask $smallA[$pass] --rna -g --keepins --gapthresh 0.3 $afileA[$pass] 2>&1`;
219 if ($? != 0) { die "FAIL: esl-alimask failed unexpectedly on pass $pass2write"; }
220 if ($output !~ /AAAAAAAACCCCCCCCGGGG/) { die "FAIL: alignment masked incorrectly on pass $pass2write"; }
221 if ($output !~ /55554\*44388888888899/) { die "FAIL: alignment masked incorrectly on pass $pass2write"; }
222 if ($output !~ /:::::::::<<<<___>>>>/) { die "FAIL: alignment masked incorrectly on pass $pass2write"; }
223 }
224
225 if ($have_rfA[$pass]) {
226 $output = `$eslalimask $smallA[$pass] --rna -g --keepins --gapthresh 0.7 $afileA[$pass] 2>&1`;
227 if ($? != 0) { die "FAIL: esl-alimask failed unexpectedly on pass $pass2write"; }
228 if ($output !~ /\.\.AAAAaAAAAaacCcccCCCCCCcCccGGGGG\.\.\.\./) { die "FAIL: alignment masked incorrectly on pass $pass2write"; }
229 if ($output !~ /\.\.5555.4\*44\.\.\.3\.\.\.888888\.8\.\.8899\.\.\.\.\./) { die "FAIL: alignment masked incorrectly on pass $pass2write"; }
230 if ($output !~ /::::::::::::::<\-\-\-<<<<______>>>>>::::/) { die "FAIL: alignment masked incorrectly on pass $pass2write"; }
231 }
232
233 if ($have_rfA[$pass]) {
234 $output = `$eslalimask $smallA[$pass] --rna -g --keepins --gapthresh 0.7 $afileA[$pass] 2>&1`;
235 if ($? != 0) { die "FAIL: esl-alimask failed unexpectedly on pass $pass2write"; }
236 if ($output !~ /\.\.AAAAaAAAAaacCcccCCCCCCcCccGGGGG\.\.\.\./) { die "FAIL: alignment masked incorrectly on pass $pass2write"; }
237 if ($output !~ /\.\.5555.4\*44\.\.\.3\.\.\.888888\.8\.\.8899\.\.\.\.\./) { die "FAIL: alignment masked incorrectly on pass $pass2write"; }
238 if ($output !~ /::::::::::::::<\-\-\-<<<<______>>>>>::::/) { die "FAIL: alignment masked incorrectly on pass $pass2write"; }
239 }
240
241 $output = `$eslalimask $smallA[$pass] --gmask-all $tmppfx.gmaskall --rna -g --gapthresh 0.7 $afileA[$pass] 2>&1`;
242 if ($? != 0) { die "FAIL: esl-alimask failed unexpectedly on pass $pass2write"; }
243 $output = `cat $tmppfx.gmaskall`;
244 if ($have_rfA[$pass]) {
245 if ($output !~ /00111100111100010001111110100111110000/) { die "FAIL: alignment masked incorrectly on pass $pass2write"; }
246 $output = `$eslalimask $smallA[$pass] --gmask-rf $tmppfx.gmaskrf --rna -g --gapthresh 0.7 $afileA[$pass] 2>&1`;
247 if ($? != 0) { die "FAIL: esl-alimask failed unexpectedly on pass $pass2write"; }
248 $output = `cat $tmppfx.gmaskrf`;
249 if ($output !~ /111111111111111111111/) { die "FAIL: alignment masked incorrectly on pass $pass2write"; }
250 }
251 else {
252 if ($output !~ /11111110111111111111111111111111111111/) { die "FAIL: alignment masked incorrectly on pass $pass2write"; }
253 }
254
255 $output = `$eslalimask $smallA[$pass] -p --rna $afileA[$pass] 2>&1`;
256 if ($? != 0) { die "FAIL: esl-alimask failed unexpectedly on pass $pass2write"; }
257 if ($have_rfA[$pass]) {
258 if ($output !~ /\s+A\s+/) { die "FAIL: alignment masked incorrectly on pass $pass2write"; }
259 if ($output !~ /\s+8\s+/) { die "FAIL: alignment masked incorrectly on pass $pass2write"; }
260 if ($output !~ /\s+\:\s+/) { die "FAIL: alignment masked incorrectly on pass $pass2write"; }
261 }
262 else {
263 if ($output !~ /\s+a\.Aaaccccc\s+/) { die "FAIL: alignment masked incorrectly on pass $pass2write"; }
264 if ($output !~ /\s+\*\*\*\*\*\*\*\*\*\*\s+/) { die "FAIL: alignment masked incorrectly on pass $pass2write"; }
265 }
266
267 $output = `$eslalimask $smallA[$pass] --pavg 0.73 -p --rna $afileA[$pass] 2>&1`;
268 if ($? != 0) { die "FAIL: esl-alimask failed unexpectedly on pass $pass2write"; }
269 if ($have_rfA[$pass]) {
270 if ($output !~ /\s+AAAAAACCCCCCCCGGGG\s+/) { die "FAIL: alignment masked incorrectly on pass $pass2write"; }
271 if ($output !~ /\s+55554\*388888888899\s+/) { die "FAIL: alignment masked incorrectly on pass $pass2write"; }
272 if ($output !~ /\s+:::::::<<<<___>>>>\s+/) { die "FAIL: alignment masked incorrectly on pass $pass2write"; }
273 }
274 else {
275 if ($output !~ /\s+AAAAa\.AAaacCcccCCCCCCcCccGGGG\s+/) { die "FAIL: alignment masked incorrectly on pass $pass2write"; }
276 if ($output !~ /\s+5555\.\.4\*\.\.\.3\.\.\.888888\.8\.\.8899\s+/) { die "FAIL: alignment masked incorrectly on pass $pass2write"; }
277 }
278
279 if ($have_rfA[$pass]) {
280 $output = `$eslalimask $smallA[$pass] --ppcons 0.85 -p --rna $afileA[$pass] 2>&1`;
281 if ($? != 0) { die "FAIL: esl-alimask failed unexpectedly on pass $pass2write"; }
282 if ($output !~ /\s+AACCCCCCGGGG\s+/) { die "FAIL: alignment masked incorrectly on pass $pass2write"; }
283 if ($output !~ /\s+9\*\*\*\*\*999999\s+/) { die "FAIL: alignment masked incorrectly on pass $pass2write"; }
284 }
285
286 $output = `$eslalimask $smallA[$pass] --pthresh 0.85 --pfract 0.5 --rna -p $afileA[$pass] 2>&1`;
287 if ($? != 0) { die "FAIL: esl-alimask failed unexpectedly on pass $pass2write"; }
288 if ($have_rfA[$pass]) {
289 if ($output !~ /\s+AAAAACCCCCGG\-\s+/) { die "FAIL: alignment masked incorrectly on pass $pass2write"; }
290 if ($output !~ /\s+5554\*3888899\.\s+/) { die "FAIL: alignment masked incorrectly on pass $pass2write"; }
291 }
292 else {
293 if ($output !~ /\s+AAA\.\.AA\.\.\.Cc\.cCCCC\.\.\.GGG\s+/) { die "FAIL: alignment masked incorrectly on pass $pass2write"; }
294 if ($output !~ /\s+555\.\.4\*\.\.\.3\.\.\.8888\.\.\.99\.\s+/) { die "FAIL: alignment masked incorrectly on pass $pass2write"; }
295 }
296
297 $output = `$eslalimask $smallA[$pass] --pmask-all $tmppfx.pmaskall --rna -p --pthresh 0.75 --pfract 0.7 $afileA[$pass] 2>&1`;
298 if ($? != 0) { die "FAIL: esl-alimask failed unexpectedly on pass $pass2write"; }
299 $output = `cat $tmppfx.pmaskall`;
300 if ($have_rfA[$pass]) {
301 if ($output !~ /00000000010000000001111110000000000000/) { die "FAIL: alignment masked incorrectly on pass $pass2write"; }
302 $output = `$eslalimask $smallA[$pass] --pmask-rf $tmppfx.pmaskrf --rna -p --pthresh 0.75 --pfract 0.7 $afileA[$pass] 2>&1`;
303 if ($? != 0) { die "FAIL: esl-alimask failed unexpectedly on pass $pass2write"; }
304 $output = `cat $tmppfx.pmaskrf`;
305 if ($output !~ /000001000111111000000/) { die "FAIL: alignment masked incorrectly on pass $pass2write"; }
306 }
307 else {
308 if ($output !~ /00000011010011101111111111011000000000/) { die "FAIL: alignment masked incorrectly on pass $pass2write"; }
309 }
310 }
311
312 print "ok\n";
313 unlink "$tmppfx.stk";
314 unlink "$tmppfx.norf.stk";
315 unlink "$tmppfx.fullmask";
316 unlink "$tmppfx.rfmask";
317 unlink "$tmppfx.gmaskrf";
318 unlink "$tmppfx.gmaskall";
319 unlink "$tmppfx.pmaskrf";
320 unlink "$tmppfx.pmaskall";
321 unlink "$tmppfx.out";
322 exit 0;