Re: Subclassing Seq objects from a string
Peter Cock <[email protected]> Fri, 30 Jun 2017 15:04:27 +0100
| Newsgroups | gmane.comp.python.bio.devel |
|---|---|
| Message-ID | <CAKVJ-_4fKXETW8wmgROqevGadeAwLVVjcCSR7FAAB9Dj1pEHzw@mail.gmail.com> |
--===============0678027149320131632== Content-Type: multipart/alternative; boundary="94eb2c05ef5a3f5e2005532de5c8" --94eb2c05ef5a3f5e2005532de5c8 Content-Type: text/plain; charset="UTF-8" True doing the subclassing would immediately define the missing methods by default, but then risk a behavior change later as we make them sequence aware. Please try this on a branch or pull request? Peter On Wed, Jun 28, 2017 at 11:20 AM, Michiel de Hoon <[email protected]> wrote: > 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 <[email protected]> > 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 <[email protected]> > 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 <[email protected]> > 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 > >> [email protected] > >> http://mailman.open-bio.org/mailman/listinfo/biopython-dev > > > > > > > --94eb2c05ef5a3f5e2005532de5c8 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable <div dir=3D"ltr"><div>True doing the subclassing would immediately define t= he missing methods by default, but then risk a behavior change later as we = make them sequence aware. Please try this on a branch or pull request?<br><= /div><div><br></div><div>Peter</div><div><br></div></div><div class=3D"gmai= l_extra"><br><div class=3D"gmail_quote">On Wed, Jun 28, 2017 at 11:20 AM, M= ichiel de Hoon <span dir=3D"ltr"><<a href=3D"mailto:[email protected]"= target=3D"_blank">[email protected]</a>></span> wrote:<br><blockquote= class=3D"gmail_quote" style=3D"margin:0 0 0 .8ex;border-left:1px #ccc soli= d;padding-left:1ex"><div><div style=3D"color:#000;background-color:#fff;fon= t-family:Helvetica Neue,Helvetica,Arial,Lucida Grande,sans-serif;font-size:= 10px"><div id=3D"m_9038631847494789106yui_3_16_0_1_1498644225839_25815">We = could move faster by doing the subclassing first. There is a price for bein= g too rigorous: Improvements are taking too long to happen. Ten years in th= is case.<br></div><div id=3D"m_9038631847494789106yui_3_16_0_1_149864422583= 9_25816"><br></div><div id=3D"m_9038631847494789106yui_3_16_0_1_14986442258= 39_25898">Best,</div><div id=3D"m_9038631847494789106yui_3_16_0_1_149864422= 5839_25899">-Michiel<br></div><div><div class=3D"h5"><div id=3D"m_903863184= 7494789106yui_3_16_0_1_1498644225839_25687"><span></span></div> <div class= =3D"m_9038631847494789106qtdSeparateBR"><br><br></div><div class=3D"m_90386= 31847494789106yahoo_quoted" style=3D"display:block"> <div style=3D"font-fam= ily:Helvetica Neue,Helvetica,Arial,Lucida Grande,sans-serif;font-size:10px"= > <div style=3D"font-family:HelveticaNeue,Helvetica Neue,Helvetica,Arial,Lu= cida Grande,sans-serif;font-size:16px"> <div dir=3D"ltr"><font size=3D"2" f= ace=3D"Arial"> On Monday, June 26, 2017 6:21 PM, Peter Cock <<a href=3D"= mailto:[email protected]" target=3D"_blank">[email protected]= om</a>> wrote:<br></font></div> <br><br> <div class=3D"m_90386318474947= 89106y_msg_container"><div dir=3D"ltr">Hello all,<br clear=3D"none"><br cle= ar=3D"none">Looking at the mailing list archive, the plain text version did= n't capture<br clear=3D"none">Michael's link to the thread ten year= s ago:<br clear=3D"none"><br clear=3D"none"><a shape=3D"rect" href=3D"http:= //lists.open-bio.org/pipermail/biopython/2007-August/009867.html" target=3D= "_blank">http://lists.open-bio.org/<wbr>pipermail/biopython/2007-<wbr>Augus= t/009867.html</a><br clear=3D"none"><br clear=3D"none">We're still at s= tep two of that outlined plan:<br clear=3D"none"><br clear=3D"none">Peter w= rote in August 2007:<br clear=3D"none">> (1) Modify Seq .__str__() metho= d to ... return self.data<br clear=3D"none">><br clear=3D"none"><br clea= r=3D"none">Done, along with changes to __eq__ to match etc.<br clear=3D"non= e"><br clear=3D"none">> (2) Consider adding alphabet aware versions sele= cted string methods to<br clear=3D"none">> the Seq object (e.g. count, f= ind)<br clear=3D"none"><br clear=3D"none">While we have count, find, upper,= lower, etc we still don't have all the<br clear=3D"none">string method= s defined for the Seq object (e.g. replace is missing -<br clear=3D"none">w= hat else?)<br clear=3D"none"><br clear=3D"none">> Then, for the release = afterwards:<br clear=3D"none">> (3) actually do the class inheritance wi= th all the horrors entailed.<br clear=3D"none"><br clear=3D"none">And this = is of course pending - as per this thread title.<br clear=3D"none"><br clea= r=3D"none">--<br clear=3D"none"><br clear=3D"none">Note that in addition to= supporting all the base string methods, we<br clear=3D"none">still want th= e Seq object to also support extra biological methods<br clear=3D"none">and= perhaps additional optional arguments, e.g. overlapping counts:<br clear= =3D"none"><br clear=3D"none"><a shape=3D"rect" href=3D"https://github.com/b= iopython/biopython/issues/1294" target=3D"_blank">https://github.com/biopyt= hon/<wbr>biopython/issues/1294</a><br clear=3D"none"><br clear=3D"none">Oth= er than the translate method (mentioned below), I don't think we<br cle= ar=3D"none">have any name or argument clashes to worry about.<br clear=3D"n= one"><br clear=3D"none">Regards,<br clear=3D"none"><br clear=3D"none">Peter= <br clear=3D"none"><br clear=3D"none"><br clear=3D"none">On Wed, May 24, 20= 17 at 10:28 AM, Peter Cock <<a shape=3D"rect" href=3D"mailto:p.j.a.cock@= googlemail.com" target=3D"_blank">[email protected]</a>> wrote:<= br clear=3D"none">><br clear=3D"none">> Hi Michiel,<br clear=3D"none"= >><br clear=3D"none">> I think we'd need to work on making the AP= I more string like before it would be practical to considering subclassing.= <br clear=3D"none">><br clear=3D"none">> Would anyone like to make a = list of all the string methods which we do not currently implement, startin= g with replace (where dealing with the alphabet is tricky if new letters ar= e introduced)?<br clear=3D"none">><br clear=3D"none">> 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 w= here currently we issue an exception:<br clear=3D"none">><br clear=3D"no= ne">> <a shape=3D"rect" href=3D"https://github.com/biopython/biopython/b= lob/biopython-169/Bio/Seq.py#L985" target=3D"_blank">https://github.com/bio= python/<wbr>biopython/blob/biopython-169/<wbr>Bio/Seq.py#L985</a><br clear= =3D"none">><br clear=3D"none">> Peter<br clear=3D"none">><br clear= =3D"none">><br clear=3D"none">><br clear=3D"none">><br clear=3D"no= ne">> On Tue, May 23, 2017 at 2:32 AM, Michiel de Hoon <<a shape=3D"r= ect" href=3D"mailto:[email protected]" target=3D"_blank">mjldehoon@yahoo.= com</a>> wrote:<br clear=3D"none">>><br clear=3D"none">>> De= ar all,<br clear=3D"none">>><br clear=3D"none">>> Ten years ago= we talked about subclassing Seq objects from a string:<br clear=3D"none">&= gt;><br clear=3D"none">>> [BioPython] Making the Seq object act mo= re like a string<br clear=3D"none">>> <a shape=3D"rect" href=3D"http:= //lists.open-bio.org/pipermail/biopython/2007-August/009867.html" target=3D= "_blank">http://lists.open-bio.org/<wbr>pipermail/biopython/2007-<wbr>Augus= t/009867.html</a><div class=3D"m_9038631847494789106yqt6638886566" id=3D"m_= 9038631847494789106yqtfd28806"><br clear=3D"none">>><br clear=3D"none= ">>> Can we move forward?<br clear=3D"none">>> As the Seq docum= entation says, a Seq object is essentially a string with an alphabet.<br cl= ear=3D"none">>> Then, following the object oriented programming parad= igm, Seq objects should inherit from a string object.<br clear=3D"none">>= ;><br clear=3D"none">>> This would help with C extensions that tak= e Seq or string objects as arguments (as both can then be treated as string= s).<br clear=3D"none">>><br clear=3D"none">>> Best,<br clear=3D= "none">>> -Michiel<br clear=3D"none">>><br clear=3D"none">>&= gt; ______________________________<wbr>_________________<br clear=3D"none">= >> Biopython-dev mailing list<br clear=3D"none">>> <a shape=3D"= rect" href=3D"mailto:[email protected]" target=3D"_blank">= [email protected]<wbr>bio.org</a><br clear=3D"none">>> <a s= hape=3D"rect" href=3D"http://mailman.open-bio.org/mailman/listinfo/biopytho= n-dev" target=3D"_blank">http://mailman.open-bio.org/<wbr>mailman/listinfo/= biopython-dev</a><br clear=3D"none">><br clear=3D"none">><br clear=3D= "none"></div></div><br><br></div> </div> </div> </div></div></div></div><= /div></blockquote></div><br></div> --94eb2c05ef5a3f5e2005532de5c8-- --===============0678027149320131632== Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ Biopython-dev mailing list [email protected] http://mailman.open-bio.org/mailman/listinfo/biopython-dev --===============0678027149320131632==--