1 # -*-Perl-*- Test Harness script for Bioperl
10 test_begin(-tests => 41);
15 my $verbose = test_debug();
17 # Basic read and/or write tests for SeqIO. Specific tests for
18 # given module should go into their own file.
20 my @formats = qw(gcg fasta raw pir tab ace );
21 # The following files or formats are failing: swiss genbank interpro embl
23 foreach my $format (@formats) {
24 print "======== $format ========\n" if $verbose;
31 my $str = Bio::SeqIO->new(-file=> test_input_file("test.$format"),
33 ok $seq = $str->next_seq();
34 print "Sequence 1 of 2 from $format stream:\n", $seq->seq, "\n\n" if $verbose;
35 unless ($format eq 'raw') {
36 is $seq->id, 'roa1_drome',"ID for format $format";
40 unless ($format eq 'gcg') { # GCG file can contain only one sequence
41 ok $seq = $str->next_seq();
42 print "Sequence 2 of 2 from $format stream:\n", $seq->seq, $seq->seq, "\n" if $verbose;
45 my $outfile = test_output_file();
46 my $out = Bio::SeqIO->new(-file => ">$outfile",
48 ok $out->write_seq($seq);
49 if ($format eq 'fasta') {
51 ok($id_type = $out->preferred_id_type('accession.version'),
60 test_skip(-tests => 6, -requires_modules => [qw(Algorithm::Diff
63 use_ok('Algorithm::Diff');
64 eval "use Algorithm::Diff qw(diff LCS);";
65 use_ok('IO::ScalarArray');
69 #'test.embl' => 'embl',
71 'test.fasta' => 'fasta',
72 #'test.game' => 'game',
74 #'test.genbank' => 'genbank',
76 #'test_badlf.gcg' => 'gcg'
79 while( my ($file, $type) = each %files ) {
80 my $filename = test_input_file($file);
81 print "processing file $filename\n" if $verbose;
82 open(FILE, "< $filename") or die("cannot open $filename");
84 my $in = new IO::String(join('', @datain));
85 my $seqin = new Bio::SeqIO( -fh => $in,
87 my $out = new IO::String;
88 my $seqout = new Bio::SeqIO( -fh => $out,
91 while( defined($seq = $seqin->next_seq) ) {
92 $seqout->write_seq($seq);
96 my $strref = $out->string_ref;
97 my @dataout = map { $_."\n"} split(/\n/, $$strref );
98 my @diffs = &diff( \@datain, \@dataout);
101 if(@diffs && $verbose) {
102 foreach my $d ( @diffs ) {
103 foreach my $diff ( @$d ) {
105 print $diff->[0], $diff->[1], "\n>", $diff->[2], "\n";
108 print "in is \n", join('', @datain), "\n";
109 print "out is \n", join('',@dataout), "\n";