File Coverage

blib/lib/Bio/DB/RefSeq.pm
Criterion Covered Total %
statement 25 28 89.2
branch 2 4 50.0
condition n/a
subroutine 6 6 100.0
pod 2 2 100.0
total 35 40 87.5


line stmt bran cond sub pod time code
1             #
2             #
3             # BioPerl module for Bio::DB::RefSeq
4             #
5             # Please direct questions and support issues to
6             #
7             # Cared for by Heikki Lehvaslaiho
8             #
9             # Copyright Jason Stajich
10             #
11             # You may distribute this module under the same terms as perl itself
12              
13             # POD documentation - main docs before the code
14              
15             =head1 NAME
16              
17             Bio::DB::RefSeq - Database object interface for RefSeq retrieval
18              
19             =head1 SYNOPSIS
20              
21             use Bio::DB::RefSeq;
22              
23             $db = Bio::DB::RefSeq->new();
24              
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";
28              
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";
33              
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
38             };
39             print "accesion is ", $seq->accession_number, "\n" unless $@;
40              
41             # or ... best when downloading very large files, prevents
42             # keeping all of the file in memory
43              
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";
51             }
52              
53             =head1 DESCRIPTION
54              
55             Allows the dynamic retrieval of sequence objects L from the
56             RefSeq nucleotide database using the dbfetch script at EBI:
57              
58             http://www.ebi.ac.uk/Tools/dbfetch/dbfetch
59              
60             At this time the module specifically retrieves nucleotide sequences
61             only.
62              
63             In order to make changes transparent we have host type (currently only
64             ebi) and location (defaults to ebi) separated out. This allows later
65             additions of more servers in different geographical locations.
66              
67             The functionality of this module is inherited from L
68             which implements L.
69              
70             This module retrieves entries from EBI although it
71             retrieves database entries produced at NCBI. When read into bioperl
72             objects, the parser for GenBank format it used. RefSeq is a
73             NONSTANDARD GenBank file so be ready for surprises.
74              
75             =head1 FEEDBACK
76              
77             =head2 Mailing Lists
78              
79             User feedback is an integral part of the evolution of this and other
80             Bioperl modules. Send your comments and suggestions preferably to one
81             of the Bioperl mailing lists. Your participation is much appreciated.
82              
83             bioperl-l@bioperl.org - General discussion
84             http://bioperl.org/wiki/Mailing_lists - About the mailing lists
85              
86             =head2 Support
87              
88             Please direct usage questions or support issues to the mailing list:
89              
90             I
91              
92             rather than to the module maintainer directly. Many experienced and
93             reponsive experts will be able look at the problem and quickly
94             address it. Please include a thorough description of the problem
95             with code and data examples if at all possible.
96              
97             =head2 Reporting Bugs
98              
99             Report bugs to the Bioperl bug tracking system to help us keep track
100             the bugs and their resolution. Bug reports can be submitted via the
101             web:
102              
103             https://github.com/bioperl/bioperl-live/issues
104              
105             =head1 AUTHOR - Heikki Lehvaslaiho
106              
107             Email Heikki Lehvaslaiho Eheikki-at-bioperl-dot-orgE
108              
109             =head1 APPENDIX
110              
111             The rest of the documentation details each of the object
112             methods. Internal methods are usually preceded with a _
113              
114             =cut
115              
116             # Let the code begin...
117              
118             package Bio::DB::RefSeq;
119             $Bio::DB::RefSeq::VERSION = '1.7.3';
120 1     1   187029 use strict;
  1         4  
  1         28  
121 1     1   4 use vars qw($MODVERSION %HOSTS %FORMATMAP $DEFAULTFORMAT);
  1         2  
  1         57  
122              
123             $MODVERSION = '0.1';
124              
125 1     1   5 use base qw(Bio::DB::DBFetch);
  1         1  
  1         416  
126              
127             BEGIN {
128             # you can add your own here theoretically.
129 1     1   49865 %HOSTS = (
130             'dbfetch' => {
131             baseurl => 'http://%s/Tools/dbfetch/dbfetch?db=refseqn&style=raw',
132             hosts => {
133             'ebi' => 'www.ebi.ac.uk'
134             }
135             }
136             );
137 1         4 %FORMATMAP = ( 'embl' => 'embl',
138             'genbank' => 'genbank',
139             'fasta' => 'fasta'
140             );
141 1         184 $DEFAULTFORMAT = 'genbank';
142             }
143              
144             sub new {
145 1     1 1 29469 my ($class, @args ) = @_;
146 1         12 my $self = $class->SUPER::new(@args);
147              
148 1         14321 $self->{ '_hosts' } = {};
149 1         3 $self->{ '_formatmap' } = {};
150              
151 1         6 $self->hosts(\%HOSTS);
152 1         13 $self->formatmap(\%FORMATMAP);
153 1         9 $self->{'_default_format'} = $DEFAULTFORMAT;
154              
155 1         6 return $self;
156             }
157              
158              
159             sub get_seq_stream {
160 2     2 1 1253270 my ($self,%qualifiers) = @_;
161 2 50       9 if( exists $qualifiers{'-uids'} ) {
162 2 50       6 if( ref($qualifiers{'-uids'}) =~ /ARRAY/i ) {
163 0         0 foreach my $u ( @{$qualifiers{'-uids'}} ) {
  0         0  
164 0         0 $u =~ s/^(\S+)\|//;
165             }
166             } else {
167 2         7 $qualifiers{'-uids'} =~ s/^(\S+)\|//;
168             }
169             }
170 2         13 $self->SUPER::get_seq_stream(%qualifiers);
171             }
172              
173             1;