2
## Bioperl Test Harness Script for Modules
3
## $Id: Variation_IO.t,v 1.20 2005/09/17 02:11:21 bosborne Exp $
8
use vars qw($NUMTESTS $error);
10
eval { require Test; };
20
if ( $@ || $Text::Wrap::VERSION < 98 ) {
21
print STDERR "Skip tests - missing Text::Wrap 98 installed or XML::Writer\n";
25
plan tests => $NUMTESTS;
29
foreach ( $Test::ntest..$NUMTESTS) {
30
skip("Cannot complete Variation_IO tests",1);
38
use Bio::Variation::IO;
44
if ($file =~ /.*dat$/) {
47
elsif ($file =~ /.*xml$/ ) {
50
print "Wrong extension! [$file]";
58
my ($name) = $file =~ /.*.(...)$/;
64
my ($name) = $file =~ /(.*)....$/;
69
my ($t_file, $o_file) = @_;
72
my ($t_ext) = ext ($t_file);
73
my ($o_ext) = ext ($o_file);
74
my ($t_format) = fileformat ($t_file);
75
my ($o_format) = fileformat ($o_file);
76
my ($t_name) = filename($t_file);
77
my ($o_name) = filename($o_file);
83
open BEFORE, "$t_name.$o_ext";
88
ok $before;#"Error in reading input file [$t_name.$o_ext]";
90
my $in = Bio::Variation::IO->new( -file => $t_file);
92
while (my $e = $in->next) {
95
my $count = scalar @entries;
96
ok @entries > 0;# "No SeqDiff objects [$count]";
98
my $out = Bio::Variation::IO->new( -FILE => "> $o_file",
99
-FORMAT => $o_format);
101
foreach my $e (@entries) {
102
$out->write($e) or $out_ok = 0;
104
undef($out); # Flush to disk
105
ok $out_ok;# "error writing variants";
116
ok $after;# "Error in reading in again the output file [$o_file]";
117
ok $before, $after, "test output file differs from input";
118
print STDERR `diff $t_file $o_file` if $before ne $after;
122
io (Bio::Root::IO->catfile("t","data","mutations.dat"),
123
Bio::Root::IO->catfile("t","data","mutations.out.dat")); #1..5
124
io (Bio::Root::IO->catfile("t","data","polymorphism.dat"),
125
Bio::Root::IO->catfile("t","data","polymorphism.out.dat")); #6..10
128
require Bio::Variation::IO::xml;
133
"\nThe XML-format conversion requires the CPAN modules ",
134
"XML::Twig, XML::Writer, and IO::String to be installed ",
135
"on your system, which they probably aren't. Skipping these tests.\n";
136
for( $Test::ntest..$NUMTESTS) {
137
skip("No XML::Twig installed", 1);
143
if( $XML::Writer::VERSION >= 0.5 ) {
144
io (Bio::Root::IO->catfile("t","data","mutations.xml"),
145
Bio::Root::IO->catfile("t","data","mutations.out.xml")); #10..12
147
io (Bio::Root::IO->catfile("t","data","mutations.old.xml"),
148
Bio::Root::IO->catfile("t","data","mutations.out.xml")); #10..12
153
if( $XML::Writer::VERSION >= 0.5 ) {
154
io (Bio::Root::IO->catfile("t","data","polymorphism.xml"),
155
Bio::Root::IO->catfile("t","data","polymorphism.out.xml")); #13..14
157
io (Bio::Root::IO->catfile("t","data","polymorphism.old.xml"),
158
Bio::Root::IO->catfile("t","data","polymorphism.out.xml")); #13..14
164
if( $XML::Writer::VERSION >= 0.5 ) {
165
io (Bio::Root::IO->catfile("t","data","mutations.dat"),
166
Bio::Root::IO->catfile("t","data","mutations.out.xml")); #15..25
168
io (Bio::Root::IO->catfile("t","data","mutations.old.dat"),
169
Bio::Root::IO->catfile("t","data","mutations.old.out.xml")); #15..25