# Recipe 78: Finding a subsequence in parasite nucleotide sequence

def findSequence(seq):

  sequencesFile = getMediaPath("parasites.txt")
  file = open(sequencesFile,"rt")
  sequences = file.read()
  file.close()

  # Find the sequence
  seqloc = sequences.find(seq)

  #print "Found at:",seqloc
  if seqloc <> -1:
    # Now, find the ">" with the name of the sequence
    nameloc = sequences.rfind(">",0,seqloc)
    #print "Name at:",nameloc
    endline = sequences.find("\n",nameloc)
    print "Found in ",sequences[nameloc:endline]

  if seqloc == -1:
    print "Not found"

