[BioPython] help for searching overlapping occurrences
Jeffrey Chang
jchang at jeffchang.com
Wed Oct 22 11:23:34 EDT 2003
On Wednesday, October 22, 2003, at 10:51 AM, Andrew Dalke wrote:
> Alessandro:
>> I' am looking for a method like finditer from module re but
>> returning all the occurrences of a pattern in a straing even
>> if overlapping to each other.
>
> There is no such function.
>
> Such a search may be highly exponential as every ambiguous
> branch must be taken.
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
Jeff
More information about the BioPython
mailing list