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]
     
    else:
    return "It's not an ORF."
     
     
    print findORF("ATACCCCGCGCGCGCATAAGCGCGAGACGCGCGCGCGCGGAGG")
     
    print findORF("ATASDFGHJKLMAAGA")
     
    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?

happygeek commented: well, try reading the rules next time, huh... -3

Recommended Answers

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

Jump to Post

All 4 Replies

nevermind, fixed it.

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

and how do i do that?

There should be a "Mark as Solved" link below the last post.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of 1.20 million developers, IT pros, digital marketers, and technology enthusiasts learning and sharing knowledge.