0

So i m creating a program that will find a motiff and the position of the motiff in a sequence inside a fasta file. A motiff is like a specific string introduced by the user. So for example in this sequence ACCTGCTTCCGTTCGAGTTCAGTT and the motiff is GTT it needs to report that there is two occurrences and their positions.

I tried using the following code since my species name and sequence are stored inside a dictionary

def MotiffFinder(Dicionario, Motiff):
  for key, value in Dicionario.items():
    for Motiff in value:
       print(value.index(Motiff))

i also tried find() but it doesnt seem to work since it reports positions where the motiff is not in. Help

  • Or https://stackoverflow.com/questions/8899905/count-number-of-occurrences-of-a-substring-in-a-string – Stuart May 24 '23 at 23:55
  • `for Motiff in value:` will run the loop once for each CHARACTER in the value. What you need a loop with `value.find`. Remember that you can specify to `find` where to start looking. So, look for the next sequence starting just after the previous one. – Tim Roberts May 25 '23 at 00:09

0 Answers0