Bio::S...daptor(3pm)
π Bio::SeqFeature::AnnotationAdaptor β the perl man page, but make it cute π
okay bestie, so this page lives in the User Contributed Perl Documentation section, and its manual name is Bio::S...daptor(3pm) (yeah they truncated it, it's giving mysterious but it's literally just Bio::SeqFeature::AnnotationAdaptor). Sit down, grab a strawberry π, and let's get into it.
β¨ NAME β¨
Bio::SeqFeature::AnnotationAdaptor β it integrates SeqFeatureI annotation, no cap. π§
π SYNOPSIS π
use Bio::SeqFeature::Generic;
use Bio::SeqFeature::AnnotationAdaptor;
# obtain a SeqFeatureI implementing object somehow
my $feat = Bio::SeqFeature::Generic->new(-start => 10, -end => 20);
# add tag/value annotation
$feat->add_tag_value("mytag", "value of tag mytag");
$feat->add_tag_value("mytag", "another value of tag mytag");
# Bio::SeqFeature::Generic also provides annotation(), which returns a
# Bio::AnnotationCollectionI compliant object
$feat->annotation->add_Annotation("dbxref", $dblink);
# to integrate tag/value annotation with AnnotationCollectionI
# annotation, use this adaptor, which also implements
# Bio::AnnotationCollectionI
my $anncoll = Bio::SeqFeature::AnnotationAdaptor->new(-feature => $feat);
# this will now return tag/value pairs as
# Bio::Annotation::SimpleValue objects
my @anns = $anncoll->get_Annotations("mytag");
# other added before annotation is available too
my @dblinks = $anncoll->get_Annotations("dbxref");
# also supports transparent adding of tag/value pairs in
# Bio::AnnotationI flavor
my $tagval = Bio::Annotation::SimpleValue->new(-value => "some value",
-tagname => "some tag");
$anncoll->add_Annotation($tagval);
# this is now also available from the feature's tag/value system
my @vals = $feat->get_tag_values("some tag");
like, look at that. it just works. π
π¦ DESCRIPTION π¦
so Bio::SeqFeatureI defines light-weight annotation of features through tag/value pairs. meanwhile, Bio::AnnotationCollectionI plus Bio::AnnotationI defines an annotation bag, which is better typed β but more heavy-weight, because it contains every single piece of annotation as objects. the frequently used base implementation of Bio::SeqFeatureI, namely Bio::SeqFeature::Generic, defines an additional slot for AnnotationCollectionI-compliant annotation.
this adaptor gives you a Bio::AnnotationCollectionI compliant, unified, and integrated view on the annotation of Bio::SeqFeatureI objects β including tag/value pairs, and annotation through the annotation() method, if the object supports it. code that uses this adaptor does not need to worry about the different ways of possibly annotating a SeqFeatureI object; instead it can assume the object strictly follows the AnnotationCollectionI scheme. the price to pay? retrieving and adding annotation will always use objects instead of light-weight tag/value pairs. π (worth it tho.)
in other words, this adaptor lets us keep the best of both worlds. if you create tens of thousands of feature objects, and your only annotation is tag/value pairs, you are best off using the features' native tag/value system. if you create a smaller number of features, but with rich and typed annotation mixed with tag/value pairs, this adaptor may be for you. since its implementation is by double-composition, you only need to create one instance of the adaptor. in order to transparently annotate a feature object, set the feature using the feature() method. every annotation you add will be added to the feature object, and hence will not be lost when you set feature() to the next object. iconic behavior, honestly. π
π¬ 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 the Bioperl mailing list. your participation is much appreciated. π«Ά
bioperl-l@bioperl.org - General discussion
http://bioperl.org/wiki/Mailing_lists - About the mailing lists
π Support π
please direct usage questions or support issues to the mailing list:
bioperl-l@bioperl.org
rather than to the module maintainer directly. many experienced and reponsive experts will be able 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 more detail the better. π)
π Reporting Bugs π
report bugs to the Bioperl bug tracking system to help us keep track of the bugs and their resolution. bug reports can be submitted via the web:
https://github.com/bioperl/bioperl-live/issues
π AUTHOR - Hilmar Lapp π
email hlapp at gmx.net
π APPENDIX π
the rest of the documentation details each of the object methods. internal methods are usually preceded with a _.
π new π
Title : new
Usage : my $obj = Bio::SeqFeature::AnnotationAdaptor->new();
Function: Builds a new Bio::SeqFeature::AnnotationAdaptor object
Returns : an instance of Bio::SeqFeature::AnnotationAdaptor
Args : Named parameters
-feature the Bio::SeqFeatureI implementing object to adapt
(mandatory to be passed here, or set via feature()
before calling other methods)
-annotation the Bio::AnnotationCollectionI implementing object
for storing richer annotation (this will default to
the $feature->annotation() if it supports it)
-tagvalue_factory the object factory to use for creating tag/value
pair representing objects
so -feature is mandatory here (or set via feature() before you call anything else, bestie, don't forget), -annotation defaults to $feature->annotation() if the feature supports it, and -tagvalue_factory is your factory for making the tag/value pair representing objects. β¨
π feature π
Title : feature
Usage : $obj->feature($newval)
Function: Get/set the feature that this object adapts to an
AnnotationCollectionI.
Example :
Returns : value of feature (a Bio::SeqFeatureI compliant object)
Args : new value (a Bio::SeqFeatureI compliant object, optional)
get it, set it, adapt it. πΈ
π annotation π
Title : annotation
Usage : $obj->annotation($newval)
Function: Get/set the AnnotationCollectionI implementing object used by
this adaptor to store additional annotation that cannot be stored
by the SeqFeatureI itself.
If requested before having been set, the value will default to the
annotation object of the feature if it has one.
Example :
Returns : value of annotation (a Bio::AnnotationCollectionI compliant object)
Args : new value (a Bio::AnnotationCollectionI compliant object, optional)
this is where the "extra" annotation lives β the stuff the SeqFeatureI itself can't store. and if you ask for it before setting it, it just defaults to the feature's annotation object if it has one. thoughtful. π
π AnnotationCollectionI implementing methods π
π§ get_all_annotation_keys π§
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_Annotations π§
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_annotations π§
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
π Implementation specific functions - to allow adding π
π add_Annotation π
Title : add_Annotation
Usage : $self->add_Annotation('reference',$object);
$self->add_Annotation($object,'Bio::MyInterface::DiseaseI');
$self->add_Annotation($object);
$self->add_Annotation('disease',$object,'Bio::MyInterface::DiseaseI');
Function: Adds an annotation for a specific key.
If the key is omitted, the object to be added must provide a value
via its tagname().
If the archetype is provided, this and future objects added under
that tag have to comply with the archetype and will be rejected
otherwise.
This implementation will add all Bio::Annotation::SimpleValue
objects to the adapted features as tag/value pairs. Caveat: this
may potentially result in information loss if a derived object
is supplied.
Returns : none
Args : annotation key ('disease', 'dblink', ...)
object to store (must be Bio::AnnotationI compliant)
[optional] object archetype to map future storage of object
of these types to
β οΈ okay important thing: this implementation adds all Bio::Annotation::SimpleValue objects to the adapted features as tag/value pairs. Caveat β this may potentially result in information loss if a derived object is supplied. be aware, bestie, don't lose your data. π
π remove_Annotations π
Title : remove_Annotations
Usage :
Function: Remove the annotations for the specified key from this
collection.
If the key happens to be a tag, then the tag is removed
from the feature.
Example :
Returns : an array Bio::AnnotationI compliant objects which were stored
under the given key(s)
Args : the key(s) (tag name(s), one or more strings) for which to
remove annotations (optional; if none given, flushes all
annotations)
heads up: if the key happens to be a tag, the tag gets removed from the feature too. and if you give it no keys at all, it flushes all the annotations. π«§
β Additional methods β
π tagvalue_object_factory π
Title : tagvalue_object_factory
Usage : $obj->tagval_object_factory($newval)
Function: Get/set the object factory to use for creating objects that
represent tag/value pairs (e.g.,
Bio::Annotation::SimpleValue).
The object to be created is expected to follow
Bio::Annotation::SimpleValue in terms of supported
arguments at creation time, and the methods.
Example :
Returns : A Bio::Factory::ObjectFactoryI compliant object
Args : new value (a Bio::Factory::ObjectFactoryI compliant object,
optional)
(yeah, the usage says tagval_object_factory and the title says tagvalue_object_factory β that's just how it is, iykyk, don't come for me. π)
and that's the whole page, bestie!! this was documented by Hilmar Lapp, and the page itself is from perl v5.32.1, dated 2021-08-15, filed under the manual name Bio::S...daptor(3pm). slay, go forth and annotate. πβ¨ππ¦
π¦ where this page comes from
- debian bookworm: libbio-perl-perl 1.7.8-1 Β· Perl
- debian trixie: libbio-perl-perl 1.7.8-1 Β· Perl
- ubuntu jammy: libbio-perl-perl 1.7.8-1 Β· Perl
- ubuntu noble: libbio-perl-perl 1.7.8-1 Β· Perl
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms