1 # -*-Perl-*- Test Harness script for Bioperl
9 test_begin(-tests => 105);
11 use_ok 'Bio::Tools::GuessSeqFormat';
13 use_ok 'Bio::AlignIO';
17 ok my $guesser = Bio::Tools::GuessSeqFormat->new;
18 isa_ok $guesser, 'Bio::Tools::GuessSeqFormat';
22 # Test guesser interfaces
26 ok $guesser = Bio::Tools::GuessSeqFormat->new(
27 -file => test_input_file('test.fasta'),
29 is $guesser->guess, 'fasta';
32 my $string = ">test1 no comment
33 agtgctagctagctagctagct
37 ok $guesser = Bio::Tools::GuessSeqFormat->new(
40 is $guesser->guess, 'fasta';
44 test_skip(-tests => 2, -requires_modules => [qw(IO::String)]);
46 my $fh = IO::String->new($string);
47 ok $guesser = Bio::Tools::GuessSeqFormat->new(
49 ), 'Filehandle input';
50 is $guesser->guess, 'fasta';
55 # Test behavior with unknown format
58 is $guesser = Bio::Tools::GuessSeqFormat->new(
59 -file => test_input_file('test.waba'), # Bio::SearchIO::waba
60 )->guess, undef, 'Unknown file format';
63 Bio::SeqIO->new( -file=>test_input_file('test.waba') );
64 } qr/Could not guess format/;
71 my @fmts = qw{ace embl fasta fastq game gcg genbank pir raw swiss tab};
77 -requires_modules => [qw(XML::Writer XML::Parser::PerlSAX)]
81 -requires_module => 'Data::Stag'
84 my $guess = Bio::Tools::GuessSeqFormat->new(
85 -file => test_input_file("test.$fmt"),
87 is $guess, $fmt, "$fmt format";
89 ok my $input = Bio::SeqIO->new( -file=>test_input_file("test.$fmt") );
90 ok my $seq = $input->next_seq();
91 isa_ok $seq, 'Bio::PrimarySeqI';
97 # Test AlignIO formats
100 @fmts = qw{clustalw fasta fastq mase mega msf nexus pfam phylip prodom selex};
102 ## Instead of this, we should instead have a mock of those modules.
103 ## Two reasons: 1) this modules are dependent on ourselves so this
104 ## tests will only be triggered when updating. 2) it's not really our
105 ## job to check if the other module reads file correctly, we just need
106 ## to ensure that it's called to read the file.
108 test_skip(-tests => 4,
109 -requires_modules => ['Bio::AlignIO::stockholm']);
110 push(@fmts, 'stockholm');
114 my %skip_module = map {$_=>1} qw{ fastq };
116 for my $fmt (@fmts) {
117 my $guess = Bio::Tools::GuessSeqFormat->new(
118 -file => test_input_file("testaln.$fmt")
120 is $guess, $fmt, "$fmt format";
121 next if $skip_module{$fmt};
123 ok my $input = Bio::AlignIO->new( -file=>test_input_file("testaln.$fmt") );
124 ok my $seq = $input->next_aln();
125 isa_ok $seq, 'Bio::Align::AlignI';
134 blast => test_input_file('blastp2215.blast'),
135 gcgblast => test_input_file('test.gcgblast'),
136 vcf => test_input_file('example.vcf'),
139 while (my ($fmt, $file) = each %fmts) {
140 my $guess = Bio::Tools::GuessSeqFormat->new(
143 is $guess, $fmt, "$fmt format";