import random, math # Generate a random sequence of 1000 DNA nucleotides. # Each character in the generated sequence has # a 25% chance of being 'A', a 25% chance of being 'C', # a 25% chance of being 'G', and a 25% chance of being 'T'. def generateRandomSequence(): # Enter your code here return "" # The "mutate" function takes a genomic sequence as a parameter # and returns a new genomic sequence, the same as the input sequence, # except a single randomly chosen nucleotide from the sequence is changed. # The function should procede as follows: # Randomly choose an index between 0 and len(seq)-1, # and mutate the nucleotide in seq at this randomly chosen index. # If the nucletide at the randomly chosen index is 'A' then # randomly choose to mutate the nucleotide to 'C' or 'G' or 'T'. # If the nucletide at the randomly chosen index is 'C' then # randomly choose to mutate the nucleotide to 'A' or 'G' or 'T'. # If the nucletide at the randomly chosen index is 'G' then # randomly choose to mutate the nucleotide to 'A' or 'C' or 'T'. # If the nucletide at the randomly chosen index is 'T' then # randomly choose to mutate the nucleotide to 'A' or 'C' or 'G'. # The helper function "random.randint(a,b)" may be helpful in # choosing a random index between 0 and len(seq)-1 to mutate. # The helper function "random.choice(seq)" may be helpful in # choosing a random nucleotide to mutate the selected nucleotide to. def mutate(seq): # Enter your code here return "" # Takes two sequences, s1 and s2, of the same length and # counts the number of nucleotides that differ between the two sequences. # For instance, if s1="ACCGTGCTA" and s2="GCCGAGCCA" then the function # should return the number 3 since s1 and s2 contain different # nucleotides at indices 0, 4, and 7. def distanceBetweenSequences(s1, s2): # Enter your code here return 0 # Given the observed distance, p, between two sequences, this function # applies the Jukes-Cantor correction in order to estimate the actual # distance between the two sequences. The acutal distance, K, can be # estimated using the Jukes-Cantor correction as: # K = -3.0/4.0 * (1000.0) * ln(1.0-(4.0/3.0)*p/1000.0) # where "ln" refers to the natural logarithm. # In the formula above, the value 1000.0 is used since the sequence # is 1000 nucleotides in length. # In Python, the natural logarithm of a number x can be calculated # as "math.log(x)" def JukesCantorCorrection(p): # Enter your code here return 0.0 # Takes a genomic sequence, seq, and mutates randomly chosen # nucleotides in the sequence 1000 times. After each of the # 1000 mutations, the function prints out two numbers: # (1) p = the distance between the mutated sequence and the # original sequence. # (2) K = the Jukes-Cantor correction to p, i.e., the estimated # number of actual mutations that occurred between the two sequences. # For example, the first 10 (of 1000) lines printed out might look as follows: # 1 1.00066725985 # 2 2.00267141691 # 3 3.00601604815 # 4 4.01070474495 # 5 5.0167411131 # 6 6.02412877295 # 7 7.03287135945 # 7 7.03287135945 # 8 8.04297252223 # 9 9.0544359257 def mutagenesis(seq): # Enter your code here print 0, "\t", 0.0 ######################################################## ### End of functions ################################### ######################################################## s = generateRandomSequence() mutagenesis(s)