[Biopython-dev] Subclassing Seq objects from a string

Michiel de Hoon mjldehoon at yahoo.com
Wed Jun 28 10:20:21 UTC 2017


We could move faster by doing the subclassing first. There is a price for being too rigorous: Improvements are taking too long to happen. Ten years in this case.

Best,-Michiel
 

    On Monday, June 26, 2017 6:21 PM, Peter Cock <p.j.a.cock at googlemail.com> wrote:
 

 Hello all,

Looking at the mailing list archive, the plain text version didn't capture
Michael's link to the thread ten years ago:

http://lists.open-bio.org/pipermail/biopython/2007-August/009867.html

We're still at step two of that outlined plan:

Peter wrote in August 2007:
> (1) Modify Seq .__str__() method to ... return self.data
>

Done, along with changes to __eq__ to match etc.

> (2) Consider adding alphabet aware versions selected string methods to
> the Seq object (e.g. count, find)

While we have count, find, upper, lower, etc we still don't have all the
string methods defined for the Seq object (e.g. replace is missing -
what else?)

> Then, for the release afterwards:
> (3) actually do the class inheritance with all the horrors entailed.

And this is of course pending - as per this thread title.

--

Note that in addition to supporting all the base string methods, we
still want the Seq object to also support extra biological methods
and perhaps additional optional arguments, e.g. overlapping counts:

https://github.com/biopython/biopython/issues/1294

Other than the translate method (mentioned below), I don't think we
have any name or argument clashes to worry about.

Regards,

Peter


On Wed, May 24, 2017 at 10:28 AM, Peter Cock <p.j.a.cock at googlemail.com> wrote:
>
> Hi Michiel,
>
> I think we'd need to work on making the API more string like before it would be practical to considering subclassing.
>
> Would anyone like to make a list of all the string methods which we do not currently implement, starting with replace (where dealing with the alphabet is tricky if new letters are introduced)?
>
> Then there is the translate method where we deliberately did not follow the Python string method behaviour, but it would be possible to match it as a special case where currently we issue an exception:
>
> https://github.com/biopython/biopython/blob/biopython-169/Bio/Seq.py#L985
>
> Peter
>
>
>
>
> On Tue, May 23, 2017 at 2:32 AM, Michiel de Hoon <mjldehoon at yahoo.com> wrote:
>>
>> Dear all,
>>
>> Ten years ago we talked about subclassing Seq objects from a string:
>>
>> [BioPython] Making the Seq object act more like a string
>> http://lists.open-bio.org/pipermail/biopython/2007-August/009867.html
>>
>> Can we move forward?
>> As the Seq documentation says, a Seq object is essentially a string with an alphabet.
>> Then, following the object oriented programming paradigm, Seq objects should inherit from a string object.
>>
>> This would help with C extensions that take Seq or string objects as arguments (as both can then be treated as strings).
>>
>> Best,
>> -Michiel
>>
>> _______________________________________________
>> Biopython-dev mailing list
>> Biopython-dev at mailman.open-bio.org
>> http://mailman.open-bio.org/mailman/listinfo/biopython-dev
>
>


   
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.open-bio.org/pipermail/biopython-dev/attachments/20170628/d8922699/attachment.html>


More information about the Biopython-dev mailing list