[BioPython] Adding startswith and endswith methods to the Seq object
Bartek Wilczynski
bartek at rezolwenta.eu.org
Thu Apr 16 09:56:59 UTC 2009
hi,
On Thu, Apr 16, 2009 at 11:10 AM, Peter <biopython at maubp.freeserve.co.uk> wrote:
> Having these Seq object methods all cope with a Motif object is an
> interesting idea - I hadn't thought of that. We can have string or
> Seq arguments act as dumb python strings (no ambiguity magic), but
> giving a Motif object allows the ambiguity matches to be handled
> explicitly.
That's exactly what I meant.
>
> I would like to clarify that I was thinking more the other way round:
> the Motif object has a search method where you give it a Seq (or
> string?) to be searched. Much like Python's regular expression
> objects take the target string as an argument. One advantage of doing
> it this way round is the Seq object is kept quite simple (which I
> think is a good thing), and all the ambiguity complexity lives in
> Bio.Motif instead.
>
Yes, so the idea would be for the startswith, endswith etc methods to
only check
whether the argument is a motif and if so, call the proper methods of
the argument.
I need to look into it more closely (especially for the other methods
like find) but there
are search methods as well as methods for finding instances for the
whole sequence
as well as for a given position.
>> Currently there are no methods from_IUPAC or from_re, but it should be
>> fairly straightforward to implement them (if there is interest).
>
> I think there is interest - although you might want to have
> from_IUPAC_protein, from_IUPAC_DNA, from_IUPAC_RNA. Just using
> m=Motif.from_IUPAC("TAN") it isn't clear if that is protein or DNA.
> If Motif.from_IUPAC only took a Seq object with a relevant alphabet
> that would solve this ambiguity, but would not be so easy to use.
Good. I'll try to implement this.
>
>> writing the startswith method using a motif instance is very straightforward.
>
> If you say so :)
>
Once you have the motif instance, it's really easy. The problem is
with making Motif creation easy enough.
> Let's have a look at this (after Biopython 1.50 is out).
I agree
cheers
Bartek
More information about the Biopython
mailing list