[Bioperl-l] Bio::AnnotatableI function annotation()

Chris Fields cjfields at illinois.edu
Fri Mar 27 16:25:10 EDT 2009


On Mar 27, 2009, at 3:09 PM, Mark A. Jensen wrote:

> Probably folks just starting to use 1.6 will be shunted in the
> right direction by the docs, but those making the switch
> might reasonably get confused (resulting in this thread, e.g.).
> If someone tries to do $feature->annotation- 
> >getAnnotations('locus_tag')
> when $feature->annotation is undef, then probably that user is
> not hip to $feature->get_tag_values('locus_tag'), and would appreciate
> something like
> "Annotation property undefined. Did you mean $feature- 
> >get_tag_values?"
> (not nec. that specific, but you get my drift?)
> MAJ

Yes, but the result of $feature->annotation is never undef (the  
collection is created on the fly):

perl -MBio::SeqFeature::Generic -e 'my $sf = Bio::SeqFeature::Generic- 
 >new(-start => 1, -end => 100); print ref($sf->annotation)."\n"'
Bio::Annotation::Collection

We can't add a warning for lazy instantiation of the Collection w/o  
running into significant issues, as it'll pop up with code like this:

# don't create the annotation or the collection unless needed
if (defined $val) {
     $seq->annotation->add_Annotation(
     Bio::Annotation::SimpleValue->new(-tagname => 'foo', -value =>  
$val)
     );
}

-c


More information about the Bioperl-l mailing list