Bio::Tools::SiRNA and related moved to separate distribution
[bioperl-live.git] / lib / Bio / DB / SeqVersion.pm
blob2bd930d458fca2ed50ab04aeec94f5dcb0761dd7
2 # BioPerl module for Bio::DB::SeqVersion
4 # Please direct questions and support issues to <bioperl-l@bioperl.org>
6 # Cared for by Brian Osborne
8 # Copyright Brian Osborne 2006
10 # You may distribute this module under the same terms as Perl itself
12 # POD documentation - main docs before the code
14 =head1 NAME
16 Bio::DB::SeqVersion - front end to querying databases for identifier
17 versions
19 =head1 SYNOPSIS
21 use Bio::DB::SeqVersion;
23 my $query = Bio::DB::SeqVersion->new(-type => 'gi');
25 my @all_gis = $query->get_all(2);
27 my $live_gi = $query->get_recent(2);
29 =head1 DESCRIPTION
31 The default type is 'gi'.
33 =head1 FEEDBACK
35 =head2 Mailing Lists
37 User feedback is an integral part of the evolution of this and other
38 Bioperl modules. Send your comments and suggestions preferably to
39 the Bioperl mailing list. Your participation is much appreciated.
41 bioperl-l@bioperl.org - General discussion
42 http://bioperl.org/wiki/Mailing_lists - About the mailing lists
44 =head2 Support
46 Please direct usage questions or support issues to the mailing list:
48 I<bioperl-l@bioperl.org>
50 rather than to the module maintainer directly. Many experienced and
51 reponsive experts will be able look at the problem and quickly
52 address it. Please include a thorough description of the problem
53 with code and data examples if at all possible.
55 =head2 Reporting Bugs
57 Report bugs to the Bioperl bug tracking system to help us keep track
58 of the bugs and their resolution. Bug reports can be submitted via
59 the web:
61 https://github.com/bioperl/bioperl-live/issues
63 =head1 AUTHOR - Brian Osborne
65 Email bosborne at alum.mit.edu
67 =head1 CONTRIBUTORS
69 Torsten Seemann - torsten.seemann AT infotech.monash.edu.au
71 =head1 APPENDIX
73 The rest of the documentation details each of the object methods.
74 Internal methods are usually preceded with a _
76 =cut
78 # Let the code begin...
80 package Bio::DB::SeqVersion;
81 use strict;
83 use base qw(Bio::WebAgent Bio::Root::Root);
85 # Private class variable
87 my $DEFAULTIDTYPE = 'gi'; # sub default_id_type()
89 =head2 new()
91 Usage : my $obj = Bio::DB::SeqVersion->new();
92 Function: Create a Bio::DB::SeqVersion object
93 Returns : An instance of Bio::DB::SeqVersion
94 Args : -type Identifier namespace, default is 'gi'
96 =cut
98 sub new {
99 my($class,@args) = @_;
101 if( $class =~ /Bio::DB::SeqVersion::\S+/ ) {
102 my ($self) = $class->SUPER::new(@args);
103 $self->_initialize(@args);
104 return $self;
106 else {
107 my %param = @args;
108 @param{ map { lc $_ } keys %param } = values %param; # lowercase keys
110 # we delete '-type' so it doesn't get passed to the sub-class constructor
111 # note: delete() returns the value of the item deleted (undef if non-existent)
112 my $type = lc( delete($param{'-type'}) || $DEFAULTIDTYPE );
114 return unless( $class->_load_seqversion_module($type) );
116 # we pass %param here, not @args, as we have filtered out -type
117 return "Bio::DB::SeqVersion::$type"->new(%param);
121 =head2 get_recent()
123 Usage :
124 Function:
125 Example :
126 Returns :
127 Args :
129 =cut
131 sub get_recent {
132 my ($self,@args) = @_;
133 $self->throw_not_implemented();
136 =head2 get_all()
138 Usage :
139 Function:
140 Example :
141 Returns :
142 Args :
144 =cut
146 sub get_all {
147 my ($self,@args) = @_;
148 $self->throw_not_implemented();
151 =head2 _load_seqversion_module
153 Title : _load_seqversion_module
154 Usage : Used internally
155 Function: Loads up a module at run time on demand
156 Example :
157 Returns :
158 Args : Name of identifier type
160 =cut
162 sub _load_seqversion_module {
163 my ($self,$db) = @_;
164 my $module = "Bio::DB::SeqVersion::" . $db;
165 my $ok;
167 eval { $ok = $self->_load_module($module) };
168 if ( $@ ) {
169 print STDERR $@;
170 print STDERR <<END;
171 $self: $module cannot be found
172 Exception $@
173 For more information about the Bio::DB::SeqVersion system please see
174 the Bio::DB::SeqVersion docs.
178 return $ok;
181 =head2 default_id_type
183 Title : default_id_type
184 Usage : my $type = $self->default_id_type
185 Function: Returns default identifier type for this module
186 Returns : string
187 Args : none
189 =cut
191 sub default_id_type {
192 return $DEFAULTIDTYPE;