LAB TASK: You have already become familiar with using random to generate a rando
ID: 672155 • Letter: L
Question
LAB TASK: You have already become familiar with using random to generate a random DNA sequence; you learned how to incorporate this into your own function that can be called repeatedly. For today’s lab task, you’ll use these concepts to generate a biased DNA sequence, and then compare it to a randomly generated DNA sequence. You will make use of random, write your own functions, and import preexisting functions, as well.
1.) Write your script in a file called ‘lab06_task.py’. Download a file called ‘lab06Functions.py’ from Blackboard, and make sure to save it in the same location as your lab task script.
2. Using random, create your own function that generates random DNA sequences. The length of the sequence should be variable. Hint: don’t forget to import random! This should be done right after #!/usr/bin/python.
3. Write a new function, called generate_biased_DNA, using random to generate a DNA sequence with twice as many As than C/T/G. The length of the sequence should be variable. Hint: There are many ways to do this. Ultimately your goal is to have a sequence that is approximately 50% As, and the other 50% is made equally of C/T/G. IMPORTANT: make sure your functions are defined before calling them. It is good practice to write functions at the start of your code, not in the middle.
4. Use a for loop to generate a random sequence of length 20, followed by a biased sequence of length 20. Make the for loop run for 10 turns. An example output may look like this: # : random 10-mer biased 10-mer 0 : CCGTTAACCCAATGTACACG GGCTTTAAACACAGTAGAAT 1 : GATTACCAGTACTGACTTGT GGAATGTACAGACAACTAGC 2 : CGCTGCCGGGTGGCGAGAAA TAGACGCATAAGAAACTAGA 3 : TCTTATCTCGTCTGCAATCG TCAAACCATAGAAAAAACGC 4 : AATCGAAACTCATAACGCAA AATGTGAATGTTTCAAGTAA 5 : AGAATGGCAACGCACGTCAA ATAACATAACCGACTCAGGT 6 : CACGACGGGCAGTTGTAAGT ACTGCGGTCTAAAGTGAAAA 7 : CAAAAGCCAGTAAGGGGCGC AGGCGACCACGTCGGTATGA 8 : TATCCCGGGTTGCGCTGGAA CATGGAAAAAGACACAAACA 9 : AACGACTGTGGTCATCTGTT AACTAAATTCATAAGGAATG
5. Now we will make use of the functions written in lab06Functions.py. Make sure to import this (right after importing random). Within the for loop that you wrote in #4, use the function freq_A() in lab06Functions.py to count the frequency of adenines (As) in the random and biased DNA sequences. During each iteration, save the output of freq_A() for each DNA type. Hint: Declare lists outside the for loop, then use .append() to add the numbers to the respective lists; make sure to have one list for random DNAs, and one list for biased DNAs.
6. Finally, use the function avg_std() in lab06Functions.py to compute the average and standard deviation for each of your lists. The average frequency of adenines in the biased DNA set should be higher than in the random DNA set. Is this what you observe? Do you ever observe the numbers being similar enough that the biased DNA set looks random?
7. Run your script and show us the output!
PLEASE PLEASE HELP ME WITH THIS I'VE TRIED AND I DONT EVEN KNOW HOW.
Lab06Functions.py contains this so you can manually save it and continue as usual:
Explanation / Answer
Program:
Sample output:
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.