~ubuntu-branches/ubuntu/raring/bioperl/raring

« back to all changes in this revision

Viewing changes to Bio/DB/SeqVersion.pm

  • Committer: Bazaar Package Importer
  • Author(s): Charles Plessy
  • Date: 2008-03-18 14:44:57 UTC
  • mfrom: (4 hardy)
  • mto: This revision was merged to the branch mainline in revision 6.
  • Revision ID: james.westby@ubuntu.com-20080318144457-1jjoztrvqwf0gruk
* debian/control:
  - Removed MIA Matt Hope (dopey) from the Uploaders field.
    Thank you for your work, Matt. I hope you are doing well.
  - Downgraded some recommended package to the 'Suggests' priority,
    according to the following discussion on Upstream's mail list.
    http://bioperl.org/pipermail/bioperl-l/2008-March/027379.html
    (Closes: #448890)
* debian/copyright converted to machine-readable format.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
# $Id: SeqVersion.pm,v 1.5.4.2 2006/10/05 12:17:55 sendu Exp $
 
2
#
 
3
# BioPerl module for Bio::DB::SeqVersion
 
4
#
 
5
# Cared for by Brian Osborne
 
6
#
 
7
# Copyright Brian Osborne 2006
 
8
#
 
9
# You may distribute this module under the same terms as Perl itself
 
10
#
 
11
# POD documentation - main docs before the code
 
12
 
 
13
=head1 NAME
 
14
 
 
15
Bio::DB::SeqVersion - front end to querying databases for identifier 
 
16
versions
 
17
 
 
18
=head1 SYNOPSIS
 
19
 
 
20
  use Bio::DB::SeqVersion;
 
21
 
 
22
  my $query = Bio::DB::SeqVersion->new(-type => 'gi');
 
23
 
 
24
  my @all_gis = $query->get_all(2);
 
25
 
 
26
  my $live_gi = $query->get_recent(2);
 
27
 
 
28
=head1 DESCRIPTION
 
29
 
 
30
The default type is 'gi'.
 
31
 
 
32
=head1 FEEDBACK
 
33
 
 
34
=head2 Mailing Lists
 
35
 
 
36
User feedback is an integral part of the evolution of this and other
 
37
Bioperl modules. Send your comments and suggestions preferably to
 
38
the Bioperl mailing list.  Your participation is much appreciated.
 
39
 
 
40
  bioperl-l@bioperl.org                  - General discussion
 
41
  http://bioperl.org/wiki/Mailing_lists  - About the mailing lists
 
42
 
 
43
=head2 Reporting Bugs
 
44
 
 
45
Report bugs to the Bioperl bug tracking system to help us keep track
 
46
of the bugs and their resolution. Bug reports can be submitted via
 
47
the web:
 
48
 
 
49
  http://bugzilla.open-bio.org/
 
50
 
 
51
=head1 AUTHOR - Brian Osborne
 
52
 
 
53
Email bosborne at alum.mit.edu
 
54
 
 
55
=head1 CONTRIBUTORS
 
56
 
 
57
Torsten Seemann - torsten.seemann AT infotech.monash.edu.au
 
58
 
 
59
=head1 APPENDIX
 
60
 
 
61
The rest of the documentation details each of the object methods.
 
62
Internal methods are usually preceded with a _
 
63
 
 
64
=cut
 
65
 
 
66
# Let the code begin...
 
67
 
 
68
package Bio::DB::SeqVersion;
 
69
use strict;
 
70
 
 
71
use base qw(Bio::WebAgent Bio::Root::Root);
 
72
 
 
73
# Private class variable
 
74
 
 
75
my $DEFAULTIDTYPE = 'gi'; # sub default_id_type()
 
76
 
 
77
=head2 new()
 
78
 
 
79
 Usage   : my $obj = new Bio::DB::SeqVersion();
 
80
 Function: Create a Bio::DB::SeqVersion object 
 
81
 Returns : An instance of Bio::DB::SeqVersion
 
82
 Args    : -type      Identifier namespace, default is 'gi' 
 
83
 
 
84
=cut
 
85
 
 
86
sub new {
 
87
  my($class,@args) = @_;
 
88
 
 
89
  if( $class =~ /Bio::DB::SeqVersion::\S+/ ) {
 
90
    my ($self) = $class->SUPER::new(@args);
 
91
    $self->_initialize(@args);
 
92
    return $self;
 
93
  } 
 
94
  else {
 
95
    my %param = @args;
 
96
    @param{ map { lc $_ } keys %param } = values %param; # lowercase keys
 
97
 
 
98
    # we delete '-type' so it doesn't get passed to the sub-class constructor
 
99
    # note: delete() returns the value of the item deleted (undef if non-existent)
 
100
    my $type = lc( delete($param{'-type'}) || $DEFAULTIDTYPE );
 
101
 
 
102
    return unless( $class->_load_seqversion_module($type) );
 
103
    
 
104
    # we pass %param here, not @args, as we have filtered out -type
 
105
    return "Bio::DB::SeqVersion::$type"->new(%param);
 
106
  }
 
107
}
 
108
 
 
109
=head2 get_recent()
 
110
 
 
111
 Usage   :
 
112
 Function:
 
113
 Example :
 
114
 Returns : 
 
115
 Args    :
 
116
 
 
117
=cut
 
118
 
 
119
sub get_recent {
 
120
  my ($self,@args) = @_;
 
121
  $self->throw_not_implemented();
 
122
}
 
123
 
 
124
=head2 get_all()
 
125
 
 
126
 Usage   :
 
127
 Function:
 
128
 Example :
 
129
 Returns : 
 
130
 Args    :
 
131
 
 
132
=cut
 
133
 
 
134
sub get_all {
 
135
        my ($self,@args) = @_;
 
136
        $self->throw_not_implemented();
 
137
}
 
138
 
 
139
=head2 _load_seqversion_module
 
140
 
 
141
 Title   : _load_seqversion_module
 
142
 Usage   : Used internally
 
143
 Function: Loads up a module at run time on demand
 
144
 Example :
 
145
 Returns :
 
146
 Args    : Name of identifier type
 
147
 
 
148
=cut
 
149
 
 
150
sub _load_seqversion_module {
 
151
        my ($self,$db) = @_;
 
152
        my $module = "Bio::DB::SeqVersion::" . $db;
 
153
        my $ok;
 
154
 
 
155
        eval { $ok = $self->_load_module($module) };
 
156
        if ( $@ ) {
 
157
                print STDERR $@;
 
158
                print STDERR <<END;
 
159
$self: $module cannot be found
 
160
Exception $@
 
161
For more information about the Bio::DB::SeqVersion system please see
 
162
the Bio::DB::SeqVersion docs.
 
163
END
 
164
                ;
 
165
        }
 
166
        return $ok;
 
167
}
 
168
 
 
169
=head2 default_id_type
 
170
 
 
171
 Title   : default_id_type
 
172
 Usage   : my $type = $self->default_id_type
 
173
 Function: Returns default identifier type for this module
 
174
 Returns : string
 
175
 Args    : none
 
176
 
 
177
=cut
 
178
 
 
179
sub default_id_type {
 
180
    return $DEFAULTIDTYPE;
 
181
}
 
182
 
 
183
1;