2 # BioPerl module for Bio::DB::EntrezGene
4 # Please direct questions and support issues to <bioperl-l@bioperl.org>
6 # Cared for by Brian Osborne bosborne at alum.mit.edu
8 # Copyright Brian Osborne
10 # You may distribute this module under the same terms as perl itself
12 # POD documentation - main docs before the code
16 Bio::DB::EntrezGene - Database object interface to Entrez Gene
20 use Bio::DB::EntrezGene;
22 my $db = Bio::DB::EntrezGene->new;
24 my $seq = $db->get_Seq_by_id(2); # Gene id
28 my $seqio = $db->get_Stream_by_id([2, 4693, 3064]); # Gene ids
29 while ( my $seq = $seqio->next_seq ) {
30 print "id is ", $seq->display_id, "\n";
35 Allows the dynamic retrieval of Sequence objects from the
36 Entrez Gene database at NCBI, via an Entrez query using Gene ids.
38 This module requires the CPAN Bio::ASN1 module.
40 WARNING: Please do NOT spam the Entrez web server with multiple requests.
41 NCBI offers Batch Entrez for this purpose.
45 The Entrez eutils API does not allow Entrez Gene queries by name as
46 of this writing, therefore there are only get_Seq_by_id and
47 get_Stream_by_id methods in this module, and these expect Gene ids.
48 There are no get_Seq_by_acc or get_Stream_by_acc methods.
54 User feedback is an integral part of the
55 evolution of this and other Bioperl modules. Send
56 your comments and suggestions preferably to one
57 of the Bioperl mailing lists. Your participation
60 bioperl-l@bioperl.org - General discussion
61 http://bioperl.org/wiki/Mailing_lists - About the mailing lists
65 Please direct usage questions or support issues to the mailing list:
67 I<bioperl-l@bioperl.org>
69 rather than to the module maintainer directly. Many experienced and
70 reponsive experts will be able look at the problem and quickly
71 address it. Please include a thorough description of the problem
72 with code and data examples if at all possible.
76 Report bugs to the Bioperl bug tracking system to help us keep track
77 the bugs and their resolution. Bug reports can be submitted via the
80 https://github.com/bioperl/bioperl-live/issues
82 =head1 AUTHOR - Brian Osborne
84 Email bosborne at alum.mit.edu
88 The rest of the documentation details each of the object
89 methods. Internal methods are usually preceded with a _
93 # Let the code begin...
95 package Bio
::DB
::EntrezGene
;
97 use vars
qw($DEFAULTFORMAT $DEFAULTMODE %PARAMSTRING);
99 use base qw(Bio::DB::NCBIHelper);
101 $DEFAULTMODE = 'single';
102 $DEFAULTFORMAT = 'asn.1';
103 %PARAMSTRING = ('batch' => {'db' => 'gene',
106 'retmode' => 'asn.1'},
107 'gi' => {'db' => 'gene',
110 'retmode' => 'asn.1'},
111 'version' => {'db' => 'gene',
114 'retmode' => 'asn.1'},
115 'single' => {'db' => 'gene',
118 'retmode' => 'asn.1'} );
121 # the new way to make modules a little more lightweight
123 my($class, @args) = @_;
124 my $self = $class->SUPER::new
(@args);
125 # Seems that Bio::SeqIO::entrezgene requires this:
126 $self->{_retrieval_type
} = "tempfile";
127 $self->request_format($self->default_format);
134 Usage : my %params = $self->get_params($mode)
135 Function: Returns key,value pairs to be passed to NCBI database
136 for either 'batch' or 'single' sequence retrieval method
137 Returns : A key,value pair hash
138 Args : 'single' or 'batch' mode for retrieval
143 my ($self, $mode) = @_;
144 return defined $PARAMSTRING{$mode} ?
%{$PARAMSTRING{$mode}} :
145 %{$PARAMSTRING{$DEFAULTMODE}};
148 =head2 default_format
150 Title : default_format
151 Usage : my $format = $self->default_format
152 Function: Returns default sequence format for this module
159 return $DEFAULTFORMAT;
162 # from Bio::DB::WebDBSeqI from Bio::DB::RandomAccessI
164 =head1 Routines from Bio::DB::WebDBSeqI and Bio::DB::RandomAccessI
168 Title : get_Seq_by_id
169 Usage : $seq = $db->get_Seq_by_id(2)
170 Function: Gets a Bio::Seq object by its name
171 Returns : A Bio::Seq object
173 Throws : "id does not exist" exception
175 =head1 Routines implemented by Bio::DB::NCBIHelper
180 Usage : my $url = $self->get_request
181 Function: HTTP::Request
183 Args : %qualifiers = a hash of qualifiers (ids, format, etc)
185 =head2 get_Stream_by_id
187 Title : get_Stream_by_id
188 Usage : $stream = $db->get_Stream_by_id( [$gid1, $gid2] );
189 Function: Gets a series of Seq objects using Gene ids
190 Returns : A Bio::SeqIO stream object
191 Args : A reference to an array of Gene ids
193 =head2 request_format
195 Title : request_format
196 Usage : my $format = $self->request_format;
197 $self->request_format($format);
198 Function: Get or set sequence format retrieval
199 Returns : String representing format
200 Args : $format = sequence format
204 # override to force format
207 return $self->SUPER::request_format
($self->default_format());