sequence = 'atgaggagccccaagcttactcgatttaacgcccgcagcctcgccaaaccaccaaacacacca' print [[m.start(),m.end()] for m in re.finditer(r'(gatttaacg)',sequence)]
remove lookahead
. It does not capture only statements.
Conclusion: [[22, 31]]
if you need to use lookahead
use
sequence = 'atgaggagccccaagcttactcgatttaacgcccgcagcctcgccaaaccaccaaacacacca' print [[m.start(),m.start()+len("aca")] for m in re.finditer(r'(?=aca)',sequence)]
source share