Used quoted strings in Bio::Species to avoid a 'Invalid [] range in regex' error...
[bioperl-live.git] / t / AlignIO / AlignIO.t
blob411ca7739ccaa9c29cbef6653fd691739cd23580
1 # -*-Perl-*- Test Harness script for Bioperl
2 # $Id$
4 use strict;
6 BEGIN {
7     use lib '.';
8     use Bio::Root::Test;
10     test_begin(-tests => 29);
12     use_ok('Bio::AlignIO');
15 my $DEBUG = test_debug();
17 my ($str,$aln,$strout,$status);
19 # general filehandle tests
20 # not all parsers support output (noted as 0)
21 my %files = (
22     # file                   format       I  O
23     'testaln.phylip'     => ['phylip',     1, 1],
24     'testaln.psi'         => ['psi',        1, 1],
25     'testaln.arp'       => ['arp',        1, 0],
26     'rfam_tests.stk'    => ['stockholm',  1, 1],
27     'testaln.pfam'      => ['pfam',       1, 1],
28     'testaln.msf'       => ['msf',        1, 1],
29     'testaln.fasta'     => ['fasta',      1, 1],
30     'testaln.selex'     => ['selex',      1, 1],
31     'testaln.mase'      => ['mase',       1, 0],
32     'testaln.prodom'    => ['prodom',     1, 0],
33     'testaln.clustalw'  => ['clustalw',   1, 1],
34     'testaln.metafasta' => ['metafasta',  1, 1],
35     'testaln.nexus'     => ['nexus',      1, 1],
36     'testaln.po'        => ['po',         1, 1],
37     'testaln.xmfa'      => ['xmfa',       1, 1],
38  );
40 # input file handles
42 $aln = Bio::AlignIO->new(
43     -file  => test_input_file('longnames.aln'),
44     -format=>'clustalw',
45 )->next_aln();
46 isa_ok($aln, 'Bio::AnnotatableI');
48 while (my ($file, $fdata) = each %files) {
49     my ($format, $in, $out) = @{$fdata};
50     if ($in) {
51         my $fhin = Bio::AlignIO->newFh(
52            '-file'  => test_input_file($file),
53                            '-format' => $format);
54         my $fhout = Bio::AlignIO->newFh(
55            '-file' => ">".test_output_file(),
56                         '-format' => 'clustalw');
57         while ( $aln = <$fhin>) {
58             cmp_ok($aln->num_sequences, '>=', 2, "input filehandle method test : $format");
59             last;
60         }
61     }
64 # output file handles
66 while (my ($file, $fdata) = each %files) {
67     my ($format, $in, $out) = @{$fdata};
68     if ($out) {
69         my $status = 0;
70         my $fhin = Bio::AlignIO->newFh(
71            '-file' => test_input_file('testaln.clustalw'),
72                         '-format' => 'clustalw');
73         my $fhout = Bio::AlignIO->newFh(
74            '-file'  => '>'.test_output_file(),
75                            '-format' => $format);
76         while ( $aln = <$fhin> ) {
77             $status = print $fhout $aln;
78             last;
79         }
80         is $status, 1, "filehandle output test : $format";
81     }