EMDB: Electron Microscopy Data Bank: sample notebook
A worked notebook for EMDB: Electron Microscopy Data Bank, with 11 code cells and the output each one printed. On Scigantic it opens in a hosted JupyterLab with the dataset already mounted, so nothing is downloaded first.
- Provider
- EMBL-EBI (EMDB)
- License
- CC0 1.0 — EMBL-EBI places all primary and derived EMDB data in the public domain
- Stored at
- ftp.ebi.ac.uk
- Access
- Free and public. No account with the data provider is needed.
- DOI
- 10.1093/nar/gkad1019
The notebook
EMDB: every cryo-EM structure, searchable
The Electron Microscopy Data Bank holds the 3D density maps produced by cryo-EM, cryo-ET and volume-EM, together with the half-maps, masks and metadata documenting how each was determined. The whole archive is mounted read-only here, and nothing is downloaded until you read it.
EMDB is the processed counterpart to EMPIAR: EMPIAR holds the raw movies, EMDB holds the reconstruction computed from them. Both are available here and cross-reference each other.
The hard part of EMDB is not reading a map. A map is 20-60 MB and mrcfile opens it. The hard part is finding the right one among tens of thousands, which is what scigantic_emdb is for.
from scigantic_emdb import EmdbCatalog
cat = EmdbCatalog()
cat.coverage() # what this index actually holds, measured at build time
1 - Search by science, not by accession
search() matches across title, sample name, organism, method and cross-references, with cryo-EM synonyms, so "cryoET" also reaches entries spelled "cryo-ET". What you literally typed always ranks first.
# Free text runs over title, sample name, organism, method and accessions.
cat.search("spliceosome", max_res=3.5, limit=10)
Filters compose: max_res / min_res (Å), organism, method, has_pdb, has_uniprot, year / min_year / max_year, and sort= one of relevance, resolution, year, id.
# Filters compose. Resolution is in Angstrom, lower being better.
cat.search("GPCR", organism="Homo sapiens", has_pdb=True,
sort="resolution", limit=10)
Molecular filters come from the deposition, so they are powerful but not universal. max_chain_kda is the largest single protein chain, which is what you want for "a receptor under 100 kDa" — the assembled complex is almost always heavier than the molecule of interest. Check cat.coverage() for how many entries carry a weight before reading a result count as the whole picture.
# max_chain_kda is the largest single protein chain, not the whole assembly.
# That distinction matters: a receptor sits in a complex with its G protein and
# nanobodies, so filtering on the complex weight finds the wrong structures.
hits = cat.search("GPCR", max_chain_kda=100, max_res=3.5, has_half_maps=True)
hits[["id", "sample_name", "resolution_a", "max_chain_kda", "complex_kda"]].head(10)
EBI has already rendered an isosurface for about 97% of entries, so a gallery costs no map reads. The catalog stores the filename and the card points at EBI's public URL; nothing is copied.
# EBI publishes a rendering for ~97% of entries, so a gallery costs no reads.
cat.gallery(hits.head(8))
2 - Load one and look at it
Maps are gzipped CCP4/MRC volumes. load_map decompresses to local disk, caches, and opens — mrcfile needs random access, and the mount fetches bytes lazily over HTTP.
from scigantic_emdb import load_map, slices
vol, meta = load_map("EMD-22962") # decompresses to /tmp, caches, opens
print(meta["shape"], meta["voxel_size_a"], f'{meta["size_mb"]} MB')
slices(vol) # central XY / XZ / YZ sections
3 - Half-maps, masks, FSC
Deposited half-maps let you recompute an FSC rather than trusting the reported resolution. They are not present for every entry, so check rather than assume.
from scigantic_emdb import entry_files
# Half-maps, masks and FSC curves are per-deposition, not universal.
# This returns only what the entry actually has.
entry_files("EMD-22962")
4 - Which of these can I reprocess?
The structures worth reprocessing are the ones whose raw data is also public. EMDB knows the science, EMPIAR knows the availability, and joining them answers a question neither can alone.
# EMDB says what was solved; EMPIAR says whether the raw movies are public.
# has_raw_data makes that one filter rather than a join, and sort="raw_size"
# puts the cheapest to reprocess first.
cat.search("GPCR", max_res=3.0, has_raw_data=True,
sort="raw_size", limit=10)[
["id", "title", "resolution_a", "empiar_ids", "raw_size_gb"]]
Cryo-EM raw data is enormous, so scope it to what you can actually download. Of the sub-3 Å GPCR structures with public movies, none is under 1 TB and the cheapest is 1,331 GB. Only 8.2% of EMDB has public raw data at all, because most groups never deposit it.
# Scope it to what you can actually pull down. Cryo-EM raw data is enormous:
# of the sub-3 A GPCR structures with public movies, none is under 1 TB.
cat.search("ribosome", has_raw_data=True, max_raw_gb=2000, sort="raw_size")
# The full pairing, when you want the EMPIAR entries themselves.
cat.with_empiar(cat.search("GPCR", max_res=3.0, has_raw_data=True))
5 - Drugs and their targets
A drug bound to its target is a complex carrying a bound molecule, so those two filters together are the pharmacology query. has_ligand deliberately ignores the magnesium ions, water, glycosylation sugars and detergents that make up most deposited "ligands" — use ligand="..." if you want to match those by name.
# A drug bound to its target is a COMPLEX with a bound molecule. has_ligand
# counts nucleotides, cofactors and drugs but not the magnesium ions, water,
# sugars and detergents that make up 62% of deposited "ligands".
cat.search(min_proteins=2, has_ligand=True, has_model=True,
max_res=3.5, limit=10)[
["id", "title", "n_proteins", "ligands", "resolution_a"]]
Make it yours
Change the query and rerun. cat.entry("EMD-0339") returns one row; load_map takes any accession.
Do not list the mount root. There are ~60,900 entries and enumerating them takes about 23 seconds. Search the catalog instead, then address entries by accession.
The AI panel on the right knows this archive and this library. Try *"find sub-3 Å human GPCR structures from 2024 and show me the best one"*.
Run it
Open this notebook to run it, see the dataset page for the full description, or browse the full catalog.