[bug 2714]
[bioperl-live.git] / Bio / AnnotationCollectionI.pm
blobe5760e5a851cebd2ec1623a1a33aa31aeef3488a
1 # $Id$
3 # BioPerl module for Bio::AnnotationCollectionI
5 # Cared for by Ewan Birney <birney@ebi.ac.uk>
7 # Copyright Ewan Birney
9 # You may distribute this module under the same terms as perl itself
11 # POD documentation - main docs before the code
13 =head1 NAME
15 Bio::AnnotationCollectionI - Interface for annotation collections
17 =head1 SYNOPSIS
19 # get an AnnotationCollectionI somehow, eg
21 $ac = $seq->annotation();
23 foreach $key ( $ac->get_all_annotation_keys() ) {
24 @values = $ac->get_Annotations($key);
25 foreach $value ( @values ) {
26 # value is an Bio::AnnotationI, and defines a "as_text" method
27 print "Annotation ",$key," stringified value ",$value->as_text,"\n";
29 # also defined hash_tree method, which allows data orientated
30 # access into this object
31 $hash = $value->hash_tree();
35 =head1 DESCRIPTION
37 Annotation Collections are a way of storing a series of "interesting
38 facts" about something. We call an "interesting fact" in Bioperl an
39 Annotation (this differs from a Sequence Feature, which is called
40 a Sequence Feature and may or may not have an Annotation Collection).
42 A benefit of this approach is that all sorts of simple, interesting
43 observations can be collected, the possibility is endless.
45 The Bioperl approach is that the "interesting facts" are represented by
46 Bio::AnnotationI objects. The interface Bio::AnnotationI guarantees
47 two methods
49 $obj->as_text(); # string formated to display to users
51 and
53 $obj->hash_tree(); # hash with defined rules for data-orientated discovery
55 The hash_tree method is designed to play well with XML output and
56 other "nested-tag-of-data-values", think BoulderIO and/or Ace stuff. For more
57 information see L<Bio::AnnotationI>.
59 Annotations are stored in AnnotationCollections, each Annotation under a
60 different "tag". The tags allow simple discovery of the available annotations,
61 and in some cases (like the tag "gene_name") indicate how to interpret the
62 data underneath the tag. The tag is only one tag deep and each tag can have an
63 array of values.
65 In addition, AnnotationCollections are guaranteed to maintain consistent
66 types of objects under each tag - at least that each object complies to one
67 interface. The "standard" AnnotationCollection insists the following rules
68 are set up:
70 Tag Object
71 --- ------
72 comment Bio::Annotation::Comment
73 dblink Bio::Annotation::DBLink
74 description Bio::Annotation::SimpleValue
75 gene_name Bio::Annotation::SimpleValue
76 ontology_term Bio::Annotation::OntologyTerm
77 reference Bio::Annotation::Reference
79 These tags are the implict tags that the SeqIO system needs to round-trip
80 GenBank/EMBL/Swissprot.
82 However, you as a user and us collectively as a community can grow the
83 "standard" tag mapping over time and specifically for a particular
84 area.
87 =head1 FEEDBACK
89 =head2 Mailing Lists
91 User feedback is an integral part of the evolution of this and other
92 Bioperl modules. Send your comments and suggestions preferably to one
93 of the Bioperl mailing lists. Your participation is much appreciated.
95 bioperl-l@bioperl.org
97 =head2 Reporting Bugs
99 Report bugs to the Bioperl bug tracking system to help us keep track
100 the bugs and their resolution. Bug reports can be submitted via the
101 web:
103 http://bugzilla.open-bio.org/
105 =head1 AUTHOR - Ewan Birney
107 Email birney@ebi.ac.uk
109 =head1 APPENDIX
111 The rest of the documentation details each of the object methods. Internal methods
112 are usually preceded with a _
114 =cut
117 # Let the code begin...
119 package Bio::AnnotationCollectionI;
120 use strict;
122 # Interface preamble - inherits from Bio::Root::RootI
125 use base qw(Bio::Root::RootI);
127 =head1 ACCESSOR METHODS
129 Use these for Bio::AnnotationI object access.
131 =cut
133 =head2 get_all_annotation_keys()
135 Usage : $ac->get_all_annotation_keys()
136 Function: gives back a list of annotation keys, which are simple text strings
137 Returns : list of strings
138 Args : none
140 =cut
142 sub get_all_annotation_keys{
143 shift->throw_not_implemented();
147 =head2 get_Annotations()
149 Usage : my @annotations = $collection->get_Annotations('key')
150 Function: Retrieves all the Bio::AnnotationI objects for a specific key
151 Returns : list of Bio::AnnotationI - empty if no objects stored for a key
152 Args : string which is key for annotations
154 =cut
156 sub get_Annotations{
157 shift->throw_not_implemented();
160 =head2 add_Annotation()
162 Usage : $self->add_Annotation('reference',$object);
163 $self->add_Annotation($object,'Bio::MyInterface::DiseaseI');
164 $self->add_Annotation($object);
165 $self->add_Annotation('disease',$object,'Bio::MyInterface::DiseaseI');
166 Function: Adds an annotation for a specific key.
168 If the key is omitted, the object to be added must provide a value
169 via its tagname().
171 If the archetype is provided, this and future objects added under
172 that tag have to comply with the archetype and will be rejected
173 otherwise.
175 Returns : none
176 Args : annotation key ('disease', 'dblink', ...)
177 object to store (must be Bio::AnnotationI compliant)
178 [optional] object archetype to map future storage of object
179 of these types to
181 =cut
183 sub add_Annotation {
184 shift->throw_not_implemented();
187 =head2 remove_Annotations()
189 Usage :
190 Function: Remove the annotations for the specified key from this collection.
191 Returns : an list of Bio::AnnotationI compliant objects which were stored
192 under the given key(s)
193 Args : the key(s) (tag name(s), one or more strings) for which to
194 remove annotations (optional; if none given, flushes all
195 annotations)
197 =cut
199 sub remove_Annotations{
200 shift->throw_not_implemented();
203 =head2 get_num_of_annotations()
205 Usage : my $count = $collection->get_num_of_annotations()
206 Function: Returns the count of all annotations stored in this collection
207 Returns : integer
208 Args : none
210 =cut
212 sub get_num_of_annotations{
213 shift->throw_not_implemented();