~ubuntu-branches/ubuntu/trusty/bioperl/trusty-proposed

« back to all changes in this revision

Viewing changes to t/Variation/Variation_IO.t

  • Committer: Bazaar Package Importer
  • Author(s): Charles Plessy
  • Date: 2009-03-10 07:19:11 UTC
  • mfrom: (1.2.3 upstream)
  • Revision ID: james.westby@ubuntu.com-20090310071911-fukqzw54pyb1f0bd
Tags: 1.6.0-2
* Removed patch system (not used):
  - removed instuctions in debian/rules;
  - removed quilt from Build-Depends in debian/control.
* Re-enabled tests:
  - uncommented test command in debian/rules;
  - uncommented previously missing build-dependencies in debian/control.
  - Re-enabled tests and uncommented build-dependencies accordingly.
* Removed libmodule-build-perl and libtest-harness-perl from
  Build-Depends-Indep (provided by perl-modules).
* Better cleaning of empty directories using find -type d -empty -delete
  instead of rmdir in debian/rules (LP: #324001).

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
# -*-Perl-*- Test Harness script for Bioperl
 
2
# $Id: Variation_IO.t 15112 2008-12-08 18:12:38Z sendu $
 
3
 
 
4
use strict;
 
5
 
 
6
BEGIN { 
 
7
    use lib '.';
 
8
    use Bio::Root::Test;
 
9
    
 
10
    test_begin(-tests => 26,
 
11
                           -requires_modules => ['Text::Wrap 98', 'XML::Writer']);
 
12
        
 
13
        use_ok('Bio::Variation::IO');
 
14
}
 
15
 
 
16
sub io {
 
17
    my ($t_file, $o_file, $out_format) = @_; 
 
18
    my $res;
 
19
        
 
20
    my ($o_ext) = $out_format eq 'flat' ? 'dat' : 'xml';
 
21
    my ($o_format) = $out_format;
 
22
    my ($t_name) = $t_file =~ /(.*)....$/;
 
23
        
 
24
    my( $before );
 
25
    {
 
26
        local $/ = undef;
 
27
        local *BEFORE;
 
28
        open(BEFORE, "$t_name.$o_ext") || die "couldn't open $t_name.$o_ext\n";;
 
29
        $before = <BEFORE>;
 
30
        close BEFORE;
 
31
    }
 
32
 
 
33
    ok $before;#"Error in reading input file [$t_name.$o_ext]";
 
34
 
 
35
    my $in = Bio::Variation::IO->new( -file => $t_file);
 
36
    my  @entries ;
 
37
    while (my $e = $in->next) {
 
38
        push @entries, $e;
 
39
    }
 
40
    my $count = scalar @entries;
 
41
    cmp_ok @entries, '>', 0;# "No SeqDiff objects [$count]";
 
42
 
 
43
    my $out = Bio::Variation::IO->new( -FILE => ">$o_file", 
 
44
                                       -FORMAT => $o_format);
 
45
    my $out_ok = 1;
 
46
    foreach my $e (@entries) {
 
47
        $out->write($e) or $out_ok = 0;
 
48
    }
 
49
    undef($out);  # Flush to disk
 
50
    ok $out_ok;#  "error writing variants";
 
51
 
 
52
    my( $after );
 
53
    {
 
54
        local $/ = undef;
 
55
        local *AFTER;
 
56
        open AFTER, $o_file;
 
57
        $after = <AFTER>;
 
58
        close AFTER;
 
59
    }
 
60
 
 
61
    ok $after;# "Error in reading in again the output file [$o_file]";
 
62
    is $before, $after, "test output file compared to input";
 
63
    print STDERR `diff $t_file $o_file` if $before ne $after;
 
64
}
 
65
 
 
66
io  (test_input_file('mutations.dat'), 
 
67
     test_output_file(), 'flat'); #1..5
 
68
io  (test_input_file('polymorphism.dat'), 
 
69
     test_output_file(), 'flat'); #6..10
 
70
 
 
71
SKIP: {
 
72
        test_skip(-tests => 15, -requires_modules => [qw(XML::Twig
 
73
                                                                                                     XML::Writer
 
74
                                                                                                     IO::String)]);
 
75
 
 
76
        eval {
 
77
                if( $XML::Writer::VERSION >= 0.5 ) { 
 
78
                io  (test_input_file('mutations.xml'), 
 
79
                         test_output_file(), 'xml'); #10..12
 
80
                } else { 
 
81
                io  (test_input_file('mutations.old.xml'), 
 
82
                         test_output_file(), 'xml'); #10..12
 
83
                }
 
84
        };
 
85
        
 
86
        eval {
 
87
                if( $XML::Writer::VERSION >= 0.5 ) { 
 
88
                io  (test_input_file('polymorphism.xml'), 
 
89
                         test_output_file(), 'xml'); #13..14
 
90
                } else { 
 
91
                io  (test_input_file('polymorphism.old.xml'), 
 
92
                         test_output_file(), 'xml'); #13..14
 
93
        
 
94
                }
 
95
        };
 
96
        
 
97
        eval { 
 
98
                if( $XML::Writer::VERSION >= 0.5 ) { 
 
99
                io  (test_input_file('mutations.dat'), 
 
100
                         test_output_file(), 'xml'); #15..25
 
101
                } else { 
 
102
                io  (test_input_file('mutations.old.dat'), 
 
103
                         test_output_file(), 'xml'); #15..25
 
104
                }
 
105
        };
 
106
}