[BioPython] help for searching overlapping occurrences

Jeffrey Chang jchang at jeffchang.com
Wed Oct 22 13:47:07 EDT 2003


On Wednesday, October 22, 2003, at 11:58  AM, Andrew Dalke wrote:
> Jeff:
>> Would the following (untested) code do what Alessandro wants?
>>
>> def finditer_overlapped(pattern, string):
>>   for i in range(len(string)):
>>     m = re.match(pattern, string[i:])
>>     if m:
>>       yield m
>
> Consider the pattern
>
>   a(bc|bcd)
>
> when searched against
>
>   abcd

Yes, that would indeed fail.

Alessandro, can you tell us more about your problem?  I suspect you may 
be searching for occurrences of a motif, such as GA.CC, within a DNA 
sequence.  If so, you may not need exactly what you said you needed...

Jeff



More information about the BioPython mailing list