|
30 | 30 | } |
31 | 31 | }, |
32 | 32 | "source": [ |
33 | | - "## 01-Warmup: Python & Notebook" |
| 33 | + "## Python & Notebook" |
34 | 34 | ] |
35 | 35 | }, |
36 | 36 | { |
37 | 37 | "cell_type": "markdown", |
38 | 38 | "metadata": {}, |
39 | 39 | "source": [ |
40 | 40 | "- Explain the notebook. Environment for using python that's great for teaching and exploring\n", |
41 | | - "- Rename our untitled notebook\n", |
42 | | - "- save it\n", |
43 | | - "- cells" |
| 41 | + "- Rename our untitled notebook and save it\n", |
| 42 | + "- Explore cells" |
44 | 43 | ] |
45 | 44 | }, |
46 | 45 | { |
|
81 | 80 | }, |
82 | 81 | { |
83 | 82 | "cell_type": "code", |
84 | | - "execution_count": 2, |
| 83 | + "execution_count": 10, |
85 | 84 | "metadata": { |
86 | 85 | "collapsed": false |
87 | 86 | }, |
88 | | - "outputs": [], |
| 87 | + "outputs": [ |
| 88 | + { |
| 89 | + "ename": "SyntaxError", |
| 90 | + "evalue": "invalid syntax (<ipython-input-10-b9f0e0801bac>, line 1)", |
| 91 | + "output_type": "error", |
| 92 | + "traceback": [ |
| 93 | + "\u001b[0;36m File \u001b[0;32m\"<ipython-input-10-b9f0e0801bac>\"\u001b[0;36m, line \u001b[0;32m1\u001b[0m\n\u001b[0;31m print Hello world\u001b[0m\n\u001b[0m ^\u001b[0m\n\u001b[0;31mSyntaxError\u001b[0m\u001b[0;31m:\u001b[0m invalid syntax\n" |
| 94 | + ] |
| 95 | + } |
| 96 | + ], |
89 | 97 | "source": [ |
90 | | - "# print Hello world" |
| 98 | + "print Hello world" |
91 | 99 | ] |
92 | 100 | }, |
93 | 101 | { |
|
309 | 317 | "9.0 / 10.0 # Make sure we divide with floats, otherwise we get integers" |
310 | 318 | ] |
311 | 319 | }, |
| 320 | + { |
| 321 | + "cell_type": "markdown", |
| 322 | + "metadata": {}, |
| 323 | + "source": [ |
| 324 | + "**Summary slide in presentation**" |
| 325 | + ] |
| 326 | + }, |
312 | 327 | { |
313 | 328 | "cell_type": "markdown", |
314 | 329 | "metadata": {}, |
|
470 | 485 | "'a' not in name" |
471 | 486 | ] |
472 | 487 | }, |
| 488 | + { |
| 489 | + "cell_type": "markdown", |
| 490 | + "metadata": {}, |
| 491 | + "source": [ |
| 492 | + "**Summary slide in presentation**" |
| 493 | + ] |
| 494 | + }, |
473 | 495 | { |
474 | 496 | "cell_type": "markdown", |
475 | 497 | "metadata": {}, |
|
634 | 656 | "This isn't surprising if you think of the program as just a list of steps, but if you expect it to behave like a spreadsheet, it may be surprising." |
635 | 657 | ] |
636 | 658 | }, |
| 659 | + { |
| 660 | + "cell_type": "markdown", |
| 661 | + "metadata": {}, |
| 662 | + "source": [ |
| 663 | + "**Summary slide in presentation**" |
| 664 | + ] |
| 665 | + }, |
637 | 666 | { |
638 | 667 | "cell_type": "markdown", |
639 | 668 | "metadata": {}, |
|
734 | 763 | }, |
735 | 764 | { |
736 | 765 | "cell_type": "code", |
737 | | - "execution_count": 26, |
| 766 | + "execution_count": 11, |
738 | 767 | "metadata": { |
739 | 768 | "collapsed": false |
740 | 769 | }, |
741 | | - "outputs": [], |
| 770 | + "outputs": [ |
| 771 | + { |
| 772 | + "ename": "NameError", |
| 773 | + "evalue": "name 'r3' is not defined", |
| 774 | + "output_type": "error", |
| 775 | + "traceback": [ |
| 776 | + "\u001b[0;31m---------------------------------------------------------------------------\u001b[0m", |
| 777 | + "\u001b[0;31mNameError\u001b[0m Traceback (most recent call last)", |
| 778 | + "\u001b[0;32m<ipython-input-11-fbfbf23cf48f>\u001b[0m in \u001b[0;36m<module>\u001b[0;34m()\u001b[0m\n\u001b[0;32m----> 1\u001b[0;31m \u001b[0mr3\u001b[0m\u001b[0;34m[\u001b[0m\u001b[0;36m2\u001b[0m\u001b[0;34m]\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0;34m'G'\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m", |
| 779 | + "\u001b[0;31mNameError\u001b[0m: name 'r3' is not defined" |
| 780 | + ] |
| 781 | + } |
| 782 | + ], |
742 | 783 | "source": [ |
743 | | - "# r3[2] = 'G'" |
| 784 | + "r3[2] = 'G'" |
744 | 785 | ] |
745 | 786 | }, |
746 | 787 | { |
|
791 | 832 | "cell_type": "markdown", |
792 | 833 | "metadata": {}, |
793 | 834 | "source": [ |
794 | | - "Let's quickly take stock of what we know. \n", |
795 | | - "\n", |
796 | | - "1. Our DNA sequence is represented as a string, and has a variable name\n", |
797 | | - "2. Strings are sequences of characters, each character at a numbered position (starting from 0)\n", |
798 | | - "3. We can access characters with the `[ ]` square brackets and the position number\n", |
799 | | - "4. We can combine characters back into strings with the `+` (plus sign)\n", |
800 | | - "\n", |
801 | | - "So, we can pull out characters in any order we want, and combine them into a new sequence by adding them together:" |
| 835 | + "** slide in presentation**" |
802 | 836 | ] |
803 | 837 | }, |
804 | 838 | { |
|
947 | 981 | "Now, I think we're ready to reverse the sequence. Let's make this a hands-on exercise to write some code that reverses the sequence in `seq10` and puts it in a variable called `rev10`. Remember, you can add strings together and the order is important!" |
948 | 982 | ] |
949 | 983 | }, |
| 984 | + { |
| 985 | + "cell_type": "markdown", |
| 986 | + "metadata": {}, |
| 987 | + "source": [ |
| 988 | + "**Exercise in presentation**" |
| 989 | + ] |
| 990 | + }, |
950 | 991 | { |
951 | 992 | "cell_type": "code", |
952 | 993 | "execution_count": 32, |
|
969 | 1010 | "print rev10" |
970 | 1011 | ] |
971 | 1012 | }, |
| 1013 | + { |
| 1014 | + "cell_type": "markdown", |
| 1015 | + "metadata": {}, |
| 1016 | + "source": [ |
| 1017 | + "**Summary slide in presentation**" |
| 1018 | + ] |
| 1019 | + }, |
| 1020 | + { |
| 1021 | + "cell_type": "markdown", |
| 1022 | + "metadata": {}, |
| 1023 | + "source": [ |
| 1024 | + "**Intro Dictionaries slide in presentation**" |
| 1025 | + ] |
| 1026 | + }, |
972 | 1027 | { |
973 | 1028 | "cell_type": "markdown", |
974 | 1029 | "metadata": {}, |
|
980 | 1035 | "cell_type": "markdown", |
981 | 1036 | "metadata": {}, |
982 | 1037 | "source": [ |
983 | | - "Now that we've got reverse figured out, we can tackle complementing. To do that, we need to look up the complementary base for base, and build a new sequence:\n", |
984 | | - "\n", |
985 | | - " A -> T\n", |
986 | | - " C -> G\n", |
987 | | - " G -> C\n", |
988 | | - " T -> A\n", |
989 | | - "\n", |
990 | | - "Python has a data type called a dictionary that's great for looking things up. It works like a dictionary - you have a key (e.g. the word you're looking up) and a value (e.g. the definition). Each key can only be in the dictionary once, but the values may be repeated." |
| 1038 | + "Python has a data type called a dictionary that's great for looking things up. It associates pairs of things together: a key and a value." |
991 | 1039 | ] |
992 | 1040 | }, |
993 | 1041 | { |
|
1415 | 1463 | }, |
1416 | 1464 | "outputs": [], |
1417 | 1465 | "source": [ |
1418 | | - "# sequence_types[1] = 'dna'" |
| 1466 | + "sequence_types[1] = 'dna'" |
| 1467 | + ] |
| 1468 | + }, |
| 1469 | + { |
| 1470 | + "cell_type": "markdown", |
| 1471 | + "metadata": {}, |
| 1472 | + "source": [ |
| 1473 | + "**Summary slide in presentation**" |
1419 | 1474 | ] |
1420 | 1475 | }, |
1421 | 1476 | { |
|
1468 | 1523 | "cell_type": "markdown", |
1469 | 1524 | "metadata": {}, |
1470 | 1525 | "source": [ |
1471 | | - "We can have multiple conditions we check too, and to demonstrate that, I want to calculate the **GC-content percentage** of the sequence.\n", |
1472 | | - "\n", |
1473 | | - "(G + C) / (A + T + G + C)\n", |
1474 | | - " " |
1475 | | - ] |
1476 | | - }, |
1477 | | - { |
1478 | | - "cell_type": "markdown", |
1479 | | - "metadata": {}, |
1480 | | - "source": [ |
1481 | | - "So to approach this, we're going to loop over the sequence and total up the G's and C's. We also need to total up The A's and T's\n", |
1482 | | - "\n", |
1483 | | - "The general algorithm here will be\n", |
1484 | | - "\n", |
1485 | | - "- Loop over each item in the sequence\n", |
1486 | | - " - If it's a `G` or a `C`, increment our GC counter\n", |
1487 | | - " - For all items, increment our ATGC counter\n", |
1488 | | - " \n", |
1489 | | - "We know how to write a loop, and we know how to write a counter and incrment it. And we just saw `if`, but we haven't used it in our loop, so let's write that" |
| 1526 | + "**Instruction slide in presentation**" |
1490 | 1527 | ] |
1491 | 1528 | }, |
1492 | 1529 | { |
|
1586 | 1623 | " print 'High'" |
1587 | 1624 | ] |
1588 | 1625 | }, |
| 1626 | + { |
| 1627 | + "cell_type": "markdown", |
| 1628 | + "metadata": {}, |
| 1629 | + "source": [ |
| 1630 | + "**Summary slide in presentation**" |
| 1631 | + ] |
| 1632 | + }, |
1589 | 1633 | { |
1590 | 1634 | "cell_type": "markdown", |
1591 | 1635 | "metadata": {}, |
|
1758 | 1802 | "cell_type": "markdown", |
1759 | 1803 | "metadata": {}, |
1760 | 1804 | "source": [ |
1761 | | - "Exercise: Split, upper, and reverse" |
| 1805 | + "**Exercise slide in presentation**" |
1762 | 1806 | ] |
1763 | 1807 | }, |
1764 | 1808 | { |
|
2165 | 2209 | "cell_type": "markdown", |
2166 | 2210 | "metadata": {}, |
2167 | 2211 | "source": [ |
2168 | | - "Exercise: I found out that you can reverse a string (or a list) by using the slice notation `[::-1]`. Update the reverse function to use this and see if anything changes with `reverse_complement`" |
| 2212 | + "**Exercise slide in presentation**" |
2169 | 2213 | ] |
2170 | 2214 | }, |
2171 | 2215 | { |
2172 | | - "cell_type": "code", |
2173 | | - "execution_count": 75, |
2174 | | - "metadata": { |
2175 | | - "collapsed": false |
2176 | | - }, |
2177 | | - "outputs": [ |
2178 | | - { |
2179 | | - "name": "stdout", |
2180 | | - "output_type": "stream", |
2181 | | - "text": [ |
2182 | | - "cba\n" |
2183 | | - ] |
2184 | | - } |
2185 | | - ], |
2186 | | - "source": [ |
2187 | | - "s = 'abc'\n", |
2188 | | - "r = s[::-1]\n", |
2189 | | - "print r" |
2190 | | - ] |
2191 | | - }, |
2192 | | - { |
2193 | | - "cell_type": "code", |
2194 | | - "execution_count": 76, |
| 2216 | + "cell_type": "markdown", |
2195 | 2217 | "metadata": { |
2196 | 2218 | "collapsed": true |
2197 | 2219 | }, |
2198 | | - "outputs": [], |
2199 | 2220 | "source": [ |
2200 | | - "def double(x):\n", |
2201 | | - " return x * 2" |
| 2221 | + "**Summary slide in presentation**" |
2202 | 2222 | ] |
2203 | 2223 | }, |
2204 | 2224 | { |
|
2525 | 2545 | " exit(1)\n" |
2526 | 2546 | ] |
2527 | 2547 | }, |
| 2548 | + { |
| 2549 | + "cell_type": "markdown", |
| 2550 | + "metadata": {}, |
| 2551 | + "source": [ |
| 2552 | + "**Summary slide in presentation**" |
| 2553 | + ] |
| 2554 | + }, |
2528 | 2555 | { |
2529 | 2556 | "cell_type": "markdown", |
2530 | 2557 | "metadata": {}, |
|
0 commit comments