t/AlignIO/AlignIO.t: fix number of tests in plan (fixup c523e6bed866)
[bioperl-live.git] / Bio / DB / RefSeq.pm
blobbc0acafc495850ecfe234db7cbfb518d2bfebe8c
3 # BioPerl module for Bio::DB::EMBL
5 # Please direct questions and support issues to <bioperl-l@bioperl.org>
7 # Cared for by Heikki Lehvaslaiho <heikki-at-bioperl-dot-org>
9 # Copyright Jason Stajich
11 # You may distribute this module under the same terms as perl itself
13 # POD documentation - main docs before the code
15 =head1 NAME
17 Bio::DB::RefSeq - Database object interface for RefSeq retrieval
19 =head1 SYNOPSIS
21 use Bio::DB::RefSeq;
23 $db = Bio::DB::RefSeq->new();
25 # most of the time RefSeq_ID eq RefSeq acc
26 $seq = $db->get_Seq_by_id('NM_006732'); # RefSeq ID
27 print "accession is ", $seq->accession_number, "\n";
29 # or changeing to accession number and Fasta format ...
30 $db->request_format('fasta');
31 $seq = $db->get_Seq_by_acc('NM_006732'); # RefSeq ACC
32 print "seq is ", $seq->seq, "\n";
34 # especially when using versions, you better be prepared
35 # in not getting what what want
36 eval {
37 $seq = $db->get_Seq_by_version('NM_006732.1'); # RefSeq VERSION
39 print "accesion is ", $seq->accession_number, "\n" unless $@;
41 # or ... best when downloading very large files, prevents
42 # keeping all of the file in memory
44 # also don't want features, just sequence so let's save bandwidth
45 # and request Fasta sequence
46 $db = Bio::DB::RefSeq->new(-retrievaltype => 'tempfile' ,
47 -format => 'fasta');
48 my $seqio = $db->get_Stream_by_id(['NM_006732', 'NM_005252'] );
49 while( my $seq = $seqio->next_seq ) {
50 print "seqid is ", $seq->id, "\n";
53 =head1 DESCRIPTION
55 Allows the dynamic retrieval of sequence objects L<Bio::Seq> from the
56 RefSeq database using the dbfetch script at EBI:
58 http://www.ebi.ac.uk/Tools/dbfetch/dbfetch
60 In order to make changes transparent we have host type (currently only
61 ebi) and location (defaults to ebi) separated out. This allows later
62 additions of more servers in different geographical locations.
64 The functionality of this module is inherited from L<Bio::DB::DBFetch>
65 which implements L<Bio::DB::WebDBSeqI>.
67 This module retrieves entries from EBI although it
68 retrieves database entries produced at NCBI. When read into bioperl
69 objects, the parser for GenBank format it used. RefSeq is a
70 NONSTANDARD GenBank file so be ready for surprises.
72 =head1 FEEDBACK
74 =head2 Mailing Lists
76 User feedback is an integral part of the evolution of this and other
77 Bioperl modules. Send your comments and suggestions preferably to one
78 of the Bioperl mailing lists. Your participation is much appreciated.
80 bioperl-l@bioperl.org - General discussion
81 http://bioperl.org/wiki/Mailing_lists - About the mailing lists
83 =head2 Support
85 Please direct usage questions or support issues to the mailing list:
87 I<bioperl-l@bioperl.org>
89 rather than to the module maintainer directly. Many experienced and
90 reponsive experts will be able look at the problem and quickly
91 address it. Please include a thorough description of the problem
92 with code and data examples if at all possible.
94 =head2 Reporting Bugs
96 Report bugs to the Bioperl bug tracking system to help us keep track
97 the bugs and their resolution. Bug reports can be submitted via the
98 web:
100 https://github.com/bioperl/bioperl-live/issues
102 =head1 AUTHOR - Heikki Lehvaslaiho
104 Email Heikki Lehvaslaiho E<lt>heikki-at-bioperl-dot-orgE<gt>
106 =head1 APPENDIX
108 The rest of the documentation details each of the object
109 methods. Internal methods are usually preceded with a _
111 =cut
113 # Let the code begin...
115 package Bio::DB::RefSeq;
116 use strict;
117 use vars qw($MODVERSION %HOSTS %FORMATMAP $DEFAULTFORMAT);
119 $MODVERSION = '0.1';
121 use base qw(Bio::DB::DBFetch);
123 BEGIN {
124 # you can add your own here theoretically.
125 %HOSTS = (
126 'dbfetch' => {
127 baseurl => 'http://%s/Tools/dbfetch/dbfetch?db=refseq&style=raw',
128 hosts => {
129 'ebi' => 'www.ebi.ac.uk'
133 %FORMATMAP = ( 'embl' => 'embl',
134 'genbank' => 'genbank',
135 'fasta' => 'fasta'
137 $DEFAULTFORMAT = 'genbank';
140 sub new {
141 my ($class, @args ) = @_;
142 my $self = $class->SUPER::new(@args);
144 $self->{ '_hosts' } = {};
145 $self->{ '_formatmap' } = {};
147 $self->hosts(\%HOSTS);
148 $self->formatmap(\%FORMATMAP);
149 $self->{'_default_format'} = $DEFAULTFORMAT;
151 return $self;
155 sub get_seq_stream {
156 my ($self,%qualifiers) = @_;
157 if( exists $qualifiers{'-uids'} ) {
158 if( ref($qualifiers{'-uids'}) =~ /ARRAY/i ) {
159 foreach my $u ( @{$qualifiers{'-uids'}} ) {
160 $u =~ s/^(\S+)\|//;
162 } else {
163 $qualifiers{'-uids'} =~ s/^(\S+)\|//;
166 $self->SUPER::get_seq_stream(%qualifiers);