r/pythonhelp • • Mar 22 '21

So guys, I wrote a script that should print out all CDS sequences from my file but the problem is that I'm only getting the first CDS sequence printed out multiple times and nothing more.. what can be the problem? 🤔

Post image
4 Upvotes

1 comment sorted by

1

u/MT1961 Mar 22 '21

Find takes a substring, not a list of boolean conditions. You are searching for TAA or TGA or TAG which results in looking for "true".
Write your own function to search for the sequence:

def find_sequence(string):
ret = string.find("TAA"):
if ret == -1:
ret = string.find("TGA"):

if ret == -1:
ret = string.find("TAG"):

return ret

Then it will either return the starting position of the first sequence it finds, or -1.