Skip to content

Commit e38040f

Browse files
committed
Last-minute changes to automation lesson
1 parent afbeb3f commit e38040f

4 files changed

Lines changed: 1735 additions & 1131 deletions

File tree

automation_python.ipynb

Lines changed: 7 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -479,27 +479,15 @@
479479
"cell_type": "markdown",
480480
"metadata": {},
481481
"source": [
482-
"For errors we get without directly calling `raise`, both the class of `Error` and the message are predetermined. This is useful in some situations, but less so in others. Suppose you wrote a reverse complement function like the one below:"
482+
"For errors we get without directly calling `raise`, both the class of `Error` and the message are predetermined. This is useful in some situations, but less so in others. Suppose you wrote a reverse complement function:"
483483
]
484484
},
485485
{
486486
"cell_type": "code",
487487
"execution_count": null,
488488
"metadata": {},
489489
"outputs": [],
490-
"source": [
491-
"def reverse_complement(dna_sequence):\n",
492-
" \"\"\"Reverses the complement of a dna sequence\"\"\"\n",
493-
" complements = {\"T\":\"A\", \"A\":\"T\", \"C\":\"G\", \"G\":\"C\"}\n",
494-
" reverse = dna_sequence[::-1]\n",
495-
" result = \"\"\n",
496-
" for letter in reverse:\n",
497-
" result = result + complements[letter]\n",
498-
" return(result)\n",
499-
"\n",
500-
"help(reverse_complement)\n",
501-
"print(reverse_complement(\"CAAT\"))"
502-
]
490+
"source": []
503491
},
504492
{
505493
"cell_type": "markdown",
@@ -804,14 +792,14 @@
804792
"gapminder['region'] = gapminder['region'].astype(str)\n",
805793
"\n",
806794
"# Method 1 for formatting the 'region' column:\n",
807-
"gapminder_copy['region'] = gapminder_copy['region'].str.lstrip() # Strip white space on left\n",
808-
"gapminder_copy['region'] = gapminder_copy['region'].str.rstrip() # Strip white space on right\n",
809-
"gapminder_copy['region'] = gapminder_copy['region'].str.lower() # Convert to lowercase\n",
795+
"gapminder['region'] = gapminder['region'].str.lstrip() # Strip white space on left\n",
796+
"gapminder['region'] = gapminder['region'].str.rstrip() # Strip white space on right\n",
797+
"gapminder['region'] = gapminder['region'].str.lower() # Convert to lowercase\n",
810798
"\n",
811799
"# Method 2 for formatting the 'region' column:\n",
812-
"gapminder_copy['region'] = gapminder['region'].str.lstrip().str.rstrip().str.lower() # Strip white space on left and right, and convert to lowercase\n",
800+
"gapminder['region'] = gapminder['region'].str.lstrip().str.rstrip().str.lower() # Strip white space on left and right, and convert to lowercase\n",
813801
"\n",
814-
"print(gapminder_copy['region'])"
802+
"print(gapminder['region'])"
815803
]
816804
},
817805
{

automation_python_instructor.ipynb

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -556,7 +556,7 @@
556556
"cell_type": "markdown",
557557
"metadata": {},
558558
"source": [
559-
"For errors we get without directly calling `raise`, both the class of `Error` and the message are predetermined. This is useful in some situations, but less so in others. Suppose you wrote a reverse complement function like the one below:"
559+
"For errors we get without directly calling `raise`, both the class of `Error` and the message are predetermined. This is useful in some situations, but less so in others. Suppose you wrote a reverse complement function:"
560560
]
561561
},
562562
{
@@ -565,6 +565,7 @@
565565
"metadata": {},
566566
"outputs": [],
567567
"source": [
568+
"# live demo\n",
568569
"def reverse_complement(dna_sequence):\n",
569570
" \"\"\"Reverses the complement of a dna sequence\"\"\"\n",
570571
" complements = {\"T\":\"A\", \"A\":\"T\", \"C\":\"G\", \"G\":\"C\"}\n",
@@ -975,14 +976,14 @@
975976
"gapminder['region'] = gapminder['region'].astype(str)\n",
976977
"\n",
977978
"# Method 1 for formatting the 'region' column:\n",
978-
"gapminder_copy['region'] = gapminder_copy['region'].str.lstrip() # Strip white space on left\n",
979-
"gapminder_copy['region'] = gapminder_copy['region'].str.rstrip() # Strip white space on right\n",
980-
"gapminder_copy['region'] = gapminder_copy['region'].str.lower() # Convert to lowercase\n",
979+
"gapminder['region'] = gapminder['region'].str.lstrip() # Strip white space on left\n",
980+
"gapminder['region'] = gapminder['region'].str.rstrip() # Strip white space on right\n",
981+
"gapminder['region'] = gapminder['region'].str.lower() # Convert to lowercase\n",
981982
"\n",
982983
"# Method 2 for formatting the 'region' column:\n",
983-
"gapminder_copy['region'] = gapminder['region'].str.lstrip().str.rstrip().str.lower() # Strip white space on left and right, and convert to lowercase\n",
984+
"gapminder['region'] = gapminder['region'].str.lstrip().str.rstrip().str.lower() # Strip white space on left and right, and convert to lowercase\n",
984985
"\n",
985-
"print(gapminder_copy['region'])"
986+
"print(gapminder['region'])"
986987
]
987988
},
988989
{

0 commit comments

Comments
 (0)