use
vars
qw($NUMTESTS $DEBUG)
;
$DEBUG
=
$ENV
{
'BIOPERLDEBUG'
} || 0;
use
lib
'.'
,
'./blib/lib'
;
my
$error
;
BEGIN {
$error
= 0;
if
( $@ ) {
}
$NUMTESTS
= 27;
plan
tests
=>
$NUMTESTS
;
if
( $@ ) {
warn
(
"No LWP::UserAgent or IO::String installed\n"
);
$error
= 1;
}
}
END {
foreach
(
$Test::ntest
..
$NUMTESTS
) {
skip(
'unable to run all of the Biblio/Biofetch tests - probably no network or LWP not installed'
,1);
}
}
if
(
$error
== 1 ) {
exit
(0);
}
my
$verbose
= -1;
my
(
$db
,
$db2
,
$seq
,
$seqio
);
$seq
=
$seqio
=
undef
;
ok
defined
(
$db
= new Bio::DB::BioFetch(
-verbose
=>
$verbose
));
eval
{
ok
$db
->db(
'refseq'
);
$seq
=
$db
->get_Seq_by_acc(
'NM_006732'
);
$seq
? ok 1 :
exit
;
ok
$seq
->accession_number;
$db
->db(
'embl'
);
ok(
defined
(
$seq
=
$db
->get_Seq_by_acc(
'J00522'
)));
ok(
$seq
->
length
, 408);
ok(
defined
(
$seq
=
$db
->get_Seq_by_acc(
'J02231'
)));
ok
$seq
->id,
'J02231'
;
ok(
$seq
->
length
, 200);
ok(
defined
(
$seqio
=
$db
->get_Stream_by_id([
'BUM'
])));
undef
$db
;
ok(
defined
(
$seq
=
$seqio
->next_seq()));
ok(
$seq
->
length
, 200);
ok
defined
(
$db2
= new Bio::DB::BioFetch(
-db
=>
'swissprot'
));
ok(
defined
(
$seq
=
$db2
->get_Seq_by_id(
'YNB3_YEAST'
)));
ok(
$seq
->
length
, 125);
ok(
$seq
->division,
'YEAST'
);
$db2
->request_format(
'fasta'
);
ok(
defined
(
$seq
=
$db2
->get_Seq_by_acc(
'P43780'
)));
ok(
$seq
->
length
,103);
};
if
($@) {
if
(
$DEBUG
) {
print
STDERR
"Warning: Couldn't connect to EMBL with Bio::DB::EMBL.pm!\n"
. $@;
}
foreach
(
$Test::ntest
..
$NUMTESTS
) {
skip(
'Could not open database, probably no network access'
,1);
}
exit
(0);
}
$seq
=
$seqio
=
undef
;
eval
{
$db
= new Bio::DB::BioFetch(
-retrievaltype
=>
'tempfile'
,
-format
=>
'fasta'
,
-verbose
=>
$verbose
);
$db
->db(
'embl'
);
ok(
defined
(
$seqio
=
$db
->get_Stream_by_id(
'J00522 AF303112 J02231'
)));
my
%seqs
;
while
(
my
$s
=
$seqio
->next_seq ) {
my
(
$type
,
$x
,
$name
) =
split
(/\|/,
$s
->display_id);
$seqs
{
$x
} =
$s
->
length
;
}
ok(
$seqs
{
'J00522'
},408);
ok(
$seqs
{
'AF303112'
},1611);
ok(
$seqs
{
'J02231'
},200);
};
if
($@) {
if
(
$DEBUG
) {
warn
"Batch access test failed.\nError: $@\n"
; }
foreach
(
$Test::ntest
..
$NUMTESTS
) { skip(
'no network access skipping fasta retrieval'
,1); }
exit
(0);
}
$verbose
= -1;
ok
$db
= new Bio::DB::BioFetch(
-db
=>
'EMBL'
,
-verbose
=>
$verbose
);
eval
{
$seq
=
$db
->get_Seq_by_acc(
'NT_006732'
);
};
ok $@;
eval
{
ok
$seq
=
$db
->get_Seq_by_acc(
'NM_006732'
);
ok(
$seq
);
ok(
$seq
->
length
, 3775);
};
if
($@) {
if
(
$DEBUG
) {
print
STDERR
"Warning: Couldn't connect to BioFetch server with Bio::DB::BioFetch.pm!\n"
. $@;
}
foreach
(
$Test::ntest
..
$NUMTESTS
) {
skip(
'Could not open database, probably no network access'
,1);
}
exit
(0);
}