How can I get the position of a matched characters(small string) inside a string(fasta) in python?
I am using a fasta file as String to search for a motif using regular expression '[AGCT][TG][TC][GT]TG'
along with the motif, I also wish to know and save the position of motif occurred in the string.
rdict = dict([ (x[1],x[0]) for x in enumerate(Seq) ])
motif = '[AGCT][TG][TC][GT]TG'
#for match in Seq:
matches = re.findall(motif, Seq.upper())
print(matches)
Seq.index(matches)
The above code does the work to search for the motif but returns only position of one character. How can I change this to give the start to end position of the motif(small string).