~ubuntu-branches/ubuntu/raring/bioperl/raring

« back to all changes in this revision

Viewing changes to t/Variation_IO.t

  • Committer: Bazaar Package Importer
  • Author(s): Charles Plessy
  • Date: 2008-03-18 14:44:57 UTC
  • mfrom: (4 hardy)
  • mto: This revision was merged to the branch mainline in revision 6.
  • Revision ID: james.westby@ubuntu.com-20080318144457-1jjoztrvqwf0gruk
* debian/control:
  - Removed MIA Matt Hope (dopey) from the Uploaders field.
    Thank you for your work, Matt. I hope you are doing well.
  - Downgraded some recommended package to the 'Suggests' priority,
    according to the following discussion on Upstream's mail list.
    http://bioperl.org/pipermail/bioperl-l/2008-March/027379.html
    (Closes: #448890)
* debian/copyright converted to machine-readable format.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
# -*-Perl-*-
2
2
## Bioperl Test Harness Script for Modules
3
 
## $Id: Variation_IO.t,v 1.13 2001/12/14 17:52:44 jason Exp $
 
3
## $Id: Variation_IO.t,v 1.20 2005/09/17 02:11:21 bosborne Exp $
4
4
 
5
5
use strict;
6
 
use vars qw($NUMTESTS);
7
 
BEGIN { 
8
 
    eval { require Test; };
9
 
    if( $@ ) {
10
 
        use lib 't';
11
 
    }
12
 
    use Test;
13
 
 
14
 
    eval { require 'Text/Wrap.pm' };
15
 
    if( $@ || $Text::Wrap::VERSION < 98 ) {
16
 
        print STDERR "Must have at least Text::Wrap 98 installed\n";
17
 
        plan tests => 1;
18
 
        ok(1);
 
6
 
 
7
BEGIN {
 
8
        use vars qw($NUMTESTS $error);
 
9
        $error = 0;
 
10
        eval { require Test; };
 
11
        if( $@ ) {
 
12
                use lib 't';
 
13
        }
 
14
        use Test;
 
15
 
 
16
        eval {
 
17
                require Text::Wrap;
 
18
                require XML::Writer;
 
19
        };
 
20
        if ( $@ || $Text::Wrap::VERSION < 98 ) {
 
21
                print STDERR "Skip tests - missing Text::Wrap 98 installed or XML::Writer\n";
 
22
                $error = 1;
 
23
        }
 
24
        $NUMTESTS = 25;
 
25
        plan tests => $NUMTESTS;
 
26
}
 
27
 
 
28
END {
 
29
        foreach ( $Test::ntest..$NUMTESTS) {
 
30
                skip("Cannot complete Variation_IO tests",1);
 
31
        }
 
32
}
 
33
 
 
34
if ($error == 1 ) {
19
35
        exit(0);
20
 
    }
21
 
    $NUMTESTS = 25;
22
 
    plan tests => $NUMTESTS;
23
36
}
24
37
 
25
 
use Text::Wrap 98;
26
38
use Bio::Variation::IO;
27
39
use Bio::Root::IO;
28
40
 
29
41
sub fileformat ($) {
30
 
    my ($file) = shift;
31
 
    my $format;
32
 
    if ($file =~ /.*dat$/) {
33
 
        $format = 'flat';
34
 
    }
35
 
    elsif ($file =~ /.*xml$/ ) {
36
 
        $format = 'xml';
37
 
    } else {
38
 
        print "Wrong extension! [$file]";
39
 
        exit;
40
 
    }
41
 
    return $format;
 
42
        my ($file) = shift;
 
43
        my $format;
 
44
        if ($file =~ /.*dat$/) {
 
45
                $format = 'flat';
 
46
        }
 
47
        elsif ($file =~ /.*xml$/ ) {
 
48
                $format = 'xml';
 
49
        } else {
 
50
                print "Wrong extension! [$file]";
 
51
                exit;
 
52
        }
 
53
        return $format;
42
54
}
43
55
 
44
56
sub ext ($) {
45
 
    my ($file) = @_;
46
 
    my ($name) = $file =~ /.*.(...)$/;
47
 
    return $name;
 
57
        my ($file) = @_;
 
58
        my ($name) = $file =~ /.*.(...)$/;
 
59
        return $name;
48
60
}
49
61
 
50
62
sub filename ($) {
51
 
    my ($file) = @_;
52
 
    my ($name) = $file =~ /(.*)....$/;
53
 
    return $name;
 
63
        my ($file) = @_;
 
64
        my ($name) = $file =~ /(.*)....$/;
 
65
        return $name;
54
66
}
55
67
 
56
68
sub io {
82
94
    }
83
95
    my $count = scalar @entries;
84
96
    ok @entries > 0;# "No SeqDiff objects [$count]";
85
 
    
 
97
 
86
98
    my $out = Bio::Variation::IO->new( -FILE => "> $o_file", 
87
99
                                       -FORMAT => $o_format);
88
100
    my $out_ok = 1;
102
114
    }
103
115
 
104
116
    ok $after;# "Error in reading in again the output file [$o_file]";
105
 
 
106
117
    ok $before, $after, "test output file differs from input";
107
118
    print STDERR `diff $t_file $o_file` if $before ne $after;
108
119
    unlink($o_file); 
109
120
}
110
121
 
111
 
 
112
 
 
113
 
 
114
122
io  (Bio::Root::IO->catfile("t","data","mutations.dat"), 
115
 
   Bio::Root::IO->catfile("t","data","mutations.out.dat")); #1..5
116
 
 
 
123
     Bio::Root::IO->catfile("t","data","mutations.out.dat")); #1..5
117
124
io  (Bio::Root::IO->catfile("t","data","polymorphism.dat"), 
118
 
   Bio::Root::IO->catfile("t","data","polymorphism.out.dat")); #6..10
119
 
 
 
125
     Bio::Root::IO->catfile("t","data","polymorphism.out.dat")); #6..10
120
126
 
121
127
eval {
122
128
    require Bio::Variation::IO::xml;
134
140
}
135
141
 
136
142
eval {
137
 
    io  (Bio::Root::IO->catfile("t","data","mutations.xml"), 
138
 
        Bio::Root::IO->catfile("t","data","mutations.out.xml")); #10..12
 
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
 
146
    } else { 
 
147
        io  (Bio::Root::IO->catfile("t","data","mutations.old.xml"), 
 
148
             Bio::Root::IO->catfile("t","data","mutations.out.xml")); #10..12
 
149
    }
139
150
};
140
151
 
141
152
eval {
142
 
    io  (Bio::Root::IO->catfile("t","data","polymorphism.xml"), 
143
 
        Bio::Root::IO->catfile("t","data","polymorphism.out.xml")); #13..14
 
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
 
156
    } else { 
 
157
        io  (Bio::Root::IO->catfile("t","data","polymorphism.old.xml"), 
 
158
             Bio::Root::IO->catfile("t","data","polymorphism.out.xml")); #13..14
 
159
 
 
160
    }
144
161
};
145
162
 
146
 
 
147
163
eval { 
148
 
         io  (Bio::Root::IO->catfile("t","data","mutations.dat"), 
149
 
            Bio::Root::IO->catfile("t","data","mutations.out.xml")); #15..25
 
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
 
167
    } else { 
 
168
        io  (Bio::Root::IO->catfile("t","data","mutations.old.dat"), 
 
169
             Bio::Root::IO->catfile("t","data","mutations.old.out.xml")); #15..25
 
170
    }
150
171
};
151
 
 
152