1 # -*-Perl-*- Test Harness script for Bioperl
10 test_begin(-tests => 105);
12 use_ok 'Bio::Tools::GuessSeqFormat';
14 use_ok 'Bio::AlignIO';
18 ok my $guesser = Bio::Tools::GuessSeqFormat->new;
19 isa_ok $guesser, 'Bio::Tools::GuessSeqFormat';
23 # Test guesser interfaces
27 ok $guesser = Bio::Tools::GuessSeqFormat->new(
28 -file => test_input_file('test.fasta'),
30 is $guesser->guess, 'fasta';
33 my $string = ">test1 no comment
34 agtgctagctagctagctagct
38 ok $guesser = Bio::Tools::GuessSeqFormat->new(
41 is $guesser->guess, 'fasta';
45 test_skip(-tests => 2, -requires_modules => [qw(IO::String)]);
47 my $fh = IO::String->new($string);
48 ok $guesser = Bio::Tools::GuessSeqFormat->new(
50 ), 'Filehandle input';
51 is $guesser->guess, 'fasta';
56 # Test behavior with unknown format
59 is $guesser = Bio::Tools::GuessSeqFormat->new(
60 -file => test_input_file('test.waba'), # Bio::SearchIO::waba
61 )->guess, undef, 'Unknown file format';
64 Bio::SeqIO->new( -file=>test_input_file('test.waba') );
65 } qr/Could not guess format/;
72 my @fmts = qw{ace embl fasta fastq game gcg genbank pir raw swiss tab};
78 -requires_modules => [qw(XML::Writer XML::Parser::PerlSAX)]
82 -requires_module => 'Data::Stag'
85 my $guess = Bio::Tools::GuessSeqFormat->new(
86 -file => test_input_file("test.$fmt"),
88 is $guess, $fmt, "$fmt format";
90 ok my $input = Bio::SeqIO->new( -file=>test_input_file("test.$fmt") );
91 ok my $seq = $input->next_seq();
92 isa_ok $seq, 'Bio::PrimarySeqI';
98 # Test AlignIO formats
101 @fmts = qw{clustalw fasta fastq mase mega msf nexus pfam phylip prodom selex stockholm};
102 my %skip_module = map {$_=>1} qw{ fastq };
104 for my $fmt (@fmts) {
105 my $guess = Bio::Tools::GuessSeqFormat->new(
106 -file => test_input_file("testaln.$fmt")
108 is $guess, $fmt, "$fmt format";
109 next if $skip_module{$fmt};
111 ok my $input = Bio::AlignIO->new( -file=>test_input_file("testaln.$fmt") );
112 ok my $seq = $input->next_aln();
113 isa_ok $seq, 'Bio::Align::AlignI';
122 blast => test_input_file('blastp2215.blast'),
123 gcgblast => test_input_file('test.gcgblast'),
124 vcf => test_input_file('example.vcf'),
127 while (my ($fmt, $file) = each %fmts) {
128 my $guess = Bio::Tools::GuessSeqFormat->new(
131 is $guess, $fmt, "$fmt format";