Databases (Python)#

geckopy objects in geckopy.databases.

Functions#

Function

Summary

aggregate_and_write

Group rows by (kind, ec, substrate, organism) and write three TSVs.

BrendaData

Loaded BRENDA tables.

BrendaDownloadError

Raised when the BRENDA bulk JSON cannot be located or validated.

calculate_mw

Compute the molecular weight of a protein from its sequence.

ComplexPortalEntry

One ComplexPortal complex.

DLKcatIgnoreLists

Lists of metabolites to skip when writing DLKcat input.

download_kegg

Download per-gene KEGG data for kegg_id and write to out_path.

download_phyl_dist

Download the KEGG phylogenetic distance file distributed with RAVEN.

download_uniprot

Download UniProt protein data for an organism and write a TSV.

ensure_brenda_json

Return the path to the unpacked BRENDA JSON, extracting if needed.

extract_brenda_json

Extract the single JSON member from a BRENDA tarball.

fetch_brenda_asset

Download (once) the BRENDA files and return the folder that holds them.

find_met_smiles

Populate metabolite.annotation['smiles'] from PubChem.

FluxData

Per-condition flux measurements with per-reaction exchange data.

get_complex_data

Download complex stoichiometries from EBI Complex Portal.

KeggDB

Parsed kegg.tsv. Arrays are aligned: row i in every field

load_brenda_data

Load BRENDA kcat, SA, and MW dumps from a folder.

load_brenda_measurements

The BRENDA measurement table of a BRENDA folder.

load_complex_portal_json

Parse a ComplexPortal JSON file into a list of entries.

load_dlkcat_ignore_lists

Load the two DLKcat ignore-list TSV files.

load_flux_data

Parse a GECKO fluxData.tsv into a FluxData.

load_kegg_tsv

Parse a kegg.tsv into a KeggDB.

load_pax_db

Parse a paxDB.tsv file and return a ProtData.

load_phyl_dist

Load a KEGG phylogenetic distance struct from a MATLAB .mat file.

load_prot_data

Load (and optionally filter) absolute proteomics data.

load_uniprot_tsv

Parse a uniprot.tsv file into a UniprotDB.

met_smiles

The metabolite's SMILES, whatever shape its annotation is in.

parse_brenda_json

Yield one Row per (kind, EC, substrate, organism) measurement.

PhylDist

KEGG phylogenetic distance structure.

ProtData

Pre-loaded proteomics data for f-factor and concentration filling.

Row

One measurement yielded by parse_brenda_json.

sha256_of

Return the hex sha256 digest of a file's contents.

UniprotDB

Parsed uniprot.tsv. Arrays are aligned: row i in every field

Reference#

aggregate_and_write#

aggregate_and_write(rows: Iterable[Row], out_dir: str | Path, *, release: str, date: str | None=None)

Group rows by (kind, ec, substrate, organism) and write three TSVs.

For kcat and SA the snapshot keeps one wide row per triple with both max and median columns; for MW only the per-triple max is written.

Parameters

rows

Iterable of Row from parse_brenda_json.

out_dir

Output directory for kcat.tsv, sa.tsv, mw.tsv. Created if missing.

release

BRENDA release string, e.g. "2026.1". Written into the header line of each TSV.

date

ISO date string for the header. Defaults to today.

Returns

dict

Mapping of Kind to written path.

BrendaData#

Loaded BRENDA tables.

Each kcat / SA table is exposed as separate _max and _median DataFrames built once at load time. Both views share the same row set (one per (ec, substrate, organism) triple); they differ only in which aggregation of the raw measurements fills the kcat column. Choose between views via kcat_for / sa_for.

Attributes

kcat_max, kcat_median

DataFrames with columns ec_code (str), substrate (str), organism (str), kcat (float, 1/s), n (Int64).

sa_max, sa_median

Same shape, joined with MW to give an SA-derived kcat. Columns ec_code, organism, kcat (float, 1/s), mw (float, g/mmol), n (Int64).

BrendaDownloadError#

Raised when the BRENDA bulk JSON cannot be located or validated.

calculate_mw#

calculate_mw(sequence: str)

Compute the molecular weight of a protein from its sequence.

Ported from GECKO MATLAB: src/geckomat/get_enzyme_data/calculateMW.m.

Each residue contributes its average mass; one water mass is added once (representing the H + OH at the peptide termini, equivalent to one un-eliminated water relative to N residues + N water masses).

Recognized amino acid codes (the sequence is uppercased first, so matching is case-insensitive):

ACDEFGHIKLMNPQRSTVWY  - the 20 standard residues
BJOZUX                - non-standard / ambiguous codes

Whitespace and digits are skipped silently. Any other unrecognized character is also skipped, but triggers one warning per call listing every distinct offending character.

Parameters

sequence

Protein sequence as a string. May contain whitespace, digits, and other non-letter characters; those are ignored.

Returns

float

Molecular weight in g/mol (Da). Returns nan for an empty/all-skipped sequence (no residues), so a missing sequence is not mistaken for an 18 Da "protein".

ComplexPortalEntry#

One ComplexPortal complex.

The JSON field name stochiometry (a typo in the original ComplexPortal API) is renamed to stoichiometry here. The field geneName is renamed to gene_names for Python conventions. Both renames happen only on this in-memory object; the JSON file itself is untouched.

DLKcatIgnoreLists#

Lists of metabolites to skip when writing DLKcat input.

Attributes

ignore_names

Normalized (lowercase, alphanumeric-only) metabolite names to skip entirely.

ignore_smiles

SMILES strings to skip; matched as-is against metabolite.annotation['smiles'].

currency_pairs

Pairs of normalized metabolite names. When both halves of a pair appear in the same reaction, both are stripped from that reaction's substrates (unless removal would leave no substrates).

download_kegg#

download_kegg(kegg_id: str, out_path: str | Path, *, gene_id_field: str='kegg', session: requests.Session | None=None)

Download per-gene KEGG data for kegg_id and write to out_path.

Parameters

kegg_id

KEGG organism code, e.g. "sce".

out_path

Destination CSV path (overwritten if it exists).

gene_id_field

KEGG entry field to use as the gene matching key in col 2. "kegg" (default) copies the bare KEGG gene ID from ENTRY. Other values name an alternative annotation line (e.g. "OrderedLocus"), which is matched on the prefix.

session

Optional requests.Session for connection reuse and test injection. A new transient session is created if absent.

Returns

Path

The written out_path.

Raises

RuntimeError

If the organism list cannot be retrieved or a KEGG request is rejected (e.g. an invalid organism code). Batches that come back with fewer entries than requested are not an error; the missing gene IDs are skipped with a debug log.

ValueError

If gene_id_field is not present in any returned entry.

download_phyl_dist#

download_phyl_dist(out_path: str | Path, *, url: str=KEGG_PHYL_DIST_URL, session: requests.Session | None=None)

Download the KEGG phylogenetic distance file distributed with RAVEN.

fuzzy_kcat_matching uses it to pick the evolutionarily closest organism when BRENDA has no entry for the model's own organism. The file covers all KEGG organisms (~5 MB). It is written to a temporary file next to out_path and only moved into place once load_phyl_dist can read it, so a failed download never leaves a partial file at out_path.

Parameters

out_path

Destination .mat path (overwritten if it exists), typically adapter.get_phyl_dist_path().

url

Source URL. Defaults to keggPhylDist.mat of RAVEN 3.0.0b1.

session

Optional requests.Session for connection reuse and test injection. A new transient session is created if absent.

Returns

Path

The written out_path.

Raises

requests.HTTPError

If the download fails.

KeyError

If the downloaded file is not a phylDistStruct .mat file.

download_uniprot#

download_uniprot(uniprot_id: str | int, out_path: str | Path, *, id_type: str='taxonomy_id', gene_id_field: str='gene_oln', reviewed: bool=True, session: requests.Session | None=None)

Download UniProt protein data for an organism and write a TSV.

Parameters

uniprot_id

UniProt-side identifier whose meaning depends on id_type. For id_type='taxonomy_id' this is an NCBI taxonomy ID (e.g. 559292 for Saccharomyces cerevisiae S288C).

out_path

Destination TSV path (overwritten if it exists).

id_type

UniProt query field for uniprot_id. Default "taxonomy_id". MATLAB's adapter accepts the alias "taxonomy"; pass either.

gene_id_field

UniProt field that becomes the second column (the gene matching key). Default "gene_oln" (Ordered Locus Names) works for most prokaryotes and budding yeast.

reviewed

If True (default), restrict the query to reviewed (Swiss-Prot) entries.

session

Optional requests.Session for connection reuse and test injection. A new transient session is used otherwise.

Returns

Path

The written out_path.

Raises

RuntimeError

If the UniProt request fails after retries.

ensure_brenda_json#

ensure_brenda_json(cache_dir: str | Path, *, expected_sha256: str | None=None)

Return the path to the unpacked BRENDA JSON, extracting if needed.

Look-up order in cache_dir: 1. *.json already unpacked: return as-is. 2. *.json.tar.gz tarball: validate expected_sha256 (if given), extract the single JSON member, return its path. 3. Neither present: raise BrendaDownloadError with instructions for manual download.

Parameters

cache_dir

Directory in which the user drops the BRENDA download. Created if missing.

expected_sha256

If given, the tarball must hash to this value or the function raises BrendaDownloadError. Ignored when only an unpacked .json is present.

Returns

Path

Absolute path to the unpacked BRENDA JSON.

extract_brenda_json#

extract_brenda_json(tarball_path: str | Path, dest_dir: str | Path)

Extract the single JSON member from a BRENDA tarball.

Parameters

tarball_path

Path to brenda_<release>.json.tar.gz.

dest_dir

Directory to extract the JSON into. The file is written under its name as stored inside the tarball.

Returns

Path

Path to the extracted JSON file.

fetch_brenda_asset#

fetch_brenda_asset(files: Iterable[str]=TABLES)

Download (once) the BRENDA files and return the folder that holds them.

Parameters

files

File names without .gz (default: kcat.tsv, sa.tsv, mw.tsv and measurements.tsv); further files of the release are sequences.fasta, substrates.tsv and kcatCombineParams.tsv.

Returns

pathlib.Path

The cache folder with the files, decompressed.

find_met_smiles#

find_met_smiles(model: 'cobra.Model', *, cache_path: Optional[Path]=None)

Populate metabolite.annotation['smiles'] from PubChem.

Ported from GECKO MATLAB: src/geckomat/change_model/findMetSmiles.m.

For every metabolite in the model:

  1. Skip if the name starts with prot_ (enzyme pseudometabolite).

  2. Skip if annotation['smiles'] is already set.

  3. Look up the metabolite name in the local TSV cache.

  4. If still not found, query PubChem; cache the result.

The same metabolite name may appear on many cobra.Metabolite instances (different compartments). Lookup is done once per unique name and the SMILES is applied to every metabolite sharing that name.

Parameters

model

A cobra.Model. Mutated in place: each metabolite gains annotation['smiles'] when a SMILES is found.

cache_path

Path to the SMILES cache TSV. If None, defaults to model.adapter.params.path / "data" / "smilesDB.tsv" if the model is an EcModel with adapter; otherwise raises ValueError. The file is created if missing and appended to as new SMILES are downloaded.

FluxData#

Per-condition flux measurements with per-reaction exchange data.

Attributes

conds

Names of the experimental conditions / samples.

p_tot

Total protein content per condition, g/gDCW. Shape (n_conds,).

gr_rate

Measured growth rate per condition, 1/h. Shape (n_conds,).

exch_fluxes

Exchange flux per (condition, reaction), mmol/gDCW/h. Shape (n_conds, n_rxns). NaN means "no measurement"; +/-1000 means unconstrained (used by apply_flux_data_constraints).

exch_mets

Metabolite names matching the columns of exch_fluxes.

exch_rxn_ids

Exchange reaction IDs in the model, matching the columns of exch_fluxes and exch_mets.

evotune_rmse_weight

Optional per-condition weights for the evotune-kcat-tuning RMSE term. None if the source file did not have the evotuneRMSEweight column.

source

Optional per-condition free-text describing where the data came from. None if the source file did not have a source column.

get_complex_data#

get_complex_data(taxonomic_id: Optional[int], *, write_to: Optional[Path]=None)

Download complex stoichiometries from EBI Complex Portal.

Ported from GECKO MATLAB: src/geckomat/change_model/getComplexData.m.

Taxonomic ID semantics:

  • A positive integer queries that organism only.

  • 0 queries all organisms (no species filter).

  • None raises ValueError.

The response is post-processed to expand "complexes of complexes": when a Complex Portal entry references other complexes as subunits, those are flattened into one combined protein list with multiplied stoichiometries.

Parameters

taxonomic_id

NCBI taxonomy ID for the organism, or 0 for all organisms.

write_to

Optional path. If given, the data is also written as JSON (matching the MATLAB ComplexPortal.json format) to this path so subsequent runs can use load_complex_portal_json.

Returns

list of ComplexPortalEntry

Parsed and post-processed complexes.

Raises

ValueError

If taxonomic_id is None.

requests.HTTPError

If the API returns an unrecoverable error.

KeggDB#

Parsed kegg.tsv. Arrays are aligned: row i in every field

describes the same KEGG entry.

mw is in Da, matching the file column verbatim.

load_brenda_data#

load_brenda_data(folder: str | Path, *, filter_outlier_kcats: bool=True)

Load BRENDA kcat, SA, and MW dumps from a folder.

Ported from GECKO MATLAB: src/geckomat/get_enzyme_data/loadBRENDAdata.m.

Reads kcat.tsv, sa.tsv, mw.tsv from folder, splits the kcat and SA wide tables into per-aggregation views, applies the GECKO unit conversions, and joins SA + MW on EC + organism (case-insensitive) to produce derived kcat tables.

Unit conventions:

  • KCAT: file values are in 1/s already; no scaling.

  • SA: file values in [umol/min/mg] are multiplied by 1/60 to give [mmol/s/g].

  • MW: file value in [g/mol] is multiplied by 1/1000 to give [g/mmol].

  • Derived kcat in the SA table is SA * MW = [1/s].

Both kcat and SA are loaded as separate max and median views over the raw measurements aggregated per (ec, substrate, organism) triple, so a project can opt into median aggregation via adapter.params.kcat_aggregate_brenda without regenerating the snapshot. See docs/kcat_aggregation.md for the rationale.

Malformed lines (wrong number of fields, non-numeric value column) are skipped with a logger.warning; the rest of the file is parsed normally.

Parameters

folder

Directory containing all three BRENDA dump files.

filter_outlier_kcats

If True (default), drop a row whose kcat is more than 4 orders of magnitude below the typical kcat of its EC before it can be matched to any reaction -- see _filter_outlier_rows for the rationale and mechanism. Set False to reproduce the unfiltered 1.0-era behaviour.

Returns

BrendaData

Both kcat views may be empty if the source files were empty or contained only malformed lines; both SA views may be empty if no SA row matched any MW row.

Raises

FileNotFoundError

If any of the three expected files is missing.

load_brenda_measurements#

load_brenda_measurements(folder: str | Path)

The BRENDA measurement table of a BRENDA folder.

Returns

pandas.DataFrame

Columns as in the file (ec, substrate, substrate_inchikey, organism, taxid, uniprot, seq_id, kcat, temperature, ph, pmid) plus log10_kcat. The release line of the file (e.g. BRENDA release 2026.1) is in attrs["release"].

load_complex_portal_json#

load_complex_portal_json(path: str | Path)

Parse a ComplexPortal JSON file into a list of entries.

Parameters

path

Path to a ComplexPortal.json file. The file is expected to be a JSON array of complex objects with these fields: complexID, name, specie, geneName, protID, stochiometry.

Returns

list of ComplexPortalEntry :

Raises

FileNotFoundError

If the file does not exist.

ValueError

If the file is not valid JSON or any entry is malformed.

load_dlkcat_ignore_lists#

load_dlkcat_ignore_lists(project_data_folder: Path | str | None=None)

Load the two DLKcat ignore-list TSV files.

Looks for DLKcatIgnoreMets.tsv and DLKcatCurrencyMets.tsv in project_data_folder first; falls back to the defaults shipped inside geckopy.data for any file missing from the project folder.

The two files are independent: the project folder may override just one of them.

Ported from GECKO MATLAB: the inline file-loading parts of src/geckomat/gather_kcats/writeDLKcatInput.m.

Parameters

project_data_folder

Project's data/ folder, typically adapter.params.path / "data". If None (or the file is absent there), the geckopy-shipped default is used.

Returns

DLKcatIgnoreLists

Normalized ignore lists ready to feed to write_dlkcat_input.

load_flux_data#

load_flux_data(path: str | Path)

Parse a GECKO fluxData.tsv into a FluxData.

File format (tab-delimited, one header row):

condition  Ptot  grRate  <met1> (<rxn1>)  <met2> (<rxn2>)  ...
c1         0.5   0.4     -10.0            5.0              ...
c2         0.6   0.5     -8.5             4.2              ...

Optional extra columns (in any position):

  • evotuneRMSEweight (float): weights for evotune kcat tuning.

  • source (str): free-text describing the data origin.

Both columns are dropped from the matrix and surfaced on the returned FluxData as evotune_rmse_weight and source.

Ported from GECKO MATLAB: src/geckomat/utilities/loadFluxData.m.

Parameters

path

Path to the TSV file.

Returns

FluxData :

Raises

FileNotFoundError

If path does not exist.

ValueError

If the file has no header row or no exchange columns.

load_kegg_tsv#

load_kegg_tsv(path: str | Path, *, kegg_id: str | None=None, gene_id_field: str='kegg', auto_download: bool=True)

Parse a kegg.tsv into a KeggDB.

If path does not exist and kegg_id is given and auto_download is True, fetches the data via download_kegg first, then parses.

Parameters

path

Path to kegg.tsv. May not exist if kegg_id triggers an auto-download.

kegg_id

KEGG organism code (e.g. "sce"). Required for auto-download; otherwise unused.

gene_id_field

KEGG entry field to use as the gene matching key. Default "kegg" uses column 2, the bare KEGG gene ID.

auto_download

If True (default) and path is missing, trigger download_kegg(kegg_id, path, gene_id_field=...) before parsing. Set to False to keep the loader pure (e.g. tests).

Returns

KeggDB :

Raises

FileNotFoundError

If path does not exist and either auto_download is False or kegg_id is None.

ValueError

If the file has malformed rows.

load_pax_db#

load_pax_db(path: str | Path, uniprot_db: 'UniprotDB')

Parse a paxDB.tsv file and return a ProtData.

The file is tab-delimited with one or more #-prefixed header lines and three data columns: internal_id, gene_id, level. Gene IDs are stripped of any leading <digits>. modifier (paxDB's internal species/version prefix) before matching against uniprot_db.genes. Rows whose gene name is not in the UniProt DB are dropped silently.

Abundance for each surviving row is computed as level * uniprot_db.mw[matched_index]. The returned abundances array is 1-D since paxDB files contain a single column of levels; callers can stack multiple ProtData objects column-wise to form a 2-D array if they want multi-sample averaging.

Ported from GECKO MATLAB: the inline paxDB-parsing block of src/geckomat/limit_proteins/calculateFfactor.m.

Parameters

path

Path to paxDB.tsv.

uniprot_db

Loaded UniProt database, used to resolve gene names to UniProt IDs and look up molecular weights.

Returns

ProtData :

Raises

FileNotFoundError

If path does not exist.

load_phyl_dist#

load_phyl_dist(path: str | Path)

Load a KEGG phylogenetic distance struct from a MATLAB .mat file.

The .mat file is expected to contain a single variable phylDistStruct with fields names (cell of strings) and distMat (N x N numeric matrix). The MATLAB ids field is ignored: fuzzy_kcat_matching never uses it.

Names are stripped of any trailing parenthetical comment, matching MATLAB's regexprep(names, '\s*\(.*', ''). The resulting cleaned names populate two pre-computed lookup maps for fast organism resolution at match time:

  • name_to_index: lowercased full name -> first matching index.

  • genus_to_indices: lowercased genus (first whitespace token) -> all matching indices.

Ported from GECKO MATLAB (inline KEGG_struct helper in src/geckomat/gather_kcats/fuzzyKcatMatching.m).

Parameters

path

Path to PhylDist.mat.

Returns

PhylDist

Populated dataclass.

Raises

FileNotFoundError

If path does not exist.

KeyError

If the .mat file does not contain a phylDistStruct variable with both names and distMat fields.

load_prot_data#

load_prot_data(source: Union[str, Path, ProtData], repl_per_cond: list[int], *, filter_data: bool=True, min_val: float=0.0, max_rsd: float=1.0, max_missing: Union[float, list[float]]=2.0 / 3.0, cut_lowest: float=5.0, add_stdevs: float=1.0)

Load (and optionally filter) absolute proteomics data.

The input file is tab-delimited with one header row and columns uniprot, repl1, repl2, ..., replN where the replicate columns are concatenated across conditions in the order given by repl_per_cond (e.g. [3, 2] -> first three columns are condition 0's triplicate, next two are condition 1's duplicate). Levels are in mg/gDCW.

For each condition, the per-replicate measurements are reduced to a single value per protein:

  1. filter_data=True applies the following pipeline (matching MATLAB):

    • maxMissing: rows with fewer than max_missing * n_replicates strictly-positive measurements have all replicates set to NaN.

    • RSD: rows whose std/mean > max_rsd are set to NaN.

    • Collapse: per-row mean + add_stdevs * std.

    • minVal: collapsed values below min_val -> NaN.

    • Bottom cut: among non-NaN values, the lowest cut_lowest percent are set to NaN.

  2. filter_data=False just takes the per-row mean (NaN-safe).

Rows that end up NaN in every condition are dropped, along with their UniProt IDs.

Ported from GECKO MATLAB: src/geckomat/utilities/loadProtData.m.

Parameters

source

Path to the TSV file, OR a pre-loaded ProtData to re-filter (matching MATLAB).

repl_per_cond

Number of replicates per condition. The total of these must equal the number of replicate columns in the file.

filter_data

Whether to apply the filtering pipeline. When False, every other parameter is unused.

min_val

Minimum collapsed value to keep.

max_rsd

Maximum relative standard deviation per row.

max_missing

Minimum fraction of strictly-positive replicates required. May be a single float (applied to all conditions) or a list of length len(repl_per_cond).

cut_lowest

Percentage of lowest collapsed values to discard per condition.

add_stdevs

Number of standard deviations to add to the per-row mean when collapsing.

Returns

ProtData

abundances shape (n_proteins_kept, n_conditions).

Raises

FileNotFoundError

If a path is given that does not exist.

ValueError

If repl_per_cond is empty, the file has no replicate columns, or the column count does not match.

load_uniprot_tsv#

load_uniprot_tsv(path: str | Path, *, split_gene_cells: bool=False, uniprot_id: str | int | None=None, id_type: str='taxonomy_id', gene_id_field: str='gene_oln', reviewed: bool=True, auto_download: bool=True)

Parse a uniprot.tsv file into a UniprotDB.

If path does not exist and uniprot_id is given and auto_download is True, download_uniprot is invoked first.

Parameters

path

Path to uniprot.tsv. May not exist if uniprot_id triggers an auto-download.

split_gene_cells

If True, rows whose Gene Names cell contains whitespace-separated multiple names are expanded into one row per gene name. All other fields (Entry, EC, MW, sequence) are duplicated across the expanded rows. This matters for organisms where the UniProt gene_oln field returns multiple space-separated ORF names per entry: with the default of False, the cell is stored verbatim (including any embedded whitespace), so an exact-match lookup against a single ORF name silently misses those genes.

uniprot_id

UniProt-side identifier (e.g. NCBI taxonomy ID). Required for auto-download; otherwise unused.

id_type

UniProt query field type for uniprot_id. Default "taxonomy_id".

gene_id_field

UniProt field that becomes the Gene Names column. Default "gene_oln".

reviewed

If True (default), restrict the auto-download query to reviewed (Swiss-Prot) entries.

auto_download

If True (default) and path is missing, trigger download_uniprot before parsing. Set to False to keep the loader pure (e.g. tests).

Returns

UniprotDB

Parsed database. MW is in Da.

Raises

FileNotFoundError

If path does not exist and either auto_download is False or uniprot_id is None.

ValueError

If the file has duplicate Entry values, or if the header does not have at least 5 tab-delimited fields.

Notes

Empty cells (common for EC number and Sequence) become empty strings, matching MATLAB textscan with %q behavior. Duplicate entries raise, matching MATLAB's dispEM failure mode.

met_smiles#

met_smiles(metabolite)

The metabolite's SMILES, whatever shape its annotation is in.

cobra stores an annotation value as the object it was assigned, and returns a list for a model read back from a file: a metabolite annotated in memory by find_met_smiles carries "CCO", and the same metabolite after a save/load round trip carries ["CCO"]. Readers that assume a string get a list that compares equal to nothing and is not hashable.

Returns the first non-empty entry, or "" when there is none.

parse_brenda_json#

parse_brenda_json(path: str | Path)

Yield one Row per (kind, EC, substrate, organism) measurement.

Range values like "0.1-2.5 {NADH}" collapse to their upper bound. Mutant-flagged rows, the -999 missing-value marker, kcat values above the physical ceiling, and the spontaneous pseudo-EC are skipped. Measurements fan out across proteins[] so one input row may produce several output rows (one per organism).

Parameters

path

Path to the unpacked BRENDA bulk JSON file (Release 2026.1 or later, schema version 2.0.0).

Yields

Row :

PhylDist#

KEGG phylogenetic distance structure.

Attributes

names

KEGG organism names, with any trailing parenthetical comment stripped. Stored in original case.

dist_matrix

N x N pairwise evolutionary distance matrix. dist_matrix[i, j] is the distance between names[i] and names[j].

name_to_index

Lowercased name -> index in names. First occurrence wins for duplicate names (matching MATLAB find(..., 1)).

genus_to_indices

Lowercased genus (first whitespace-delimited word of the name) -> list of indices in names whose genus matches.

ProtData#

Pre-loaded proteomics data for f-factor and concentration filling.

Attributes

uniprot_ids

UniProt IDs (one per protein measurement).

abundances

Numeric abundances. Shape (n_proteins,) for a single sample, or (n_proteins, n_samples) if multiple datasets were merged. Units are arbitrary (only ratios are used).

Row#

One measurement yielded by parse_brenda_json.

sha256_of#

sha256_of(path: str | Path, *, chunk_size: int=65536)

Return the hex sha256 digest of a file's contents.

UniprotDB#

Parsed uniprot.tsv. Arrays are aligned: row i in every field

describes the same database entry (or gene-name row when split).

mw is in Da, matching the Mass column of the TSV verbatim.