All courses / Data engineering / Series 1

Data Engineering for Chemistry · Series 1

Data Engineering for Cheminformatics

From SDF files to chemical data pipelines that scale to millions of molecules, survive failures and can be trusted.

Starts January 202715 modules Beginner-friendly, every term explainedFree

Start here

  1. Open Module 1 and read it on any device.
  2. To run its code, click Open this lesson in Google Colab in its Get set up box: you need only a free Google account, nothing to install.
  3. New to notebooks? Start here shows every step, and what each word means.

The big picture: a chemist thinking like a data engineer

The problem

Every week, three suppliers send your group their catalogues as SDF and SMILES files, and ChEMBL publishes new activity data. Together that is about two million molecules, and it keeps growing. Some structures will not parse, the same compound arrives under five different names, one supplier quietly changes its file format, and last month's numbers cannot be rebuilt. Your colleagues want one clean, de-duplicated, searchable library, refreshed every Monday, that their models can train on and that can be traced back to its sources. Doing it by hand takes a week, and nobody can repeat it exactly.

How do you build a pipeline that does it for you, reliably, every week?

A chemist would solve this one file at a time. A data engineer solves it once, for every file, every week, without anyone watching. The diagram is that solution, step by step, with the module that teaches each step. Choose a step to see why it matters, how it is done, where the course covers it and when it happens.

The path of the data

  1. Bring it in

  2. Make it right

  3. Put it to use

At every step

1Sources

The chemist asksWhere did these molecules come from, and can I trust them?

The data engineer answersKnow every source, its format and its quirks, before reading a single record.

Why
Chemical data arrives from instruments, supplier catalogues, public databases and lab notebooks, each in its own format and each with its own errors. A pipeline is only as good as what it is fed.
How
  • Supplier SDF and SMILES files
  • ChEMBL and PubChem web services
  • Electronic lab notebooks and instrument exports
  • A record of where every file came from
When
Before anything else, and again whenever a new source is added.

2Read and represent

The chemist asksWhat is a molecule to a computer?

The data engineer answersChoose the representation that fits the job: a graph, a matrix, a string or a fingerprint.

Why
Every later step, from validation to machine learning, works on a representation. Choosing the wrong one loses information (stereochemistry, charges) or makes a fast job slow.
How
  • Molecules as graphs with NetworkX
  • Adjacency and bond-order matrices in NumPy
  • SMILES, SMARTS, InChI and fingerprints
  • Reading files with RDKit and Open Babel, and seeing where toolkits disagree
When
Every time a molecule is read in or handed to another tool.

3Ingest

The chemist asksNew compounds arrived this week. Do I have to start again?

The data engineer answersLoad only what is new, safely, so running the job twice gives the same result.

Why
Re-downloading and reprocessing everything wastes hours and hides what changed. Ingestion that is incremental and repeatable can run every night.
How
  • Watermarks: remember how far the last run got
  • Idempotent loads that can be repeated safely
  • Polite API use: paging, retries and rate limits
  • Identity by InChIKey, so the same compound is not loaded twice
When
On a schedule (nightly, weekly) or when a supplier sends a file.

4Validate molecules

The chemist asksIs this structure even chemically possible?

The data engineer answersCheck every structure and record why each rejected one was rejected.

Why
One broken structure (an impossible valence, an unexpected element) can crash a job or, worse, pass silently into a model. Catching it at the door is cheap; finding it later is not.
How
  • Parsing and sanitisation errors
  • Valence, element, charge and size rules
  • Fix, reject or quarantine, with the reason kept
When
As soon as data is read, before it is stored.

5Standardise and identify

The chemist asksAre these two entries the same compound?

The data engineer answersPut every structure in one agreed form, then give it one identity.

Why
Salts, solvents, charges and tautomers make one compound look like many. Without standardisation, counts, joins and models are all wrong.
How
  • Strip salts and solvents, neutralise charges
  • Canonical tautomers with RDKit's rdMolStandardize
  • Tested, versioned standardisation rules
  • InChIKeys for identity and de-duplication
When
After validation, before storing; the same rules every time.

6Check the contract

The chemist asksIs this batch fit for the people who use it?

The data engineer answersAgree what good data looks like, and test every batch against it.

Why
A data contract is a written promise between whoever produces data and whoever uses it: columns, types, units, ranges. Testing it stops a bad batch before it reaches a database or a model.
How
  • Records checked with Pydantic
  • Tables checked with Pandera
  • Units on one scale (nM and pIC50)
  • Stop the batch, or quarantine the bad rows
When
On every batch, before it is published to others.

7Store

The chemist asksWhere do I keep all this so I can find it again?

The data engineer answersModel the data first, then pick the store that fits the questions you will ask.

Why
Relational databases answer structured questions and substructure searches; graph databases follow links between molecules, reactions and targets; columnar files hold millions of rows for analysis.
How
  • Choosing the kind of database for the questions asked: relational or NoSQL (document, key-value, wide-column, graph, vector)
  • Data modelling: entities, relationships, an ER diagram
  • Normalised models for recording, star schemas for analysis
  • Schemas, keys, constraints and indexes
  • Metadata: a data dictionary and provenance columns
  • PostgreSQL with the RDKit cartridge
  • Neo4j and Cypher for linked data
  • Parquet and DuckDB for analysis
  • Migrations when the schema changes
When
Once data has passed its checks: one place everybody reads from.

8Compute at scale

The chemist asksMy laptop runs out of memory at a million molecules. Now what?

The data engineer answersStream data in batches, use every core, and spread work across machines when one is not enough.

Why
Virtual libraries now hold billions of molecules. Code that loads everything at once stops working long before that.
How
  • Streaming and batching with generators
  • Compact types and memory measurement
  • joblib on one machine, Dask across many
When
Whenever the data no longer fits in memory or a job takes too long.

9Serve

The chemist asksHow do my colleagues, my models and my dashboards use this?

The data engineer answersPublish clean, documented, versioned data that others can rely on.

Why
Data is only worth the questions it answers: a search, a dashboard, a training set for a model, the tools an AI agent calls.
How
  • Queries and search
  • Machine-learning-ready tables
  • Dashboards and reports
  • Models and agents (later courses)
When
Continuously, to whoever needs it.

Series 2 swaps the hand-built parts for industry tools; MLOps for Chemists and Agentic AI in Chemistry build on what is served here.

Reliability

The chemist asksThe job failed at molecule 600,000. Do I start again?

The data engineer answersDesign every step to fail safely and carry on from where it stopped.

Why
Long jobs fail: a network drops, a machine restarts, one record is malformed. A reliable pipeline loses minutes, not days.
How
  • Checkpoints and resume
  • Retries with back-off for temporary errors
  • Quarantine for records that will never work
  • Atomic writes, so a half-written file never counts as done
  • Long jobs on a server or virtual machine, in tmux, so they outlive your connection
When
At every step, from the first line of a pipeline.

Versioning

The chemist asksCan I rebuild last month's result exactly?

The data engineer answersVersion code, environments, schemas, rules, data and results, and record which went into what.

Why
A number nobody can reproduce cannot be trusted or published. Versioning everything makes every result traceable.
How
  • Git commits and tags
  • Lock files and container images
  • Numbered database migrations
  • Content hashes, manifests and DVC
  • A provenance record next to every output
When
Whenever anything changes, and at every run.

Monitoring

The chemist asksHow do I know something went wrong before someone else tells me?

The data engineer answersLog, measure and alert, so problems show up while they are small.

Why
Pipelines fail quietly: a supplier changes a format, a rejection rate creeps up, a job slows down. Monitoring turns silent failures into alerts.
How
  • Structured logs instead of print
  • Metrics for every run
  • Drift and quality checks
  • Alerts with clear rules
When
On every run, and between runs.

Orchestration and tools

The chemist asksWho runs all of this, in the right order, every night?

The data engineer answersHand the schedule, the order and the retries to an orchestrator, once you understand what it does.

Why
Series 1 builds each idea by hand so you know what the tools do. Series 2 then hands the work to industry tools that do it at scale.
How
  • The capstone pipeline, end to end (Series 1)
  • dlt, DuckDB, dbt and Prefect (Series 2)
When
When a pipeline must run regularly without you.

Fifteen modules on the engineering that sits between raw chemical files and machine learning. It starts with how molecules are represented and stored, in relational and graph databases; then the course turns to what breaks in practice: libraries too big for memory, jobs that need many cores, pipelines that fail halfway, data that drifts, and results nobody can reproduce. Each idea is built by hand first, so you understand it before Series 2 hands it to industry tools.

The cohort starts in January 2027, with one module a week. The modules already written are open now: you can start reading and running them today, on your own.

Modules

  1. Foundations
  2. 1

    Molecules as graphs and matrices

    A molecule is a graph: atoms are nodes, bonds are edges. Build it in NetworkX, write it as adjacency, bond-order and distance matrices, encode atom and bond properties (weights, one-hot features, bond tensors, edge lists), and compute on it with NumPy, up to one step of message passing.

    RDKitNetworkXNumPypandas
    Read the lesson →
    Open to read
  3. 2

    Molecules as text, patterns and numbers

    SMILES (canonical and isomeric), InChI and InChIKey, molfiles and SDF, 3D conformers, SMARTS patterns, fingerprints and descriptors: what each keeps, what each loses (stereochemistry, tautomers, aromaticity), and which to store for which job.

    RDKitpandas
    Read the lesson →
    Open to read
  4. 3

    Chemical files and identity

    The files molecules travel in (SDF, SMILES, CSV, Parquet), what each costs in space and time, and a stable identity for every molecule (InChIKey) so duplicates can be found.

    RDKitPyArrowParquet
    Read the lesson →
    Open to read
  5. 4

    Databases, schemas and a chemical database

    What a database is, the main kinds (relational, and the NoSQL kinds such as MongoDB and Neo4j), and which questions each answers best. How to plan the tables for chemical data before storing anything, and how to describe them so others can use them. Then run PostgreSQL with its RDKit chemistry add-on in Docker, log in safely, search molecules by substructure and similarity, and analyse a library quickly with DuckDB.

    PostgreSQLRDKit cartridgeDuckDBSQLDocker
    Read the lesson →
    Open to read
  6. 5

    Molecules as graphs, and graph databases

    A molecule is a graph: atoms are nodes, bonds are edges. Work with it as one (rings, paths, substructure as subgraph matching, maximum common substructure), then store chemistry in a graph database: molecules linked to reactions, targets and assays, queried with Cypher. Compare it with the relational database and see where each one wins.

    RDKitNetworkXNeo4jCypher
    Read the lesson →
    Open to read
  7. 6

    Validating molecules

    Catch broken structures before they spread: parsing and sanitisation errors, impossible valences, unexpected elements and charges, missing or contradictory stereochemistry, size limits; decide what to fix, what to reject and how to record why.

    RDKit
    Read the lesson →
    Open to read
  8. 7

    Standardisation as a tested transformation

    Strip salts, neutralise charges and choose one tautomer as a pure, deterministic function with versioned rules and unit tests.

    RDKit MolStandardizepytest
    Read the lesson →
    Open to read
  9. Scale
  10. 8

    Libraries larger than memory

    Stream molecules in batches instead of loading them all, write partitioned Parquet, and query far more rows than fit in memory; measure memory and throughput as you go.

    PyArrowParquetDuckDB
    Read the lesson →
    Open to read
  11. 9

    Parallel and distributed processing

    Spread standardisation and fingerprints across cores with joblib, then across memory and machines with Dask: chunk sizes, passing SMILES instead of molecule objects, when parallel work stops helping, and a scaling curve; the same code on Windows, macOS and Linux.

    joblibDask
    Read the lesson →
    Open to read
  12. Reliability
  13. 10

    Pipelines that survive failure

    Idempotent steps, checkpoints and cached results, resuming from the last good batch, retries with back-off, atomic writes, quarantining bad molecules instead of crashing, settings checked before a run starts, and running long jobs on a server or virtual machine with tmux.

    Pythonjoblib.MemoryPydantic settingsPostgreSQLtmux
    Read the lesson →
    Open to read
  14. 11

    Incremental ingestion from ChEMBL and PubChem

    Fetch only what changed, page through APIs within their rate limits, cache responses, check every response against a model so a changed API fails loudly, and run backfills safely.

    ChEMBL and PubChem APIsPydanticParquet
    Read the lesson →
    Open to read
  15. 12

    Validating data: records with Pydantic, tables with Pandera

    Check single records at the edges with Pydantic and whole batches in bulk with Pandera: column types, required fields, value ranges, units (nM, µM, pIC50), duplicates, links between tables, and counts that agree across sources; measure why a million rows are not checked one at a time; stop or quarantine a batch that fails, and report why.

    PydanticPanderaRDKitPostgreSQL
    Read the lesson →
    Open to read
  16. 13

    Versioning everything

    Version code, environments, database schemas, standardisation rules, datasets and results, so any number can be traced back and rebuilt exactly.

    GituvDockerSQL migrationsDVC
    Read the lesson →
    Open to read
  17. 14

    Monitoring pipelines

    Structured logs, run history, counts in and out that must reconcile, throughput and error rates, freshness, drift in molecular properties, and alerts when something goes wrong.

    Python loggingPostgreSQLalerts
    Read the lesson →
    Open to read
  18. Capstone
  19. 15

    Capstone: a resumable, monitored pipeline over a large library

    Standardise, deduplicate, filter and fingerprint millions of molecules end to end; stop it halfway, resume it, version the output and show that every count reconciles.

    Everything above
    Read the lesson →
    Open to read