Old

balanceReactionsInTrainingData(training_data)[source]

Balance the reactions in the training data by adding water and removing unbalanced reactions

Computes an element-conservation matrix from the nonstandard InChI element matrix, adds water molecules to reactions that are unbalanced only in oxygen, then removes any reactions that remain unbalanced, pruning the corresponding columns of every per-reaction field.

USAGE:

training_data = balanceReactionsInTrainingData (training_data)

INPUTS:

training_data – training-data structure. Fields used:

  • .nstd_inchi - m x 1 nonstandard InChI strings

  • .Ematrix - m x k element matrix (added/updated here)

  • .S - m x n stoichiometric matrix

  • .cids - m x 1 compound ids

  • .balance - n x 1 true where the reaction should be balance-checked

  • .dG0_prime - n x 1 standard transformed reaction Gibbs energies

  • .T - n x 1 temperatures

  • .I - n x 1 ionic strengths

  • .pH - n x 1 pH values

  • .pMg - n x 1 pMg values

  • .weights - n x 1 reaction weights

OUTPUTS:

training_data – the training-data structure with balanced reactions and the unbalanced reactions removed

checkForMissingStereo(model, nist)[source]

Identify model metabolites whose stereochemistry is missing relative to the NIST data

Compares standard InChI without stereochemistry against standard InChI with stereochemistry for the NIST training data, then returns the model metabolite abbreviations that match a NIST compound but lack stereochemical detail.

USAGE:

missingStereo = checkForMissingStereo (model, nist)

INPUTS:
  • model – COBRA model structure. Fields used:

    • .mets - metabolite abbreviations

    • .inchi.standard - standard InChI without stereochemistry

    • .inchi.standardWithStereo - standard InChI with stereochemistry

  • nist – NIST training-data structure. Fields used:

    • .std_inchi - standard InChI without stereochemistry

    • .std_inchi_stereo - standard InChI with stereochemistry

OUTPUTS:

missingStereo – cell array of model metabolite abbreviations present in the NIST data but lacking stereochemistry

getInchies(target_cids, use_cache)[source]

Retrieve InChI strings for a set of KEGG compounds using OpenBabel

Loads cached InChIs when available, otherwise obtains the MOL file for each KEGG compound and converts it to standard, stereo, stereo+charge and nonstandard InChI strings with OpenBabel, caching the result.

USAGE:

inchies = getInchies (target_cids, use_cache)

INPUTS:

target_cids – numeric vector of KEGG compound identifiers to retrieve

OPTIONAL INPUT:

use_cache – logical, when true (default) load previously cached InChIs from disk instead of recomputing them

OUTPUTS:

inchies – structure of InChI strings with fields:

  • .cids - KEGG compound identifiers

  • .std_inchi - standard InChI

  • .std_inchi_stereo - standard InChI with stereochemistry

  • .std_inchi_stereo_charge - standard InChI with stereochemistry and charge

  • .nstd_inchi - nonstandard InChI

getKeggpKas(target_cids, target_inchi, n_pkas)[source]

Estimate pKa values and pseudoisomer data for KEGG compounds using cxcalc

For each KEGG compound, converts its InChI to SMILES with OpenBabel and runs the ChemAxon cxcalc plugin to estimate acidic/basic pKa values, then derives the pseudoisomer charges and proton counts at pH 7.

USAGE:

KeggSpeciespKa = getKeggpKas (target_cids, target_inchi, n_pkas)

INPUTS:
  • target_cids – numeric vector of KEGG compound identifiers

  • target_inchi – cell array of InChI strings, one per compound in target_cids

OPTIONAL INPUT:

n_pkas – maximum number of acidic and basic pKa values to estimate per compound (default: 20)

OUTPUTS:

KeggSpeciespKa – structure array of pseudoisomer data with fields:

  • .pKas - matrix of pKa values between pseudoisomers

  • .majorMSpH7 - logical marking the major microspecies at pH 7

  • .zs - pseudoisomer charges

  • .nHs - pseudoisomer proton counts

  • .cid - KEGG compound identifier

getTrainingDatapKas(training_data, use_cache)[source]

Get the pKa values for the compounds in the training data, using ChemAxon

Loads cached pKa values when available, otherwise computes them with getKeggpKas for every compound in the training data and caches the result.

USAGE:

kegg_pKa = getTrainingDatapKas (training_data, use_cache)

INPUTS:

training_data – training-data structure. Fields used:

  • .cids - m x 1 KEGG compound ids

  • .nstd_inchi - m x 1 nonstandard InChI strings

OPTIONAL INPUT:

use_cache – logical, when true (default) load previously cached pKa values from disk instead of recomputing them

OUTPUTS:

kegg_pKa – structure array of pKa/pseudoisomer data, one entry per compound (see getKeggpKas)

loadTrainingData(formation_weight)[source]

Generate the structure that contains all the training data needed for Component Contribution

Reads the TECRDB (NIST), formation-energy and redox-potential data files and assembles a stoichiometric matrix over the union of compounds together with the associated thermodynamic parameters.

USAGE:

training_data = loadTrainingData (formation_weight)

OPTIONAL INPUT:

formation_weight – the relative weight to give the formation energies (Alberty’s data) compared to the reaction measurements (TECRDB); default 1

OUTPUTS:

training_data – structure with data for Component Contribution:

  • .cids - m x 1 compound ids

  • .cids_that_dont_decompose - ids of compounds that do not decompose

  • .S - m x n stoichiometric matrix of training data

  • .dG0_prime - n x 1 standard transformed reaction Gibbs energies

  • .T - n x 1 temperatures

  • .I - n x 1 ionic strengths

  • .pH - n x 1 pH values

  • .pMg - n x 1 pMg values

  • .weights - n x 1 reaction weights

  • .balance - n x 1 true where the reaction is balanced

prepareTrainingData(model, printLevel, params)[source]

Given a standard COBRA model, add thermodynamic data to it using the Component Contribution method

Loads the training data, retrieves InChIs and pKa values for the training compounds, balances the training reactions, builds the group incidence matrix against the model, and applies the reverse Legendre transform.

USAGE:

[training_data, mappingScore] = prepareTrainingData (model, printLevel, params)

INPUTS:

model – COBRA model structure

OPTIONAL INPUTS:
  • printLevel – verbose level (default: 0)

  • params – structure of parameters. Fields used:

    • .use_cached_kegg_inchis - logical, use cached KEGG InChIs

    • .use_model_pKas_by_default - logical, prefer model pKa data

OUTPUTS:
  • training_data – training-data structure with thermodynamic data and the group incidence matrix

  • mappingScore – score of the mapping between the model and the training data compounds

reverseTransformTrainingData(model, training_data, use_model_pKas_by_default)[source]

Calculate the reverse Legendre transform for all reactions in the training data

Applies the reverse Legendre transform to convert the standard transformed reaction Gibbs energies (.dG0_prime) into standard reaction Gibbs energies (.dG0), using either the model or the training-data pseudoisomer/pKa data.

USAGE:

training_data = reverseTransformTrainingData (model, training_data, use_model_pKas_by_default)

INPUTS:
  • model – COBRA model structure. Field used:

    • .pseudoisomers - structure array of model pseudoisomer data

  • training_data – training-data structure. Fields used:

    • .S - m x n stoichiometric matrix of training reactions

    • .cids - m x 1 compound ids

    • .I - n x 1 ionic strengths (NaN entries default to 0.25 M)

    • .pMg - n x 1 pMg values (NaN entries default to 14)

    • .T - n x 1 temperatures

    • .pH - n x 1 pH values

    • .kegg_pKa - structure array of KEGG pKa/pseudoisomer data

    • .Model2TrainingMap - map from model to training-data compound indices

    • .dG0_prime - n x 1 standard transformed reaction Gibbs energy

  • use_model_pKas_by_default – logical, when true use the model pseudoisomer data in preference to the training data

OUTPUTS:

training_data – the training data with an added field:

  • .dG0 - n x 1 standard reaction Gibbs energy