1
# This is -*-Perl-*- code
2
## Bioperl Test Harness Script for Modules
4
# $Id: Perl.t,v 1.8.6.1 2006/10/16 17:08:15 sendu Exp $
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 $
10
use vars qw($NUMTESTS $DEBUG $BIODBTESTS);
11
$DEBUG = $ENV{'BIOPERLDEBUG'} || 0;
16
# to handle systems with no installed Test module
17
# we include the t dir (where a copy of Test.pm is located)
19
eval { require Test; };
28
plan tests => $NUMTESTS;
29
eval { require IO::String };
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);
40
# clean up after oneself
42
for ( $Test::ntest..$NUMTESTS ) {
43
skip("Unable to run database access tests",1);
50
## End of black magic.
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.
10
test_begin(-tests => 29,
11
-requires_module => 'IO::String');
16
# Bio::Perl isn't OO so we don't see Bio::Perl->new() here
56
18
my ($seq_object,$filename,@seq_object_array);
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';
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';
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';
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';
75
43
ok ($trans = translate($seq_object));
45
isa_ok $trans, 'Bio::SeqI';
77
47
ok ($trans = translate("ATTGGTTTGGGGACCCAATTTGTGTGTTATATGTA"));
49
isa_ok $trans, 'Bio::PrimarySeqI';
79
51
ok ($trans = translate_as_string($seq_object));
53
is $trans, 'IGLGTQFVCYM';
81
57
ok ($trans = translate_as_string("ATTGGTTTGGGGACCCAATTTGTGTGTTATATGTA"));
59
is $trans, 'IGLGTQFVCYM';
84
61
# we need to keep tests that depend on net connection at the end
89
ok ($seq_object = get_sequence('swissprot',"ROA1_HUMAN"));
93
warn "Warning: Couldn't connect to SWISS-PROT! Do you have network access?\n";
62
# these now run only with BIOPERLDEBUG set
65
test_skip(-tests => 10, -requires_networking => 1);
70
$seq_object = get_sequence('swissprot',"ROA1_HUMAN");
73
skip("problem connecting to SwissProt:$@",2);
76
isa_ok $seq_object, 'Bio::SeqI';
100
ok ($seq_object = get_sequence('embl',"BUM"));
104
warn "Warning: Couldn't connect to EMBL! Do you have network access?\n";
83
$seq_object = get_sequence('embl',"BUM");
86
skip("problem connecting to EMBL:$@",2);
89
isa_ok $seq_object, 'Bio::SeqI';
111
ok ($seq_object = get_sequence('genbank',"AI129902"));
115
warn "Warning: Couldn't connect to GenBank! Do you have network access?\n";
96
$seq_object = get_sequence('genbank',"AI129902");
99
skip("problem connecting to GenBank:$@",2);
102
isa_ok $seq_object, 'Bio::SeqI';
122
ok ($seq_object = get_sequence('genbank',"NM_006732"));
126
warn "Warning: Couldn't connect to RefSeq! Do you have network access?\n";
133
ok ($seq_object = get_sequence('genpept',"AAC06201"));
137
warn "Warning: Couldn't connect to GenPept! Do you have network access?\n";
109
$seq_object = get_sequence('genbank',"NM_006732");
112
skip("problem connecting to RefSeq:$@",2);
115
isa_ok $seq_object, 'Bio::SeqI';
122
$seq_object = get_sequence('genpept',"AAC06201");
125
skip("problem connecting to RefSeq:$@",2);
128
isa_ok $seq_object, 'Bio::SeqI';