test hook
[bioperl-live.git] / t / Perl.t
blobb8e997b0d10b891a1ae47a1ae39f6382bbb3ff05
1 # -*-Perl-*- Test Harness script for Bioperl
2 # $Id$
4 use strict;
6 BEGIN { 
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');
16 # Bio::Perl isn't OO so we don't see Bio::Perl->new() here
18 my ($seq_object,$filename,@seq_object_array);
20 # will guess file format from extension
21 $filename = test_input_file('cysprot1.fa');
22 ok ($seq_object = read_sequence($filename));
23 isa_ok $seq_object, 'Bio::SeqI';
25 # forces genbank format
26 $filename = test_input_file('AF165282.gb');
27 ok  ($seq_object = read_sequence($filename,'genbank'));
28 isa_ok $seq_object, 'Bio::SeqI';
30 # reads an array of sequences
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';
36 $filename = test_output_file();
37 ok write_sequence(">$filename",'genbank',$seq_object);
38 ok ($seq_object = new_sequence("ATTGGTTTGGGGACCCAATTTGTGTGTTATATGTA","myname","AL12232"));
39 isa_ok $seq_object, 'Bio::SeqI';
41 my $trans;
43 ok ($trans = translate($seq_object));
45 isa_ok $trans, 'Bio::SeqI';
47 ok ($trans = translate("ATTGGTTTGGGGACCCAATTTGTGTGTTATATGTA"));
49 isa_ok $trans, 'Bio::PrimarySeqI';
51 ok ($trans = translate_as_string($seq_object));
53 is $trans, 'IGLGTQFVCYM';
55 $trans = '';
57 ok ($trans = translate_as_string("ATTGGTTTGGGGACCCAATTTGTGTGTTATATGTA"));
59 is $trans, 'IGLGTQFVCYM';
61 # we need to keep tests that depend on net connection at the end
62 # these now run only with BIOPERLDEBUG set
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         
80     # embl
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                 }
91         }
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                 }
104         }
106     # refseq
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         }