| 1 | # | ||||||||||
| 2 | # | ||||||||||
| 3 | # BioPerl module for Bio::DB::RefSeq | ||||||||||
| 4 | # | ||||||||||
| 5 | # Please direct questions and support issues to <bioperl-l@bioperl.org> | ||||||||||
| 6 | # | ||||||||||
| 7 | # Cared for by Heikki Lehvaslaiho <heikki-at-bioperl-dot-org> | ||||||||||
| 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<Bio::Seq> 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<Bio::DB::DBFetch> | ||||||||||
| 68 | which implements L<Bio::DB::WebDBSeqI>. | ||||||||||
| 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<bioperl-l@bioperl.org> | ||||||||||
| 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 E<lt>heikki-at-bioperl-dot-orgE<gt> | ||||||||||
| 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 | 2 | $Bio::DB::RefSeq::VERSION = '1.7.4'; | |||||||||
| 120 | 2 | ▶ | use strict; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 121 | 2 | ▶ | use vars qw($MODVERSION %HOSTS %FORMATMAP $DEFAULTFORMAT); | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 122 | |||||||||||
| 123 | 2 | $MODVERSION = '0.1'; | |||||||||
| 124 | |||||||||||
| 125 | 2 | ▶ | use base qw(Bio::DB::DBFetch); | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 126 | |||||||||||
| 127 | 2 | ▶ | BEGIN { | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 128 | # you can add your own here theoretically. | ||||||||||
| 129 | 2 | %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 | 2 | %FORMATMAP = ( 'embl' => 'embl', | |||||||||
| 138 | 'genbank' => 'genbank', | ||||||||||
| 139 | 'fasta' => 'fasta' | ||||||||||
| 140 | ); | ||||||||||
| 141 | 2 | $DEFAULTFORMAT = 'genbank'; | |||||||||
| 142 | } | ||||||||||
| 143 | |||||||||||
| 144 | 1 | ▶ | sub new { | ||||||||
|
Subroutine
new: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||
| 145 | 1 | my ($class, @args ) = @_; | |||||||||
| 146 | 1 | my $self = $class->SUPER::new(@args); | |||||||||
| 147 | |||||||||||
| 148 | 1 | $self->{ '_hosts' } = {}; | |||||||||
| 149 | 1 | $self->{ '_formatmap' } = {}; | |||||||||
| 150 | |||||||||||
| 151 | 1 | $self->hosts(\%HOSTS); | |||||||||
| 152 | 1 | $self->formatmap(\%FORMATMAP); | |||||||||
| 153 | 1 | $self->{'_default_format'} = $DEFAULTFORMAT; | |||||||||
| 154 | |||||||||||
| 155 | 1 | return $self; | |||||||||
| 156 | } | ||||||||||
| 157 | |||||||||||
| 158 | |||||||||||
| 159 | 2 | ▶ | sub get_seq_stream { | ||||||||
|
Subroutine
get_seq_stream: called CC=4 SCAR=16.4
Pod
documented
| |||||||||||
| 160 | 2 | my ($self,%qualifiers) = @_; | |||||||||
| 161 | 2 | ▶ | if( exists $qualifiers{'-uids'} ) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 162 | 2 | ▶ | if( ref($qualifiers{'-uids'}) =~ /ARRAY/i ) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 163 | 0 | foreach my $u ( @{$qualifiers{'-uids'}} ) { | |||||||||
| 164 | 0 | $u =~ s/^(\S+)\|//; | |||||||||
| 165 | } | ||||||||||
| 166 | } else { | ||||||||||
| 167 | 2 | $qualifiers{'-uids'} =~ s/^(\S+)\|//; | |||||||||
| 168 | } | ||||||||||
| 169 | } | ||||||||||
| 170 | 2 | $self->SUPER::get_seq_stream(%qualifiers); | |||||||||
| 171 | } | ||||||||||
| 172 | |||||||||||
| 173 | 2 | 1; | |||||||||