1 # -*-Perl-*- Test Harness script for Bioperl
10 test_begin(-tests => 26,
11 -requires_modules => ['Text::Wrap 98', 'XML::Writer']);
13 use_ok('Bio::Variation::IO');
17 my ($t_file, $o_file, $out_format) = @_;
20 my ($o_ext) = $out_format eq 'flat' ? 'dat' : 'xml';
21 my ($o_format) = $out_format;
22 my ($t_name) = $t_file =~ /(.*)....$/;
27 open my $BEFORE, '<', "$t_name.$o_ext" or die "Could not read file '$t_name.$o_ext': $!\n";
32 ok $before;#"Error in reading input file [$t_name.$o_ext]";
34 my $in = Bio::Variation::IO->new( -file => $t_file);
36 while (my $e = $in->next) {
39 my $count = scalar @entries;
40 cmp_ok @entries, '>', 0;# "No SeqDiff objects [$count]";
42 my $out = Bio::Variation::IO->new( -FILE => ">$o_file",
43 -FORMAT => $o_format);
45 foreach my $e (@entries) {
46 $out->write($e) or $out_ok = 0;
48 undef($out); # Flush to disk
49 ok $out_ok;# "error writing variants";
54 open my $AFTER, '<', $o_file or die "Could not read file '$o_file': $!\n";
59 ok $after;# "Error in reading in again the output file [$o_file]";
60 is $before, $after, "test output file compared to input";
61 print STDERR `diff $t_file $o_file` if $before ne $after;
64 io (test_input_file('mutations.dat'),
65 test_output_file(), 'flat'); #1..5
66 io (test_input_file('polymorphism.dat'),
67 test_output_file(), 'flat'); #6..10
70 test_skip(-tests => 15, -requires_modules => [qw(XML::Twig
75 if( $XML::Writer::VERSION >= 0.5 ) {
76 io (test_input_file('mutations.xml'),
77 test_output_file(), 'xml'); #10..12
79 io (test_input_file('mutations.old.xml'),
80 test_output_file(), 'xml'); #10..12
85 if( $XML::Writer::VERSION >= 0.5 ) {
86 io (test_input_file('polymorphism.xml'),
87 test_output_file(), 'xml'); #13..14
89 io (test_input_file('polymorphism.old.xml'),
90 test_output_file(), 'xml'); #13..14
96 if( $XML::Writer::VERSION >= 0.5 ) {
97 io (test_input_file('mutations.dat'),
98 test_output_file(), 'xml'); #15..25
100 io (test_input_file('mutations.old.dat'),
101 test_output_file(), 'xml'); #15..25