Skip to content

Commit 3565c85

Browse files
committed
Adds directions for slides, tidies up a few more things
1 parent 09ad100 commit 3565c85

File tree

1 file changed

+101
-74
lines changed

1 file changed

+101
-74
lines changed

2016-python.ipynb

Lines changed: 101 additions & 74 deletions
Original file line numberDiff line numberDiff line change
@@ -30,17 +30,16 @@
3030
}
3131
},
3232
"source": [
33-
"## 01-Warmup: Python & Notebook"
33+
"## Python & Notebook"
3434
]
3535
},
3636
{
3737
"cell_type": "markdown",
3838
"metadata": {},
3939
"source": [
4040
"- 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"
4443
]
4544
},
4645
{
@@ -81,13 +80,22 @@
8180
},
8281
{
8382
"cell_type": "code",
84-
"execution_count": 2,
83+
"execution_count": 10,
8584
"metadata": {
8685
"collapsed": false
8786
},
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+
],
8997
"source": [
90-
"# print Hello world"
98+
"print Hello world"
9199
]
92100
},
93101
{
@@ -309,6 +317,13 @@
309317
"9.0 / 10.0 # Make sure we divide with floats, otherwise we get integers"
310318
]
311319
},
320+
{
321+
"cell_type": "markdown",
322+
"metadata": {},
323+
"source": [
324+
"**Summary slide in presentation**"
325+
]
326+
},
312327
{
313328
"cell_type": "markdown",
314329
"metadata": {},
@@ -470,6 +485,13 @@
470485
"'a' not in name"
471486
]
472487
},
488+
{
489+
"cell_type": "markdown",
490+
"metadata": {},
491+
"source": [
492+
"**Summary slide in presentation**"
493+
]
494+
},
473495
{
474496
"cell_type": "markdown",
475497
"metadata": {},
@@ -634,6 +656,13 @@
634656
"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."
635657
]
636658
},
659+
{
660+
"cell_type": "markdown",
661+
"metadata": {},
662+
"source": [
663+
"**Summary slide in presentation**"
664+
]
665+
},
637666
{
638667
"cell_type": "markdown",
639668
"metadata": {},
@@ -734,13 +763,25 @@
734763
},
735764
{
736765
"cell_type": "code",
737-
"execution_count": 26,
766+
"execution_count": 11,
738767
"metadata": {
739768
"collapsed": false
740769
},
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+
],
742783
"source": [
743-
"# r3[2] = 'G'"
784+
"r3[2] = 'G'"
744785
]
745786
},
746787
{
@@ -791,14 +832,7 @@
791832
"cell_type": "markdown",
792833
"metadata": {},
793834
"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**"
802836
]
803837
},
804838
{
@@ -947,6 +981,13 @@
947981
"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!"
948982
]
949983
},
984+
{
985+
"cell_type": "markdown",
986+
"metadata": {},
987+
"source": [
988+
"**Exercise in presentation**"
989+
]
990+
},
950991
{
951992
"cell_type": "code",
952993
"execution_count": 32,
@@ -969,6 +1010,20 @@
9691010
"print rev10"
9701011
]
9711012
},
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+
},
9721027
{
9731028
"cell_type": "markdown",
9741029
"metadata": {},
@@ -980,14 +1035,7 @@
9801035
"cell_type": "markdown",
9811036
"metadata": {},
9821037
"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."
9911039
]
9921040
},
9931041
{
@@ -1415,7 +1463,14 @@
14151463
},
14161464
"outputs": [],
14171465
"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**"
14191474
]
14201475
},
14211476
{
@@ -1468,25 +1523,7 @@
14681523
"cell_type": "markdown",
14691524
"metadata": {},
14701525
"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**"
14901527
]
14911528
},
14921529
{
@@ -1586,6 +1623,13 @@
15861623
" print 'High'"
15871624
]
15881625
},
1626+
{
1627+
"cell_type": "markdown",
1628+
"metadata": {},
1629+
"source": [
1630+
"**Summary slide in presentation**"
1631+
]
1632+
},
15891633
{
15901634
"cell_type": "markdown",
15911635
"metadata": {},
@@ -1758,7 +1802,7 @@
17581802
"cell_type": "markdown",
17591803
"metadata": {},
17601804
"source": [
1761-
"Exercise: Split, upper, and reverse"
1805+
"**Exercise slide in presentation**"
17621806
]
17631807
},
17641808
{
@@ -2165,40 +2209,16 @@
21652209
"cell_type": "markdown",
21662210
"metadata": {},
21672211
"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**"
21692213
]
21702214
},
21712215
{
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",
21952217
"metadata": {
21962218
"collapsed": true
21972219
},
2198-
"outputs": [],
21992220
"source": [
2200-
"def double(x):\n",
2201-
" return x * 2"
2221+
"**Summary slide in presentation**"
22022222
]
22032223
},
22042224
{
@@ -2525,6 +2545,13 @@
25252545
" exit(1)\n"
25262546
]
25272547
},
2548+
{
2549+
"cell_type": "markdown",
2550+
"metadata": {},
2551+
"source": [
2552+
"**Summary slide in presentation**"
2553+
]
2554+
},
25282555
{
25292556
"cell_type": "markdown",
25302557
"metadata": {},

0 commit comments

Comments
 (0)