Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Given a sequence of the DNA bases {A, C, G, T}, stored as a string, returns a conditional probability table in a data structure such

Given a sequence of the DNA bases {A, C, G, T}, stored as a string, returns a conditional probability table in a data structure such that one base (b1) can be looked up, and then a second (b2), to get the probability p(b2 | b1) of the second base occurring immediately after the first. (Assumes the length of seq is >= 3, and that the probability of any b1 and b2 which have never been seen together is 0. Ignores the probability that b1 will be followed by the end of the string character.)

Here is an example:

GAAAGG 

P(A | G) = probability of A given the letter G occured directly before it = 1/2 = 0.5. The denominator is 2 instead of 3 because the last G does not have a letter after it. The denominator should be the number of times a letter appears with annother letter directly after it.

P( G | G ) = probability of G given the letter G occured directly before it = 1/2 = 0.5

P(G | A) = probability of G given the letter A occured directly before it = 1/3 = 0.33

P(A | A) = probability of A given the letter A occured directly before it = 2/3 = .66

The dictionary returned by dna_prob2 should be:

{'A': {'A': 2/3, 'G': 1/3, 'T': 0, 'C': 0}, 'G': {'A': 1/2, 'G': 1/2, 'T': 0, 'C': 0}, 'T': {'A': 0, 'T': 0, 'G': 0, 'C': 0}, 'C': {'A': 0, 'G': 0, 'T': 0, 'C': 0}} 

Notice this is a "nested" dictionary, where the value of the outer dictionary is also a dictionary. All of the keys are strings.

Note: 2 extra points adds 20% to your final homework grade. This can improve your grade substantially. So, I recommend working on this, if you are worried about the quizzes and Midterm.

[ ]:

def dna_prob2(seq): # Write code here return ... # The code should return a dictionary 

The lines below give example inputs and correct outputs using asserts, and can be run to test the code. Passing these tests isNOTsufficient to guarantee your implementation is correct. You may add additional test cases, but do not remove any tests.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access with AI-Powered Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Financial and Managerial Accounting the basis for business decisions

Authors: Jan Williams, Susan Haka, Mark Bettner, Joseph Carcello

18th edition

125969240X, 978-1259692406

Students also viewed these Mathematics questions

Question

Why is desire important for success? (p. 271)

Answered: 1 week ago

Question

What is the effect of word war second?

Answered: 1 week ago