[Biopython-dev] [Bug 2351] Make Seq more like a string, even subclass string?

bugzilla-daemon at portal.open-bio.org bugzilla-daemon at portal.open-bio.org
Mon Sep 29 12:02:55 UTC 2008


http://bugzilla.open-bio.org/show_bug.cgi?id=2351





------- Comment #16 from biopython-bugzilla at maubp.freeserve.co.uk  2008-09-29 08:02 EST -------
(In reply to comment #15)
> This is a suggested implementation of the split method for our Seq object,
> modelled after the python string method which it calls internall.  Note that I
> have made the separator non-optional on the grounds that the string method's
> default of white space isn't (usually) sensible for sequences.  I'm happy to
> change this if people this its better to be as close as possible to the string
> method.
> 
>     def split(self, sep, maxsplit=None) :
>         """Split method, like that of a python string.
> 
>         Return a list of the 'words' in the string (as Seq objects),
>         using sep as the delimiter string.  If maxsplit is given, at
>         most maxsplit splits are done.
> 
>         Unlike the python string method, sep must be specified (as
>         there shouldn't be any whitespace strings in a sequence).
> 
>         e.g. print my_seq.split("-")
>         """
>         if maxsplit :
>             parts = self.data.split(sep, maxsplit)
>         else :
>             parts = self.data.split(sep)
>         return [Seq(chunk, self.alphabet) for chunk in parts]
> 

After some debate on the mailing list, following the python string method
defaults is probably preferable for consistency (even if we don't expect any
white space in a Seq object's sequence).

I have extended Bug 2596 to cover the split method in addition to the strip
methods, and uploaded a revised patch there.


-- 
Configure bugmail: http://bugzilla.open-bio.org/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug, or are watching the assignee.



More information about the Biopython-dev mailing list