Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
P
Programming course
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Model registry
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
courses
Programming course
Commits
14546372
Commit
14546372
authored
11 years ago
by
J.F.J. Laros
Browse files
Options
Downloads
Patches
Plain Diff
Updated the slides on object oriented programming.
parent
103acb3f
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
classes.ipynb
+95
-9
95 additions, 9 deletions
classes.ipynb
with
95 additions
and
9 deletions
classes.ipynb
+
95
−
9
View file @
14546372
...
...
@@ -42,7 +42,7 @@
"\n",
"You can use nbconvert to convert the slides to HTML and serve them:\n",
"\n",
" ipython nbconvert --to slides --post serve
matplotlib
.ipynb\n",
" ipython nbconvert --to slides --post serve
classes
.ipynb\n",
"\n",
"This will open the slides in a new browser window."
]
...
...
@@ -73,7 +73,11 @@
},
{
"cell_type": "markdown",
"metadata": {},
"metadata": {
"slideshow": {
"slide_type": "slide"
}
},
"source": [
"Imagine we are collecting a number of attributes of some persons:\n",
"\n",
...
...
@@ -378,7 +382,11 @@
},
{
"cell_type": "markdown",
"metadata": {},
"metadata": {
"slideshow": {
"slide_type": "slide"
}
},
"source": [
" class Person(object):\n",
" ...\n",
...
...
@@ -436,7 +444,11 @@
},
{
"cell_type": "markdown",
"metadata": {},
"metadata": {
"slideshow": {
"slide_type": "slide"
}
},
"source": [
" class Person(object):\n",
" ...\n",
...
...
@@ -556,7 +568,11 @@
},
{
"cell_type": "markdown",
"metadata": {},
"metadata": {
"slideshow": {
"slide_type": "slide"
}
},
"source": [
" class Person(object):\n",
" ...\n",
...
...
@@ -607,7 +623,11 @@
" self.eye_colour, self.hair_colour, self.weight, self.length)"
],
"language": "python",
"metadata": {},
"metadata": {
"slideshow": {
"slide_type": "slide"
}
},
"outputs": [],
"prompt_number": 127
},
...
...
@@ -633,9 +653,75 @@
"prompt_number": 86
},
{
"cell_type": "markdown",
"metadata": {},
"source": []
"cell_type": "code",
"collapsed": false,
"input": [
"class Read(object):\n",
" def __init__(self):\n",
" self.read = \"\"\n",
" self.qual = []\n",
" \n",
" def __str__(self):\n",
" return self.read\n",
" \n",
" def add(self, base):\n",
" self.read += base[0]\n",
" self.qual.append(base[1])\n",
" \n",
" def quality(self):\n",
" return sum(self.qual) / len(self.read)\n",
" \n",
" def trim(self, score):\n",
" for position in range(len(self.read) - 1, -1, -1):\n",
" if self.qual[position] >= score:\n",
" return self.read[:position]"
],
"language": "python",
"metadata": {
"slideshow": {
"slide_type": "slide"
}
},
"outputs": [],
"prompt_number": 7
},
{
"cell_type": "code",
"collapsed": false,
"input": [
"from sequencer import Sequencer\n",
"\n",
"spots = 2\n",
"run = Sequencer(spots, readlength=60)\n",
"\n",
"reads = [Read() for _ in range(spots)]\n",
"for tile in run:\n",
" for read_id, base in enumerate(tile):\n",
" reads[read_id].add(base)\n",
"\n",
"for i in reads:\n",
" print i, i.quality()\n",
" print i.trim(39)"
],
"language": "python",
"metadata": {
"slideshow": {
"slide_type": "slide"
}
},
"outputs": [
{
"output_type": "stream",
"stream": "stdout",
"text": [
"GGTGTGATTCCCGTTCGGTGGGCCGCCTTGGGTCATTGCTCGGTTGAGGAGGGAAGACCT 30\n",
"GGTGTGATTCCCGTTCGGTGGGCCGCCTTGGGTCAT\n",
"GGCTTTAGAATGTCTCCTGCATCTGATGCTATTAAAAGCTATGTTTTTCACATAGTACGG 29\n",
"GGCTTTAGAATGTCTCCTGCATCTGATGCTATTAAAAGCTATGTTTTTCACATAGT\n"
]
}
],
"prompt_number": 8
}
],
"metadata": {}
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment