Applied Programming: Course plan

Søren and I spent this afternoon planning our upcoming course, Applied Programming (essentially a Python programming class with focus on bioinformatics applications).  See my previous thoughts on the class here and here.

Course plan

The class runs for seven weeks, and this is the plan we came up with is listed below.  There is eight weeks there, since the first and last week are really half-weeks.

Week 1: Introduction to Python

One lecture:

  • Logging into the department’s computers and running Python there (plus how to use Idle).
  • Installing Python on your own computer.
  • Interactive Python sessions
    • expressions
    • comparisons
    • assignments
    • multiple-assignments
  • Using help() to learn more
  • built-in data types
  • scripts in files (and how to execute them)

Week 2: Control structures

First lecture:

  • branching
  • looping
  • indentation

Second lecture:

  • functions
  • (list comprehension)
  • generators
  • exceptions

Hand-in exercise:

  • Locate ORFs in a string
  • Translate them into proteins
  • Calculate frequencies of AA

Week 3: Parsing

First lecture:

  • files and IO
  • string operations

Second lecture:

  • regular expressions

Hand-in exercise:

  • parse table of genes (GFF)
  • parse sequences from FASTA
  • calculate AA frequencies

Week 4: Structuring code

First lecture:

  • modules
  • classes

Second lecture:

  • “Design by Contract”
  • Unit testing

Hand-in exercise:

  • write a class containing a multiple sequence alignment
  • add a method for iterating through the columns of the alignment
  • add a method to restrict to subset of species
  • add a method to slice the alignment
  • add a method to remove all-gaps columns

Week 5: BioPython

First lecture:

  • Introduction to BioPython (and Bio*)

Second lecture:

  • Sequences and sequence parsers
  • NCBI access
  • Blast

Hand-in exercise:

  • Read a list of human genes (or IDs) from a table
  • Download them from NCBI
  • Blast them against the mouse

Week 6: SciPy

First lecture:

  • Plotting using matplotlib (pylab)

Second lecture:

  • Fitting functions
  • Linear regression

Week 7: Go faster stripes (profiling and optimizing)

First lecture:

  • cProfile
  • Timing code-chunks

Second lecture:

  • Algorithmic complexity
  • “Big O” notation (and roughly how to figure it out)

Hand-in exercise:

  • Implement a program that builds a string by appending vs. using join()
  • Measure the running time on both solutions
  • plot and fit to O(n) and O(n2)

Week 8: Introducing the exam project

We still haven’t decided on the exam project, but it is a take-home exam where they will need to write a small program and then hand it in together with a short report.

Teaching material

We had a discussion about the teaching material.  We would really like to have a text book for this, but we have been looking for a while without finding one that fits our needs.

We also thought about using one of the many online introductions.  There are some pretty good ones.

Still, they are typically more or less at the tutorial level, and that we could just as easily write ourselves, and then get it exactly the way we want it.

I wrote my own lecture notes in previous classes (see e.g. here).  It is a lot of work, but it is nice to taylor it exactly to the needs of the class.

The downside is, of course, that the first time the class runs the notes will be pretty short and not proofread in sufficient detail.

Figures and Word

I’m used to writing my papers in (La)TeX.  In mathematics and computer science, that is the tradition, and quite frankly it is the only choice if you include a lot of math in your documents.

Recently, though, I’m working with people used to writing in Word, and rather than forcing them to learn LaTeX I’ve decided to use Word as well.  Only when the math content is low, though.  Writing math in Word is too painful to even contemplate.

Anyway, for simple text editing I have no complains with Word.  It does what it is supposed to, and I find the grammar checker a great help (I do have a grammar checker in the editor I use for LaTeX, but it isn’t quite as good).

I run into problems when I try to do anything but simple text editing.

Like today, I am trying to insert a figure in a document.  I have a plot in PDF and I want to insert that together with a caption.

I can insert the figure and write the caption in a text box.  No problem.  It looks something like this:

Now, to make the editing easier, I want to group the figure with the caption, so I can move them around as a unit if I need to move them later on.

If I do that, it looks like this:

WTF? Why did it suddenly turn my (vector graphic) PDF into (a very pixilated) bitmap image?

This is so not what I expected, and certainly not what I wanted…