reimplement various methods in terms of get_dbxrefs, for consistency
[bioperl-live.git] / Bio / IdentifiableI.pm
blob05bbfd23dca50f79288b4bf009c2dccc22d93414
1 # $Id$
3 # This module is licensed under the same terms as Perl itself. You use,
4 # modify, and redistribute it under the terms of the Perl Artistic License.
7 =head1 NAME
9 Bio::IdentifiableI - interface for objects with identifiers
11 =head1 SYNOPSIS
13 # to test this is an identifiable object
15 $obj->isa("Bio::IdentifiableI") ||
16 $obj->throw("$obj does not implement the Bio::IdentifiableI interface");
18 # Accessors
20 $object_id = $obj->object_id();
21 $namespace = $obj->namespace();
22 $authority = $obj->authority();
23 $version = $obj->version();
24 # Gets authority:namespace:object_id
25 $lsid = $obj->lsid_string();
26 # Gets namespace:object_id.version
27 $ns_string = $obj->namespace_string();
29 =head1 DESCRIPTION
31 This interface describes methods expected on identifiable objects, i.e.
32 ones which have identifiers expected to make sense across a number of
33 instances and/or domains. This interface is modeled after pretty much
34 ubiquitous ideas for names in bioinformatics being
36 databasename:object_id.version
38 Example:
40 swissprot:P012334.2
42 or:
44 GO:0007048
46 The object will also work with LSID proposals which adds the concept of an
47 authority, being the DNS name of the organisation assigning the namespace.
48 See L<http://lsid.sourceforge.net/>.
50 Helper functions are provided to make useful strings:
52 lsid_string - string complying to the LSID standard
54 namespace_string - string complying to the usual convention of
55 namespace:object_id.version
57 =head1 FEEDBACK
59 =head2 Mailing Lists
61 User feedback is an integral part of the evolution of this and other
62 Bioperl modules. Send your comments and suggestions preferably to one
63 of the Bioperl mailing lists. Your participation is much appreciated.
65 bioperl-l@bioperl.org - General discussion
66 http://bioperl.org/wiki/Mailing_lists - About the mailing lists
68 =head2 Support
70 Please direct usage questions or support issues to the mailing list:
72 I<bioperl-l@bioperl.org>
74 rather than to the module maintainer directly. Many experienced and
75 reponsive experts will be able look at the problem and quickly
76 address it. Please include a thorough description of the problem
77 with code and data examples if at all possible.
79 =head2 Reporting Bugs
81 Report bugs to the Bioperl bug tracking system to help us keep track
82 the bugs and their resolution. Bug reports can be submitted via the
83 web:
85 http://bugzilla.open-bio.org/
87 =head1 AUTHOR - Ewan Birney
89 Email birney@ebi.ac.uk
91 =cut
93 package Bio::IdentifiableI;
94 use strict;
97 use base qw(Bio::Root::RootI);
99 =head1 Implementation Specific Functions
101 These functions are the ones that a specific implementation must
102 define.
104 =head2 object_id
106 Title : object_id
107 Usage : $string = $obj->object_id()
108 Function: a string which represents the stable primary identifier
109 in this namespace of this object. For DNA sequences this
110 is its accession_number, similarly for protein sequences
111 Returns : A scalar
112 Status : Virtual
114 =cut
116 sub object_id {
117 my ($self) = @_;
118 $self->throw_not_implemented();
121 =head2 version
123 Title : version
124 Usage : $version = $obj->version()
125 Function: a number which differentiates between versions of
126 the same object. Higher numbers are considered to be
127 later and more relevant, but a single object described
128 the same identifier should represent the same concept
129 Returns : A number
130 Status : Virtual
132 =cut
134 sub version {
135 my ($self) = @_;
136 $self->throw_not_implemented();
140 =head2 authority
142 Title : authority
143 Usage : $authority = $obj->authority()
144 Function: a string which represents the organisation which
145 granted the namespace, written as the DNS name for
146 organisation (eg, wormbase.org)
147 Returns : A scalar
148 Status : Virtual
150 =cut
152 sub authority {
153 my ($self) = @_;
154 $self->throw_not_implemented();
158 =head2 namespace
160 Title : namespace
161 Usage : $string = $obj->namespace()
162 Function: A string representing the name space this identifier
163 is valid in, often the database name or the name
164 describing the collection
165 Returns : A scalar
166 Status : Virtual
168 =cut
170 sub namespace {
171 my ($self) = @_;
172 $self->throw_not_implemented();
176 =head1 Implementation optional functions
178 These functions are helper functions that are provided by
179 the interface but can be overridden if so wished
181 =head2 lsid_string
183 Title : lsid_string
184 Usage : $string = $obj->lsid_string()
185 Function: a string which gives the LSID standard
186 notation for the identifier of interest
189 Returns : A scalar
191 =cut
193 sub lsid_string {
194 my ($self) = @_;
196 return $self->authority.":".$self->namespace.":".$self->object_id;
201 =head2 namespace_string
203 Title : namespace_string
204 Usage : $string = $obj->namespace_string()
205 Function: a string which gives the common notation of
206 namespace:object_id.version
207 Returns : A scalar
209 =cut
211 sub namespace_string {
212 my ($self) = @_;
214 return $self->namespace.":".$self->object_id .
215 (defined($self->version()) ? ".".$self->version : '');