Answer to Question #290523 in Python for Ashok

Question #290523

Generate a DNA string of "ATGCN" of length at most 2048 bases (characters) using



your own random function and store it into a text file.

1
Expert's answer
2022-01-25T10:47:16-0500
def generateDNASequence():
    file = open('DNAFILE.txt', 'w')
    # list of available DNA bases
    l = ['C', 'A', 'G', 'T']
    res = ""
    for i in range(0, 2048):
        # creating the DNA strand by appending 
        # random characters from the list
        res = res + random.choice(l)
        file.write(res)

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS