{ "metadata": { "name": "", "signature": "sha256:616eaf0e05144c103f7b3fd2eba4af463deb4388007d7290d8827ceea563edca" }, "nbformat": 3, "nbformat_minor": 0, "worksheets": [ { "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "## [Python Programming for Biologists, Tel-Aviv University / 0411-3122 / Spring 2015](http://py4life.github.io/TAU2015/)\n", "# Homework 2\n", "## 1) Bacteria growth\n", "The bacteria _P. pythonicus_ replicates every one hour, in a 100 ml tube. Being a very unfriendly bacteria, they reach stationary phase when there are 1,000,000 or more bacteria in the tube. \n", " \n", "**a)** Write a program that will calculate the number of bacteria after one hour, two hours, etc, until stationarity is reached. The program will receive the starter size (number of bacteria to begin with), and start calculating from there. At each time point, the following message should be printed: \n", "< time > hours: < no. of bacteria > bacteria" ] }, { "cell_type": "code", "collapsed": false, "input": [ "starter = 100 # Replace with a value of your choice.\n", "bacteria = starter\n", "time = 0\n", "\n", "while __________________:\n", " # your code here. remove the pass statement\n", " pass\n", " \n", " \n", " " ], "language": "python", "metadata": {}, "outputs": [] }, { "cell_type": "markdown", "metadata": {}, "source": [ "**b)** It turns out that the growth rate of _P. pythonicus_ is affected by temperature. It's replication time _r_, is a function of the temperature T, so that: \n", "$r = \\frac{19 T (T - 70)}{2450} + 10$. \n", "However, when the temperature is below 5, or over 50, the bacteria don't grow at all. \n", "Write a program that will receive the starter size __and__ the growth temperature, and will calculate the time to reach stationarity, printing the number of bacteria at each time point (like in part a). If bacteria can't grow, print an appropriate message (and don't do any calculation)." ] }, { "cell_type": "code", "collapsed": false, "input": [ "starter = 100 # Replace with a value of your choice.\n", "temp = 30 # Replace with a value of your choice.\n", "\n", "# check temperature and calculate replication time\n", "\n", "\n", "\n", "# calculate and growth\n", "\n", "\n", "\n" ], "language": "python", "metadata": {}, "outputs": [] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## 2) Splicing out introns\n", "\n", "**a)** \n", "Here\u2019s a short section of genomic DNA:\n", "\n", "```\n", "ATCGATCGATCGATCGACTGACTAGTCATAGCTATGCATGTAGCTACTCGATCGATCGATCGATCGATCGATCGATCGATCGATCATGCTATCATCGATCGATATCGATGCATCGACTACTAT\n", "```\n", "\n", "It comprises two exons and an intron. The first exon runs from the start of the sequence to the sixty-third character, and the second exon runs from the ninety-first character to the end of the sequence. \n", "\n", "Write a program that will print just the coding regions of the DNA sequence." ] }, { "cell_type": "code", "collapsed": false, "input": [ "seq = 'ATCGATCGATCGATCGACTGACTAGTCATAGCTATGCATGTAGCTACTCGATCGATCGATCGATCGATCGATCGATCGATCGATCATGCTATCATCGATCGATATCGATGCATCGACTACTAT'\n", "\n", "## your code goes here" ], "language": "python", "metadata": {}, "outputs": [], "prompt_number": 2 }, { "cell_type": "markdown", "metadata": {}, "source": [ "**b)** \n", "Using the sequence from **a**, write a program that will calculate what percentage of the DNA sequence is coding." ] }, { "cell_type": "code", "collapsed": false, "input": [ "## your code goes here" ], "language": "python", "metadata": {}, "outputs": [], "prompt_number": 3 }, { "cell_type": "markdown", "metadata": {}, "source": [ "**c)**\n", "Using the sequence from **a**, write a program that will print out the original genomic DNA sequence with coding bases in uppercase and non-coding bases in lowercase." ] }, { "cell_type": "code", "collapsed": false, "input": [ "## your code goes here" ], "language": "python", "metadata": {}, "outputs": [], "prompt_number": 4 }, { "cell_type": "markdown", "metadata": {}, "source": [ "## 3) Processing DNA\n", "\n", "The list `sequences` contains a number of DNA sequences as strings. Each sequence starts with the same 14 base pair fragment \u2013 a sequencing adapter that should have been removed. \n", "\n", "Write a program that will trim this adapter and print the cleaned sequences to the screen. The program will then print the length of each cleaned sequence to the screen." ] }, { "cell_type": "code", "collapsed": false, "input": [ "sequences = ['ATTCGATTATAAGCTCGATCGATCGATCGATCGATCGATCGATCGATCGATCGATC', \\\n", "'ATTCGATTATAAGCACTGATCGATCGATCGATCGATCGATGCTATCGTCGT', \\\n", "'ATTCGATTATAAGCATCGATCACGATCTATCGTACGTATGCATATCGATATCGATCGTAGTC', \\\n", "'ATTCGATTATAAGCACTATCGATGATCTAGCTACGATCGTAGCTGTA', \\\n", "'ATTCGATTATAAGCACTAGCTAGTCTCGATGCATGATCAGCTTAGCTGATGATGCTATGCA']\n", "\n", "\n", "## your code goes here" ], "language": "python", "metadata": {}, "outputs": [], "prompt_number": 8 }, { "cell_type": "markdown", "metadata": {}, "source": [ "## 4) Multiple exons from genomic DNA\n", "\n", "The string `genomic_dna` contains a section of genomic DNA.\n", "\n", "The list `exons` contains start/stop positions of exons as string indices. \n", "Each exon is a separate list (within the list of exons) with two elements: the start and stop positions. \n", "\n", "Write a program that will extract the exon segments from `genomic_dna` using the positions in `exons`, concatenate them, and print them to the screen." ] }, { "cell_type": "code", "collapsed": false, "input": [ "genomic_dna = 'TCGATCGTACCGTCGACGATGCTACGATCGTCGATCGTAGTCGATCATCGATCGATCGACTGATCGATCGATCGATCGATCGATATCGATCGATATCATCGATGCATCGATCATCGATCGATCGATCGATCGATCGATCATATGTCAGTCGATGCATCGTAGCATCGTATAGTAGCTACGTAGCTACGATCGATCGATCGATCGTAGCTAGCTAGCTAGATCGATCATCATCGTAGCTAGCTCGACTAGCTACGTACGATCGATGCATCGATCGTAGCTAGTACGATCGCGTAGCTAGCATGCTACGTAGATCGATCGATGCATGCTAGCTAGCTAGCTACGATCGATCGATCGATCGATCGATCGATCGATCGATCGATCGTAGCTAGCTACGATCGATGCTACGTAGATCGATCGCTAGTAGATCGATCGCTAGCTAGCTGACTAGTACGCTGCTAGTAGTCAGCTAGATCGATGCTAGTCA'\n", "exons = [[5, 58], [72, 133], [190, 276], [340, 398]] # [[start, stop], [start, stop], ...]\n", "\n", "## your code goes here" ], "language": "python", "metadata": {}, "outputs": [], "prompt_number": 11 }, { "cell_type": "markdown", "metadata": {}, "source": [ "\n", "## References\n", "\n", "Questions modified from [Python for Biologists](http://pythonforbiologists.com/index.php/introduction-to-python-for-biologists/lists-and-loops/), a great book by Martin Jones." ] } ], "metadata": {} } ] }