Skip to content

6. Trouble shooting models

Helena Cooper edited this page Jul 9, 2024 · 5 revisions

The Bactabolize patch_model function

bactabolize patch_model \
  --draft_model_fp data/test_data/model_patching_example/KPN2285_model.json \
  --ref_model_fp KpSC_pan-metabolic_model_v1.json \
  --patch_fp KPN2285_patch.json \
  --biomass_reaction_id BIOMASS_Core_Oct2019 \
  --output_fp KPN2285_patched.json

The bactabolize draft_model function automatically tests the ability of a draft model to simulate biomass production (predict positive growth) on the user specified media. When a model fails this test, Bactabolize automatically runs a gap-filling process to identify essential genes/reactions that are missing from the model and required for biomass production. This information is written to disk and can be used to patch the draft model with bactabolize patch_model. (Note, it might not always be appropriate to patch the model i.e. if the media used for the growth test is not expected to support universal growth or if the strain is a genuine auxotroph).

Bactabolize will list all reactions that are identified during gap-filling over the five iterations as a combined list (under "Missing reactions required to fix model"), followed by the combination of reactions identified per iteration (under "Iteration 1", "Iteration 2" etc). Note that the minimum number of reactions required to fix the model versus the total number of unique reactions identified may be different. For example, the code below shows that PSD160 was identified as required across all five iterations and needs to be included to fix the model, but either PSD161 OR PSD181 are sufficient to fix the model (rather than both).

Missing reactions required to fix model (iterations: 5; threshold: 1e-07)
PSD160 5/5
PSD161 3/5
PSD181 2/5

Iteration 1
PSD160
PSD161

Iteration 2
PSD160
PSD181

When patching the models, using either the combined summary list or a single set of reactions under an individual iteration will fix the model. However, using a single iteration is more accurate as gap-filling with a pan-reference model may incorporate reactions that are not conserved across your species of interest.

After the missing reactions have been added into the model, Bactabolize will retest for growth in your choice of conditions. If the model again fails to simulate growth, the gap-filling process will be repeated and a list of the newly identified missing reactions will be saved to disk.

draft_model flow chart

Input files

Three files are required:

1. The model to be patched in BiGG compatible JSON format

E.g. draft model output from bactabolize draft_model.

2. Reference model in BiGG compatible JSON format

3. Patch file in JSON format

This file specifies the reactions to be added into the model. See here for details.

Outputs

Be default bactabolize patch_model will output a single updated draft model in BiGG compatible JSON format. If the --memote_report_fp option is specified, a corresponding memote quality report will also be produced.

Command options

Required

--draft_model_fp - Input draft model to be edited (.json)

--ref_model_fp - Reference model (.json)

--patch_fp - Missing reactions to add to draft model (.json)

--output_fp - Output filename

Optional

--biomass_reaction_id - ID of reference model's Biomass function. DEFAULT: BIOMASS_

--media_type - Choose growth media for model building. One of: bg11, lb_carveme, lb, m9, nutrient, tsa, tsa_sheep_blood. DEFAULT: m9

--atmosphere_type - Choose atmosphere for model building. One of: aerobic, anaerobic. DEFAULT: aerobic

--memote_report_fp - MEMOTE model quality report output filepath. Note that this will add >5 minutes of compute time PER assembly

Example

# K_variicola_variicola_342.json fails to produce biomass as it lacks DTDP-4-dehydrorhamnose 3,5-epimerase and
# DTDP-4-dehydrorhamnose reductase, which are required to create DTDP-L-rhamnose
# Here we assume DTDP-L-rhamnose is not essential for growth and patch the model accordingly
bactabolize patch_model \
    --draft_model_fp K_variicola_variicola_342.json \
    --ref_model_fp iYL1228_annotated.json \
    --biomass_reaction_id YOUR_BIOMASS_ID \
    --patch_fp patch.json \
    --media_type m9 \
    --atmosphere_type aerobic \
    --output_fp K_variicola_variicola_342_patched.json

# Assess model with FBA
bactabolize fba \
    --model_fp K_variicola_variicola_342_patched.json \
    --fba_spec_fp data/fba_specs/m9_spec.json \
    --output_fp K_variicola_variicola_342_patched_FBA.tsv \
    --fba_open_value -20

Patch file

The patch file is used to specify the reactions that should be added into a draft model e.g. those identified as missing reactions in the automated gap-filling process. Only the reactions are required, their associated metabolites and genes (if any) will be added automatically.

The model name listed in the file must match exactly the model name listed inside the draft model file (found just above the "compartments":{ line).

Example patch.json file:

{
  "KPN2285": {
    "reactions": {
      "PSD160": "add",
      "PSD161": "add",
      "PSD181": "add",
      "PSD180": "add"
    }
  }
}

This patch file specifies that the KPN2285 model requires two reactions to be added (PSD160, PSD161, PSD181 and PSD180). You can find the details about these reactions by searching the BiGG website.