add MANIFEST file on the fly
[bioperl-live.git] / t / AlignIO / AlignIO.t
blob0b6928136335db637c262718ed74ff6679ee480a
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,
11                -requires_module => 'Data::Stag');
13     use_ok('Bio::AlignIO');
16 my $DEBUG = test_debug();
18 my ($str,$aln,$strout,$status);
20 # general filehandle tests
21 # not all parsers support output (noted as 0)
22 my %files = (
23     # file                   format       I  O
24     'testaln.phylip'     => ['phylip',     1, 1],
25     'testaln.psi'         => ['psi',        1, 1],
26     'testaln.arp'       => ['arp',        1, 0],
27     'rfam_tests.stk'    => ['stockholm',  1, 1],
28     'testaln.pfam'      => ['pfam',       1, 1],
29     'testaln.msf'       => ['msf',        1, 1],
30     'testaln.fasta'     => ['fasta',      1, 1],
31     'testaln.selex'     => ['selex',      1, 1],
32     'testaln.mase'      => ['mase',       1, 0],
33     'testaln.prodom'    => ['prodom',     1, 0],
34     'testaln.clustalw'  => ['clustalw',   1, 1],
35     'testaln.metafasta' => ['metafasta',  1, 1],
36     'testaln.nexus'     => ['nexus',      1, 1],
37     'testaln.po'        => ['po',         1, 1],
38     'testaln.xmfa'      => ['xmfa',       1, 1],
39  );
41 # input file handles
43 $aln = Bio::AlignIO->new(
44     -file  => test_input_file('longnames.aln'),
45     -format=>'clustalw',
46 )->next_aln();
47 isa_ok($aln, 'Bio::AnnotatableI');
49 while (my ($file, $fdata) = each %files) {
50     my ($format, $in, $out) = @{$fdata};
51     if ($in) {
52         my $fhin = Bio::AlignIO->newFh(
53            '-file'  => test_input_file($file),
54                            '-format' => $format);
55         my $fhout = Bio::AlignIO->newFh(
56            '-file' => ">".test_output_file(),
57                         '-format' => 'clustalw');
58         while ( $aln = <$fhin>) {
59             cmp_ok($aln->num_sequences, '>=', 2, "input filehandle method test : $format");
60             last;
61         }
62     }
65 # output file handles
67 while (my ($file, $fdata) = each %files) {
68     my ($format, $in, $out) = @{$fdata};
69     if ($out) {
70         my $status = 0;
71         my $fhin = Bio::AlignIO->newFh(
72            '-file' => test_input_file('testaln.clustalw'),
73                         '-format' => 'clustalw');
74         my $fhout = Bio::AlignIO->newFh(
75            '-file'  => '>'.test_output_file(),
76                            '-format' => $format);
77         while ( $aln = <$fhin> ) {
78             $status = print $fhout $aln;
79             last;
80         }
81         is $status, 1, "filehandle output test : $format";
82     }