1 # -*-Perl-*- Test Harness script for Bioperl
10 test_begin(-tests => 45);
15 my $verbose = test_debug();
17 my @formats = qw(gcg fasta raw pir tab ace );
18 # The following files or formats are failing: swiss genbank interpro embl
20 foreach my $format (@formats) {
21 print "======== $format ========\n" if $verbose;
28 my $str = Bio::SeqIO->new(-file=> test_input_file("test.$format"),
30 ok $seq = $str->next_seq();
31 print "Sequence 1 of 2 from $format stream:\n", $seq->seq, "\n\n" if $verbose;
32 unless ($format eq 'raw') {
33 is $seq->id, 'roa1_drome',"ID for format $format";
37 unless ($format eq 'gcg') { # GCG file can contain only one sequence
38 ok $seq = $str->next_seq();
39 print "Sequence 2 of 2 from $format stream:\n", $seq->seq, $seq->seq, "\n" if $verbose;
42 my $outfile = test_output_file();
43 my $out = Bio::SeqIO->new(-file => ">$outfile",
45 ok $out->write_seq($seq);
46 if ($format eq 'fasta') {
48 ok($id_type = $out->preferred_id_type('accession.version'),
57 test_skip(-tests => 6, -requires_modules => [qw(Algorithm::Diff
60 use_ok('Algorithm::Diff');
61 eval "use Algorithm::Diff qw(diff LCS);";
62 use_ok('IO::ScalarArray');
66 #'test.embl' => 'embl',
68 'test.fasta' => 'fasta',
69 #'test.game' => 'game',
71 #'test.genbank' => 'genbank',
73 #'test_badlf.gcg' => 'gcg'
76 while( my ($file, $type) = each %files ) {
77 my $filename = test_input_file($file);
78 print "processing file $filename\n" if $verbose;
79 open(FILE, "< $filename") or die("cannot open $filename");
81 my $in = new IO::String(join('', @datain));
82 my $seqin = new Bio::SeqIO( -fh => $in,
84 my $out = new IO::String;
85 my $seqout = new Bio::SeqIO( -fh => $out,
88 while( defined($seq = $seqin->next_seq) ) {
89 $seqout->write_seq($seq);
93 my $strref = $out->string_ref;
94 my @dataout = map { $_."\n"} split(/\n/, $$strref );
95 my @diffs = &diff( \@datain, \@dataout);
98 if(@diffs && $verbose) {
99 foreach my $d ( @diffs ) {
100 foreach my $diff ( @$d ) {
102 print $diff->[0], $diff->[1], "\n>", $diff->[2], "\n";
105 print "in is \n", join('', @datain), "\n";
106 print "out is \n", join('',@dataout), "\n";
111 # simple tests specific to Bio::SeqIO interface (applicable to all SeqIO
114 ############ EXCEPTION HANDLING ############
118 } qr/No file, fh, or string argument provided/, 'Must pass a file or file handle';
121 Bio::SeqIO->new(-fh => undef);
122 } qr/fh argument provided, but with an undefined value/,
123 'Must pass a file or file handle';
126 Bio::SeqIO->new(-file => undef);
127 } qr/file argument provided, but with an undefined value/,
128 'Must pass a file or file handle';
131 Bio::SeqIO->new(-file => 'foo.bar');
132 } qr/Can not open 'foo.bar' for reading: No such file or directory/,
133 'Must pass a real file';