import re
seq = "ATATAAGATGCGCGCGCTTATGCGCGCA"
rgx = re.compile("TAT")
i = 1
for mo in rgx.finditer(seq):
    print('Ocurrence %s: %s'%(i,mo.group()))
    print('Position: From %s to %s'%(mo.start(),mo.end()))
    i += 1    

This code is part of the book "Python for Bioinformatics", by Sebastian Bassi (sbassi@genesdigitales.com). Return to home page.