Question: 179 PYTHON PROGRAM WRITE A PYTHON PROGRAM POST A SCREENSHOT OF RESULT Write a function mutate(dna) that returns a copy of the string dna with
179
PYTHON PROGRAM
WRITE A PYTHON PROGRAM
POST A SCREENSHOT OF RESULT
Write a function mutate(dna) that returns a copy of the string dna with one of its nucleotide bases (randomly chosen) randomly mutated to a different base.
Use the mutate() function from the previous program to simulate many repeated mutations on a long string of DNA that begins with only one base (such as all Gs). How long does it take before the result seems to be like a random string of DNA?
DNA Sequences
1 # dna.py
2
3 from random import choice
4
5 def complement(dna):
6 result = ""
7 for c in dna:
8 if c == "A":
9 result += "T"
10 elif c == "T":
11 result += "A"
12 elif c == "C":
13 result += "G"
14 elif c == "G":
15 result += "C"
16 return result
17
18 def reversecomp(dna):
19 return complement(dna)[::1]
20
21 def random_dna(length=30):
22 fragment = ""
23 for j in range(length):
24 fragment += choice("ACGT")
25 return fragment
26
27 def main():
28 for i in range(10):
29 dna = random_dna()
30 print(dna + " " + reversecomp(dna))
31 print(complement(dna) + " ")
32
33 main()
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
