Skip to content
Dave Walker edited this page Jul 6, 2026 · 6 revisions

A Python toolkit for simulating sequence evolution, exploring molecular clock models and implementing phylogenetic reconstruction algorithms from first principles.

Overview

Molecular clocks use DNA sequence variation to estimate evolutionary relationships and divergence times between species.

This project explores the computational foundations of molecular clock analysis by building the core algorithms from first principles. It includes simulation engines for generating synthetic evolutionary datasets, interactive tools for exploring molecular clock models, and implementations of phylogenetic reconstruction algorithms. Rather than relying on existing phylogenetics libraries, the aim is to understand how evolutionary histories are simulated, represented, reconstructed and ultimately interpreted.

The repository combines reusable simulation engines, command-line interfaces for generating synthetic datasets, and interactive explorers for experimenting with both strict and relaxed molecular clock models.

The project is intended both as an educational resource and as a computational laboratory for investigating phylogenetic algorithms.

Current Features

Strict Molecular Clock Simulation

The core simulator implements a strict molecular clock capable of generating complete synthetic evolutionary datasets.

Features include:

  • Random ancestral DNA sequence generation
  • Rooted phylogenetic tree generation
  • Balanced and random branching models
  • Ultrametric tree calibration
  • DNA sequence evolution along each branch
  • Complete evolutionary history tracking
  • Export of simulated datasets in FASTA, Newick and JSON formats

These datasets provide known ground truth against which future phylogenetic reconstruction algorithms can be evaluated.

Relaxed Molecular Clock Simulation

A second simulation engine implements a simple autocorrelated relaxed molecular clock.

Unlike the strict clock model, individual lineages evolve at different mutation rates while preserving a complete known evolutionary history.

Features include:

  • Independent relaxed clock simulation engine
  • Lineage-specific mutation rates
  • Autocorrelated rate inheritance
  • Time and genetic distance tracking
  • Export in FASTA, Newick and JSON formats
  • Complete mutation and lineage-rate history

The relaxed clock engine complements the existing strict clock simulator, providing synthetic datasets for investigating the effects of rate variation on downstream phylogenetic analysis.

Molecular Clock Explorers

The project includes interactive Streamlit applications built directly on top of both simulation engines.

Strict Molecular Clock Explorer

The Strict Molecular Clock Explorer provides an interactive interface for experimenting with the strict molecular clock model.

Simulation parameters can be adjusted before generating a new evolutionary history and visualising the resulting ultrametric phylogenetic tree.

The explorer provides an intuitive way to investigate how sequence length, mutation rate and tree topology influence the simulated dataset.

Relaxed Molecular Clock Explorer

The Relaxed Molecular Clock Explorer extends the same interface to the relaxed molecular clock model.

In addition to the standard simulation controls, it introduces lineage-specific mutation rates and allows the effects of evolutionary rate variation to be explored interactively.

The explorer visualises branch-specific genetic change, observed substitutions and simulation summary statistics, providing an intuitive way to investigate how relaxed molecular clocks differ from the strict clock model.

Both explorers are built on the underlying command-line simulation engines, which remain fully supported for reproducible dataset generation and downstream analysis.

Clone this wiki locally