Hello! I didn't read the rules or anything, so I don't know if I'm posting in the right place, but I need help with a program as soon as possible.
I have to answer this question: Find the first ORF in a sequence from a position (findORF(DNA, position)). It must return the first ORF found.

PS: ORF(Open Reading Frame) is a sequence of DNA that is multiple of 3.
PS2: The ORF begins with "ATA" and can either end with "AGA" or "AGG".

The program is:

def find(word, letter, position):
    while position < len(word):
    position2 = position + len(letter)
    if word[position:position2] == letter: 
    return position 
    position = position + 1
    return -1
    def findORF(DNA):
    beginning = find(DNA,"ATA", 0) 
    stop1 = find(DNA,"AGA", beginning + 3)
    stop2 = find(DNA,"AGG", beginning + 3) 
    if len(DNA[beginning:stop1])%3 == 0: 
    return DNA[beginning:stop1 + 3]
    if len(DNA[beginning:stop1])%3 != 0:
    if len(DNA[beginning:stop2])%3 == 0:
    return DNA[beginning:stop2 + 3]
    return "It's not an ORF."
    print findORF("AFFATAAAGAAAAGG")
    print findORF("KKKKKSD")

I'm having a problem with print findORF("ATASDFGHJKLMAAGA") and print findORF("KKKKKSD"). They should return "It's not an ORF.", but it's not working. Can someone help me, please?

Edited by sindel: I didn't use [code]. Sorry, I didn't know I could edit or that I couldn't delete my posts.

Votes + Comments
well, try reading the rules next time, huh...
5 Years
Discussion Span
Last Post by woooee

Please make the post "Solved" so you aren't rude to those who would otherwise read this unnecessarily.

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.