Question: 178 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

178

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.

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

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!