Downloading the E. coli archives
The four E. coli datasets of The E. coli datasets are served as archives by the tc-data endpoint. A loader constructed with TC_DATA_URL set downloads its archive, checks the sha256, unpacks the store, and opens the records, so no build step and no source file is needed. This page covers what the endpoint serves, what a download leaves on disk, how long it takes, and how to check the records against the knowledge-graph release. The endpoint’s routes, the other file tiers and the curl commands are in Downloading datasets. The code blocks are parts of the tutorial script, ecoli_download_tutorial.py.
Terms used below:
archive: one
tar.xzfile holding one store, named<slug>-<torchcell version>-<first eight hex digits of its sha256>.tar.xz.content hash: the sha256 over the sorted experiment ids of a dataset. An experiment id is the sha256 of one record’s
experiment, and each knowledge-graph release records one content hash per dataset.slug: the directory name of a store, which is also the dataset’s name on the endpoint.
store: the built form of a dataset. Its
processed/directory holds the records LMDB and theinternedLMDB beside it, and itspreprocess/directory holds the build manifest and the tables the loader wrote.
Set the endpoint
import hashlib
import json
import os
from pathlib import Path
from typing import Any
import numpy as np
import pandas as pd
from torchcell.datasets.artifact import content_sha256
from torchcell.datasets.client import DatasetClient
from torchcell.datasets.ecoli.babu2014 import GeneInteractionBabu2014Dataset
from torchcell.datasets.ecoli.campos2018 import (
FEATURE_UNITS,
MORPHOLOGY_ASSAY,
GrowthRateCampos2018Dataset,
MorphologyCampos2018Dataset,
)
from torchcell.datasets.ecoli.fuhrer2017 import MetabolomeFuhrer2017Dataset
from torchcell.endpoint_http import DEFAULT_URL
from torchcell.sequence.genome.standard import genome_for, standard_genomes
# A loader downloads its built store only when TC_DATA_URL is set. Without it the loader
# builds the store from the publisher's files, which is the developer path.
os.environ.setdefault("TC_DATA_URL", DEFAULT_URL)
os.environ.setdefault("DATA_ROOT", ".") # genome files go to ./torchcell-genomes/
DATA = Path("data/torchcell") # each dataset unpacks into DATA/<slug>/
pd.set_option("display.precision", 4)
def brief(value: Any, depth: int = 1) -> Any:
"""A record part with anything nested deeper than ``depth`` replaced by its size."""
if isinstance(value, dict):
kept = {k: v for k, v in value.items() if k != "provenance_gaps"}
if depth < 0:
return f"<{len(kept)} fields>"
return {k: brief(v, depth - 1) for k, v in kept.items()}
if isinstance(value, list):
return f"<{len(value)} items>" if value else []
return getattr(value, "value", value) # an enum member prints as its value
def show(part: dict[str, Any]) -> None:
"""Print one part of a record as indented JSON, two levels deep."""
print(json.dumps(brief(part), indent=2, default=str))
DEFAULT_URL is the public endpoint. It takes no key and no account. A loader downloads only when TC_DATA_URL is set in the process environment. With the variable unset, the same constructor builds the store from the publisher’s files, which needs the raw-file mirror of a development machine.
See what the endpoint serves
client = DatasetClient.from_env()
print("endpoint", client.url)
SLUGS = (
"ecoli_growth_rate_campos2018",
"ecoli_morphology_campos2018",
"gene_interaction_babu2014",
"metabolome_fuhrer2017",
)
for slug in SLUGS:
artifact = client.select(slug) # newest archive the installed major.minor reads
if artifact is None:
raise SystemExit(f"{client.url} serves no {slug} archive this torchcell reads")
print(slug)
print(f" loader {artifact.dataset_class}")
print(f" archive {artifact.archive} ({artifact.archive_bytes:,} bytes)")
print(f" records {artifact.n_experiments:,}")
print(f" release knowledge graph {artifact.kg_version} ({artifact.kg_release})")
endpoint http://torchcell-database.ncsa.illinois.edu:8724
ecoli_growth_rate_campos2018
loader GrowthRateCampos2018Dataset
archive ecoli_growth_rate_campos2018-1.8.4-ef455265.tar.xz (144,152 bytes)
records 3,664
release knowledge graph 4.0 (2026.10.17-4295f7ca)
ecoli_morphology_campos2018
loader MorphologyCampos2018Dataset
archive ecoli_morphology_campos2018-1.8.4-52643bef.tar.xz (856,456 bytes)
records 3,664
release knowledge graph 4.0 (2026.10.17-4295f7ca)
gene_interaction_babu2014
loader GeneInteractionBabu2014Dataset
archive gene_interaction_babu2014-1.8.4-412a73ed.tar.xz (1,049,192 bytes)
records 42,705
release knowledge graph 4.0 (2026.10.17-4295f7ca)
metabolome_fuhrer2017
loader MetabolomeFuhrer2017Dataset
archive metabolome_fuhrer2017-1.8.4-7eb33983.tar.xz (81,780,576 bytes)
records 3,806
release knowledge graph 4.0 (2026.10.17-4295f7ca)
select returns the newest archive whose torchcell_version shares the installed major.minor, and None when the endpoint has no such archive. An archive name includes the version it was packaged with, and every release on that major.minor line reads it.
Download by constructing a loader
growth = GrowthRateCampos2018Dataset(root=str(DATA / "ecoli_growth_rate_campos2018"))
print(f"{len(growth):,} records")
3,664 records
The constructor did the download. After it returns, data/torchcell/ecoli_growth_rate_campos2018/ holds the archive under artifacts/ and the store under processed/ and preprocess/. A second construction with the same root opens the store without a request. The other three loaders work the same way, each with its own slug as the directory name.
What a download costs
The seconds below run from the call of a loader’s constructor on an empty directory to the opened store. They cover the index request, the download, the sha256 check, and the unpacking.
Dataset |
Archive (MB) |
On disk after unpacking (MB) |
Seconds on gilahyper |
Seconds on radiant |
|---|---|---|---|---|
Campos 2018, growth rate |
0.14 |
14.0 |
0.18 |
0.67 |
Campos 2018, imaging |
0.86 |
14.0 |
0.21 |
0.51 |
Babu 2014, genetic interaction |
1.05 |
177.9 |
0.63 |
1.30 |
Fuhrer 2017, metabolome |
81.8 |
796.8 |
7.98 |
12.24 |
All four |
83.8 |
1002.7 |
9.00 |
14.73 |
Check the records against the release
The endpoint’s index row holds the content hash the knowledge-graph release recorded for the dataset. Hashing the loaded records the same way reproduces it when the download holds exactly the records the graph serves.
def experiment_id(record: dict[str, Any]) -> str:
"""The id the knowledge graph gives this record: sha256 of its experiment."""
return hashlib.sha256(json.dumps(record["experiment"]).encode("utf-8")).hexdigest()
for slug, dataset in loaded.items():
ids = (experiment_id(dataset[i]) for i in range(len(dataset)))
digest = content_sha256(ids) # one hash over every record of the dataset
served = client.select(slug).content_sha256 # what the release recorded
print(
f"{slug} {digest} {'matches' if digest == served else 'DIFFERS FROM'} the release"
)
ecoli_growth_rate_campos2018 a8ced65c7e68b1d673ad404f001dc47fb9807db7cc3b131282bf532d10f7e11c matches the release
ecoli_morphology_campos2018 15d7c23e9300015d48426f8b7e813aec540bd5a9854e8392b7ab1eef19836e6b matches the release
gene_interaction_babu2014 fb1f87b2c861a2df6e06bfe8abdcb71bbd46ff77fe56ba2c53996a65f2584f10 matches the release
metabolome_fuhrer2017 adeb2d85353f426d3a775eab4c09e99e97c47b9c3b96be6684c54cfa6d2162bd matches the release
The archives
Archive |
sha256, first 16 |
Content hash, first 16 |
Store built at commit |
Store built on |
Packaged with torchcell |
Knowledge-graph release (version) |
|---|---|---|---|---|---|---|
|
|
|
|
2026-10-16 |
1.8.4 |
2026.10.17-4295f7ca (4.0) |
|
|
|
|
2026-10-16 |
1.8.4 |
2026.10.17-4295f7ca (4.0) |
|
|
|
|
2026-10-16 |
1.8.4 |
2026.10.17-4295f7ca (4.0) |
|
|
|
|
2026-10-16 |
1.8.4 |
2026.10.17-4295f7ca (4.0) |
The archives were packaged by scripts/package_dataset_lmdb.py from the stores the loaders built.
Caveats
A loader builds instead of downloading when TC_DATA_URL is unset. torchcell does not read a .env file by itself, and the built-in DEFAULT_URL does not switch a loader to the download. Set the variable in the shell or in the process before the first constructor, as the setup block does.
An archive is tied to a major.minor line. select returns None for an installed version on another line, and the loader then raises and names the slug. It does not fall back to building.
torchcell 1.8.4 and earlier need torch-scatter before a loader imports. From 1.8.5 the loaders import without it (Install timings and release checks).