[Bioperl-l] Annotated.pm
Hilmar Lapp
hlapp at gmx.net
Sat Nov 27 02:31:08 EST 2004
On Friday, November 26, 2004, at 11:06 PM, Allen Day wrote:
> On Fri, 26 Nov 2004, Hilmar Lapp wrote:
>
>> Well, if you return an object from source_tag() instead of a string
>> your SeqFeatureI compliance goes out the window right there. Friendly
>> stringification through overloading double quotes does not mitigate
>> this.
>>
>> Same goes BTW for primary_tag(), seq_id() etc. Looking at the code,
>> you're returning an object for these. Not SeqFeatureI
>> contract-compliant.
>
> stringified reference ( e.g. REF(0x804d584) ) is a string in my book.
> this is a backward compatible change. if you're worried that the user
> will see the stringified reference if treating the returned value as a
> string and not a data structure, that's what the overloading is for.
>
> i don't see a problem here.
Well, what 'string' as return type basically means in perl speak is a
scalar that when evaluated yields the value of the string.
I.e., when I call $feature->primary_tag("my primary tag") and later ask
for $tag = $feature->primary_tag() then
ref($tag) eq ""; # is true
print $tag; # prints the string my primary tag
length($tag) == 14; # is true
join("",split(//,$tag)) eq $tag; # is true
and other things expecting a string will work as expected, like
my $stringio = IO::String->new($tag);
$dbi_statement_handle->bind_param(1, $tag);
to name a few.
If you can achieve this by returning a data structure instead of a
string, fine with me.
-hilmar
>
>> As an aside, your get_Annotations() short-cut is brittle. If someone
>> happens to add a second 'source' annotation (or any other tag for that
>> matter), it will break and return the length of the array instead of
>
> this is intentional and documented.
>
>> the first element. Furthermore, I wouldn't test for IS-A
>> Bio::Annotation::OntologyTerm - this is only an implementation class
>> and one day there may be better ones. What you really care about is
>> that the object IS-A Bio::AnnotationI (so that you can add it to the
>> collection) and IS-A Bio::Ontology::TermI (so that you have your
>> ontology-enforced typing).
>
> what class are you referring to here?
>
>>
>> -hilmar
>>
>> On Thursday, November 25, 2004, at 02:45 AM, Allen Day wrote:
>>
>>> i don't think it should do this, the whole point of using an AC is to
>>> retain typing. if you want to have a friendly stringification of the
>>> source attribute, use overloading in SimpleValue. there is an
>>> as_text()
>>> method already in there that is currently commented out.
>>>
>>> -allen
>>>
>>>
>>> On Thu, 25 Nov 2004, Steffen Grossman wrote:
>>>
>>>> Update of /home/repository/bioperl/bioperl-live/Bio/SeqFeature
>>>> In directory pub.open-bio.org:/tmp/cvs-serv22868
>>>>
>>>> Modified Files:
>>>> Annotated.pm
>>>> Log Message:
>>>> 'source' now gives back its value instead of a
>>>> Bio::Annotation::SimpleValue object. (This is consisitent with
>>>> 'type').
>>>>
>>>>
>>>> Index: Annotated.pm
>>>> ===================================================================
>>>> RCS file:
>>>> /home/repository/bioperl/bioperl-live/Bio/SeqFeature/Annotated.pm,v
>>>> retrieving revision 1.17
>>>> retrieving revision 1.18
>>>> diff -C2 -d -r1.17 -r1.18
>>>> *** Annotated.pm 24 Nov 2004 16:31:59 -0000 1.17
>>>> --- Annotated.pm 25 Nov 2004 10:02:50 -0000 1.18
>>>> ***************
>>>> *** 181,185 ****
>>>> }
>>>>
>>>> ! return $self->get_Annotations('source');
>>>> }
>>>>
>>>> --- 181,188 ----
>>>> }
>>>>
>>>> ! my $source_anno = $self->get_Annotations('source');
>>>> !
>>>> ! return $source_anno->value if ($source_anno);
>>>> ! return undef;
>>>> }
>>>>
>>>>
>>>> _______________________________________________
>>>> Bioperl-guts-l mailing list
>>>> Bioperl-guts-l at portal.open-bio.org
>>>> http://portal.open-bio.org/mailman/listinfo/bioperl-guts-l
>>>>
>>> _______________________________________________
>>> Bioperl-l mailing list
>>> Bioperl-l at portal.open-bio.org
>>> http://portal.open-bio.org/mailman/listinfo/bioperl-l
>>>
>>>
>>
> _______________________________________________
> Bioperl-l mailing list
> Bioperl-l at portal.open-bio.org
> http://portal.open-bio.org/mailman/listinfo/bioperl-l
>
>
--
-------------------------------------------------------------
Hilmar Lapp email: lapp at gnf.org
GNF, San Diego, Ca. 92121 phone: +1-858-812-1757
-------------------------------------------------------------
More information about the Bioperl-l
mailing list