~ubuntu-branches/ubuntu/saucy/bioperl/saucy-proposed

« back to all changes in this revision

Viewing changes to t/Perl.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
 
# This is -*-Perl-*- code
2
 
## Bioperl Test Harness Script for Modules
3
 
##
4
 
# $Id: Perl.t,v 1.8.6.1 2006/10/16 17:08:15 sendu Exp $
5
 
 
6
 
# Before `make install' is performed this script should be runnable with
7
 
# `make test'. After `make install' it should work as `perl test.t'
 
1
# -*-Perl-*- Test Harness script for Bioperl
 
2
# $Id: Perl.t 15112 2008-12-08 18:12:38Z sendu $
8
3
 
9
4
use strict;
10
 
use vars qw($NUMTESTS $DEBUG $BIODBTESTS);
11
 
$DEBUG = $ENV{'BIOPERLDEBUG'} || 0;
12
 
 
13
 
my $error;
14
5
 
15
6
BEGIN { 
16
 
        # to handle systems with no installed Test module
17
 
        # we include the t dir (where a copy of Test.pm is located)
18
 
        # as a fallback
19
 
        eval { require Test; };
20
 
        $error = 0;
21
 
        if( $@ ) {
22
 
                use lib 't';
23
 
        }
24
 
        use Test;
25
 
 
26
 
        $NUMTESTS = 14;
27
 
        $BIODBTESTS = 5;
28
 
        plan tests => $NUMTESTS;
29
 
        eval { require IO::String };
30
 
        if( $@ ) {
31
 
                print STDERR "IO::String not installed. This means the Bio::DB::* modules are not usable. Skipping some tests.\n";
32
 
                for( 1..$BIODBTESTS ) {
33
 
                        skip("IO::String not installed. This means the Bio::DB::* modules are not usable. Skipping some tests",1);
34
 
                }
35
 
                $error = 1;
36
 
        }
37
 
}
38
 
 
39
 
END {
40
 
        # clean up after oneself
41
 
        unlink (  'Perltmp' );
42
 
        for ( $Test::ntest..$NUMTESTS ) {
43
 
                skip("Unable to run database access tests",1);
44
 
        }
45
 
}
46
 
 
47
 
use Bio::Perl;
48
 
use File::Spec;
49
 
 
50
 
## End of black magic.
51
 
##
52
 
## Insert additional test code below but remember to change
53
 
## the print "1..x\n" in the BEGIN block to reflect the
54
 
## total number of tests that will be run. 
 
7
        use lib '.';
 
8
    use Bio::Root::Test;
 
9
    
 
10
    test_begin(-tests => 29,
 
11
                           -requires_module => 'IO::String');
 
12
        
 
13
        use_ok('Bio::Perl');
 
14
}
 
15
 
 
16
# Bio::Perl isn't OO so we don't see Bio::Perl->new() here
55
17
 
56
18
my ($seq_object,$filename,@seq_object_array);
57
19
 
58
 
 
59
 
 
60
20
# will guess file format from extension
61
 
$filename = File::Spec->catfile(qw(t data cysprot1.fa));
62
 
ok ($seq_object = read_sequence($filename)); 
 
21
$filename = test_input_file('cysprot1.fa');
 
22
ok ($seq_object = read_sequence($filename));
 
23
isa_ok $seq_object, 'Bio::SeqI';
 
24
 
63
25
# forces genbank format
64
 
$filename = File::Spec->catfile(qw(t data AF165282.gb));
65
 
ok  ($seq_object = read_sequence($filename,'genbank')); 
 
26
$filename = test_input_file('AF165282.gb');
 
27
ok  ($seq_object = read_sequence($filename,'genbank'));
 
28
isa_ok $seq_object, 'Bio::SeqI';
 
29
 
66
30
# reads an array of sequences
67
 
$filename = File::Spec->catfile(qw(t data amino.fa));
68
 
ok (@seq_object_array = read_all_sequences($filename,'fasta'), 2); 
69
 
$filename = 'Perltmp';
 
31
$filename = test_input_file('amino.fa');
 
32
is (@seq_object_array = read_all_sequences($filename,'fasta'), 2);
 
33
isa_ok $seq_object_array[0], 'Bio::SeqI';
 
34
isa_ok $seq_object_array[1], 'Bio::SeqI';
 
35
 
 
36
$filename = test_output_file();
70
37
ok write_sequence(">$filename",'genbank',$seq_object);
71
38
ok ($seq_object = new_sequence("ATTGGTTTGGGGACCCAATTTGTGTGTTATATGTA","myname","AL12232"));
 
39
isa_ok $seq_object, 'Bio::SeqI';
72
40
 
73
41
my $trans;
74
42
 
75
43
ok ($trans = translate($seq_object));
76
44
 
 
45
isa_ok $trans, 'Bio::SeqI';
 
46
 
77
47
ok ($trans = translate("ATTGGTTTGGGGACCCAATTTGTGTGTTATATGTA"));
78
48
 
 
49
isa_ok $trans, 'Bio::PrimarySeqI';
 
50
 
79
51
ok ($trans = translate_as_string($seq_object));
80
52
 
 
53
is $trans, 'IGLGTQFVCYM';
 
54
 
 
55
$trans = '';
 
56
 
81
57
ok ($trans = translate_as_string("ATTGGTTTGGGGACCCAATTTGTGTGTTATATGTA"));
82
58
 
 
59
is $trans, 'IGLGTQFVCYM';
83
60
 
84
61
# we need to keep tests that depend on net connection at the end
85
 
 
86
 
unless ( $error ) {
87
 
    # swissprot
88
 
    eval {
89
 
        ok ($seq_object = get_sequence('swissprot',"ROA1_HUMAN"));
90
 
    };
91
 
    if ($@) {
92
 
        if($DEBUG) {
93
 
            warn "Warning: Couldn't connect to SWISS-PROT! Do you have network access?\n";
94
 
        }
95
 
        exit 0;
96
 
    }
97
 
 
 
62
# these now run only with BIOPERLDEBUG set
 
63
 
 
64
SKIP: {
 
65
        test_skip(-tests => 10, -requires_networking => 1);
 
66
        
 
67
        # swissprot
 
68
        SKIP: {
 
69
                eval {
 
70
                        $seq_object = get_sequence('swissprot',"ROA1_HUMAN");
 
71
                };
 
72
                if ($@) {
 
73
                        skip("problem connecting to SwissProt:$@",2);
 
74
                } else {
 
75
                        ok $seq_object;
 
76
                        isa_ok $seq_object, 'Bio::SeqI';
 
77
                }
 
78
        }
 
79
        
98
80
    # embl
99
 
    eval {
100
 
        ok ($seq_object = get_sequence('embl',"BUM"));
101
 
    };
102
 
    if ($@) {
103
 
        if($DEBUG ) {
104
 
            warn "Warning: Couldn't connect to EMBL! Do you have network access?\n";
 
81
        SKIP: {
 
82
                eval {
 
83
                        $seq_object = get_sequence('embl',"BUM");
 
84
                };
 
85
                if ($@) {
 
86
                        skip("problem connecting to EMBL:$@",2);
 
87
                } else {
 
88
                        ok $seq_object;
 
89
                        isa_ok $seq_object, 'Bio::SeqI';
 
90
                }
105
91
        }
106
 
        exit 0;
107
 
    }
108
92
 
109
 
    # genbank
110
 
    eval {
111
 
        ok ($seq_object = get_sequence('genbank',"AI129902"));
112
 
    };
113
 
    if ($@) {
114
 
        if($DEBUG) {
115
 
            warn "Warning: Couldn't connect to GenBank! Do you have network access?\n";
 
93
        # genbank       
 
94
        SKIP: {
 
95
                eval {
 
96
                        $seq_object = get_sequence('genbank',"AI129902");
 
97
                };
 
98
                if ($@) {
 
99
                        skip("problem connecting to GenBank:$@",2);
 
100
                } else {
 
101
                        ok $seq_object;
 
102
                        isa_ok $seq_object, 'Bio::SeqI';
 
103
                }
116
104
        }
117
 
        exit 0;
118
 
    }
119
105
 
120
106
    # refseq
121
 
    eval {
122
 
        ok ($seq_object = get_sequence('genbank',"NM_006732"));
123
 
    };
124
 
    if ($@) {
125
 
        if( $DEBUG ) {
126
 
            warn "Warning: Couldn't connect to RefSeq! Do you have network access?\n";
127
 
        }
128
 
        exit 0;
129
 
    }
130
 
 
131
 
        # genbank
132
 
    eval {
133
 
        ok ($seq_object = get_sequence('genpept',"AAC06201"));
134
 
    };
135
 
    if ($@) {
136
 
        if($DEBUG) {
137
 
            warn "Warning: Couldn't connect to GenPept! Do you have network access?\n";
138
 
        }
139
 
        exit 0;
140
 
    }
141
 
 
 
107
        SKIP: {
 
108
                eval {
 
109
                        $seq_object = get_sequence('genbank',"NM_006732");
 
110
                };
 
111
                if( $@ ) {
 
112
                        skip("problem connecting to RefSeq:$@",2);
 
113
                } else {
 
114
                        ok $seq_object;
 
115
                        isa_ok $seq_object, 'Bio::SeqI';
 
116
                }
 
117
        }
 
118
        
 
119
        # genpept
 
120
        SKIP: {
 
121
                eval {
 
122
                        $seq_object = get_sequence('genpept',"AAC06201");
 
123
                };
 
124
                if ($@) {
 
125
                        skip("problem connecting to RefSeq:$@",2);
 
126
                } else {
 
127
                        ok $seq_object;
 
128
                        isa_ok $seq_object, 'Bio::SeqI';
 
129
                }
 
130
        }
142
131
}