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

Chris Fields cjfields at illinois.edu
Fri Mar 27 15:49:26 EDT 2009


What exactly would the hint be?  I'm not sure, but I don't think there  
is any documentation indicating that one should use anything other  
than tag methods to retrieve generic data.  We *could* possibly add in  
code to check the feature's Bio::Annotation::Collection for the same  
tag name, then add any returned AnnotationI::display_text to the array  
of returned values.

This all depends on:

1) whether you want to mix your 'peanut butter' with your 'chocolate'  
or keep them separate (amazingly, some people don't like Reese's  
peanut butter cups), and
2) whether you want to automatically check for the empty collection  
each time (the Collection is lazily created on the fly if one isn't  
supplied, so it may slow things down by creating the instance for  
every has_tag check).

chris

On Mar 27, 2009, at 1:29 PM, Mark A. Jensen wrote:

> Thanks Hilmar-- so there isn't really a bug, but would it
> be useful if the object warned a user who attempts to access an  
> empty $feature->annotation with a hint encapsulating
> your discussion below?
> MAJ
> ----- Original Message ----- From: "Hilmar Lapp" <hlapp at gmx.net>
> To: "Govind Chandra" <govind.chandra at bbsrc.ac.uk>
> Cc: "Mark A. Jensen" <maj at fortinbras.us>; <bioperl-l at lists.open-bio.org 
> >
> Sent: Friday, March 27, 2009 2:14 PM
> Subject: Re: [Bioperl-l] Bio::AnnotatableI function annotation()
>
>
>> $feature->annotation() is a legitimate method call (it implements   
>> AnnotatableI).
>> SeqFeature::Generic has indeed two mechanism to store annotation,  
>> the  tag system and the annotation collection. This is because it  
>> inherits  from SeqFeatureI (which brings in the tag/value  
>> annotation) and from  AnnotatableI (which brings in annotation()).
>> I agree this can be confusing from a user's perspective. As a rule  
>> of  thumb, SeqIO parsers will almost universally populate only the  
>> tag/ value system, because typically they will (or should) assume  
>> not more  than that the feature object they are dealing with is a  
>> SeqFeatureI.
>> Once you have the feature objects in your hands, you can add to  
>> either  tag/values or annotation() to your heart's content. Just be  
>> aware that  nearly all SeqIO writers won't use the annotation()  
>> collection when  you pass the sequence back to them since typically  
>> they won't really  know what to do with feature annotation that  
>> isn't tag/value (unlike  as for sequence annotation).
>> If in your code you want to treat tag/value annotation in the same  
>> way  as (i.e., as if it were part of) the annotation that's in the   
>> annotation collection then use SeqFeature::AnnotationAdaptor.  
>> That's  in fact what Bioperl-db does to ensure that all annotation  
>> gets  serialized to the database no matter where it is.
>> Hth,
>> -hilmar
>> On Mar 27, 2009, at 1:44 PM, Govind Chandra wrote:
>>> Hi Mark,
>>> Will it be unfair to say that the documentation as well as the
>>> implementation are confusing. SeqFeature::Generic should cause an   
>>> error
>>> when annotation() is called on it if it cannot do the right thing.  
>>> For
>>> the time being I will stick with the old ways (has_tag etc.). Good  
>>> to
>>> know they are not deprecated in the way I intend to use them (via
>>> SeqFeature::Generic).
>>> Cheers
>>> Govind
>>>
>>>
>>>
>>> On Fri, 2009-03-27 at 13:30 -0400, Mark A. Jensen wrote:
>>>> Hey Govind--
>>>> You're right-- SeqFeature::Generic object inherits from
>>>> AnnotatableI-- but the *_tags_* methods are now
>>>> SeqFeature::Generic methods--ie, you can use these
>>>> on features, and they are no longer hitting AnnotableI.
>>>> It appears that the feature's AnnotationCollection doesn't
>>>> even get loaded now.
>>>> [developer out there like to chime in?]
>>>> cheers,
>>>> Mark
>>>> ----- Original Message -----
>>>> From: "Govind Chandra" <govind.chandra at bbsrc.ac.uk>
>>>> To: "Mark A. Jensen" <maj at fortinbras.us>
>>>> Cc: <bioperl-l at lists.open-bio.org>
>>>> Sent: Friday, March 27, 2009 1:09 PM
>>>> Subject: [Bioperl-l] Bio::AnnotatableI function annotation()
>>>>
>>>>
>>>>> Thanks Mark,
>>>>>
>>>>> Sorry for not putting a proper subject in the last post.
>>>>>
>>>>> What you suggest is what I have been doing for a long time. I  
>>>>> am  just
>>>>> trying to alter my code to conform to the latest bioperl  
>>>>> version  and ran
>>>>> into this issue. I could be wrong (I am more a user rather than   
>>>>> writer
>>>>> of modules) but since $feature->annotation() does not result in  
>>>>> an  error
>>>>> I think $feature is-a Bio::AnnotatableI as well.
>>>>>
>>>>> Cheers
>>>>>
>>>>> Govind
>>>>>
>>>>>
>>>>>
>>>>> On Fri, 2009-03-27 at 12:17 -0400, Mark A. Jensen wrote:
>>>>>> Hi Govind-
>>>>>>
>>>>>> As near as I can tell, the *_tags methods are deprecated for
>>>>>> Bio::AnnotatableI objects, but these methods are available
>>>>>> off the SeqFeatureI objects themselves: i.e., rather than
>>>>>>
>>>>>>> $ac=$feature->annotation();
>>>>>>> $temp1=$ac->get_Annotations("locus_tag");
>>>>>>
>>>>>> do
>>>>>>
>>>>>> $temp1 = $feature->get_tag_values("locus_tag");
>>>>>>
>>>>>> directly.
>>>>>>
>>>>>> hope it helps -
>>>>>> Mark
>>>>>>
>>>>>> ----- Original Message -----
>>>>>> From: "Govind Chandra" <govind.chandra at bbsrc.ac.uk>
>>>>>> To: <bioperl-l at lists.open-bio.org>
>>>>>> Sent: Friday, March 27, 2009 11:26 AM
>>>>>> Subject: Re: [Bioperl-l] Bioperl-l Digest, Vol 71, Issue 15
>>>>>>
>>>>>>
>>>>>>> Hi,
>>>>>>>
>>>>>>> The code below
>>>>>>>
>>>>>>>
>>>>>>> ====== code begins =======
>>>>>>> #use strict;
>>>>>>> use Bio::SeqIO;
>>>>>>>
>>>>>>> $infile='NC_000913.gbk';
>>>>>>> my $seqio=Bio::SeqIO->new(-file => $infile);
>>>>>>> my $seqobj=$seqio->next_seq();
>>>>>>> my @features=$seqobj->all_SeqFeatures();
>>>>>>> my $count=0;
>>>>>>> foreach my $feature (@features) {
>>>>>>> unless($feature->primary_tag() eq 'CDS') {next;}
>>>>>>> print($feature->start(),"   ", $feature->end(), "
>>>>>>> ",$feature->strand(),"\n");
>>>>>>> $ac=$feature->annotation();
>>>>>>> $temp1=$ac->get_Annotations("locus_tag");
>>>>>>> @temp2=$ac->get_Annotations();
>>>>>>> print("$temp1   $temp2[0] @temp2\n");
>>>>>>> if($count++ > 5) {last;}
>>>>>>> }
>>>>>>>
>>>>>>> print(ref($ac),"\n");
>>>>>>> exit;
>>>>>>>
>>>>>>> ======= code ends ========
>>>>>>>
>>>>>>> produces the output
>>>>>>>
>>>>>>> ========== output begins ========
>>>>>>>
>>>>>>> 190   255   1
>>>>>>> 0
>>>>>>> 337   2799   1
>>>>>>> 0
>>>>>>> 2801   3733   1
>>>>>>> 0
>>>>>>> 3734   5020   1
>>>>>>> 0
>>>>>>> 5234   5530   1
>>>>>>> 0
>>>>>>> 5683   6459   -1
>>>>>>> 0
>>>>>>> 6529   7959   -1
>>>>>>> 0
>>>>>>> Bio::Annotation::Collection
>>>>>>>
>>>>>>> =========== output ends ==========
>>>>>>>
>>>>>>> $ac is-a Bio::Annotation::Collection but does not actually   
>>>>>>> contain any
>>>>>>> annotation from the feature. Is this how it should be? I  
>>>>>>> cannot  figure
>>>>>>> out what is wrong with the script. Earlier I used to use   
>>>>>>> has_tag(),
>>>>>>> get_tag_values() etc. but the documentation says these are   
>>>>>>> deprecated.
>>>>>>>
>>>>>>> Perl is 5.8.8. BioPerl version is 1.6 (installed today).  
>>>>>>> Output  of uname
>>>>>>> -a is
>>>>>>>
>>>>>>> Linux n61347 2.6.18-92.1.6.el5 #1 SMP Fri Jun 20 02:36:06 EDT  
>>>>>>> 2008
>>>>>>> x86_64 x86_64 x86_64 GNU/Linux
>>>>>>>
>>>>>>> Thanks in advance for any help.
>>>>>>>
>>>>>>> Govind
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>> _______________________________________________
>>>>>>> Bioperl-l mailing list
>>>>>>> Bioperl-l at lists.open-bio.org
>>>>>>> http://lists.open-bio.org/mailman/listinfo/bioperl-l
>>>>>>>
>>>>>>>
>>>>>>
>>>>>
>>>>> _______________________________________________
>>>>> Bioperl-l mailing list
>>>>> Bioperl-l at lists.open-bio.org
>>>>> http://lists.open-bio.org/mailman/listinfo/bioperl-l
>>>>>
>>>>>
>>>
>>> _______________________________________________
>>> Bioperl-l mailing list
>>> Bioperl-l at lists.open-bio.org
>>> http://lists.open-bio.org/mailman/listinfo/bioperl-l
>> -- 
>> ===========================================================
>> : Hilmar Lapp  -:-  Durham, NC  -:-  hlapp at gmx dot net :
>> ===========================================================
>>
> _______________________________________________
> Bioperl-l mailing list
> Bioperl-l at lists.open-bio.org
> http://lists.open-bio.org/mailman/listinfo/bioperl-l




More information about the Bioperl-l mailing list