{ "metadata": { "name": "testing-with-nose" }, "nbformat": 3, "nbformat_minor": 0, "worksheets": [ { "cells": [ { "cell_type": "code", "collapsed": false, "input": [ "%%file calc_gc.py\n", "\n", "def calc_gc(dna):\n", " dna = dna.upper()\n", " gc = dna.count('G') + dna.count('C')\n", " at = dna.count('A') + dna.count('T')\n", " \n", " total = gc + at\n", " if total == 0:\n", " return 0.0\n", " \n", " frac = gc / float(total)\n", " return frac\n", "\n", "def test_correct_counting_gc():\n", " x = calc_gc('ATGC')\n", " assert x == 0.5, x\n", " \n", "def test_correct_counting_at():\n", " x = calc_gc('AAAA')\n", " assert x == 0.0, x\n", "\n", "def test_3():\n", " x = calc_gc('atgc')\n", " assert x == 0.5, x\n", " \n", "def test_4():\n", " x = calc_gc('AtgCNN')\n", " assert x == 0.5, x\n", " \n", "def test_5():\n", " x = calc_gc('NNNNNN')\n", " assert x == 0.0, x" ], "language": "python", "metadata": {}, "outputs": [ { "output_type": "stream", "stream": "stdout", "text": [ "Overwriting calc_gc.py" ] }, { "output_type": "stream", "stream": "stdout", "text": [ "\n" ] } ], "prompt_number": 23 }, { "cell_type": "code", "collapsed": false, "input": [ "!nosetests -v calc_gc.py" ], "language": "python", "metadata": {}, "outputs": [ { "output_type": "stream", "stream": "stdout", "text": [ "calc_gc.test_correct_counting_gc ... ok\r\n", "calc_gc.test_correct_counting_at ... ok\r\n", "calc_gc.test_3 ... ok\r\n", "calc_gc.test_4 ... ok\r\n", "calc_gc.test_5 ... ok\r\n", "\r\n", "----------------------------------------------------------------------\r\n", "Ran 5 tests in 0.001s\r\n", "\r\n", "OK\r\n" ] } ], "prompt_number": 24 }, { "cell_type": "code", "collapsed": false, "input": [ "!pip install git+https://github.com/ged-lab/screed.git\n" ], "language": "python", "metadata": {}, "outputs": [ { "output_type": "stream", "stream": "stdout", "text": [ "Downloading/unpacking git+https://github.com/ged-lab/screed.git\r\n", " Cloning https://github.com/ged-lab/screed.git to /var/folders/y6/s1r3q87933s6gjdrtmts1npc0000gq/T/pip-Ha7xSv-build\r\n" ] }, { "output_type": "stream", "stream": "stdout", "text": [ " Running setup.py egg_info for package from git+https://github.com/ged-lab/screed.git\r\n" ] }, { "output_type": "stream", "stream": "stdout", "text": [ " \r\n", "Cleaning up...\r\n" ] } ], "prompt_number": 25 }, { "cell_type": "code", "collapsed": false, "input": [], "language": "python", "metadata": {}, "outputs": [] } ], "metadata": {} } ] }