Run update21b to get the starting point files for this week's lab, which will appear in cs21b/labs/02/. The program handin21b will only submit files from this directory.
This week's problems will focus on using numbers and strings as
accumulators. You should start working on each problem by
writing a pseudocode algorithm on paper. Each program should use the
accumulator pattern at least one time. Once you feel you understand
the steps necessary to solve the problem, you can begin implementing
it in python.
In this problem you will simulate the growth of a biological population. Edit the file popGrowth.py in this week's lab directory to create your solution. Your program should produce the following sort of interaction with the user:
This program models the growth of a population. Enter the initial size of the population> 100 Enter the net growth rate per year (0.1 for 10 percent)> .05 Enter the number of years> 15 Year Size 0 100 1 105 2 110 3 115 4 121 5 127 6 134 7 140 8 147 9 155 10 162 11 171 12 179 13 188 14 197 15 207
Notice that when the net growth rate (taking both births and deaths into account) is 5 percent the population doubles within 15 years.
Gene expression involves the processes of transcription and translation. This is the central dogma of gene expression at the molecular level.
First DNA transcribes into RNA. DNA is made up of the bases A, G, C, and T. RNA is similar, but contains the base U instead of T. There is a one to one correspondence between DNA and RNA bases.
Next, the messenger form of RNA (mRNA) is translated into a sequence of amino acids. There is a three to one correspondence between mRNA bases and amino acids. In other words, each set of three mRNA bases codes for one amino acid. There are 64 possible triplets of mRNA bases and only 20 different amino acids, so the code is redundant. Using a RNA codon table you can translate mRNA triplets into the appropriate amino acid. Try the following in python:
>>> from genetics import * >>> translate('UUU') 'F' >>> translate('UUA') 'L'and check that the results match the data given in the RNA codon table. If you'd rather translate each triplet into the longer abbreviations of the amino acid names you can do:
>>> translateName('UUU') 'Phe' >>> translateName('UUA') 'Leu'
For this lab we will be focusing on the translation process. You will be writing a program that first generates a random string of mRNA. You should use the choice function from the random library to help you create this mRNA string. Next you will translate the mRNA string into the appropriate amino acid sequence using the translate function from the genetics library.
When importing libraries into a program always put the import statements at the top of the file, prior to the definition of the main.
Edit the file translatemRNA.py in this week's lab directory to create your solution. Your program should produce the following sort of interaction with the user:
This program generates a random string of mRNA and then translates it into the amino acid sequence it codes for. Length of mRNA to generate (should be multiple of 3): 21 Random mRNA: AGAGAUCUAAAAGCGUGACAG Translated amino acid sequence: RDLKA$QIf you prefer, your code can output the longer abbreviations for the amino acids shown below. Notice that there are special stop codons. In the above version they will appears as a dollar sign and in the below version they will appear as STOP.
This program generates a random string of mRNA and then translates it into the amino acid sequence it codes for. Length of mRNA to generate (should be multiple of 3): 60 Random mRNA: CUGCUAAGUAGGAGUUCUUACGUGUAGACUGACAUCAACUGCGACACUUCGCCAGGUCCC Translated amino acid sequence: LeuLeuSerArgSerSerTyrValSTOPThrAspIleAsnCysAspThrSerProGlyPro
Once you are satisfied with your programs, hand them in by typing handin21b at the unix prompt. Recall that you may run handin21b as many times as you like, and only the most recent submission will be recorded.