I'm looking for the possible algorithm for script which will search my long DNA sequence defined in str object for the specified motifs (Shorter DNA fragments), count each findings (assuming that my seq has several identical motifs), and print first nucleotide number in sequence where motif have been detected.
assuming that defined below each object I should use such searching in some loop because both below examples could find motifs only 1 time. What are the proper way to specify such looping ?
#Loading data
seq = open('motif.txt', 'r')
chains=[]
[chains.append(line[:-1]) for line in seq]
Seq,Motif = chains[0], chains[1]
count=0
# Search motif
Seq.find(Motif)
if y == 1:
print "%s has been detected" %(Motif)
if Motif in Seq:
print "%s has been detected" %(Motif)