File: RefSeq.t

package info (click to toggle)
bioperl 1.4-1
  • links: PTS
  • area: main
  • in suites: etch, etch-m68k, sarge
  • size: 20,336 kB
  • ctags: 8,476
  • sloc: perl: 119,890; xml: 6,001; lisp: 121; makefile: 57
file content (111 lines) | stat: -rw-r--r-- 2,535 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
# This is -*-Perl-*- code
## Bioperl Test Harness Script for Modules
##
# $Id: RefSeq.t,v 1.10 2003/12/18 10:35:24 heikki Exp $

# Before `make install' is performed this script should be runnable with
# `make test'. After `make install' it should work as `perl test.t'

use strict;
use vars qw($NUMTESTS $DEBUG);
$DEBUG = $ENV{'BIOPERLDEBUG'} || 0;
my $error;

BEGIN { 
    # to handle systems with no installed Test module
    # we include the t dir (where a copy of Test.pm is located)
    # as a fallback
    eval { require Test; };
    $error = 0;
    if( $@ ) {
	use lib 't';
    }
    use Test;

    $NUMTESTS = 13;
    plan tests => $NUMTESTS;
    eval { require 'IO/String.pm' };
    if( $@ ) {
	for( $Test::ntest..$NUMTESTS ) {
	    skip("IO::String not installed. This means the Bio::DB::* modules are not usable. Skipping tests",1);
	}
       $error = 1; 
    }
}

END {
    for ( $Test::ntest..$NUMTESTS ) {
        skip("Skipping tests which require remote servers - set env variable BIOPERLDEBUG to test",1);
    }
}

if( $error ==  1 ) {
    exit(0);
}

require  Bio::DB::RefSeq;
require  Bio::DB::GenBank;
require  Bio::DB::EMBL;

my $testnum;
my $verbose = 0;

## End of black magic.
##
## Insert additional test code below but remember to change
## the print "1..x\n" in the BEGIN block to reflect the
## total number of tests that will be run. 

my ($db,$seq,$db2,$seq2,$seqio);
# get a single seq

$seq = $seqio = undef;

#test redirection from GenBank and EMBL
$verbose = -1;
#GenBank
ok $db = new Bio::DB::GenBank('-verbose'=>$verbose) ;     
#EMBL
ok $db2 = new Bio::DB::EMBL('-verbose'=>$verbose) ;     

eval {
    $seq = $db->get_Seq_by_acc('NT_006732');
    $seq2 = $db2->get_Seq_by_acc('NT_006732');
};
ok $@;

exit unless $DEBUG;
eval {
    ok($seq = $db->get_Seq_by_acc('NM_006732'));
    ok($seq && $seq->length eq 3775);
    ok $seq2 = $db2->get_Seq_by_acc('NM_006732');
    ok($seq2 && $seq2->length eq 3775);
};

if ($@) {
    if( $DEBUG ) {
	print STDERR "Warning: Couldn't connect to RefSeq with Bio::DB::RefSeq.pm!\n" . $@;
    }
    exit(0);
}



$verbose = 0;

eval { 
    ok defined($db = new Bio::DB::RefSeq(-verbose=>$verbose)); 
    ok(defined($seq = $db->get_Seq_by_acc('NM_006732')));
    ok( $seq->length, 3775);
    ok defined ($db->request_format('fasta'));
    ok(defined($seq = $db->get_Seq_by_acc('NM_006732')));
    ok( $seq->length, 3775); 
};

if ($@) {
    if( $DEBUG ) {
	print STDERR "Warning: Couldn't connect to RefSeq with Bio::DB::RefSeq.pm!\n" . $@;
    }
    exit(0);
}