Add experimental stockholm write_aln() support
[bioperl-live.git] / t / AlignIO.t
blobe66df0788496ada52425637538cfe64e32557376
1 # This is -*-Perl-*- code
2 # $Id$
3 use strict;
5 my $DEBUG = $ENV{'BIOPERLDEBUG'} || 0;
6 BEGIN {
7         eval { require Test::More; };
8         if( $@ ) {
9                 use lib 't/lib';
10         }
11         use Test::More;
12         plan tests => 193;
14 use_ok('Bio::SimpleAlign');
15 use_ok('Bio::AlignIO');
16 use_ok('Bio::Root::IO');
18 END {
19     unlink(Bio::Root::IO->catfile("t","data","testout2.pfam"),
20            Bio::Root::IO->catfile("t","data","testout.selex"),
21            Bio::Root::IO->catfile("t","data","testout.pfam"),
22            Bio::Root::IO->catfile("t","data","testout.msf"),
23            Bio::Root::IO->catfile("t","data","testout.fasta"),
24            Bio::Root::IO->catfile("t","data","testout.clustal"),
25            Bio::Root::IO->catfile("t","data","testout.phylip"),
26            Bio::Root::IO->catfile("t","data","testout.nexus"),
27            Bio::Root::IO->catfile("t","data","testout.mega"),
28            Bio::Root::IO->catfile("t","data","testout.po"),
29            Bio::Root::IO->catfile("t","data","testout.largemultifasta")
30           );
33 my ($str,$aln,$strout,$status);
35 #PSI format  
36 $str  = new Bio::AlignIO (
37     '-file'     => Bio::Root::IO->catfile("t","data","testaln.psi"),
38     '-format'   => 'psi');
39 isa_ok($str,'Bio::AlignIO');
40 $aln = $str->next_aln();
41 isa_ok($aln,'Bio::Align::AlignI');
42 is($aln->get_seq_by_pos(1)->get_nse, 'QUERY/1-798');
43 is($aln->no_sequences, 56);
45 # STOCKHOLM (multiple concatenated files)
46 # Rfam
47 $str  = new Bio::AlignIO (
48     '-file'     => Bio::Root::IO->catfile("t","data","rfam_tests.stk"),
49     '-format'   => 'stockholm');
50 isa_ok($str,'Bio::AlignIO');
51 $aln = $str->next_aln();
52 isa_ok($aln,'Bio::Align::AlignI');
53 is($aln->get_seq_by_pos(1)->get_nse, 'Z11765.1/1-89');
54 is($aln->accession, 'RF00006');
55 is($aln->id, 'Vault');
56 is($aln->description,'Vault RNA');
57 $aln = $str->next_aln();
58 isa_ok($aln,'Bio::Align::AlignI');
59 is($aln->get_seq_by_pos(1)->get_nse, 'L43844.1/2-149');
60 is($aln->accession, 'RF00007');
61 is($aln->id, 'U12');
62 is($aln->description,'U12 minor spliceosomal RNA');
63 $aln = $str->next_aln();
64 isa_ok($aln,'Bio::Align::AlignI');
65 is($aln->get_seq_by_pos(1)->get_nse, 'AJ295015.1/58-1');
66 is($aln->accession, 'RF00008');
67 is($aln->id, 'Hammerhead_3');
68 is($aln->description,'Hammerhead ribozyme (type III)');
70 # Pfam
71 $str  = new Bio::AlignIO (
72     '-file'     => Bio::Root::IO->catfile("t","data","pfam_tests.stk"),
73     '-format'   => 'stockholm');
74 isa_ok($str,'Bio::AlignIO');
75 $aln = $str->next_aln();
76 isa_ok($aln,'Bio::Align::AlignI');
77 is($aln->get_seq_by_pos(1)->get_nse, 'RAD25_SCHPO/5-240');
78 is($aln->accession, 'PF00244.9');
79 is($aln->id, '14-3-3');
80 is($aln->description,'14-3-3 protein');
81 $aln = $str->next_aln();
82 isa_ok($aln,'Bio::Align::AlignI');
83 is($aln->get_seq_by_pos(1)->get_nse, 'COMB_CLOAB/6-235');
84 is($aln->accession, 'PF04029.4');
85 is($aln->id, '2-ph_phosp');
86 is($aln->description,'2-phosphosulpholactate phosphatase');
87 $aln = $str->next_aln();
88 isa_ok($aln,'Bio::Align::AlignI');
89 is($aln->get_seq_by_pos(1)->get_nse, 'Y278_HAEIN/174-219');
90 is($aln->accession, 'PF03475.3');
91 is($aln->id, '3-alpha');
92 is($aln->description,'3-alpha domain');
94 # PFAM
95 $str = Bio::AlignIO->new(
96           '-file' => Bio::Root::IO->catfile("t","data","testaln.pfam"));
97 isa_ok($str,'Bio::AlignIO');
98 $aln = $str->next_aln();
99 isa_ok($aln,'Bio::Align::AlignI');
100 is($aln->get_seq_by_pos(1)->get_nse, '1433_LYCES/9-246');
102 $strout = Bio::AlignIO->new(
103    '-file' => ">".Bio::Root::IO->catfile("t","data","testout.pfam"), 
104                             '-format' => 'pfam');
105 $status = $strout->write_aln($aln);
106 is($status, 1, " failed pfam output test");
109 # MAF
110 $str = Bio::AlignIO->new(
111           '-file' => Bio::Root::IO->catfile("t","data","humor.maf"));
112 $aln = $str->next_aln();
113 isa_ok($aln,'Bio::Align::AlignI');
114 is $aln->get_seq_by_pos(1)->get_nse, 'NM_006987/1-5000', " failed maf input test";
115 is $aln->get_seq_by_pos(1)->strand, '-';
117 # MSF
118 $str = Bio::AlignIO->new(
119     '-file' => Bio::Root::IO->catfile("t","data","testaln.msf"));
120 $aln = $str->next_aln();
121 isa_ok($aln,'Bio::Align::AlignI');
122 is $aln->get_seq_by_pos(1)->get_nse, '1433_LYCES/9-246', " failed msf input test";
124 $strout = Bio::AlignIO->new(
125    '-file' => ">".Bio::Root::IO->catfile("t","data","testout.msf"), 
126                             '-format' => 'msf');
127 $status = $strout->write_aln($aln);
128 is $status, 1, "  failed msf output test";
131 # FASTA
132 $str = Bio::AlignIO->new(
133                  -file => Bio::Root::IO->catfile("t","data","testaln.fasta"), 
134                  -format => 'fasta');
135 $aln = $str->next_aln();
136 isa_ok($aln,'Bio::Align::AlignI');
137 is $aln->get_seq_by_pos(1)->get_nse, 'AK1H_ECOLI/114-431', 
138   " failed fasta input test ";
139 is ($aln->get_seq_by_pos(1)->description, 'DESCRIPTION HERE', 
140     " failed fasta input test for description");
141 is ($aln->get_seq_by_pos(11)->display_id, 'AK_YEAST',
142     " failed fasta input test for id");
144 is ($aln->get_seq_by_pos(2)->end, 318,
145     " failed fasta input test for end");
147 is ($aln->get_seq_by_pos(11)->description, 'A COMMENT FOR YEAST', 
148     " failed fasta input test for description");
150 $strout = Bio::AlignIO->new(
151    '-file' => ">".Bio::Root::IO->catfile("t","data","testout.fasta"), 
152                               '-format' => 'fasta');
153 $status = $strout->write_aln($aln);
154 is $status, 1,"  failed fasta output test";
156 my $in = Bio::AlignIO->newFh(
157    '-file'  => Bio::Root::IO->catfile("t","data","testaln.fasta"), 
158                                '-format' => 'fasta');
159 my $out = Bio::AlignIO->newFh(
160    '-file' => ">".Bio::Root::IO->catfile("t","data","testout2.pfam"), 
161                                 '-format' => 'pfam');
162 while ( $aln = <$in>) {
163     is $aln->get_seq_by_pos(1)->get_nse, 'AK1H_ECOLI/114-431',
164      "  failed filehandle input test  ";
165     $status = print $out $aln;
166     last;
168 is $status, 1, "  failed filehandle output test";
171 # SELEX
172 $str = Bio::AlignIO->new(
173     '-file' => Bio::Root::IO->catfile("t","data","testaln.selex"),
174                            '-format' => 'selex');
175 $aln = $str->next_aln();
176 isa_ok($aln,'Bio::Align::AlignI');
177 is $aln->get_seq_by_pos(1)->get_nse, 'AK1H_ECOLI/114-431', " failed selex format test ";
179 $strout = Bio::AlignIO->new(
180    '-file' => ">".Bio::Root::IO->catfile("t","data","testout.selex"), 
181                               '-format' => 'selex');
182 $status = $strout->write_aln($aln);
183 is $status, 1, "  failed selex output test";
186 # MASE
187 $str = Bio::AlignIO->new(
188    '-file' => Bio::Root::IO->catfile("t","data","testaln.mase"),
189                            '-format' => 'mase');
190 $aln = $str->next_aln();
191 isa_ok($aln,'Bio::Align::AlignI');
192 is $aln->get_seq_by_pos(1)->get_nse, 'AK1H_ECOLI/1-318', " failed mase input test ";
195 # PRODOM
196 $str = Bio::AlignIO->new(
197    '-file' => Bio::Root::IO->catfile("t","data","testaln.prodom"),
198                            '-format' => 'prodom');
199 $aln = $str->next_aln();
200 isa_ok($aln,'Bio::Align::AlignI');
201 is $aln->get_seq_by_pos(1)->get_nse, 'P04777/1-33', " failed prodom input test ";
204 # CLUSTAL
205 $strout = Bio::AlignIO->new(
206    '-file' => ">".Bio::Root::IO->catfile("t","data","testout.clustal"), 
207                               '-format' => 'clustalw');
208 $status = $strout->write_aln($aln);
209 is $status, 1, "  failed clustalw (.aln) output test";
210 undef $strout;
211 $str = Bio::AlignIO->new(
212    '-file'=> Bio::Root::IO->catfile("t","data","testout.clustal"), 
213                            '-format' => 'clustalw');
214 $aln = $str->next_aln($aln);
215 isa_ok($aln,'Bio::Align::AlignI');
216 is $aln->get_seq_by_pos(1)->get_nse, 'P04777/1-33', "  failed clustalw (.aln) input test";
217 my $io = Bio::AlignIO->new(
218    -file => Bio::Root::IO->catfile("t","data","testaln.aln") );
219 $aln = $io->next_aln();
220 isa_ok($aln,'Bio::Align::AlignI');
221 is $aln->consensus_string, 'MNEGEHQIKLDELFEKLLRARKIFKNKDVLRHSWEPKDLPHRHEQIEALAQILVPVLRGETMKIIFCGHHACELGEDRGTKGFVIDELKDVDEDRNGKVDVIEINCEHMDTHYRVLPNIAKLFDDCTGIGVPMHGGPTDEVTAKLKQVIDMKERFVIIVLDEIDKLVKKSGDEVLYSLTRINTELKRAKVSVIGISNDLKFKEYLDPRVLSSLSEEEVVFPPYDANQLRDILTQRAEEAFYPGVLDEGVIPLCAALAAREHGDARKALDLLRVAGEIAEREGASKVTEKHVWKAQEKIEQDMMEEVIKTLPLQSKVLLYAIVLLDENGDLPANTGDVYAVYRELCEYIDLEPLTQRRISDLINELDMLGIINAKVVSKGRYGRTKEIRLMVTSYKIRNVLRYDYSIQPLLTISLKSEQRRLI', " failed clustalw consensus_string test";
224 # BL2SEQ
225 $str = Bio::AlignIO->new(
226    '-file'   => Bio::Root::IO->catfile("t","data","bl2seq.out"),
227                          '-format' => 'bl2seq',
228                          '-report_type' => 'blastp');
229 $aln = $str->next_aln();
230 isa_ok($aln,'Bio::Align::AlignI');
231 is $aln->get_seq_by_pos(2)->get_nse, 'ALEU_HORVU/60-360', 
232     "failed BLAST bl2seq format test";
235 # PHYLIP interleaved
236 $str = Bio::AlignIO->new(
237     '-file' => Bio::Root::IO->catfile("t","data","testaln.phylip"),
238     '-format' => 'phylip');
239 isa_ok($str,'Bio::AlignIO');
240 $aln = $str->next_aln();
241 isa_ok($aln,'Bio::Align::AlignI');
242 is $aln->get_seq_by_pos(1)->get_nse, 'Homo_sapie/1-45';
244 $strout = Bio::AlignIO->new(
245     '-file'  => ">".Bio::Root::IO->catfile("t","data","testout.phylip"),
246     '-format' => 'phylip');
247 $status = $strout->write_aln($aln);
248 is $status, 1, "  failed phylip output test";
251 # METAFASTA (tests 37-39)
252 print STDERR "Better Metafasta tests needed\n" if $DEBUG;
253 $io = Bio::AlignIO->new(-verbose => -1, 
254    -file => Bio::Root::IO->catfile("t","data","testaln.metafasta"));
255 $aln = $io->next_aln;
256 isa_ok($aln,'Bio::Align::AlignI');
257 is $aln->consensus_string,'CDEFHIJKLMNOPQRSTUVWXYZ', " failed consensus_string on metafasta";
258 is $aln->symbol_chars,'23'," failed symbol_chars() using metafasta";
260 # NEXUS
261 $str = Bio::AlignIO->new(
262    '-file' => Bio::Root::IO->catfile("t","data","testaln.nexus"),
263                           '-format' => 'nexus');
264 isa_ok($str,'Bio::AlignIO');
265 $aln = $str->next_aln();
266 isa_ok($aln,'Bio::Align::AlignI');
267 is $aln->get_seq_by_pos(1)->get_nse, 'Homo_sapiens/1-45';
268 $strout = Bio::AlignIO->new('-file'  => ">".
269                           Bio::Root::IO->catfile("t", "data", "testout.nexus"),
270                             '-format' => 'nexus', );
271 $status = $strout->write_aln($aln);
272 is $status, 1, "  failed nexus output test";
274 $str = Bio::AlignIO->new(
275    '-file' => Bio::Root::IO->catfile("t","data","Bird_Ovomucoids.nex"),
276                           '-format' => 'nexus');
277 isa_ok($str,'Bio::AlignIO');
278 $aln = $str->next_aln();
279 isa_ok($aln,'Bio::Align::AlignI');
280 $str = Bio::AlignIO->new(
281    '-file' => Bio::Root::IO->catfile("t","data","basic-ladder.nex"),
282                           '-format' => 'nexus');
283 isa_ok($str,'Bio::AlignIO');
284 $aln = $str->next_aln();
285 isa_ok($aln,'Bio::Align::AlignI');
286 $str = Bio::AlignIO->new(
287    '-file' => Bio::Root::IO->catfile("t","data","Kingdoms_DNA.nex"),
288                           '-format' => 'nexus');
289 isa_ok($str,'Bio::AlignIO');
290 $aln = $str->next_aln();
291 isa_ok($aln,'Bio::Align::AlignI');
292 $str = Bio::AlignIO->new(
293   '-file' => Bio::Root::IO->catfile("t","data","char-interleave.nex"),
294                           '-format' => 'nexus');
295 isa_ok($str,'Bio::AlignIO');
296 $aln = $str->next_aln();
297 isa_ok($aln,'Bio::Align::AlignI');
298 $str = Bio::AlignIO->new(
299    '-file' => Bio::Root::IO->catfile("t","data","Primate_mtDNA.nex"),
300                           '-format' => 'nexus');
301 isa_ok($str,'Bio::AlignIO');
302 $aln = $str->next_aln();
303 isa_ok($aln,'Bio::Align::AlignI');
304 $str = Bio::AlignIO->new(
305    '-file' => Bio::Root::IO->catfile("t","data","char-matrix-spaces.nex"),
306                           '-format' => 'nexus');
307 isa_ok($str,'Bio::AlignIO');
308 $aln = $str->next_aln();
309 isa_ok($aln,'Bio::Align::AlignI');
310 $str = Bio::AlignIO->new(
311    '-file' => Bio::Root::IO->catfile("t","data","SPAN_Family4nl.nex"),
312                           '-format' => 'nexus');
313 isa_ok($str,'Bio::AlignIO');
314 $aln = $str->next_aln();
315 isa_ok($aln,'Bio::Align::AlignI');
316 $str = Bio::AlignIO->new(
317    '-file' => Bio::Root::IO->catfile("t","data","intrablock-comment.nex"),
318                           '-format' => 'nexus');
319 isa_ok($str,'Bio::AlignIO');
320 $aln = $str->next_aln();
321 isa_ok($aln,'Bio::Align::AlignI');
322 $str = Bio::AlignIO->new(
323    '-file' => Bio::Root::IO->catfile("t","data","SPAN_Family7n.nex"),
324                           '-format' => 'nexus');
325 isa_ok($str,'Bio::AlignIO');
326 $aln = $str->next_aln();
327 isa_ok($aln,'Bio::Align::AlignI');
328 $str = Bio::AlignIO->new(
329    '-file' => Bio::Root::IO->catfile("t","data","long-names.nex"),
330                           '-format' => 'nexus');
331 isa_ok($str,'Bio::AlignIO');
332 $aln = $str->next_aln();
333 isa_ok($aln,'Bio::Align::AlignI');
334 $str = Bio::AlignIO->new(
335    '-file' => Bio::Root::IO->catfile("t","data","SPAN_Family8a.nex"),
336                           '-format' => 'nexus');
337 isa_ok($str,'Bio::AlignIO');
338 $aln = $str->next_aln();
339 isa_ok($aln,'Bio::Align::AlignI');
340 $str = Bio::AlignIO->new(
341    '-file' => Bio::Root::IO->catfile("t","data","multiline-intrablock-comment.nex"),
342                           '-format' => 'nexus');
343 isa_ok($str,'Bio::AlignIO');
344 $aln = $str->next_aln();
345 isa_ok($aln,'Bio::Align::AlignI');
346 $str = Bio::AlignIO->new(
347   '-file' => Bio::Root::IO->catfile("t","data","Treebase-chlamy-dna.nex"),
348                           '-format' => 'nexus');
349 isa_ok($str,'Bio::AlignIO');
350 $aln = $str->next_aln();
351 isa_ok($aln,'Bio::Align::AlignI');
352 $str = Bio::AlignIO->new(
353   '-file' => Bio::Root::IO->catfile("t","data","quoted-strings1.nex"),
354                           '-format' => 'nexus');
355 isa_ok($str,'Bio::AlignIO');
356 $aln = $str->next_aln();
357 isa_ok($aln,'Bio::Align::AlignI');
358 $str = Bio::AlignIO->new(
359    '-file' => Bio::Root::IO->catfile("t","data","UnaSmithHIV-both.nex"),
360                           '-format' => 'nexus');
361 isa_ok($str,'Bio::AlignIO');
362 $aln = $str->next_aln();
363 isa_ok($aln,'Bio::Align::AlignI');
364 $str = Bio::AlignIO->new(
365   '-file' => Bio::Root::IO->catfile("t","data","quoted-strings2.nex"),
366                           '-format' => 'nexus');
367 isa_ok($str,'Bio::AlignIO');
368 $aln = $str->next_aln();
369 isa_ok($aln,'Bio::Align::AlignI');
370 $str = Bio::AlignIO->new(
371    '-file' => Bio::Root::IO->catfile("t","data","barns-combined.nex"),
372                           '-format' => 'nexus');
373 isa_ok($str,'Bio::AlignIO');
374 $aln = $str->next_aln();
375 isa_ok($aln,'Bio::Align::AlignI');
376 $str = Bio::AlignIO->new(
377    '-file' => Bio::Root::IO->catfile("t","data","radical-whitespace.nex"),
378                           '-format' => 'nexus');
379 isa_ok($str,'Bio::AlignIO');
380 $aln = $str->next_aln();
381 isa_ok($aln,'Bio::Align::AlignI');
382 $str = Bio::AlignIO->new(
383    '-file' => Bio::Root::IO->catfile("t","data","basic-bush.nex"),
384                           '-format' => 'nexus');
385 isa_ok($str,'Bio::AlignIO');
386 $aln = $str->next_aln();
387 isa_ok($aln,'Bio::Align::AlignI');
388 $str = Bio::AlignIO->new(
389   '-file' => Bio::Root::IO->catfile("t","data","radical-whitespace_02.nex"),
390                           '-format' => 'nexus');
393 # EMBOSS water
394 $str = new Bio::AlignIO('-format' => 'emboss',
395                  '-file'   => Bio::Root::IO->catfile("t", "data", 'cysprot.water'));
396 $aln = $str->next_aln();
397 isa_ok($aln,'Bio::Align::AlignI');
398 is($aln->score,'501.50');
399 is($aln->get_seq_by_pos(1)->get_nse,'PAPA_CARPA/3-342');
400 is($aln->get_seq_by_pos(2)->get_nse,'CATL_HUMAN/1-331');
401 is(sprintf("%.1f",$aln->overall_percentage_identity),33.8);
402 is(sprintf("%.1f",$aln->average_percentage_identity),40.1);
404 is($aln->get_seq_by_pos(1)->start, 3);
405 is($aln->length,364);
408 # EMBOSS needle
409 $str = new Bio::AlignIO('-format' => 'emboss',
410           '-file'   => Bio::Root::IO->catfile("t", "data", 'cysprot.needle'));
411 $aln = $str->next_aln();
412 isa_ok($aln,'Bio::Align::AlignI');
413 is($aln->score,'499.50');
414 is($aln->get_seq_by_pos(1)->get_nse,'PAPA_CARPA/1-345');
415 is($aln->get_seq_by_pos(2)->get_nse,'CATL_HUMAN/1-333');
418 # EMBOSS water 2.2.x
419 $str = new Bio::AlignIO('-format' => 'emboss',
420          '-file'   => Bio::Root::IO->catfile("t", "data", 'cys1_dicdi.water'));
421 $aln = $str->next_aln();
422 isa_ok($aln,'Bio::Align::AlignI');
423 is($aln->get_seq_by_pos(1)->get_nse,'CYS1_DICDI/1-343');
424 is($aln->get_seq_by_pos(2)->get_nse,'CYS1_DICDI-1/1-343');
425 is($aln->score,'1841.0');
426 $aln = $str->next_aln();
427 isa_ok($aln,'Bio::Align::AlignI');
428 is($aln->get_seq_by_pos(1)->get_nse,'CYS1_DICDI/29-343');
429 is($aln->get_seq_by_pos(2)->get_nse,'ALEU_HORVU/61-360');
432 # EMBOSS water 2.2.x sparse needle
433 $str = new Bio::AlignIO(-verbose => $DEBUG,
434           '-format' => 'emboss',
435         '-file'   => Bio::Root::IO->catfile("t", "data", 'sparsealn.needle'));
436 $aln = $str->next_aln();
437 isa_ok($aln,'Bio::Align::AlignI');
438 is($aln->score,'18.0');
439 is(sprintf("%.1f",$aln->overall_percentage_identity), 2.1);
440 is(sprintf("%.1f",$aln->average_percentage_identity), 38.5);
441 is($aln->get_seq_by_pos(1)->length, 238);
442 is($aln->length,238);
443 is($aln->get_seq_by_pos(1)->get_nse,'KV1K_HUMAN/1-108');
444 is($aln->get_seq_by_pos(2)->get_nse,'IF1Y_HUMAN/1-143');
445 is($aln->get_seq_by_pos(1)->seq(), 'DIQMTQSPSTLSVSVGDRVTITCEASQTVLSYLNWYQQKPGKAPKLLIYAASSLETGVPSRFSGQGSGTBFTFTISSVZPZBFATYYCQZYLDLPRTFGQGTKVDLKR'.'-'x130);
446 is($aln->get_seq_by_pos(2)->seq(), ('-'x94).'PKNKGKGGK-NRRRGKNENESEKRELVFKEDGQEYAQVIKMLGNGRLEALCFDGVKRLCHIRGKLRKKVWINTSDIILVGLRDYQDNKADVILKYNADEARSLKAYGGLPEHAKINETDTFGPGDDDEIQFDDIGDDDEDIDDI');
447 is($aln->is_flush, 1);
450 # MEGA
451 $str = new Bio::AlignIO('-format' => 'mega',
452         '-file'   => Bio::Root::IO->catfile("t","data","hemoglobinA.meg"));
454 $aln = $str->next_aln();
455 isa_ok($aln,'Bio::Align::AlignI');
456 is($aln->get_seq_by_pos(1)->get_nse,'Human/1-141');
457 is($aln->get_seq_by_pos(2)->get_nse,'Horse/1-144');
458 $aln->unmatch();
459 is($aln->get_seq_by_pos(3)->subseq(1,10), 'V-LSAADKGN');
461 $strout = new Bio::AlignIO('-format' => 'mega',
462           '-file'   => ">" .Bio::Root::IO->catfile("t","data","testout.mega"));
464 $status = $strout->write_aln($aln);
465 is $status, 1, "  failed mega output test";
468 # EMBOSS needle
469 $str = new Bio::AlignIO('-format' => 'emboss',
470           '-file'   => Bio::Root::IO->catfile('t','data','gf-s71.needle'));
471 $aln = $str->next_aln();
472 isa_ok($aln,'Bio::Align::AlignI');
473 is($aln->get_seq_by_pos(2)->seq(), 'MEDVTLFQFTWRKPI-RLQGEIVYKTSETQTIETNKKDVECVANFQENKEVQTDS-VDNGVGENVKKDITISKEVLNLLYDFVRDDSKVNYDRLLEFHKFDKVALETVQKYHVETRNENIILMISSSSRKTLILFGGISHETFCSHQARALLCSSSTSFSIPLPVCAISAVFYSSTQFILGDVSGNISMCSKDKIIFEKKITDGAVTCLEMCRHGLLSGSDDGNIILWQIGTSGLEKLGGTKLTVSDLSRKIRRSSTSNKPVAIVSMQVYVWPSGEEACVATETGGLYLLTLPTLDYKPLSHQTATSINKILFENQFVAVIYHTSNAAVFNSEGLVDEIPFVATLAVR----------PKLVLF--YTSVCVQDITLNCTSPFREFNNEYNPVIKFSKIRFSADLSVING-FRTSSPNSNN-----------------------------------------------');
474 is($aln->get_seq_by_pos(1)->seq(), 'MEDVTLHHFRWRKPVENKNGEIVYKTSETQTAEISRKDVECVANFQKSQESQTDDFMQNGVGDGIKKEIRISKEVLGHIYDFLRDDSKVNYDRLLEFHKFDKVSLETVQKYHVETRNENIILMISNSSRKTLILFGGLSHETFCSHQARAVLCSSSTTSSLPLPVCAISAVFYSSTQFLLGDISGNISMWTKEKMIFENKVTDGSVTSLELCRYGLLSGSDDGNVILWKVEESKIEKIEGIKLTVSDLSRKIRRSSTSNKPVAIVSMQV----SGDEVCVATETGGLYLLTLPTLESKPLT-QSATSIFKILYEHPYIAVVYHTSNSAIFNSEGLVDEIPFVATLAVRCGAYFIFSNQSRLIIWSMNTRSTVIDENLNCHS-ICSLSND--------------TLQVLDGDFNLNSQSENSATSESENLRISDLQNLRMLKLQNLRTSEFQNFRTSESQYFKKDNGEL');
475 is($aln->is_flush(), 1);
476 is($aln->get_seq_by_pos(1)->get_nse,'gf.s71.44/1-448');
477 is($aln->get_seq_by_pos(2)->get_nse,'Y50C1A.2/1-406');
480 # PHYLIP sequential/non-interleaved
481 $strout = Bio::AlignIO->new('-file'  =>
482                             Bio::Root::IO->catfile("t","data",
483                                                    "noninterleaved.phy"),
484                             '-format' => 'phylip');
485 $aln = $strout->next_aln($aln);
486 isa_ok($aln,'Bio::Align::AlignI');
487 is($aln->get_seq_by_pos(2)->seq(), 'CCTCAGATCACTCTTTGGCAACGACCCCTCGTCACAATAAAGGTAGGGGGGCAACTAAAGGAAGCTCTATTAGATACAGGAGCAGATGATACAGTATTAGAAGACATGAATTTGCCAGGAAGATGGAAACCAAAAATGATAGGGGGAATTGGAGGGTTTATCAAAGTAAGACAGTATGATCAGATACCCATAGAGATCTGTGGACATAAAGCTATAGGTACAGTATTAGTAGGACCCACACCTGTCAATATAATTGGAAGAAATCTGTTGACTCAGATTGGTTGCACTTTAAATTTT' );
490 # LARGEMULTIFASTA
491 $str = Bio::AlignIO->new(
492    '-file' => Bio::Root::IO->catfile("t", "data","little.largemultifasta"),
493                          '-format' => 'largemultifasta');
494 $aln = $str->next_aln();
495 isa_ok($aln,'Bio::Align::AlignI');
496 is $aln->get_seq_by_pos(1)->get_nse, 'Human:/1-81', " failed fasta input test ";
497 is ($aln->get_seq_by_pos(1)->description,
498     '72.0:1018606-3386002; 73.0:0-14850845; 74.0:0-83355922; SPECIAL_hsApr2003_3.0:0-414023;',
499     " failed fasta input test for description");
500 is ($aln->get_seq_by_pos(3)->display_id, 'Rat:',
501     " failed fasta input test for id");
503 is ($aln->get_seq_by_pos(3)->description,
504     '72.0:1018606-3386002; 73.0:0-14850845; 74.0:0-83355922; SPECIAL_hsApr2003_3.0:0-414023;',
505     " failed fasta input test for description");
507 $strout = Bio::AlignIO->new(
508    '-file' => ">".Bio::Root::IO->catfile("t", "data",
509                                        "testout.largemultifasta"),
510                             '-format' => 'largemultifasta');
511 $status = $strout->write_aln($aln);
512 is $status, 1,"  failed fasta output test";
515 # POA
516 # just skip on perl 5.6.0 and earlier as it causes a crash on 
517 # default perl with OS X 10.2
518 # fink perl 5.6.0 does not seem to have the problem
519 # can't figure out what it is so just skip for now
520 if( $^O ne 'darwin' || $] > 5.006 ) {
521         $str = new Bio::AlignIO(
522                           -file   => Bio::Root::IO->catfile("t", "data", "testaln.po"),
523                           -format => 'po',
524                           );
525         isa_ok($str, 'Bio::AlignIO');
526         $aln = $str->next_aln();
527         isa_ok($aln,'Bio::Align::AlignI');
528         is $aln->no_sequences, 6;
530 # output is? i.e. does conversion from clustalw to po give the same alignment?
531         $str = new Bio::AlignIO(
532                   '-file'   => Bio::Root::IO->catfile("t", "data", "testaln.aln"),
533                   '-format' => 'clustalw');
534         isa_ok($str,'Bio::AlignIO');
535         $aln = $str->next_aln();
536         isa_ok($aln,'Bio::Align::AlignI');
537         $strout = Bio::AlignIO->new(
538                  '-file'   => ">" . Bio::Root::IO->catfile("t", "data", "testout.po"),
539                  '-format' => 'po');
540         $status = $strout->write_aln($aln);
541         is $status, 1, " failed po output test";
543         $str = new Bio::AlignIO(
544                  '-file'   => Bio::Root::IO->catfile("t", "data", "testaln.po"),
545                  '-format' => 'po');
546         isa_ok($str,'Bio::AlignIO');
547         my $aln2 = $str->next_aln();
548         isa_ok($aln2,'Bio::Align::AlignI');
549         is $aln2->no_sequences, $aln->no_sequences;
550         is $aln2->length, $aln->length;
551 } else {
552         for ( 1..14 ) {
553                 skip(1,"skipping due to bug in perl 5.6.0 that comes with OS X 10.2");
554         }
558 # MEME
559 # this file has no Strand column
560 $str = new Bio::AlignIO(
561                 -file => Bio::Root::IO->catfile("t", "data", "test.meme"),
562                 -format => 'meme');
563 isa_ok($str,'Bio::AlignIO');
564 $aln = $str->next_aln();
565 isa_ok($aln,'Bio::Align::AlignI');is $aln->length,25;
566 is $aln->no_sequences,4;
567 is $aln->get_seq_by_pos(3)->seq(),"CCTTAAAATAAAATCCCCACCACCA";
568 is $aln->get_seq_by_pos(3)->strand,"1";
570 # this file has a Strand column
571 $str = new Bio::AlignIO(
572                 -file => Bio::Root::IO->catfile("t", "data", "test.meme2"),
573                 -format => 'meme');
574 isa_ok($str,'Bio::AlignIO');
575 $aln = $str->next_aln();
576 isa_ok($aln,'Bio::Align::AlignI');is $aln->length,20;
577 is $aln->no_sequences,8;
578 is $aln->get_seq_by_pos(8)->seq(),"CCAGTCTCCCCTGAATACCC";
579 is $aln->get_seq_by_pos(7)->strand,"-1";
580 is $aln->get_seq_by_pos(6)->strand,"1";