bug 2549; fixed small bug in Bio::Taxon which doesn't catch -common_name
[bioperl-live.git] / Bio / IdentifiableI.pm
blob263242333bc3e6255cf4e6617f6fee1949113b0a
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 Reporting Bugs
70 Report bugs to the Bioperl bug tracking system to help us keep track
71 the bugs and their resolution. Bug reports can be submitted via the
72 web:
74 http://bugzilla.open-bio.org/
76 =head1 AUTHOR - Ewan Birney
78 Email birney@ebi.ac.uk
80 =cut
82 package Bio::IdentifiableI;
83 use strict;
86 use base qw(Bio::Root::RootI);
88 =head1 Implementation Specific Functions
90 These functions are the ones that a specific implementation must
91 define.
93 =head2 object_id
95 Title : object_id
96 Usage : $string = $obj->object_id()
97 Function: a string which represents the stable primary identifier
98 in this namespace of this object. For DNA sequences this
99 is its accession_number, similarly for protein sequences
100 Returns : A scalar
101 Status : Virtual
103 =cut
105 sub object_id {
106 my ($self) = @_;
107 $self->throw_not_implemented();
110 =head2 version
112 Title : version
113 Usage : $version = $obj->version()
114 Function: a number which differentiates between versions of
115 the same object. Higher numbers are considered to be
116 later and more relevant, but a single object described
117 the same identifier should represent the same concept
118 Returns : A number
119 Status : Virtual
121 =cut
123 sub version {
124 my ($self) = @_;
125 $self->throw_not_implemented();
129 =head2 authority
131 Title : authority
132 Usage : $authority = $obj->authority()
133 Function: a string which represents the organisation which
134 granted the namespace, written as the DNS name for
135 organisation (eg, wormbase.org)
136 Returns : A scalar
137 Status : Virtual
139 =cut
141 sub authority {
142 my ($self) = @_;
143 $self->throw_not_implemented();
147 =head2 namespace
149 Title : namespace
150 Usage : $string = $obj->namespace()
151 Function: A string representing the name space this identifier
152 is valid in, often the database name or the name
153 describing the collection
154 Returns : A scalar
155 Status : Virtual
157 =cut
159 sub namespace {
160 my ($self) = @_;
161 $self->throw_not_implemented();
165 =head1 Implementation optional functions
167 These functions are helper functions that are provided by
168 the interface but can be overridden if so wished
170 =head2 lsid_string
172 Title : lsid_string
173 Usage : $string = $obj->lsid_string()
174 Function: a string which gives the LSID standard
175 notation for the identifier of interest
178 Returns : A scalar
180 =cut
182 sub lsid_string {
183 my ($self) = @_;
185 return $self->authority.":".$self->namespace.":".$self->object_id;
190 =head2 namespace_string
192 Title : namespace_string
193 Usage : $string = $obj->namespace_string()
194 Function: a string which gives the common notation of
195 namespace:object_id.version
196 Returns : A scalar
198 =cut
200 sub namespace_string {
201 my ($self) = @_;
203 return $self->namespace.":".$self->object_id .
204 (defined($self->version()) ? ".".$self->version : '');