Rust for bioinformaticians (under construction)
An intensive course teaching Rust to 4th-year biology students who have already taken one introductory programming course (R, Python, or — at worst — MATLAB). The unit of design is the concept ↔︎ biology pairing: every Rust feature is introduced together with a biological problem that motivates it.
Where to start
- Audience — who this course is for, and what we can and cannot assume they already know.
Before you start
- Install Rust, VS Code, and the plugins you need — about 15 minutes on a fresh machine. Do this once, before day 1.
Exercises by day
Day 1 — Toolchain, scalars, control flow, functions
Day 2 — Ownership, borrowing, strings, slices, bytes
Day 3 — Structs, enums, iterators, recursion, error handling
Day 4 — I/O, crates, modules, plotting, zip
Day 5 — Tests, --release, parallelism, ecosystem
Day 6 — Rust for the web
A pure-Rust web app: Yew frontend (compiled to WebAssembly), axum backend, shared types crate — all in one cargo workspace.
Day 7 — SQL and databases
Modelling data in relational form, querying it from the sqlite CLI, then reading and writing the same database from Rust.
Day 8 — Traits
The Rust mechanism for shared interfaces — impl Trait for Type, generic functions with trait bounds, and Box<dyn Trait> for heterogeneous collections.
Day 9 — Algorithms and complexity
A short day on data-structure complexity (Big-O) and how to recognise it in code — two diagnostic quizzes that drive the lecture.
Day 10 — Working with matrices
Dense and sparse matrix representations (ndarray, sprs), iterative linear-system solvers, and Markov chains via power iteration.
Day 11 — GPUs and tensors with Burn
GPU-aware tensors via the Burn framework, with every Rust example paired against the equivalent PyTorch / NumPy. Builds up to PCA via nalgebra, a PWM motif scanner as Conv1d, and a small trainable promoter classifier.
Day 12 — GPU compute kernels with wgpu
The “how” beneath day 11’s “what” — write WebGPU Shading Language compute shaders by hand and dispatch them with wgpu. Several exercises revisit earlier problems (GC content, reverse complement, pairwise distances) as raw GPU kernels.
Working with the exercises
Each exercise pairs a short .qmd walkthrough with one or two real cargo projects:
- The walkthrough holds the prose, the hints (as collapsible callouts), and a reference solution snippet.
- The sibling
ex-<name>/cargo project contains code that the Rust compiler will actually check, plus acargo testspec that pins down the expected behaviour. - The
ex-<name>-solution/cargo project contains the reference solution as runnable code.
Building this site
make # render the whole site to _site/
make preview # start a live-reload preview server
make clean # delete _site/ and run `cargo clean` in every exercise crateYou will need Quarto and a recent Rust toolchain installed.