Bio Annotation
SummaryIncluded librariesPackage variablesSynopsisDescriptionGeneral documentationMethods
Summary
Bio::Annotation - A generic object for annotations.
Package variables
No package variables defined.
Included modules
Bio::Annotation::Comment
Bio::Annotation::DBLink
Bio::Annotation::Reference
Bio::Root::Root
Inherit
Bio::Root::Root
Synopsis
    use Bio::Annotation;
    use Bio::Annotation::DBLink;
    use Bio::Annotation::Comment;

    my $link = new Bio::Annotation::DBLink(-database => 'TSC',
                                     -primary_id => 'TSC0000030'
                                     );
    my $ann = Bio::Annotation->new('-description'  => 'some description');
    $ann->add_DBLink($link);

    my $comment = Bio::Annotation::Comment->new('-text' => 'Text of comment');
    my $comment2 = Bio::Annotation::Comment->new('-text' => 'Second comment');
    $ann->add_Comment($comment);
    $ann->add_Comment($comment2);

    my $ref = Bio::Annotation::Reference->new( '-authors' => 'author line',
                                           '-title'   => 'title line',
                                           '-location'=> 'location line',
                                           '-start'   => 12);
    $ann->add_Reference($ref);

    # description is a simple, one line description
    print "Description is ",$ann->description, "\n";

    foreach $comment ( $ann->each_Comment ) {
       # $comment is a Bio::Annotation::Comment object
       print "Comment: ", $comment->text(), "\n";
    }

    foreach $link ( $ann->each_DBLink ) {
       # link is a Bio::Annotation::DBLink object
       print "Link to ",$link->primary_id, " in database", $link->database,"\n";    }

    foreach $ref ( $ann->each_Reference ) {
       # link is a Bio::Annotation::Reference object
       print "Reference title ", $ref->title , "\n";
    }
Description
The object represents generic biological annotation of an object. It
has the ability to provide
    a brief, one line description
    free text comments
    links to other biological objects
    references to literature
It does not have the following abilities
    The basis (experimental/non experimental/homology) 
       of the annotation. This is considered to be part of
       the object which owns the annotation. This is 
       because the type of relevant basis is usually 
       dependent on the object

    The previous revisions of the object
       This should be a property of whatever database this
       object comes from
Methods
newDescriptionCode
descriptionDescriptionCode
gene_name
No description
Code
add_gene_nameDescriptionCode
remove_gene_nameDescriptionCode
each_gene_nameDescriptionCode
add_ReferenceDescriptionCode
remove_ReferenceDescriptionCode
each_ReferenceDescriptionCode
add_CommentDescriptionCode
remove_CommentDescriptionCode
each_CommentDescriptionCode
add_DBLinkDescriptionCode
remove_DBLinkDescriptionCode
each_DBLinkDescriptionCode
Methods description
newcode    nextTop
 Title   : new
 Usage   : $annotation = Bio::Annotation->new( '-description' => 'a description line');
 Function: Makes a new Annotation object. The main thing 
           you will want to do with this is add comment objects and
           dblink objects, with calls like

            $annotation->add_Comment($comment);
            $annotation->add_DBLink($dblink);

 Example :
 Returns : a new Bio::Annotation Object
 Args    : hash, potentially with one field, -description
descriptioncodeprevnextTop
 Title   : description
 Usage   : $obj->description($newval)
 Function: 
 Example : 
 Returns : value of description
 Args    : newvalue (optional)
add_gene_namecodeprevnextTop
 Title   : add_gene_name
 Usage   : $self->add_gene_name($name1[,$name2,...])
 Function: adds a reference object
 Example :
 Returns : 
 Args    : a string, or a list of strings
remove_gene_namecodeprevnextTop
 Title   : remove_gene_name
 Usage   : $self->remove_gene_name($index)
 Function: removes a particular gene name
 Example :
 Returns : 
 Args    : index of the name to remove
each_gene_namecodeprevnextTop
 Title   : each_gene_name
 Usage   : foreach $genename ( $self->each_gene_name() ) {
               print "seq has gene name $genename\n";
           }
 Function: gets the array of gene names
 Example :
 Returns : an array of strings
 Args    :
add_ReferencecodeprevnextTop
 Title   : add_Reference
 Usage   : $self->add_Reference($ref1[,$ref2,...])
 Function: adds a reference object
 Example :
 Returns : 
 Args    : a Bio::Annotation::Reference or derived object
remove_ReferencecodeprevnextTop
 Title   : remove_Reference
 Usage   : $self->remove_Reference($index)
 Function: removes a reference object
 Example :
 Returns : 
 Args    : index number from references array
each_ReferencecodeprevnextTop
 Title   : each_Reference
 Usage   : foreach $ref ( $self->each_Reference() )
 Function: gets an array of reference
 Example :
 Returns : an array of Bio::Annotation::Reference or derived objects
 Args    :
add_CommentcodeprevnextTop
 Title   : add_Comment
 Usage   : $self->add_Comment($ref)
 Function: adds a Comment object
 Example :
 Returns : 
 Args    : a Bio::Annotation::Comment or derived object
remove_CommentcodeprevnextTop
 Title   : remove_Comment
 Usage   : $self->remove_Comment($index)
 Function: removes a comment object
 Example :
 Returns : 
 Args    : index number from comments array
each_CommentcodeprevnextTop
 Title   : each_Comment
 Usage   : foreach $ref ( $self->each_Comment() )
 Function: gets an array of Comment of objects
 Example :
 Returns : an array of Bio::Annotation::Comment or derived objects
 Args    : none
add_DBLinkcodeprevnextTop
 Title   : add_DBLink
 Usage   : $self->add_DBLink($ref)
 Function: adds a link object
 Example :
 Returns : 
 Args    : a Bio::Annotation::DBLink or derived object
remove_DBLinkcodeprevnextTop
 Title   : remove_DBLink
 Usage   : $self->remove_DBLink($index)
 Function: removes a DBLink object
 Example :
 Returns : 
 Args    : index number from links array
each_DBLinkcodeprevnextTop
 Title   : each_DBLink
 Usage   : foreach $ref ( $self->each_DBlink() )
 Function: gets an array of DBlink of objects
 Example :
 Returns : an array of Bio::Annotation::DBlink or derived objects
 Args    :
Methods code
newdescriptionprevnextTop
sub new {
  my($class,@args) = @_;
  my $self = $class->SUPER::new(@args);
  
  my ($text ) = $self->_rearrange([qw(DESCRIPTION)], @args);
  
  defined $text && $self->description($text);
  $self->{ 'refs' } = [];
  $self->{ 'comment' } = [];
  $self->{ 'link' } = [];
  $self->{ '_names' } = [];

  return $self;
}
descriptiondescriptionprevnextTop
sub description {
   my ($self,$value) = @_;
   if( defined $value) {
      $self->{'description'} = $value;
    }
    return $self->{'description'};
}
gene_namedescriptionprevnextTop
sub gene_name {
    my ($self,$value) = @_;

    $self->warn("gene_name() is deprecated. Use add_gene_name/each_gene_name instead.");
    if( defined $value) {
	$self->add_gene_name($value);
    }
    ($value) = $self->each_gene_name();
    return $value;
}
add_gene_namedescriptionprevnextTop
sub add_gene_name {
    my ($self) = shift;
    foreach my $name ( @_ ) {
	push(@{$self->{'_names'}},$name);
    }
}
remove_gene_namedescriptionprevnextTop
sub remove_gene_name {
   my ($self,$idx) = @_;
   splice @{$self->{'_names'}}, $idx, 1;
}
each_gene_namedescriptionprevnextTop
sub each_gene_name {
   my ($self,@args) = @_;
   
   return @{$self->{'_names'}};
}
add_ReferencedescriptionprevnextTop
sub add_Reference {
   my ($self) = shift;
   foreach my $ref ( @_ ) {
       if( ! $ref->isa('Bio::Annotation::Reference') ) {
	   $self->throw("Is not a Bio::Annotation::Reference object but a [$ref]");
       }
       push(@{$self->{'refs'}},$ref);
   }
}
remove_ReferencedescriptionprevnextTop
sub remove_Reference {
   my ($self,$idx) = @_;
   splice @{$self->{'refs'}}, $idx, 1;
}
each_ReferencedescriptionprevnextTop
sub each_Reference {
   my ($self,@args) = @_;
   
   return @{$self->{'refs'}};
}
add_CommentdescriptionprevnextTop
sub add_Comment {
   my ($self) = shift;
   foreach my $com ( @_ ) {
       if( ! $com->isa('Bio::Annotation::Comment') ) {
	   $self->throw("Is not a comment object but a  [$com]");
       }
       push(@{$self->{'comment'}},$com);
   }
}
remove_CommentdescriptionprevnextTop
sub remove_Comment {
   my ($self,$idx) = @_;
   splice @{$self->{'comment'}}, $idx, 1;
}
each_CommentdescriptionprevnextTop
sub each_Comment {
   my ($self) = @_;
   
   return @{$self->{'comment'}};
}
add_DBLinkdescriptionprevnextTop
sub add_DBLink {
   my ($self,@list) = @_;

   foreach my $com ( @list ) {
       if( ! $com->isa('Bio::Annotation::DBLink') ) {
	   $self->throw("Is not a link object but a  [$com]");
       }
   push(@{$self->{'link'}},$com);
   }
}
remove_DBLinkdescriptionprevnextTop
sub remove_DBLink {
   my ($self,$idx) = @_;
   splice @{$self->{'link'}}, $idx, 1;
}
each_DBLinkdescriptionprevnextTop
sub each_DBLink {
   my ($self) = @_;
   
   return @{$self->{'link'}};
}
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@bio.perl.org
  http://bio.perl.org/bioperl-bugs/
AUTHOR - Ewan Birney Top
Email birney@ebi.ac.uk
APPENDIXTop
The rest of the documentation details each of the object methods. Internal methods are usually preceded with a _