Bio::Annotation Collection
SummaryIncluded librariesPackage variablesSynopsisDescriptionGeneral documentationMethods
Summary
Bio::Annotation::Collection - Default Perl implementation of AnnotationCollectionI
Package variables
No package variables defined.
Included modules
Bio::Annotation::SimpleValue
Bio::Annotation::TypeManager
Bio::AnnotationCollectionI
Bio::Root::Root
Inherit
Bio::AnnotationCollectionI Bio::Root::Root
Synopsis
  # add synopsis here
Description
Bioperl implementation for Bio::AnnotationCollecitonI
Methods
newDescriptionCode
get_all_annotation_keysDescriptionCode
get_AnnotationsDescriptionCode
get_num_of_annotationsDescriptionCode
add_AnnotationDescriptionCode
descriptionDescriptionCode
add_gene_nameDescriptionCode
each_gene_nameDescriptionCode
add_ReferenceDescriptionCode
each_ReferenceDescriptionCode
add_CommentDescriptionCode
each_CommentDescriptionCode
add_DBLinkDescriptionCode
each_DBLinkDescriptionCode
_typemapDescriptionCode
Methods description
newcode    nextTop
 Title   : new
 Usage   : $coll = Bio::Annotation::Collection->new()
 Function: Makes a new Annotation::Collection object. 
 Returns : Bio::Annotation::Collection
 Args    : none
get_all_annotation_keyscodeprevnextTop
 Title   : get_all_annotation_keys
 Usage   : $ac->get_all_annotation_keys()
 Function: gives back a list of annotation keys, which are simple text strings
 Returns : list of strings
 Args    : none
get_AnnotationscodeprevnextTop
 Title   : get_Annotations
 Usage   : my @annotations = $collection->get_Annotations('key')
 Function: Retrieves all the Bio::AnnotationI objects for a specific key
 Returns : list of Bio::AnnotationI - empty if no objects stored for a key
 Args    : string which is key for annotations
get_num_of_annotationscodeprevnextTop
 Title   : get_num_of_annotations
 Usage   : my $count = $collection->get_num_of_annotations()
 Function: Returns the count of all annotations stored in this collection 
 Returns : integer
 Args    : none
add_AnnotationcodeprevnextTop
 Title   : add_Annotation
 Usage   : $self->add_Annotation('reference',$object);
           $self->add_Annotation('disease',$object,'Bio::MyInterface::DiseaseI');
 Function: Adds an annotation for a specific 
 Returns : none
 Args    : annotation key ('disease', 'dblink', ...)
           object to store (must be Bio::AnnotationI compliant)
           [optional] object archytype to map future storage of object 
                      of these types to
descriptioncodeprevnextTop
 Title   : description
 Usage   :
 Function:
 Example :
 Returns : 
 Args    :
add_gene_namecodeprevnextTop
 Title   : add_gene_name
 Usage   :
 Function:
 Example :
 Returns : 
 Args    :
each_gene_namecodeprevnextTop
 Title   : each_gene_name
 Usage   :
 Function:
 Example :
 Returns : 
 Args    :
add_ReferencecodeprevnextTop
 Title   : add_Reference
 Usage   :
 Function:
 Example :
 Returns : 
 Args    :
each_ReferencecodeprevnextTop
 Title   : each_Reference
 Usage   :
 Function:
 Example :
 Returns : 
 Args    :
add_CommentcodeprevnextTop
 Title   : add_Comment
 Usage   :
 Function:
 Example :
 Returns : 
 Args    :
each_CommentcodeprevnextTop
 Title   : each_Comment
 Usage   :
 Function:
 Example :
 Returns : 
 Args    :
add_DBLinkcodeprevnextTop
 Title   : add_DBLink
 Usage   :
 Function:
 Example :
 Returns : 
 Args    :
each_DBLinkcodeprevnextTop
 Title   : each_DBLink
 Usage   :
 Function:
 Example :
 Returns : 
 Args    :
_typemapcodeprevnextTop
 Title   : _typemap
 Usage   : $obj->_typemap($newval)
 Function: 
 Example : 
 Returns : value of _typemap
 Args    : newvalue (optional)
Methods code
newdescriptionprevnextTop
sub new {
   my ($class,@args) = @_;

   my $self = $class->SUPER::new(@args);

   $self->{'_annotation'} = {};
   $self->_typemap(Bio::Annotation::TypeManager->new());

   return $self;
}
get_all_annotation_keysdescriptionprevnextTop
sub get_all_annotation_keys {
   my ($self) = @_;
   return keys %{$self->{'_annotation'}};
}
get_AnnotationsdescriptionprevnextTop
sub get_Annotations {
   my ($self,$key) = @_;

   if( !defined $self->{'_annotation'}->{$key} ) {
       return ();
   } else {
       return @{$self->{'_annotation'}->{$key}};
   }
}
get_num_of_annotationsdescriptionprevnextTop
sub get_num_of_annotations {
   my ($self) = @_;
   my $count = 0;
   map { $count += scalar @$_ } values %{$self->{'_annotation'}};
   return $count;
}
add_AnnotationdescriptionprevnextTop
sub add_Annotation {
   my ($self,$key,$object,$archytype) = @_;
   
   if( !defined $object ) {
       $self->throw("Must have at least key and object in add_Annotation");
   }

   if( !ref $object ) {
       $self->throw("Must add an object. Use Bio::Annotation::Comment, SimpleValue or ControledVocabTerm for simple text additions");
   }

   if( !$object->isa("Bio::AnnotationI") ) {
       $self->throw("object must be AnnotationI compliant, otherwise we wont add it!");
   }

   # ok, now we are ready! If we don't have an archytype, set it
# from the type of the object
if( !defined $archytype ) { $archytype = ref $object; } # check typemap, storing if needed.
my $stored_map = $self->_typemap->type_for_key($key); if( defined $stored_map ) { # check validity, irregardless of archytype. A little cheeky
# this means isa stuff is executed correctly
if( !$self->_typemap()->is_valid($key,$object) ) { $self->throw("Object $object was not valid with key $key. If you were adding new keys in, perhaps you want to make use of the archytype method to allow registration to a more basic type"); } } else { $self->_typemap->_add_type_map($key,$archytype); } # we are ok to store
if( !defined $self->{'_annotation'}->{$key} ) { $self->{'_annotation'}->{$key} = []; } push(@{$self->{'_annotation'}->{$key}},$object); return 1;
}
descriptiondescriptionprevnextTop
sub description {
   my ($self,$value) = @_;

   $self->deprecated("Using old style annotation call on new Annotation::Collection object");

   if( defined $value ) {
       my $val = Bio::Annotation::SimpleValue->new();
       $val->value($value);
       $self->add_Annotation('description',$val);
   }

   my ($desc) = $self->get_Annotations('description');
   
   # If no description tag exists, do not attempt to call value on undef:
return $desc ? $desc->value : undef;
}
add_gene_namedescriptionprevnextTop
sub add_gene_name {
   my ($self,$value) = @_;

   $self->deprecated("Old style add_gene_name called on new style Annotation::Collection");

   my $val = Bio::Annotation::SimpleValue->new();
   $val->value($value);
   $self->add_Annotation('gene_name',$val);
}
each_gene_namedescriptionprevnextTop
sub each_gene_name {
   my ($self) = @_;

   $self->deprecated("Old style each_gene_name called on new style Annotation::Collection");

   my @out;
   my @gene = $self->get_Annotations('gene_name');

   foreach my $g ( @gene ) {
       push(@out,$g->value);
   }

   return @out;
}
add_ReferencedescriptionprevnextTop
sub add_Reference {
   my ($self, @values) = @_;

   $self->deprecated("add_Reference (old style Annotation) on new style Annotation::Collection");
   
   # Allow multiple (or no) references to be passed, as per old method
foreach my $value (@values) { $self->add_Annotation('reference',$value); }
}
each_ReferencedescriptionprevnextTop
sub each_Reference {
   my ($self) = @_;

   $self->deprecated("each_Reference (old style Annotation) on new style Annotation::Collection");
   
   return $self->get_Annotations('reference');
}
add_CommentdescriptionprevnextTop
sub add_Comment {
   my ($self,$value) = @_;

   $self->deprecated("add_Comment (old style Annotation) on new style Annotation::Collection");

   $self->add_Annotation('comment',$value);
}
each_CommentdescriptionprevnextTop
sub each_Comment {
   my ($self) = @_;

   $self->deprecated("each_Comment (old style Annotation) on new style Annotation::Collection");
   
   return $self->get_Annotations('comment');
}
add_DBLinkdescriptionprevnextTop
sub add_DBLink {
   my ($self,$value) = @_;

   $self->deprecated("add_DBLink (old style Annotation) on new style Annotation::Collection");

   $self->add_Annotation('dblink',$value);
}
each_DBLinkdescriptionprevnextTop
sub each_DBLink {
   my ($self) = @_;

   $self->deprecated("each_DBLink (old style Annotation) on new style Annotation::Collection");
   
   return $self->get_Annotations('dblink');
}
_typemapdescriptionprevnextTop
sub _typemap {
   my ($self,$value) = @_;
   if( defined $value) {
      $self->{'_typemap'} = $value;
    }
    return $self->{'_typemap'};
}
General documentation
FEEDBACKTop
Mailing ListsTop
User feedback is an integral part of the evolution of this and other
Bioperl modules. Send your comments and suggestions preferably to one
of the Bioperl mailing lists. Your participation is much appreciated.
  bioperl-l@bioperl.org              - General discussion
  http://bio.perl.org/MailList.html  - About the mailing lists
Reporting BugsTop
Report bugs to the Bioperl bug tracking system to help us keep track
the bugs and their resolution. Bug reports can be submitted via email
or the web:
  bioperl-bugs@bioperl.org
  http://bio.perl.org/bioperl-bugs/
AUTHOR - Ewan BirneyTop
Email birney@ebi.ac.uk
Describe contact details here
APPENDIXTop
The rest of the documentation details each of the object
methods. Internal methods are usually preceded with a _
Bio::Annotation::CollectionI implementing methodsTop
Implementation specific functions - mainly for addingTop
Backward compatible functionsTop
Functions put in for backward compatibility with old
Bio::Annotation.pm stuff
Implementation management functionsTop