Question
Use python!

Average length to an ATG Please put all of your code for this problem in a file called lengthTOATG.py Lets assume that we have a long DNA sequence in which each symbol is random and equally likely to be an A, C, T, or G. Wed like to determine the average number of symbols until we see the first occurrence of a start codon ATG Once youve written a function to compute this, youll do the same thing to find the average number of symbols until we see the first occurrence of the codon AAA Surprisingly, the average for ATG and the average for AAA are not the same! Well break this task up into a few parts lengthToATG() First, write a function called lengthTOATG( ) that takes no input, generates a random letter from·A, T, C, or G, and then if the last three letters generated are ATG, it returns the total number of symbols that were generated. Otherwise, it repeats the process by generating a next random letter Recall that in order to generate things at random, you simply include the line... import randon T, 叱· 6) to generate a random symbol from the list t , , , . at the top of your file. Then, you can use random. choice(A, Clearly, youll need to have a loop to keep generating symbols untl we see the pattern ATG. Since we dont know in advance how many symbols wll need to be generated before we see this pattern, a while loop is the right choice
media%2F0eb%2F0ebad565-6cf0-4ccf-a43e-8f
0 0
Add a comment Improve this question Transcribed image text
Answer #1
import random


def lengthToATG():
    count = 0
    seq = ''
    string = 'ACTG'
    while True:
        count += 1
        seq += string[random.randint(0, len(string)-1)]
        if seq.endswith('ATG'):
            break
    return count


def meanToATG(trials):
    total = 0
    for i in range(trials):
        total += lengthToATG()
    return total/trials


print(meanToATG(100))

1.6 Process finished with e xit code 0

Add a comment
Know the answer?
Add Answer to:
Use python! Average length to an ATG Please put all of your code for this problem...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT