Bio::AnnotationI(3pm)

πŸ“¦
version 1.7.8 Β· 3 versions
, in debian bookworm, debian trixie, ubuntu jammy, ubuntu noble

🌸 Bio::AnnotationI β€” the manual, but make it a group chat 🌸

okay so bestie, you've wandered into Bio::AnnotationI(3pm) and honestly? you're in the right place. This is the annotation interface β€” the vibe every annotation in Bioperl has to match. Let's get into it πŸ’…


✨ SYNOPSIS ✨

  # generally you get AnnotationI's from AnnotationCollectionI's

   foreach $key ( $ac->get_all_annotation_keys() ) {
       @values = $ac->get_Annotations($key);
       foreach $value ( @values ) {
          # value is an Bio::AnnotationI, and defines a "as_text" method
          print "Annotation ",$key," stringified value ",$value->as_text,"\n";
          # you can also use a generic hash_tree method for getting
          # stuff out say into XML format
          $hash_tree = $value->hash_tree();
       }
   }

πŸ¦‹ DESCRIPTION πŸ¦‹

This is the interface that all annotations must support. And no, it's not asking for much β€” there are literally two things every annotation has to bring to the table.

  $annotation->as_text()

Every annotation needs an as_text method. It should give you a single text string, with no newlines, representing the annotation β€” and the whole point is human readability. It is not trying to be a way to store or represent the annotation. Like, it's for your eyes, not for the database, iykyk πŸ‘€

The second method lets annotations at least attempt to represent themselves as pure data, for storage/display/whatever. That method, hash_tree, should return an anonymous hash with "XML-like" formatting:

   $hash = $annotation->hash_tree();

Here's the formatting tea β˜•:

  1. For each key in the hash, if the value is a reference'd array β€”
  2. For each element of the array if the value is a object β€” Assume the object has the method hash_tree;
  3. else if the value is a reference to a hash Recurse again from point (1)
  4. else Assume the value is a scalar, and handle it directly as text
  5. else (if not an array) apply rules 2,3 and 4 to value

The XML path in tags is represented by the keys taken in the hashes. When arrays show up, they're all present in the path level of this tag. Slay ✨

This is a pretty "natural" representation of an object tree in an XML style β€” without forcing literally everything to inherit off some super-generic interface just to represent stuff in the hash. No cap, it's a good system.


πŸ’Œ FEEDBACK πŸ’Œ

Mailing Lists πŸ“¬

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

Support πŸ›Ÿ

Please direct usage questions or support issues to the mailing list:

bioperl-l@bioperl.org

rather than to the module maintainer directly. There are so many experienced and reponsive experts who'll be able to look at the problem and quickly address it. Please include a thorough description of the problem with code and data examples if at all possible. (fr fr, the code examples help so much 😭)

Reporting Bugs πŸ›

Report bugs to the Bioperl bug tracking system to help us keep track the bugs and their resolution. Bug reports can be submitted via the web:

  https://github.com/bioperl/bioperl-live/issues

πŸ‘‘ AUTHOR - Ewan Birney πŸ‘‘

Email birney@ebi.ac.uk


πŸŽ€ APPENDIX πŸŽ€

The rest of the documentation details each of the object methods. Internal methods are usually preceded with a _ (yes, the underscore is the secret handshake 🀫).

as_text

 Title   : as_text
 Usage   :
 Function: single text string, without newlines representing the
           annotation, mainly for human readability. It is not aimed
           at being able to store/represent the annotation.
 Example :
 Returns : a string
 Args    : none

display_text

 Title   : display_text
 Usage   : my $str = $ann->display_text();
 Function: returns a string. Unlike as_text(), this method returns a string
           formatted as would be expected for the specific implementation.

           Implementations should allow passing a callback as an argument which
           allows custom text generation; the callback will be passed the
           current implementation.

           Note that this is meant to be used as a simple representation
           of the annotation data but probably shouldn't be used in cases
           where more complex comparisons are needed or where data is
           stored.
 Example :
 Returns : a string
 Args    : [optional] callback

hash_tree

 Title   : hash_tree
 Usage   :
 Function: should return an anonymous hash with "XML-like" formatting
 Example :
 Returns : a hash reference
 Args    : none

tagname

 Title   : tagname
 Usage   : $obj->tagname($newval)
 Function: Get/set the tagname for this annotation value.

           Setting this is optional. If set, it obviates the need to
           provide a tag to Bio::AnnotationCollectionI when adding
           this object. When obtaining an AnnotationI object from the
           collection, the collection will set the value to the tag
           under which it was stored unless the object has a tag
           stored already.

 Example :
 Returns : value of tagname (a scalar)
 Args    : new value (a scalar, optional)

🫢 and that's the whole page, bestie. go forth and annotate.

This iconic little doc came from perl v5.32.1, dated 2021-08-15, and it lives under the name Bio::AnnotationI(3pm) πŸ’–βœ¨

πŸ“¦ where this page comes from