Bio-DB-BioFetch
view release on metacpan or search on metacpan
lib/Bio/DB/BioFetch.pm view on Meta::CPAN
#
# BioPerl module for Bio::DB::BioFetch
#
# Please direct questions and support issues to <bioperl-l@bioperl.org>
#
# Cared for by Lincoln Stein <lstein@cshl.org>
#
# Copyright Lincoln Stein
#
# You may distribute this module under the same terms as perl itself
#
# POD documentation - main docs before the code
#
package Bio::DB::BioFetch;
$Bio::DB::BioFetch::VERSION = '1.7.3';
use strict;
use Carp;
use HTTP::Request::Common 'POST';
=head1 NAME
Bio::DB::BioFetch - Database object interface to BioFetch retrieval
=head1 SYNOPSIS
use Bio::DB::BioFetch;
$bf = Bio::DB::BioFetch->new();
$seq = $bf->get_Seq_by_id('HSFOS'); # EMBL or SWALL ID
# change formats, storage procedures
$bf = Bio::DB::BioFetch->new(-format => 'fasta',
-retrievaltype => 'tempfile',
-db => 'EMBL');
$stream = $bf->get_Stream_by_id(['HSFOS','J00231']);
while (my $s = $stream->next_seq) {
print $s->seq,"\n";
}
# get a RefSeq entry
$bf->db('refseq');
eval {
$seq = $bf->get_Seq_by_version('NM_006732.1'); # RefSeq VERSION
};
print "accession is ", $seq->accession_number, "\n" unless $@;
=head1 DESCRIPTION
Bio::DB::BioFetch is a guaranteed best effort sequence entry fetching
method. It goes to the Web-based dbfetch server located at the EBI
(http://www.ebi.ac.uk/Tools/dbfetch/dbfetch) to retrieve sequences in the
EMBL or GenBank sequence repositories.
This module implements all the Bio::DB::RandomAccessI interface, plus
the get_Stream_by_id() and get_Stream_by_acc() methods that are found
in the Bio::DB::SwissProt interface.
=head1 FEEDBACK
=head2 Mailing Lists
User feedback is an integral part of the evolution of this and other
Bioperl modules. Send your comments and suggestions preferably to one
of the Bioperl mailing lists. Your participation is much appreciated.
bioperl-l@bioperl.org - General discussion
http://bioperl.org/wiki/Mailing_lists - About the mailing lists
=head2 Support
Please direct usage questions or support issues to the mailing list:
I<bioperl-l@bioperl.org>
rather than to the module maintainer directly. Many experienced and
lib/Bio/DB/BioFetch.pm view on Meta::CPAN
Function: Gets a Bio::Seq object by sequence version
Returns : A Bio::Seq object
Args : accession.version (as a string)
Throws : "acc.version does not exist" exception
=cut
sub get_Seq_by_version {
my ($self,$seqid) = @_;
return $self->get_Seq_by_acc($seqid);
}
=head2 get_Stream_by_id
Title : get_Stream_by_id
Usage : $stream = $db->get_Stream_by_id( [$uid1, $uid2] );
Function: Gets a series of Seq objects by unique identifiers
Returns : a Bio::SeqIO stream object
Args : $ref : a reference to an array of unique identifiers for
the desired sequence entries
=cut
=head2 get_Stream_by_gi
Title : get_Stream_by_gi
Usage : $seq = $db->get_Seq_by_gi([$gi1, $gi2]);
Function: Gets a series of Seq objects by gi numbers
Returns : a Bio::SeqIO stream object
Args : $ref : a reference to an array of gi numbers for
the desired sequence entries
Note : For GenBank, this just calls the same code for get_Stream_by_id()
=cut
=head2 get_Stream_by_batch
Title : get_Stream_by_batch
Usage : $seq = $db->get_Stream_by_batch($ref);
Function: Get a series of Seq objects by their IDs
Example :
Returns : a Bio::SeqIO stream object
Args : $ref : an array reference containing a list of unique
ids/accession numbers.
In some of the Bio::DB::* moduels, get_Stream_by_id() is called
get_Stream_by_batch(). Since there seems to be no consensus, this
is provided as an alias.
=cut
*get_Stream_by_batch = \&Bio::DB::WebDBSeqI::get_Stream_by_id;
=head1 The remainder of these methods are for internal use
=head2 get_request
Title : get_request
Usage : my $url = $self->get_request
Function: returns a HTTP::Request object
Returns :
Args : %qualifiers = a hash of qualifiers (ids, format, etc)
=cut
sub get_request {
my ($self, @qualifiers) = @_;
my ($uids, $format) = $self->_rearrange([qw(UIDS FORMAT)],
@qualifiers);
my $db = $self->db;
my $namespace = $self->_namespace;
$self->throw("Must specify a value for UIDs to fetch")
unless defined $uids;
my $tmp;
my $format_string = '';
$format ||= $self->default_format;
($format, $tmp) = $self->request_format($format);
my $base = $self->url_base_address;
my $uid = join('+',ref $uids ? @$uids : $uids);
$self->debug("\n$base$format_string&id=$uid\n");
return POST($base,
[ db => $namespace,
id => join('+',ref $uids ? @$uids : $uids),
format => $format,
style => 'raw'
]);
}
=head2 default_format
Title : default_format
Usage : $format = $self->default_format
Function: return the default format
Returns : a string
Args :
=cut
sub default_format {
return 'default';
}
=head2 default_db
Title : default_db
Usage : $db = $self->default_db
Function: return the default database
Returns : a string
Args :
=cut
sub default_db { 'embl' }
=head2 db
( run in 2.010 seconds using v1.01-cache-2.11-cpan-39bf76dae61 )