EntrezGene.pm

filter: Statementstmt 96.1% 25 / 26 Branchbran 50.0% 1 / 2 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 8 / 8 Podpod 100% 4 / 4 totaltotal 95.0% 38 / 40 CC 2 SCAR 2.3
CC
2
Cov
93%
get_params
2.1
BEGIN
1.0
BEGIN
1.0
CRAP 1.3
« GenPept.pm ↑ Summary
1 #
2 # BioPerl module for Bio::DB::EntrezGene
3 #
4 # Please direct questions and support issues to <bioperl-l@bioperl.org>
5 #
6 # Cared for by Brian Osborne bosborne at alum.mit.edu
7 #
8 # Copyright Brian Osborne
9 #
10 # You may distribute this module under the same terms as perl itself
11  
12 # POD documentation - main docs before the code
13  
14 =head1 NAME
15  
16 Bio::DB::EntrezGene - Database object interface to Entrez Gene
17  
18 =head1 SYNOPSIS
19  
20 use Bio::DB::EntrezGene;
21  
22 my $db = Bio::DB::EntrezGene->new;
23  
24 my $seq = $db->get_Seq_by_id(2); # Gene id
25  
26 # or ...
27  
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";
31 }
32  
33 =head1 DESCRIPTION
34  
35 Allows the dynamic retrieval of Sequence objects from the
36 Entrez Gene database at NCBI, via an Entrez query using Gene ids.
37  
38 This module requires the CPAN Bio::ASN1 module.
39  
40 WARNING: Please do NOT spam the Entrez web server with multiple requests.
41 NCBI offers Batch Entrez for this purpose.
42  
43 =head1 NOTES
44  
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.
49  
50 =head1 FEEDBACK
51  
52 =head2 Mailing Lists
53  
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
58 is much appreciated.
59  
60 bioperl-l@bioperl.org - General discussion
61 http://bioperl.org/wiki/Mailing_lists - About the mailing lists
62  
63 =head2 Support
64  
65 Please direct usage questions or support issues to the mailing list:
66  
67 I<bioperl-l@bioperl.org>
68  
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.
73  
74 =head2 Reporting Bugs
75  
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
78 web:
79  
80 https://github.com/bioperl/bioperl-live/issues
81  
82 =head1 AUTHOR - Brian Osborne
83  
84 Email bosborne at alum.mit.edu
85  
86 =head1 APPENDIX
87  
88 The rest of the documentation details each of the object
89 methods. Internal methods are usually preceded with a _
90  
91 =cut
92  
93 # Let the code begin...
94  
95 package Bio::DB::EntrezGene;
96 2 $Bio::DB::EntrezGene::VERSION = '1.7.8';
97 2 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
98 2 ▶use vars qw($DEFAULTFORMAT $DEFAULTMODE %PARAMSTRING);
Subroutine BEGIN: called CC=1 SCAR=0.0
99  
100 2 ▶use base qw(Bio::DB::NCBIHelper);
Subroutine BEGIN: called CC=1 SCAR=0.0
101 2 ▶BEGIN {
Subroutine BEGIN: called CC=1 SCAR=0.0
102 2 $DEFAULTMODE = 'single';
103 2 $DEFAULTFORMAT = 'asn.1';
104 2 %PARAMSTRING = ('batch' => {'db' => 'gene',
105 'usehistory' => 'y',
106 'tool' => 'bioperl',
107 'retmode' => 'asn.1'},
108 'gi' => {'db' => 'gene',
109 'usehistory' => 'y',
110 'tool' => 'bioperl',
111 'retmode' => 'asn.1'},
112 'version' => {'db' => 'gene',
113 'usehistory' => 'y',
114 'tool' => 'bioperl',
115 'retmode' => 'asn.1'},
116 'single' => {'db' => 'gene',
117 'usehistory' => 'y',
118 'tool' => 'bioperl',
119 'retmode' => 'asn.1'} );
120 }
121  
122 # the new way to make modules a little more lightweight
123 1 ▶sub new {
Subroutine new: called CC=1 SCAR=0.0
Pod documented
124 1 my($class, @args) = @_;
125 1 my $self = $class->SUPER::new(@args);
126 # Seems that Bio::SeqIO::entrezgene requires this:
127 1 $self->{_retrieval_type} = "tempfile";
128 1 $self->request_format($self->default_format);
129 1 return $self;
130 }
131  
132 =head2 get_params
133  
134 Title : get_params
135 Usage : my %params = $self->get_params($mode)
136 Function: Returns key,value pairs to be passed to NCBI database
137 for either 'batch' or 'single' sequence retrieval method
138 Returns : A key,value pair hash
139 Args : 'single' or 'batch' mode for retrieval
140  
141 =cut
142  
143 2 ▶sub get_params {
Subroutine get_params: called CC=2 SCAR=7.6
Pod documented
144 2 my ($self, $mode) = @_;
145 2 return defined $PARAMSTRING{$mode} ? %{$PARAMSTRING{$mode}} :
146 0 ▶ %{$PARAMSTRING{$DEFAULTMODE}};
Branch: 1 branch
BranchTrueFalseTotal
defined $Bio::DB::EntrezGene::PARAMSTRING{$mode} ? : 2 0 2
147 }
148  
149 =head2 default_format
150  
151 Title : default_format
152 Usage : my $format = $self->default_format
153 Function: Returns default sequence format for this module
154 Returns : string
155 Args : none
156  
157 =cut
158  
159 12 ▶sub default_format {
Subroutine default_format: called CC=1 SCAR=0.0
Pod documented
160 12 return $DEFAULTFORMAT;
161 }
162  
163 # from Bio::DB::WebDBSeqI from Bio::DB::RandomAccessI
164  
165 =head1 Routines from Bio::DB::WebDBSeqI and Bio::DB::RandomAccessI
166  
167 =head2 get_Seq_by_id
168  
169 Title : get_Seq_by_id
170 Usage : $seq = $db->get_Seq_by_id(2)
171 Function: Gets a Bio::Seq object by its name
172 Returns : A Bio::Seq object
173 Args : Gene id
174 Throws : "id does not exist" exception
175  
176 =head1 Routines implemented by Bio::DB::NCBIHelper
177  
178 =head2 get_request
179  
180 Title : get_request
181 Usage : my $url = $self->get_request
182 Function: HTTP::Request
183 Returns :
184 Args : %qualifiers = a hash of qualifiers (ids, format, etc)
185  
186 =head2 get_Stream_by_id
187  
188 Title : get_Stream_by_id
189 Usage : $stream = $db->get_Stream_by_id( [$gid1, $gid2] );
190 Function: Gets a series of Seq objects using Gene ids
191 Returns : A Bio::SeqIO stream object
192 Args : A reference to an array of Gene ids
193  
194 =head2 request_format
195  
196 Title : request_format
197 Usage : my $format = $self->request_format;
198 $self->request_format($format);
199 Function: Get or set sequence format retrieval
200 Returns : String representing format
201 Args : $format = sequence format
202  
203 =cut
204  
205 # override to force format
206 10 ▶sub request_format {
Subroutine request_format: called CC=1 SCAR=0.0
Pod documented
207 10 my ($self) = @_;
208 10 return $self->SUPER::request_format($self->default_format());
209 }
210  
211 2 1;
212  
213 __END__
« GenPept.pm ↑ Summary