Skip to content
Snippets Groups Projects
Commit fea25678 authored by Documenter.jl's avatar Documenter.jl
Browse files

build based on bea55385

parent 674361ca
No related branches found
No related tags found
No related merge requests found
Showing
with 111 additions and 111 deletions
......@@ -87,4 +87,4 @@ end</code></pre><p>In turn, these variants can be used in <a href="../../functio
nothing
nothing
[7.47738193404817, 1.8840414375838503e-8, 4.860861010127701, -16.023526104614593, … ]
[7.47738193404817, 1.8840414375838503e-8, 4.860861010127701, -16.023526104614593, … ]</code></pre></article><nav class="docs-footer"><a class="docs-footer-prevpage" href="../">« All advanced tutorials</a><a class="docs-footer-nextpage" href="../2_custom_model/">Working with custom models »</a><div class="flexbox-break"></div><p class="footer-message">Powered by <a href="https://github.com/JuliaDocs/Documenter.jl">Documenter.jl</a> and the <a href="https://julialang.org/">Julia Programming Language</a>.</p></nav></div><div class="modal" id="documenter-settings"><div class="modal-background"></div><div class="modal-card"><header class="modal-card-head"><p class="modal-card-title">Settings</p><button class="delete"></button></header><section class="modal-card-body"><p><label class="label">Theme</label><div class="select"><select id="documenter-themepicker"><option value="documenter-light">documenter-light</option><option value="documenter-dark">documenter-dark</option></select></div></p><hr/><p>This document was generated with <a href="https://github.com/JuliaDocs/Documenter.jl">Documenter.jl</a> on <span class="colophon-date" title="Friday 5 November 2021 09:29">Friday 5 November 2021</span>. Using Julia version 1.6.0.</p></section><footer class="modal-card-foot"></footer></div></div></div></body></html>
[7.47738193404817, 1.8840414375838503e-8, 4.860861010127701, -16.023526104614593, … ]</code></pre></article><nav class="docs-footer"><a class="docs-footer-prevpage" href="../">« All advanced tutorials</a><a class="docs-footer-nextpage" href="../2_custom_model/">Working with custom models »</a><div class="flexbox-break"></div><p class="footer-message">Powered by <a href="https://github.com/JuliaDocs/Documenter.jl">Documenter.jl</a> and the <a href="https://julialang.org/">Julia Programming Language</a>.</p></nav></div><div class="modal" id="documenter-settings"><div class="modal-background"></div><div class="modal-card"><header class="modal-card-head"><p class="modal-card-title">Settings</p><button class="delete"></button></header><section class="modal-card-body"><p><label class="label">Theme</label><div class="select"><select id="documenter-themepicker"><option value="documenter-light">documenter-light</option><option value="documenter-dark">documenter-dark</option></select></div></p><hr/><p>This document was generated with <a href="https://github.com/JuliaDocs/Documenter.jl">Documenter.jl</a> on <span class="colophon-date" title="Friday 5 November 2021 10:13">Friday 5 November 2021</span>. Using Julia version 1.6.0.</p></section><footer class="modal-card-foot"></footer></div></div></div></body></html>
......@@ -43,4 +43,4 @@ Dict{String, Float64} with 5 entries:
&quot;rxn4&quot; =&gt; 1.0
</code></pre><h2 id="Writing-generic-model-modifications"><a class="docs-heading-anchor" href="#Writing-generic-model-modifications">Writing generic model modifications</a><a id="Writing-generic-model-modifications-1"></a><a class="docs-heading-anchor-permalink" href="#Writing-generic-model-modifications" title="Permalink"></a></h2><p>The custom model structure can also be made compatible with many of the existing variant-generating functions and analysis modifiers.</p><p>The functions prepared for use as &quot;variants&quot; in <a href="../../functions/analysis/#COBREXA.screen-Tuple"><code>screen</code></a>, usually prefixed by <code>with_</code>, have their generic variants that only call simpler, overloadable functions for each specific model. This choice is based on the overloading dispatch system of Julia. For example,<a href="../../functions/reconstruction/#COBREXA.with_removed_metabolites-Tuple"><code>with_removed_metabolites</code></a> is implemented very generically by reducing the problem to some specific <a href="../../functions/utils/#COBREXA.remove_metabolites-Tuple{CoreModel, AbstractVector{Int64}}"><code>remove_metabolites</code></a> functions selected by the dispatch, as follows:</p><pre><code class="language-julia">with_removed_metabolites(args...; kwargs...) =
m -&gt; remove_metabolites(m, args...; kwargs...)</code></pre><p>To be able to use <a href="../../functions/reconstruction/#COBREXA.with_removed_metabolites-Tuple"><code>with_removed_metabolites</code></a> in your model, we can just overload the actual inner function. For the simple circular model, the modification might as well look like this:</p><pre><code class="language-julia">COBREXA.remove_metabolites(m::CircularModel, n::Int) =
return CircularModel(m.size - n)</code></pre><div class="admonition is-danger"><header class="admonition-header">Functions that generate model variants must be pure</header><div class="admonition-body"><p>Notice that the function is &quot;pure&quot;, i.e., does not make any in-place modifications to the original model structure. That property is required for <a href="../../functions/analysis/#COBREXA.screen-Tuple"><code>screen</code></a> and other functions to properly and predictably apply the modifications to the model. To expose potential in-place modifications to your codebase, you should instead overload the &quot;bang&quot; counterpart of remove metabolites, called <a href="../../functions/utils/#COBREXA.remove_metabolites!-Tuple{CoreModel, AbstractVector{Int64}}"><code>remove_metabolites!</code></a>.</p></div></div></article><nav class="docs-footer"><a class="docs-footer-prevpage" href="../1_variants/">« Exploring many model variants</a><a class="docs-footer-nextpage" href="../../notebooks/">All notebooks »</a><div class="flexbox-break"></div><p class="footer-message">Powered by <a href="https://github.com/JuliaDocs/Documenter.jl">Documenter.jl</a> and the <a href="https://julialang.org/">Julia Programming Language</a>.</p></nav></div><div class="modal" id="documenter-settings"><div class="modal-background"></div><div class="modal-card"><header class="modal-card-head"><p class="modal-card-title">Settings</p><button class="delete"></button></header><section class="modal-card-body"><p><label class="label">Theme</label><div class="select"><select id="documenter-themepicker"><option value="documenter-light">documenter-light</option><option value="documenter-dark">documenter-dark</option></select></div></p><hr/><p>This document was generated with <a href="https://github.com/JuliaDocs/Documenter.jl">Documenter.jl</a> on <span class="colophon-date" title="Friday 5 November 2021 09:29">Friday 5 November 2021</span>. Using Julia version 1.6.0.</p></section><footer class="modal-card-foot"></footer></div></div></div></body></html>
return CircularModel(m.size - n)</code></pre><div class="admonition is-danger"><header class="admonition-header">Functions that generate model variants must be pure</header><div class="admonition-body"><p>Notice that the function is &quot;pure&quot;, i.e., does not make any in-place modifications to the original model structure. That property is required for <a href="../../functions/analysis/#COBREXA.screen-Tuple"><code>screen</code></a> and other functions to properly and predictably apply the modifications to the model. To expose potential in-place modifications to your codebase, you should instead overload the &quot;bang&quot; counterpart of remove metabolites, called <a href="../../functions/utils/#COBREXA.remove_metabolites!-Tuple{CoreModel, AbstractVector{Int64}}"><code>remove_metabolites!</code></a>.</p></div></div></article><nav class="docs-footer"><a class="docs-footer-prevpage" href="../1_variants/">« Exploring many model variants</a><a class="docs-footer-nextpage" href="../../notebooks/">All notebooks »</a><div class="flexbox-break"></div><p class="footer-message">Powered by <a href="https://github.com/JuliaDocs/Documenter.jl">Documenter.jl</a> and the <a href="https://julialang.org/">Julia Programming Language</a>.</p></nav></div><div class="modal" id="documenter-settings"><div class="modal-background"></div><div class="modal-card"><header class="modal-card-head"><p class="modal-card-title">Settings</p><button class="delete"></button></header><section class="modal-card-body"><p><label class="label">Theme</label><div class="select"><select id="documenter-themepicker"><option value="documenter-light">documenter-light</option><option value="documenter-dark">documenter-dark</option></select></div></p><hr/><p>This document was generated with <a href="https://github.com/JuliaDocs/Documenter.jl">Documenter.jl</a> on <span class="colophon-date" title="Friday 5 November 2021 10:13">Friday 5 November 2021</span>. Using Julia version 1.6.0.</p></section><footer class="modal-card-foot"></footer></div></div></div></body></html>
<!DOCTYPE html>
<html lang="en"><head><meta charset="UTF-8"/><meta name="viewport" content="width=device-width, initial-scale=1.0"/><title>All advanced tutorials · COBREXA.jl</title><link href="https://fonts.googleapis.com/css?family=Lato|Roboto+Mono" rel="stylesheet" type="text/css"/><link href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.15.0/css/fontawesome.min.css" rel="stylesheet" type="text/css"/><link href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.15.0/css/solid.min.css" rel="stylesheet" type="text/css"/><link href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.15.0/css/brands.min.css" rel="stylesheet" type="text/css"/><link href="https://cdnjs.cloudflare.com/ajax/libs/KaTeX/0.11.1/katex.min.css" rel="stylesheet" type="text/css"/><script>documenterBaseURL=".."</script><script src="https://cdnjs.cloudflare.com/ajax/libs/require.js/2.3.6/require.min.js" data-main="../assets/documenter.js"></script><script src="../siteinfo.js"></script><script src="../../versions.js"></script><link class="docs-theme-link" rel="stylesheet" type="text/css" href="../assets/themes/documenter-dark.css" data-theme-name="documenter-dark" data-theme-primary-dark/><link class="docs-theme-link" rel="stylesheet" type="text/css" href="../assets/themes/documenter-light.css" data-theme-name="documenter-light" data-theme-primary/><script src="../assets/themeswap.js"></script><link href="../assets/favicon.ico" rel="icon" type="image/x-icon"/></head><body><div id="documenter"><nav class="docs-sidebar"><a class="docs-logo" href="../"><img class="docs-light-only" src="../assets/logo.svg" alt="COBREXA.jl logo"/><img class="docs-dark-only" src="../assets/logo-dark.svg" alt="COBREXA.jl logo"/></a><div class="docs-package-name"><span class="docs-autofit">COBREXA.jl</span></div><form class="docs-search" action="../search/"><input class="docs-search-query" id="documenter-search-query" name="q" type="text" placeholder="Search docs"/></form><ul class="docs-menu"><li><a class="tocitem" href="../">Home</a></li><li><span class="tocitem">User guide</span><ul><li><input class="collapse-toggle" id="menuitem-2-1" type="checkbox"/><label class="tocitem" for="menuitem-2-1"><span class="docs-label">Quickstart tutorials</span><i class="docs-chevron"></i></label><ul class="collapsed"><li><a class="tocitem" href="../tutorials/">All tutorials</a></li><li><a class="tocitem" href="../tutorials/1_loading/">Loading and converting model data</a></li><li><a class="tocitem" href="../tutorials/2_analysis/">Basic analysis of constraint-based models</a></li><li><a class="tocitem" href="../tutorials/3_hpc/">Distributed processing and HPC environments</a></li><li><a class="tocitem" href="../tutorials/4_modifying/">Modifying and saving the models</a></li></ul></li><li><input class="collapse-toggle" id="menuitem-2-2" type="checkbox" checked/><label class="tocitem" for="menuitem-2-2"><span class="docs-label">Advanced tutorials</span><i class="docs-chevron"></i></label><ul class="collapsed"><li class="is-active"><a class="tocitem" href>All advanced tutorials</a></li><li><a class="tocitem" href="1_variants/">Exploring many model variants</a></li><li><a class="tocitem" href="2_custom_model/">Working with custom models</a></li></ul></li><li><input class="collapse-toggle" id="menuitem-2-3" type="checkbox"/><label class="tocitem" for="menuitem-2-3"><span class="docs-label">Examples and notebooks</span><i class="docs-chevron"></i></label><ul class="collapsed"><li><a class="tocitem" href="../notebooks/">All notebooks</a></li><li><a class="tocitem" href="../notebooks/1_loading_converting_saving/">Loading, converting, and saving models</a></li><li><a class="tocitem" href="../notebooks/2_finding_balance/">Finding balance and variability of constraint-based models</a></li><li><a class="tocitem" href="../notebooks/3_basic_stdmodel_usage/">Basic usage of <code>StandardModel</code></a></li><li><a class="tocitem" href="../notebooks/4_basic_core_coupled_usage/">Basic usage of <code>CoreModel</code> and <code>CoreModelCoupled</code></a></li><li><a class="tocitem" href="../notebooks/5_basic_stdmodel_construction/">Model construction and modification</a></li><li><a class="tocitem" href="../notebooks/6_screening/">Exploring model variants with <code>screen</code></a></li><li><a class="tocitem" href="../notebooks/7_community_model/">Building and analysing a small community model</a></li><li><a class="tocitem" href="../notebooks/8_custom_model/">Using a custom model data structure</a></li><li><a class="tocitem" href="../notebooks/9_max_min_driving_force_analysis/">Maximum-minimum driving force analysis</a></li></ul></li></ul></li><li><span class="tocitem">Types and functions</span><ul><li><a class="tocitem" href="../functions/">Contents</a></li><li><a class="tocitem" href="../functions/analysis/">Analysis functions</a></li><li><a class="tocitem" href="../functions/base/">Base functions</a></li><li><a class="tocitem" href="../functions/io/">Input and output</a></li><li><a class="tocitem" href="../functions/reconstruction/">Model construction functions</a></li><li><a class="tocitem" href="../functions/types/">Types</a></li><li><a class="tocitem" href="../functions/utils/">Utilities</a></li></ul></li><li><a class="tocitem" href="../howToContribute/">How to contribute</a></li></ul><div class="docs-version-selector field has-addons"><div class="control"><span class="docs-label button is-static is-size-7">Version</span></div><div class="docs-selector control is-expanded"><div class="select is-fullwidth is-size-7"><select id="documenter-version-selector"></select></div></div></div></nav><div class="docs-main"><header class="docs-navbar"><nav class="breadcrumb"><ul class="is-hidden-mobile"><li><a class="is-disabled">User guide</a></li><li><a class="is-disabled">Advanced tutorials</a></li><li class="is-active"><a href>All advanced tutorials</a></li></ul><ul class="is-hidden-tablet"><li class="is-active"><a href>All advanced tutorials</a></li></ul></nav><div class="docs-right"><a class="docs-edit-link" href="https://github.com/lcsb-biocore/COBREXA.jl/blob/master/docs/src/advanced.md" title="Edit on GitHub"><span class="docs-icon fab"></span><span class="docs-label is-hidden-touch">Edit on GitHub</span></a><a class="docs-settings-button fas fa-cog" id="documenter-settings-button" href="#" title="Settings"></a><a class="docs-sidebar-button fa fa-bars is-hidden-desktop" id="documenter-sidebar-button" href="#"></a></div></header><article class="content" id="documenter-page"><h1 id="COBREXA-Advanced-tutorials"><a class="docs-heading-anchor" href="#COBREXA-Advanced-tutorials">COBREXA Advanced tutorials</a><a id="COBREXA-Advanced-tutorials-1"></a><a class="docs-heading-anchor-permalink" href="#COBREXA-Advanced-tutorials" title="Permalink"></a></h1><ul><li><a href="1_variants/#Exploring-many-model-variants">Exploring many model variants</a></li><ul><li><a href="1_variants/#Variant-specification">Variant specification</a></li><li><a href="1_variants/#Writing-custom-variant-functions">Writing custom variant functions</a></li><li><a href="1_variants/#Passing-extra-arguments-to-the-analysis-function">Passing extra arguments to the analysis function</a></li></ul><li><a href="2_custom_model/#Working-with-custom-models">Working with custom models</a></li><ul><li><a href="2_custom_model/#Writing-the-generic-accessors">Writing the generic accessors</a></li><li><a href="2_custom_model/#Writing-generic-model-modifications">Writing generic model modifications</a></li></ul></ul></article><nav class="docs-footer"><a class="docs-footer-prevpage" href="../tutorials/4_modifying/">« Modifying and saving the models</a><a class="docs-footer-nextpage" href="1_variants/">Exploring many model variants »</a><div class="flexbox-break"></div><p class="footer-message">Powered by <a href="https://github.com/JuliaDocs/Documenter.jl">Documenter.jl</a> and the <a href="https://julialang.org/">Julia Programming Language</a>.</p></nav></div><div class="modal" id="documenter-settings"><div class="modal-background"></div><div class="modal-card"><header class="modal-card-head"><p class="modal-card-title">Settings</p><button class="delete"></button></header><section class="modal-card-body"><p><label class="label">Theme</label><div class="select"><select id="documenter-themepicker"><option value="documenter-light">documenter-light</option><option value="documenter-dark">documenter-dark</option></select></div></p><hr/><p>This document was generated with <a href="https://github.com/JuliaDocs/Documenter.jl">Documenter.jl</a> on <span class="colophon-date" title="Friday 5 November 2021 09:29">Friday 5 November 2021</span>. Using Julia version 1.6.0.</p></section><footer class="modal-card-foot"></footer></div></div></div></body></html>
<html lang="en"><head><meta charset="UTF-8"/><meta name="viewport" content="width=device-width, initial-scale=1.0"/><title>All advanced tutorials · COBREXA.jl</title><link href="https://fonts.googleapis.com/css?family=Lato|Roboto+Mono" rel="stylesheet" type="text/css"/><link href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.15.0/css/fontawesome.min.css" rel="stylesheet" type="text/css"/><link href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.15.0/css/solid.min.css" rel="stylesheet" type="text/css"/><link href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.15.0/css/brands.min.css" rel="stylesheet" type="text/css"/><link href="https://cdnjs.cloudflare.com/ajax/libs/KaTeX/0.11.1/katex.min.css" rel="stylesheet" type="text/css"/><script>documenterBaseURL=".."</script><script src="https://cdnjs.cloudflare.com/ajax/libs/require.js/2.3.6/require.min.js" data-main="../assets/documenter.js"></script><script src="../siteinfo.js"></script><script src="../../versions.js"></script><link class="docs-theme-link" rel="stylesheet" type="text/css" href="../assets/themes/documenter-dark.css" data-theme-name="documenter-dark" data-theme-primary-dark/><link class="docs-theme-link" rel="stylesheet" type="text/css" href="../assets/themes/documenter-light.css" data-theme-name="documenter-light" data-theme-primary/><script src="../assets/themeswap.js"></script><link href="../assets/favicon.ico" rel="icon" type="image/x-icon"/></head><body><div id="documenter"><nav class="docs-sidebar"><a class="docs-logo" href="../"><img class="docs-light-only" src="../assets/logo.svg" alt="COBREXA.jl logo"/><img class="docs-dark-only" src="../assets/logo-dark.svg" alt="COBREXA.jl logo"/></a><div class="docs-package-name"><span class="docs-autofit">COBREXA.jl</span></div><form class="docs-search" action="../search/"><input class="docs-search-query" id="documenter-search-query" name="q" type="text" placeholder="Search docs"/></form><ul class="docs-menu"><li><a class="tocitem" href="../">Home</a></li><li><span class="tocitem">User guide</span><ul><li><input class="collapse-toggle" id="menuitem-2-1" type="checkbox"/><label class="tocitem" for="menuitem-2-1"><span class="docs-label">Quickstart tutorials</span><i class="docs-chevron"></i></label><ul class="collapsed"><li><a class="tocitem" href="../tutorials/">All tutorials</a></li><li><a class="tocitem" href="../tutorials/1_loading/">Loading and converting model data</a></li><li><a class="tocitem" href="../tutorials/2_analysis/">Basic analysis of constraint-based models</a></li><li><a class="tocitem" href="../tutorials/3_hpc/">Distributed processing and HPC environments</a></li><li><a class="tocitem" href="../tutorials/4_modifying/">Modifying and saving the models</a></li></ul></li><li><input class="collapse-toggle" id="menuitem-2-2" type="checkbox" checked/><label class="tocitem" for="menuitem-2-2"><span class="docs-label">Advanced tutorials</span><i class="docs-chevron"></i></label><ul class="collapsed"><li class="is-active"><a class="tocitem" href>All advanced tutorials</a></li><li><a class="tocitem" href="1_variants/">Exploring many model variants</a></li><li><a class="tocitem" href="2_custom_model/">Working with custom models</a></li></ul></li><li><input class="collapse-toggle" id="menuitem-2-3" type="checkbox"/><label class="tocitem" for="menuitem-2-3"><span class="docs-label">Examples and notebooks</span><i class="docs-chevron"></i></label><ul class="collapsed"><li><a class="tocitem" href="../notebooks/">All notebooks</a></li><li><a class="tocitem" href="../notebooks/1_loading_converting_saving/">Loading, converting, and saving models</a></li><li><a class="tocitem" href="../notebooks/2_finding_balance/">Finding balance and variability of constraint-based models</a></li><li><a class="tocitem" href="../notebooks/3_basic_stdmodel_usage/">Basic usage of <code>StandardModel</code></a></li><li><a class="tocitem" href="../notebooks/4_basic_core_coupled_usage/">Basic usage of <code>CoreModel</code> and <code>CoreModelCoupled</code></a></li><li><a class="tocitem" href="../notebooks/5_basic_stdmodel_construction/">Model construction and modification</a></li><li><a class="tocitem" href="../notebooks/6_screening/">Exploring model variants with <code>screen</code></a></li><li><a class="tocitem" href="../notebooks/7_community_model/">Building and analysing a small community model</a></li><li><a class="tocitem" href="../notebooks/8_custom_model/">Using a custom model data structure</a></li><li><a class="tocitem" href="../notebooks/9_max_min_driving_force_analysis/">Maximum-minimum driving force analysis</a></li></ul></li></ul></li><li><span class="tocitem">Types and functions</span><ul><li><a class="tocitem" href="../functions/">Contents</a></li><li><a class="tocitem" href="../functions/analysis/">Analysis functions</a></li><li><a class="tocitem" href="../functions/base/">Base functions</a></li><li><a class="tocitem" href="../functions/io/">Input and output</a></li><li><a class="tocitem" href="../functions/reconstruction/">Model construction functions</a></li><li><a class="tocitem" href="../functions/types/">Types</a></li><li><a class="tocitem" href="../functions/utils/">Utilities</a></li></ul></li><li><a class="tocitem" href="../howToContribute/">How to contribute</a></li></ul><div class="docs-version-selector field has-addons"><div class="control"><span class="docs-label button is-static is-size-7">Version</span></div><div class="docs-selector control is-expanded"><div class="select is-fullwidth is-size-7"><select id="documenter-version-selector"></select></div></div></div></nav><div class="docs-main"><header class="docs-navbar"><nav class="breadcrumb"><ul class="is-hidden-mobile"><li><a class="is-disabled">User guide</a></li><li><a class="is-disabled">Advanced tutorials</a></li><li class="is-active"><a href>All advanced tutorials</a></li></ul><ul class="is-hidden-tablet"><li class="is-active"><a href>All advanced tutorials</a></li></ul></nav><div class="docs-right"><a class="docs-edit-link" href="https://github.com/lcsb-biocore/COBREXA.jl/blob/master/docs/src/advanced.md" title="Edit on GitHub"><span class="docs-icon fab"></span><span class="docs-label is-hidden-touch">Edit on GitHub</span></a><a class="docs-settings-button fas fa-cog" id="documenter-settings-button" href="#" title="Settings"></a><a class="docs-sidebar-button fa fa-bars is-hidden-desktop" id="documenter-sidebar-button" href="#"></a></div></header><article class="content" id="documenter-page"><h1 id="COBREXA-Advanced-tutorials"><a class="docs-heading-anchor" href="#COBREXA-Advanced-tutorials">COBREXA Advanced tutorials</a><a id="COBREXA-Advanced-tutorials-1"></a><a class="docs-heading-anchor-permalink" href="#COBREXA-Advanced-tutorials" title="Permalink"></a></h1><ul><li><a href="1_variants/#Exploring-many-model-variants">Exploring many model variants</a></li><ul><li><a href="1_variants/#Variant-specification">Variant specification</a></li><li><a href="1_variants/#Writing-custom-variant-functions">Writing custom variant functions</a></li><li><a href="1_variants/#Passing-extra-arguments-to-the-analysis-function">Passing extra arguments to the analysis function</a></li></ul><li><a href="2_custom_model/#Working-with-custom-models">Working with custom models</a></li><ul><li><a href="2_custom_model/#Writing-the-generic-accessors">Writing the generic accessors</a></li><li><a href="2_custom_model/#Writing-generic-model-modifications">Writing generic model modifications</a></li></ul></ul></article><nav class="docs-footer"><a class="docs-footer-prevpage" href="../tutorials/4_modifying/">« Modifying and saving the models</a><a class="docs-footer-nextpage" href="1_variants/">Exploring many model variants »</a><div class="flexbox-break"></div><p class="footer-message">Powered by <a href="https://github.com/JuliaDocs/Documenter.jl">Documenter.jl</a> and the <a href="https://julialang.org/">Julia Programming Language</a>.</p></nav></div><div class="modal" id="documenter-settings"><div class="modal-background"></div><div class="modal-card"><header class="modal-card-head"><p class="modal-card-title">Settings</p><button class="delete"></button></header><section class="modal-card-body"><p><label class="label">Theme</label><div class="select"><select id="documenter-themepicker"><option value="documenter-light">documenter-light</option><option value="documenter-dark">documenter-dark</option></select></div></p><hr/><p>This document was generated with <a href="https://github.com/JuliaDocs/Documenter.jl">Documenter.jl</a> on <span class="colophon-date" title="Friday 5 November 2021 10:13">Friday 5 November 2021</span>. Using Julia version 1.6.0.</p></section><footer class="modal-card-foot"></footer></div></div></div></body></html>
This diff is collapsed.
This diff is collapsed.
<!DOCTYPE html>
<html lang="en"><head><meta charset="UTF-8"/><meta name="viewport" content="width=device-width, initial-scale=1.0"/><title>Contents · COBREXA.jl</title><link href="https://fonts.googleapis.com/css?family=Lato|Roboto+Mono" rel="stylesheet" type="text/css"/><link href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.15.0/css/fontawesome.min.css" rel="stylesheet" type="text/css"/><link href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.15.0/css/solid.min.css" rel="stylesheet" type="text/css"/><link href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.15.0/css/brands.min.css" rel="stylesheet" type="text/css"/><link href="https://cdnjs.cloudflare.com/ajax/libs/KaTeX/0.11.1/katex.min.css" rel="stylesheet" type="text/css"/><script>documenterBaseURL=".."</script><script src="https://cdnjs.cloudflare.com/ajax/libs/require.js/2.3.6/require.min.js" data-main="../assets/documenter.js"></script><script src="../siteinfo.js"></script><script src="../../versions.js"></script><link class="docs-theme-link" rel="stylesheet" type="text/css" href="../assets/themes/documenter-dark.css" data-theme-name="documenter-dark" data-theme-primary-dark/><link class="docs-theme-link" rel="stylesheet" type="text/css" href="../assets/themes/documenter-light.css" data-theme-name="documenter-light" data-theme-primary/><script src="../assets/themeswap.js"></script><link href="../assets/favicon.ico" rel="icon" type="image/x-icon"/></head><body><div id="documenter"><nav class="docs-sidebar"><a class="docs-logo" href="../"><img class="docs-light-only" src="../assets/logo.svg" alt="COBREXA.jl logo"/><img class="docs-dark-only" src="../assets/logo-dark.svg" alt="COBREXA.jl logo"/></a><div class="docs-package-name"><span class="docs-autofit">COBREXA.jl</span></div><form class="docs-search" action="../search/"><input class="docs-search-query" id="documenter-search-query" name="q" type="text" placeholder="Search docs"/></form><ul class="docs-menu"><li><a class="tocitem" href="../">Home</a></li><li><span class="tocitem">User guide</span><ul><li><input class="collapse-toggle" id="menuitem-2-1" type="checkbox"/><label class="tocitem" for="menuitem-2-1"><span class="docs-label">Quickstart tutorials</span><i class="docs-chevron"></i></label><ul class="collapsed"><li><a class="tocitem" href="../tutorials/">All tutorials</a></li><li><a class="tocitem" href="../tutorials/1_loading/">Loading and converting model data</a></li><li><a class="tocitem" href="../tutorials/2_analysis/">Basic analysis of constraint-based models</a></li><li><a class="tocitem" href="../tutorials/3_hpc/">Distributed processing and HPC environments</a></li><li><a class="tocitem" href="../tutorials/4_modifying/">Modifying and saving the models</a></li></ul></li><li><input class="collapse-toggle" id="menuitem-2-2" type="checkbox"/><label class="tocitem" for="menuitem-2-2"><span class="docs-label">Advanced tutorials</span><i class="docs-chevron"></i></label><ul class="collapsed"><li><a class="tocitem" href="../advanced/">All advanced tutorials</a></li><li><a class="tocitem" href="../advanced/1_variants/">Exploring many model variants</a></li><li><a class="tocitem" href="../advanced/2_custom_model/">Working with custom models</a></li></ul></li><li><input class="collapse-toggle" id="menuitem-2-3" type="checkbox"/><label class="tocitem" for="menuitem-2-3"><span class="docs-label">Examples and notebooks</span><i class="docs-chevron"></i></label><ul class="collapsed"><li><a class="tocitem" href="../notebooks/">All notebooks</a></li><li><a class="tocitem" href="../notebooks/1_loading_converting_saving/">Loading, converting, and saving models</a></li><li><a class="tocitem" href="../notebooks/2_finding_balance/">Finding balance and variability of constraint-based models</a></li><li><a class="tocitem" href="../notebooks/3_basic_stdmodel_usage/">Basic usage of <code>StandardModel</code></a></li><li><a class="tocitem" href="../notebooks/4_basic_core_coupled_usage/">Basic usage of <code>CoreModel</code> and <code>CoreModelCoupled</code></a></li><li><a class="tocitem" href="../notebooks/5_basic_stdmodel_construction/">Model construction and modification</a></li><li><a class="tocitem" href="../notebooks/6_screening/">Exploring model variants with <code>screen</code></a></li><li><a class="tocitem" href="../notebooks/7_community_model/">Building and analysing a small community model</a></li><li><a class="tocitem" href="../notebooks/8_custom_model/">Using a custom model data structure</a></li><li><a class="tocitem" href="../notebooks/9_max_min_driving_force_analysis/">Maximum-minimum driving force analysis</a></li></ul></li></ul></li><li><span class="tocitem">Types and functions</span><ul><li class="is-active"><a class="tocitem" href>Contents</a></li><li><a class="tocitem" href="analysis/">Analysis functions</a></li><li><a class="tocitem" href="base/">Base functions</a></li><li><a class="tocitem" href="io/">Input and output</a></li><li><a class="tocitem" href="reconstruction/">Model construction functions</a></li><li><a class="tocitem" href="types/">Types</a></li><li><a class="tocitem" href="utils/">Utilities</a></li></ul></li><li><a class="tocitem" href="../howToContribute/">How to contribute</a></li></ul><div class="docs-version-selector field has-addons"><div class="control"><span class="docs-label button is-static is-size-7">Version</span></div><div class="docs-selector control is-expanded"><div class="select is-fullwidth is-size-7"><select id="documenter-version-selector"></select></div></div></div></nav><div class="docs-main"><header class="docs-navbar"><nav class="breadcrumb"><ul class="is-hidden-mobile"><li><a class="is-disabled">Types and functions</a></li><li class="is-active"><a href>Contents</a></li></ul><ul class="is-hidden-tablet"><li class="is-active"><a href>Contents</a></li></ul></nav><div class="docs-right"><a class="docs-edit-link" href="https://github.com/lcsb-biocore/COBREXA.jl/blob/master/docs/src/functions.md" title="Edit on GitHub"><span class="docs-icon fab"></span><span class="docs-label is-hidden-touch">Edit on GitHub</span></a><a class="docs-settings-button fas fa-cog" id="documenter-settings-button" href="#" title="Settings"></a><a class="docs-sidebar-button fa fa-bars is-hidden-desktop" id="documenter-sidebar-button" href="#"></a></div></header><article class="content" id="documenter-page"><h1 id="Types-and-functions"><a class="docs-heading-anchor" href="#Types-and-functions">Types and functions</a><a id="Types-and-functions-1"></a><a class="docs-heading-anchor-permalink" href="#Types-and-functions" title="Permalink"></a></h1><ul><li><a href="analysis/#Analysis-functions">Analysis functions</a></li><ul><li><a href="analysis/#Common-analysis-functions">Common analysis functions</a></li><li><a href="analysis/#Sampling">Sampling</a></li><li><a href="analysis/#Analysis-modifiers">Analysis modifiers</a></li></ul><li><a href="base/#Base-functions">Base functions</a></li><li><a href="io/#Input-and-output">Input and output</a></li><ul><li><a href="io/#File-I/O-and-serialization">File I/O and serialization</a></li><li><a href="io/#Pretty-printing">Pretty printing</a></li></ul><li><a href="reconstruction/#Model-construction-functions">Model construction functions</a></li><ul><li><a href="reconstruction/#Functions-for-changing-the-models">Functions for changing the models</a></li><li><a href="reconstruction/#Variant-specifiers">Variant specifiers</a></li></ul><li><a href="types/#Types">Types</a></li><ul><li><a href="types/#Base-types">Base types</a></li><li><a href="types/#Model-types-and-contents">Model types and contents</a></li></ul><li><a href="utils/#Utilities">Utilities</a></li><ul><li><a href="utils/#Helper-functions">Helper functions</a></li><li><a href="utils/#Macro-generated-functions-and-internal-helpers">Macro-generated functions and internal helpers</a></li><li><a href="utils/#Logging-and-debugging-helpers">Logging and debugging helpers</a></li></ul></ul></article><nav class="docs-footer"><a class="docs-footer-prevpage" href="../notebooks/9_max_min_driving_force_analysis/">« Maximum-minimum driving force analysis</a><a class="docs-footer-nextpage" href="analysis/">Analysis functions »</a><div class="flexbox-break"></div><p class="footer-message">Powered by <a href="https://github.com/JuliaDocs/Documenter.jl">Documenter.jl</a> and the <a href="https://julialang.org/">Julia Programming Language</a>.</p></nav></div><div class="modal" id="documenter-settings"><div class="modal-background"></div><div class="modal-card"><header class="modal-card-head"><p class="modal-card-title">Settings</p><button class="delete"></button></header><section class="modal-card-body"><p><label class="label">Theme</label><div class="select"><select id="documenter-themepicker"><option value="documenter-light">documenter-light</option><option value="documenter-dark">documenter-dark</option></select></div></p><hr/><p>This document was generated with <a href="https://github.com/JuliaDocs/Documenter.jl">Documenter.jl</a> on <span class="colophon-date" title="Friday 5 November 2021 09:29">Friday 5 November 2021</span>. Using Julia version 1.6.0.</p></section><footer class="modal-card-foot"></footer></div></div></div></body></html>
<html lang="en"><head><meta charset="UTF-8"/><meta name="viewport" content="width=device-width, initial-scale=1.0"/><title>Contents · COBREXA.jl</title><link href="https://fonts.googleapis.com/css?family=Lato|Roboto+Mono" rel="stylesheet" type="text/css"/><link href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.15.0/css/fontawesome.min.css" rel="stylesheet" type="text/css"/><link href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.15.0/css/solid.min.css" rel="stylesheet" type="text/css"/><link href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.15.0/css/brands.min.css" rel="stylesheet" type="text/css"/><link href="https://cdnjs.cloudflare.com/ajax/libs/KaTeX/0.11.1/katex.min.css" rel="stylesheet" type="text/css"/><script>documenterBaseURL=".."</script><script src="https://cdnjs.cloudflare.com/ajax/libs/require.js/2.3.6/require.min.js" data-main="../assets/documenter.js"></script><script src="../siteinfo.js"></script><script src="../../versions.js"></script><link class="docs-theme-link" rel="stylesheet" type="text/css" href="../assets/themes/documenter-dark.css" data-theme-name="documenter-dark" data-theme-primary-dark/><link class="docs-theme-link" rel="stylesheet" type="text/css" href="../assets/themes/documenter-light.css" data-theme-name="documenter-light" data-theme-primary/><script src="../assets/themeswap.js"></script><link href="../assets/favicon.ico" rel="icon" type="image/x-icon"/></head><body><div id="documenter"><nav class="docs-sidebar"><a class="docs-logo" href="../"><img class="docs-light-only" src="../assets/logo.svg" alt="COBREXA.jl logo"/><img class="docs-dark-only" src="../assets/logo-dark.svg" alt="COBREXA.jl logo"/></a><div class="docs-package-name"><span class="docs-autofit">COBREXA.jl</span></div><form class="docs-search" action="../search/"><input class="docs-search-query" id="documenter-search-query" name="q" type="text" placeholder="Search docs"/></form><ul class="docs-menu"><li><a class="tocitem" href="../">Home</a></li><li><span class="tocitem">User guide</span><ul><li><input class="collapse-toggle" id="menuitem-2-1" type="checkbox"/><label class="tocitem" for="menuitem-2-1"><span class="docs-label">Quickstart tutorials</span><i class="docs-chevron"></i></label><ul class="collapsed"><li><a class="tocitem" href="../tutorials/">All tutorials</a></li><li><a class="tocitem" href="../tutorials/1_loading/">Loading and converting model data</a></li><li><a class="tocitem" href="../tutorials/2_analysis/">Basic analysis of constraint-based models</a></li><li><a class="tocitem" href="../tutorials/3_hpc/">Distributed processing and HPC environments</a></li><li><a class="tocitem" href="../tutorials/4_modifying/">Modifying and saving the models</a></li></ul></li><li><input class="collapse-toggle" id="menuitem-2-2" type="checkbox"/><label class="tocitem" for="menuitem-2-2"><span class="docs-label">Advanced tutorials</span><i class="docs-chevron"></i></label><ul class="collapsed"><li><a class="tocitem" href="../advanced/">All advanced tutorials</a></li><li><a class="tocitem" href="../advanced/1_variants/">Exploring many model variants</a></li><li><a class="tocitem" href="../advanced/2_custom_model/">Working with custom models</a></li></ul></li><li><input class="collapse-toggle" id="menuitem-2-3" type="checkbox"/><label class="tocitem" for="menuitem-2-3"><span class="docs-label">Examples and notebooks</span><i class="docs-chevron"></i></label><ul class="collapsed"><li><a class="tocitem" href="../notebooks/">All notebooks</a></li><li><a class="tocitem" href="../notebooks/1_loading_converting_saving/">Loading, converting, and saving models</a></li><li><a class="tocitem" href="../notebooks/2_finding_balance/">Finding balance and variability of constraint-based models</a></li><li><a class="tocitem" href="../notebooks/3_basic_stdmodel_usage/">Basic usage of <code>StandardModel</code></a></li><li><a class="tocitem" href="../notebooks/4_basic_core_coupled_usage/">Basic usage of <code>CoreModel</code> and <code>CoreModelCoupled</code></a></li><li><a class="tocitem" href="../notebooks/5_basic_stdmodel_construction/">Model construction and modification</a></li><li><a class="tocitem" href="../notebooks/6_screening/">Exploring model variants with <code>screen</code></a></li><li><a class="tocitem" href="../notebooks/7_community_model/">Building and analysing a small community model</a></li><li><a class="tocitem" href="../notebooks/8_custom_model/">Using a custom model data structure</a></li><li><a class="tocitem" href="../notebooks/9_max_min_driving_force_analysis/">Maximum-minimum driving force analysis</a></li></ul></li></ul></li><li><span class="tocitem">Types and functions</span><ul><li class="is-active"><a class="tocitem" href>Contents</a></li><li><a class="tocitem" href="analysis/">Analysis functions</a></li><li><a class="tocitem" href="base/">Base functions</a></li><li><a class="tocitem" href="io/">Input and output</a></li><li><a class="tocitem" href="reconstruction/">Model construction functions</a></li><li><a class="tocitem" href="types/">Types</a></li><li><a class="tocitem" href="utils/">Utilities</a></li></ul></li><li><a class="tocitem" href="../howToContribute/">How to contribute</a></li></ul><div class="docs-version-selector field has-addons"><div class="control"><span class="docs-label button is-static is-size-7">Version</span></div><div class="docs-selector control is-expanded"><div class="select is-fullwidth is-size-7"><select id="documenter-version-selector"></select></div></div></div></nav><div class="docs-main"><header class="docs-navbar"><nav class="breadcrumb"><ul class="is-hidden-mobile"><li><a class="is-disabled">Types and functions</a></li><li class="is-active"><a href>Contents</a></li></ul><ul class="is-hidden-tablet"><li class="is-active"><a href>Contents</a></li></ul></nav><div class="docs-right"><a class="docs-edit-link" href="https://github.com/lcsb-biocore/COBREXA.jl/blob/master/docs/src/functions.md" title="Edit on GitHub"><span class="docs-icon fab"></span><span class="docs-label is-hidden-touch">Edit on GitHub</span></a><a class="docs-settings-button fas fa-cog" id="documenter-settings-button" href="#" title="Settings"></a><a class="docs-sidebar-button fa fa-bars is-hidden-desktop" id="documenter-sidebar-button" href="#"></a></div></header><article class="content" id="documenter-page"><h1 id="Types-and-functions"><a class="docs-heading-anchor" href="#Types-and-functions">Types and functions</a><a id="Types-and-functions-1"></a><a class="docs-heading-anchor-permalink" href="#Types-and-functions" title="Permalink"></a></h1><ul><li><a href="analysis/#Analysis-functions">Analysis functions</a></li><ul><li><a href="analysis/#Common-analysis-functions">Common analysis functions</a></li><li><a href="analysis/#Sampling">Sampling</a></li><li><a href="analysis/#Analysis-modifiers">Analysis modifiers</a></li></ul><li><a href="base/#Base-functions">Base functions</a></li><li><a href="io/#Input-and-output">Input and output</a></li><ul><li><a href="io/#File-I/O-and-serialization">File I/O and serialization</a></li><li><a href="io/#Pretty-printing">Pretty printing</a></li></ul><li><a href="reconstruction/#Model-construction-functions">Model construction functions</a></li><ul><li><a href="reconstruction/#Functions-for-changing-the-models">Functions for changing the models</a></li><li><a href="reconstruction/#Variant-specifiers">Variant specifiers</a></li></ul><li><a href="types/#Types">Types</a></li><ul><li><a href="types/#Base-types">Base types</a></li><li><a href="types/#Model-types-and-contents">Model types and contents</a></li></ul><li><a href="utils/#Utilities">Utilities</a></li><ul><li><a href="utils/#Helper-functions">Helper functions</a></li><li><a href="utils/#Macro-generated-functions-and-internal-helpers">Macro-generated functions and internal helpers</a></li><li><a href="utils/#Logging-and-debugging-helpers">Logging and debugging helpers</a></li></ul></ul></article><nav class="docs-footer"><a class="docs-footer-prevpage" href="../notebooks/9_max_min_driving_force_analysis/">« Maximum-minimum driving force analysis</a><a class="docs-footer-nextpage" href="analysis/">Analysis functions »</a><div class="flexbox-break"></div><p class="footer-message">Powered by <a href="https://github.com/JuliaDocs/Documenter.jl">Documenter.jl</a> and the <a href="https://julialang.org/">Julia Programming Language</a>.</p></nav></div><div class="modal" id="documenter-settings"><div class="modal-background"></div><div class="modal-card"><header class="modal-card-head"><p class="modal-card-title">Settings</p><button class="delete"></button></header><section class="modal-card-body"><p><label class="label">Theme</label><div class="select"><select id="documenter-themepicker"><option value="documenter-light">documenter-light</option><option value="documenter-dark">documenter-dark</option></select></div></p><hr/><p>This document was generated with <a href="https://github.com/JuliaDocs/Documenter.jl">Documenter.jl</a> on <span class="colophon-date" title="Friday 5 November 2021 10:13">Friday 5 November 2021</span>. Using Julia version 1.6.0.</p></section><footer class="modal-card-foot"></footer></div></div></div></body></html>
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
%% Cell type:markdown id: tags:
# Loading, converting, and saving models
%% Cell type:markdown id: tags:
`COBREXA` can load models stored in `.mat`, `.json`, and `.xml` formats (with
the latter denoting SBML formatted models).
%% Cell type:markdown id: tags:
We will primarily use the *E. Coli* "core" model to demonstrate the utilities
found in `COBREXA`. First, let's download the model in several formats.
%% Cell type:code id: tags:
``` julia
# Downloads the model files if they don't already exist
!isfile("e_coli_core.mat") &&
download("http://bigg.ucsd.edu/static/models/e_coli_core.mat", "e_coli_core.mat");
!isfile("e_coli_core.json") &&
download("http://bigg.ucsd.edu/static/models/e_coli_core.json", "e_coli_core.json");
!isfile("e_coli_core.xml") &&
download("http://bigg.ucsd.edu/static/models/e_coli_core.xml", "e_coli_core.xml");
```
%% Cell type:markdown id: tags:
Now, load the package:
%% Cell type:code id: tags:
``` julia
using COBREXA
```
%% Cell type:markdown id: tags:
## Loading models
%% Cell type:markdown id: tags:
Load the models using the `load_model` function. Each model is able to
"pretty-print" itself, hiding the inner complexity.
%% Cell type:code id: tags:
``` julia
mat_model = load_model("e_coli_core.mat")
```
%% Output
Metabolic model of type MATModel
⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠆⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠈⢄⠀⠀⠀⠀⠀⠀⠀⠈⠶⠴⡆⠀⠀⠀⠀⠀⠀
⡀⢐⣀⢀⡀⡒⢒⣐⠀⣂⣂⠀⣂⣂⢂⠀⢀⠀⠀⠀⠀⠀⢀⠄⠀⠀⠀⢂⠀⢂⣀⣐⡒⡀⠆⢙⣀⠀⡀⠀
⠀⠀⠀⠀⠀⠀⠁⠀⠀⠀⠀⠀⠀⠰⠀⠀⠀⠀⠀⠀⠀⠀⠀⠠⠀⠀⠀⠀⠀⡀⠀⠀⠀⠀⠈⢑⣀⣀⠀⠀
⠀⠀⠃⠀⠃⠀⠀⠀⠘⠀⡇⠀⠀⠀⠀⠀⢸⠀⠀⠀⠀⠀⠀⠀⠁⠀⠀⠀⠀⠀⡜⠀⡄⣤⢠⠘⠙⢣⡇⠘
⠀⠐⠀⡀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠄⡀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠐⠀⠀⠀⠀⠀⠐⠁⠉⠀⠀⠀⠀⠀⠘⠄
⠀⢐⠀⠂⠀⠄⠠⠠⠀⠠⠆⠀⠄⠀⠄⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠁⠀⠀⠠⠀⠠⠀⠀⢀⠀⠀⠠⠀⠀⠁
⢀⠐⠀⠨⢀⠁⠈⣈⠀⢁⣁⠀⠀⠀⠀⠈⠀⠀⠀⠀⠀⠀⠀⠀⠀⠄⠀⠁⢀⠀⢊⠉⠀⠀⠀⢀⠀⣀⠀⢀
⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⡈⠀⡀⠆⠀⠆⠀⡀⠀⠀⠀⠀⠀⠀⠀⠈⠀⠀⠆⠀⠀⠀⠀⠀⠀⠀⠀⠀⠆⠀
⠀⠀⠂⠀⡂⠀⠀⠁⠀⠀⠀⠈⠁⠀⠀⠀⠄⠄⢁⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠈⠀⠀⠀⠀⠀⠀
⠈⠀⠁⠀⠀⢀⡀⠀⠠⠁⠁⠀⠑⠀⠐⠲⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠂⠀⠂⠀⠀⠀⠀⠀⠀⠊⠀⠀⠀⠈
⠄⠠⢠⠀⠰⠀⠠⠀⠤⠦⠄⠈⠀⠀⠀⠠⠀⠁⠀⡀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠤⠄⠄⠠⠀⠀⠀⠀⠀
⠂⠐⠀⠀⠐⡠⢐⠘⢃⠒⠂⡀⠄⠀⠀⠐⠀⠀⠀⢀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠒⠀⢀⢀⠀⠀⣀⠀⢀
⠈⠀⠁⠀⡀⠀⠀⠀⠈⠁⠅⠀⠁⠀⢀⠈⠄⠔⠀⠀⠀⠀⠀⠀⠀⠀⠐⠀⠀⠀⠀⠀⠀⠀⠀⠈⠀⠀⠀⠈
⠣⠁⠀⠀⠀⠀⠀⠀⠀⠀⠁⠀⠀⠀⠈⠀⠁⠁⠀⠈⡀⠀⠀⠀⠀⠀⠐⢣⠈⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
⠀⡀⠀⠀⠀⠀⠀⠀⠀⠀⡄⠀⠀⠀⠀⠂⠄⠤⠀⠀⠈⠂⠀⠀⠀⠀⠠⠀⠊⠒⣠⠀⠀⠀⠀⠀⠀⠀⠀⠀
Number of reactions: 95
Number of metabolites: 72
%% Cell type:code id: tags:
``` julia
json_model = load_model("e_coli_core.json")
```
%% Output
Metabolic model of type JSONModel
⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠆⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠈⢄⠀⠀⠀⠀⠀⠀⠀⠈⠶⠴⡆⠀⠀⠀⠀⠀⠀
⡀⢐⣀⢀⡀⡒⢒⣐⠀⣂⣂⠀⣂⣂⢂⠀⢀⠀⠀⠀⠀⠀⢀⠄⠀⠀⠀⢂⠀⢂⣀⣐⡒⡀⠆⢙⣀⠀⡀⠀
⠀⠀⠀⠀⠀⠀⠁⠀⠀⠀⠀⠀⠀⠰⠀⠀⠀⠀⠀⠀⠀⠀⠀⠠⠀⠀⠀⠀⠀⡀⠀⠀⠀⠀⠈⢑⣀⣀⠀⠀
⠀⠀⠃⠀⠃⠀⠀⠀⠘⠀⡇⠀⠀⠀⠀⠀⢸⠀⠀⠀⠀⠀⠀⠀⠁⠀⠀⠀⠀⠀⡜⠀⡄⣤⢠⠘⠙⢣⡇⠘
⠀⠐⠀⡀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠄⡀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠐⠀⠀⠀⠀⠀⠐⠁⠉⠀⠀⠀⠀⠀⠘⠄
⠀⢐⠀⠂⠀⠄⠠⠠⠀⠠⠆⠀⠄⠀⠄⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠁⠀⠀⠠⠀⠠⠀⠀⢀⠀⠀⠠⠀⠀⠁
⢀⠐⠀⠨⢀⠁⠈⣈⠀⢁⣁⠀⠀⠀⠀⠈⠀⠀⠀⠀⠀⠀⠀⠀⠀⠄⠀⠁⢀⠀⢊⠉⠀⠀⠀⢀⠀⣀⠀⢀
⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⡈⠀⡀⠆⠀⠆⠀⡀⠀⠀⠀⠀⠀⠀⠀⠈⠀⠀⠆⠀⠀⠀⠀⠀⠀⠀⠀⠀⠆⠀
⠀⠀⠂⠀⡂⠀⠀⠁⠀⠀⠀⠈⠁⠀⠀⠀⠄⠄⢁⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠈⠀⠀⠀⠀⠀⠀
⠈⠀⠁⠀⠀⢀⡀⠀⠠⠁⠁⠀⠑⠀⠐⠲⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠂⠀⠂⠀⠀⠀⠀⠀⠀⠊⠀⠀⠀⠈
⠄⠠⢠⠀⠰⠀⠠⠀⠤⠦⠄⠈⠀⠀⠀⠠⠀⠁⠀⡀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠤⠄⠄⠠⠀⠀⠀⠀⠀
⠂⠐⠀⠀⠐⡠⢐⠘⢃⠒⠂⡀⠄⠀⠀⠐⠀⠀⠀⢀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠒⠀⢀⢀⠀⠀⣀⠀⢀
⠈⠀⠁⠀⡀⠀⠀⠀⠈⠁⠅⠀⠁⠀⢀⠈⠄⠔⠀⠀⠀⠀⠀⠀⠀⠀⠐⠀⠀⠀⠀⠀⠀⠀⠀⠈⠀⠀⠀⠈
⠣⠁⠀⠀⠀⠀⠀⠀⠀⠀⠁⠀⠀⠀⠈⠀⠁⠁⠀⠈⡀⠀⠀⠀⠀⠀⠐⢣⠈⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
⠀⡀⠀⠀⠀⠀⠀⠀⠀⠀⡄⠀⠀⠀⠀⠂⠄⠤⠀⠀⠈⠂⠀⠀⠀⠀⠠⠀⠊⠒⣠⠀⠀⠀⠀⠀⠀⠀⠀⠀
Number of reactions: 95
Number of metabolites: 72
%% Cell type:code id: tags:
``` julia
sbml_model = load_model("e_coli_core.xml")
```
%% Output
Metabolic model of type SBMLModel
⠀⠈⢀⠀⡀⠀⠀⠀⠀⡠⠂⠀⠀⠀⠀⠈⠀⠄⠀⠀⠀⠀⠀⠀⠀⠀⠀⠠⠀⠀⠀⠀⢀⠐⡀⠀⠀⠀⠀⠄
⠀⠐⠀⠀⠀⠀⠀⠀⡠⠂⠀⠀⠀⠀⢰⠱⣀⠀⡄⢐⠀⠀⢀⠀⠀⠀⡂⠄⠔⠁⠰⠀⠠⠀⣆⠀⠄⢠⢀⠄
⠀⠀⠀⠀⠀⠀⠀⠀⠀⠁⠠⠀⠀⠐⠀⠀⠀⠀⠀⠀⢀⠀⠀⠐⠀⠂⠀⠀⠀⠄⠀⠐⠀⢁⠄⠀⠀⠀⠀⠀
⠀⢀⠀⠐⡈⠀⡀⠀⠂⠀⣀⠀⠑⡈⢀⠀⠀⠀⠀⠀⡀⡠⠀⡀⠰⠁⠈⠂⠁⠀⠠⠀⠀⠂⡂⠀⠂⠂⠀⠀
⠠⠀⠐⠀⠂⠀⠀⢀⠀⠀⠀⠀⠊⠀⡐⠊⠐⠀⠀⠀⠀⠀⠐⠀⠂⠀⠀⠐⠀⠀⠀⠀⠀⠁⠃⠠⠀⠁⠐⠀
⠀⠠⠀⡀⠄⠀⠀⠂⠀⠀⠀⠠⠀⠠⠀⠀⠄⠀⠨⠀⠀⠀⠐⠀⠀⠄⢀⠀⠀⠀⠈⠀⠀⠀⠁⠄⠀⠀⠀⠀
⠀⢐⠐⠀⠄⠀⡂⠀⢐⠀⠀⠀⠀⠂⢀⢀⠐⠂⡀⠈⠀⠀⠀⠂⠀⠈⠀⡀⡐⠀⢄⠀⢀⠀⡆⠀⡀⣀⡀⡐
⠀⠈⠀⠀⠀⠀⠀⠐⢂⠀⢀⠀⠈⠀⠀⠀⠀⠀⠠⠀⠀⠠⠀⠀⠀⠈⠂⠀⠀⠀⠄⠐⠐⠀⠁⠀⠀⠑⠁⠀
⠂⠠⠀⠀⠀⠀⠀⠀⠀⢀⠀⠀⠠⠈⠀⠀⠀⠀⠀⠁⠀⠀⠠⠐⠀⠁⠈⠀⠁⢀⠀⠀⠀⠀⠀⠀⠀⠀⠌⠀
⠀⠀⠂⢨⠀⡀⠀⠐⠁⠐⠀⠐⠊⠀⠀⠀⠀⠀⠀⠀⠀⠀⠢⠒⠈⠐⠐⠁⠂⠀⠀⠀⠄⠓⠕⠂⠃⠁⠀⠐
⠠⠀⠨⠀⠁⠤⠄⠀⠁⡄⠀⠂⠠⠄⢈⠌⠠⠄⠀⢀⠀⠀⠀⠄⠨⠀⡤⠀⢀⠀⢀⠠⠀⠁⡔⠨⠀⠈⠄⠀
⠀⢀⢀⣀⠀⡠⡒⢀⢀⣀⠀⢀⣀⡀⢀⠀⢀⠀⡀⠀⡀⠀⠈⣀⠀⢀⣀⠀⡀⠀⢀⠁⢀⣀⣀⡀⡠⡀⡀⣀
⠀⠄⠀⠀⠀⠀⠀⠀⠀⠂⠁⠀⠀⠀⠀⠀⠀⣠⠀⠀⡀⠀⠀⠀⠀⠀⠀⠀⠈⠀⠀⠀⠀⠀⠀⠐⠀⠀⠀⠀
⢀⠂⠀⠀⠂⠀⠈⠀⠐⠀⠀⠀⠁⠀⠀⠀⡀⠔⠑⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠢⠀⠀⡀⠂⠈⠀⠀⠀⠄
⠀⠐⠀⠀⡂⠀⠂⠀⠀⠀⠒⠐⠄⠂⠐⠀⠘⡀⠀⠠⡂⠃⠀⠂⠄⠂⠀⠀⠀⠀⡀⠀⡀⠀⡂⠂⠀⠀⢀⠀
Number of reactions: 95
Number of metabolites: 72
%% Cell type:markdown id: tags:
You can directly inspect the model objects, although only with a specific way
for each specific type.
%% Cell type:markdown id: tags:
JSON models contain their corresponding JSON:
%% Cell type:code id: tags:
``` julia
json_model.json
```
%% Output
Dict{String, Any} with 6 entries:
"metabolites" => Any[Dict{String, Any}("compartment"=>"e", "name"=>"D-Glucos…
"id" => "e_coli_core"
"compartments" => Dict{String, Any}("c"=>"cytosol", "e"=>"extracellular space…
"reactions" => Any[Dict{String, Any}("name"=>"Phosphofructokinase", "metab…
"version" => "1"
"genes" => Any[Dict{String, Any}("name"=>"adhE", "id"=>"b1241", "notes…
%% Cell type:markdown id: tags:
SBML models contain a complicated structure from [`SBML.jl`
package](https://github.com/LCSB-BioCore/SBML.jl):
%% Cell type:code id: tags:
``` julia
typeof(sbml_model.sbml)
```
%% Output
SBML.Model
%% Cell type:markdown id: tags:
MAT models contain MATLAB data:
%% Cell type:code id: tags:
``` julia
mat_model.mat
```
%% Output
Dict{String, Any} with 17 entries:
"description" => "e_coli_core"
"c" => [0.0; 0.0; … ; 0.0; 0.0]
"rev" => [0; 0; … ; 1; 0]
"mets" => Any["glc__D_e"; "gln__L_c"; … ; "g3p_c"; "g6p_c"]
"grRules" => Any["b3916 or b1723"; "((b0902 and b0903) and b2579) or (b09…
"subSystems" => Any["Glycolysis/Gluconeogenesis"; "Pyruvate Metabolism"; … ;…
"b" => [0.0; 0.0; … ; 0.0; 0.0]
"metFormulas" => Any["C6H12O6"; "C5H10N2O3"; … ; "C3H5O6P"; "C6H11O9P"]
"rxnGeneMat" => …
"S" => [0.0 0.0 … 0.0 0.0; 0.0 0.0 … 0.0 0.0; … ; 0.0 0.0 … 0.0 0.0…
"metNames" => Any["D-Glucose"; "L-Glutamine"; … ; "Glyceraldehyde 3-phosph…
"lb" => [0.0; 0.0; … ; -1000.0; 0.0]
"metCharge" => [0.0; 0.0; … ; -2.0; -2.0]
"ub" => [1000.0; 1000.0; … ; 1000.0; 1000.0]
"rxnNames" => Any["Phosphofructokinase"; "Pyruvate formate lyase"; … ; "O2…
"rxns" => Any["PFK"; "PFL"; … ; "O2t"; "PDH"]
"genes" => Any["b1241"; "b0351"; … ; "b2935"; "b3919"]
%% Cell type:markdown id: tags:
## Using the generic interface to access model details
%% Cell type:markdown id: tags:
To prevent the complexities of object representation, `COBREXA.jl` uses a set
of generic interface functions that extract various important information
from all supported model types. This approach ensures that the analysis
functions can work on any data.
%% Cell type:markdown id: tags:
For example, you can check the reactions and metabolites contained in SBML
and JSON models using the same accessor:
%% Cell type:code id: tags:
``` julia
reactions(json_model)
```
%% Output
95-element Vector{String}:
"PFK"
"PFL"
"PGI"
"PGK"
"PGL"
"ACALD"
"AKGt2r"
"PGM"
"PIt2r"
"ALCD2x"
"MALt2_2"
"MDH"
"ME1"
"ME2"
"NADH16"
"NADTRHD"
"NH4t"
"O2t"
"PDH"
%% Cell type:code id: tags:
``` julia
reactions(sbml_model)
```
%% Output
95-element Vector{String}:
"R_EX_fum_e"
"R_ACONTb"
"R_TPI"
"R_SUCOAS"
"R_GLNS"
"R_EX_pi_e"
"R_PPC"
"R_O2t"
"R_G6PDH2r"
"R_TALA"
"R_THD2"
"R_EX_h2o_e"
"R_GLUSy"
"R_ME1"
"R_GLUN"
"R_EX_o2_e"
"R_FRUpts2"
"R_ALCD2x"
"R_PIt2r"
%% Cell type:code id: tags:
``` julia
issetequal(reactions(json_model), reactions(mat_model)) # do models contain the same reactions?
```
%% Output
true
%% Cell type:markdown id: tags:
All accessors are defined in a single file in COBREXA source code; you may
therefore get a list of all accessors as follows:
%% Cell type:code id: tags:
``` julia
using InteractiveUtils
for method in filter(
x -> endswith(string(x.file), "MetabolicModel.jl"),
InteractiveUtils.methodswith(MetabolicModel, COBREXA),
)
println(method.name)
end
```
%% Output
balance
bounds
coupling
coupling_bounds
gene_annotations
gene_notes
genes
metabolite_annotations
metabolite_charge
metabolite_compartment
metabolite_formula
metabolite_notes
metabolites
n_coupling_constraints
n_genes
n_metabolites
n_reactions
objective
precache!
reaction_annotations
reaction_gene_association
reaction_notes
reaction_stoichiometry
reaction_subsystem
reactions
stoichiometry
%% Cell type:markdown id: tags:
## Converting between model types
%% Cell type:markdown id: tags:
It is possible to convert model types to-and-fro. To do this, use the
`convert` function, which is overloaded from Julia's `Base`.
%% Cell type:code id: tags:
``` julia
m = convert(MATModel, json_model)
```
%% Output
Metabolic model of type MATModel
⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠆⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠈⢄⠀⠀⠀⠀⠀⠀⠀⠈⠶⠴⡆⠀⠀⠀⠀⠀⠀
⡀⢐⣀⢀⡀⡒⢒⣐⠀⣂⣂⠀⣂⣂⢂⠀⢀⠀⠀⠀⠀⠀⢀⠄⠀⠀⠀⢂⠀⢂⣀⣐⡒⡀⠆⢙⣀⠀⡀⠀
⠀⠀⠀⠀⠀⠀⠁⠀⠀⠀⠀⠀⠀⠰⠀⠀⠀⠀⠀⠀⠀⠀⠀⠠⠀⠀⠀⠀⠀⡀⠀⠀⠀⠀⠈⢑⣀⣀⠀⠀
⠀⠀⠃⠀⠃⠀⠀⠀⠘⠀⡇⠀⠀⠀⠀⠀⢸⠀⠀⠀⠀⠀⠀⠀⠁⠀⠀⠀⠀⠀⡜⠀⡄⣤⢠⠘⠙⢣⡇⠘
⠀⠐⠀⡀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠄⡀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠐⠀⠀⠀⠀⠀⠐⠁⠉⠀⠀⠀⠀⠀⠘⠄
⠀⢐⠀⠂⠀⠄⠠⠠⠀⠠⠆⠀⠄⠀⠄⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠁⠀⠀⠠⠀⠠⠀⠀⢀⠀⠀⠠⠀⠀⠁
⢀⠐⠀⠨⢀⠁⠈⣈⠀⢁⣁⠀⠀⠀⠀⠈⠀⠀⠀⠀⠀⠀⠀⠀⠀⠄⠀⠁⢀⠀⢊⠉⠀⠀⠀⢀⠀⣀⠀⢀
⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⡈⠀⡀⠆⠀⠆⠀⡀⠀⠀⠀⠀⠀⠀⠀⠈⠀⠀⠆⠀⠀⠀⠀⠀⠀⠀⠀⠀⠆⠀
⠀⠀⠂⠀⡂⠀⠀⠁⠀⠀⠀⠈⠁⠀⠀⠀⠄⠄⢁⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠈⠀⠀⠀⠀⠀⠀
⠈⠀⠁⠀⠀⢀⡀⠀⠠⠁⠁⠀⠑⠀⠐⠲⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠂⠀⠂⠀⠀⠀⠀⠀⠀⠊⠀⠀⠀⠈
⠄⠠⢠⠀⠰⠀⠠⠀⠤⠦⠄⠈⠀⠀⠀⠠⠀⠁⠀⡀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠤⠄⠄⠠⠀⠀⠀⠀⠀
⠂⠐⠀⠀⠐⡠⢐⠘⢃⠒⠂⡀⠄⠀⠀⠐⠀⠀⠀⢀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠒⠀⢀⢀⠀⠀⣀⠀⢀
⠈⠀⠁⠀⡀⠀⠀⠀⠈⠁⠅⠀⠁⠀⢀⠈⠄⠔⠀⠀⠀⠀⠀⠀⠀⠀⠐⠀⠀⠀⠀⠀⠀⠀⠀⠈⠀⠀⠀⠈
⠣⠁⠀⠀⠀⠀⠀⠀⠀⠀⠁⠀⠀⠀⠈⠀⠁⠁⠀⠈⡀⠀⠀⠀⠀⠀⠐⢣⠈⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
⠀⡀⠀⠀⠀⠀⠀⠀⠀⠀⡄⠀⠀⠀⠀⠂⠄⠤⠀⠀⠈⠂⠀⠀⠀⠀⠠⠀⠊⠒⣠⠀⠀⠀⠀⠀⠀⠀⠀⠀
Number of reactions: 95
Number of metabolites: 72
%% Cell type:markdown id: tags:
`m` will now contain the MATLAB-style matrix representation of the model:
%% Cell type:code id: tags:
``` julia
Matrix(m.mat["S"])
```
%% Output
72×95 Matrix{Float64}:
0.0 0.0 0.0 0.0 0.0 0.0 0.0 … 0.0 0.0 0.0 0.0 0.0 0.0 0.0
0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0
0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0
0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0
0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0
0.0 0.0 0.0 0.0 0.0 0.0 0.0 … 0.0 0.0 0.0 0.0 0.0 0.0 0.0
0.0 0.0 0.0 0.0 -1.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0
0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0
1.0 0.0 0.0 0.0 1.0 1.0 1.0 0.0 0.0 -4.0 0.0 0.0 0.0 0.0
0.0 0.0 0.0 0.0 0.0 0.0 -1.0 0.0 0.0 3.0 0.0 0.0 0.0 0.0
⋮ ⋮ ⋱ ⋮
-1.0 0.0 1.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0
1.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0
0.0 1.0 0.0 0.0 0.0 0.0 0.0 … 0.0 0.0 0.0 0.0 0.0 0.0 0.0
0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0
0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0
0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0
0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0
0.0 0.0 0.0 0.0 0.0 0.0 0.0 … 0.0 0.0 0.0 0.0 0.0 0.0 0.0
0.0 0.0 -1.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0
%% Cell type:markdown id: tags:
The loading and conversion can be combined using a shortcut:
%% Cell type:code id: tags:
``` julia
m = load_model(MATModel, "e_coli_core.json")
```
%% Output
Metabolic model of type MATModel
⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠆⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠈⢄⠀⠀⠀⠀⠀⠀⠀⠈⠶⠴⡆⠀⠀⠀⠀⠀⠀
⡀⢐⣀⢀⡀⡒⢒⣐⠀⣂⣂⠀⣂⣂⢂⠀⢀⠀⠀⠀⠀⠀⢀⠄⠀⠀⠀⢂⠀⢂⣀⣐⡒⡀⠆⢙⣀⠀⡀⠀
⠀⠀⠀⠀⠀⠀⠁⠀⠀⠀⠀⠀⠀⠰⠀⠀⠀⠀⠀⠀⠀⠀⠀⠠⠀⠀⠀⠀⠀⡀⠀⠀⠀⠀⠈⢑⣀⣀⠀⠀
⠀⠀⠃⠀⠃⠀⠀⠀⠘⠀⡇⠀⠀⠀⠀⠀⢸⠀⠀⠀⠀⠀⠀⠀⠁⠀⠀⠀⠀⠀⡜⠀⡄⣤⢠⠘⠙⢣⡇⠘
⠀⠐⠀⡀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠄⡀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠐⠀⠀⠀⠀⠀⠐⠁⠉⠀⠀⠀⠀⠀⠘⠄
⠀⢐⠀⠂⠀⠄⠠⠠⠀⠠⠆⠀⠄⠀⠄⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠁⠀⠀⠠⠀⠠⠀⠀⢀⠀⠀⠠⠀⠀⠁
⢀⠐⠀⠨⢀⠁⠈⣈⠀⢁⣁⠀⠀⠀⠀⠈⠀⠀⠀⠀⠀⠀⠀⠀⠀⠄⠀⠁⢀⠀⢊⠉⠀⠀⠀⢀⠀⣀⠀⢀
⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⡈⠀⡀⠆⠀⠆⠀⡀⠀⠀⠀⠀⠀⠀⠀⠈⠀⠀⠆⠀⠀⠀⠀⠀⠀⠀⠀⠀⠆⠀
⠀⠀⠂⠀⡂⠀⠀⠁⠀⠀⠀⠈⠁⠀⠀⠀⠄⠄⢁⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠈⠀⠀⠀⠀⠀⠀
⠈⠀⠁⠀⠀⢀⡀⠀⠠⠁⠁⠀⠑⠀⠐⠲⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠂⠀⠂⠀⠀⠀⠀⠀⠀⠊⠀⠀⠀⠈
⠄⠠⢠⠀⠰⠀⠠⠀⠤⠦⠄⠈⠀⠀⠀⠠⠀⠁⠀⡀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠤⠄⠄⠠⠀⠀⠀⠀⠀
⠂⠐⠀⠀⠐⡠⢐⠘⢃⠒⠂⡀⠄⠀⠀⠐⠀⠀⠀⢀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠒⠀⢀⢀⠀⠀⣀⠀⢀
⠈⠀⠁⠀⡀⠀⠀⠀⠈⠁⠅⠀⠁⠀⢀⠈⠄⠔⠀⠀⠀⠀⠀⠀⠀⠀⠐⠀⠀⠀⠀⠀⠀⠀⠀⠈⠀⠀⠀⠈
⠣⠁⠀⠀⠀⠀⠀⠀⠀⠀⠁⠀⠀⠀⠈⠀⠁⠁⠀⠈⡀⠀⠀⠀⠀⠀⠐⢣⠈⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
⠀⡀⠀⠀⠀⠀⠀⠀⠀⠀⡄⠀⠀⠀⠀⠂⠄⠤⠀⠀⠈⠂⠀⠀⠀⠀⠠⠀⠊⠒⣠⠀⠀⠀⠀⠀⠀⠀⠀⠀
Number of reactions: 95
Number of metabolites: 72
%% Cell type:markdown id: tags:
## Saving and exporting models
%% Cell type:markdown id: tags:
`COBREXA.jl` supports exporting the models in JSON and MAT format, using `save_model`.
%% Cell type:code id: tags:
``` julia
save_model(m, "converted_model.json")
save_model(m, "converted_model.mat")
```
%% Cell type:markdown id: tags:
If you need a non-standard suffix, use the type-specific saving functions:
%% Cell type:code id: tags:
``` julia
save_json_model(m, "file.without.a.good.suffix")
save_mat_model(m, "another.file.matlab")
```
%% Cell type:markdown id: tags:
If you are saving the models only for future processing in Julia environment,
it is often wasteful to encode the models to external formats and decode them
back. Instead, you can use the "native" Julia data format, accessible with
package `Serialization`.
This way, you can use `serialize` to save even the `StandardModel`
that has no file format associated:
%% Cell type:code id: tags:
``` julia
using Serialization
sm = convert(StandardModel, m)
open(f -> serialize(f, sm), "myModel.stdmodel", "w")
```
%% Cell type:markdown id: tags:
The models can then be loaded back using `deserialize`:
%% Cell type:code id: tags:
``` julia
sm2 = deserialize("myModel.stdmodel")
issetequal(metabolites(sm), metabolites(sm2))
```
%% Output
true
%% Cell type:markdown id: tags:
This form of loading operation is usually pretty quick:
%% Cell type:code id: tags:
``` julia
t = @elapsed deserialize("myModel.stdmodel")
@info "Deserialization took $t seconds"
```
%% Output
┌ Info: Deserialization took 0.002031277 seconds
┌ Info: Deserialization took 0.002527651 seconds
└ @ Main.##258 string:2
%% Cell type:markdown id: tags:
Notably, large and complicated models with thousands of reactions and
annotations can take seconds to decode properly. Serialization allows you to
almost completely remove this overhead, and scales well to tens of millions
of reactions.
%% Cell type:markdown id: tags:
---
*This notebook was generated using [Literate.jl](https://github.com/fredrikekre/Literate.jl).*
......@@ -223,4 +223,4 @@ sm = convert(StandardModel, m)
open(f -&gt; serialize(f, sm), &quot;myModel.stdmodel&quot;, &quot;w&quot;)</code></pre><p>The models can then be loaded back using <code>deserialize</code>:</p><pre><code class="language-julia">sm2 = deserialize(&quot;myModel.stdmodel&quot;)
issetequal(metabolites(sm), metabolites(sm2))</code></pre><pre class="documenter-example-output">true</pre><p>This form of loading operation is usually pretty quick:</p><pre><code class="language-julia">t = @elapsed deserialize(&quot;myModel.stdmodel&quot;)
@info &quot;Deserialization took $t seconds&quot;</code></pre><pre class="documenter-example-output">[ Info: Deserialization took 0.002143039 seconds</pre><p>Notably, large and complicated models with thousands of reactions and annotations can take seconds to decode properly. Serialization allows you to almost completely remove this overhead, and scales well to tens of millions of reactions.</p><hr/><p><em>This page was generated using <a href="https://github.com/fredrikekre/Literate.jl">Literate.jl</a>.</em></p></article><nav class="docs-footer"><a class="docs-footer-prevpage" href="../">« All notebooks</a><a class="docs-footer-nextpage" href="../2_finding_balance/">Finding balance and variability of constraint-based models »</a><div class="flexbox-break"></div><p class="footer-message">Powered by <a href="https://github.com/JuliaDocs/Documenter.jl">Documenter.jl</a> and the <a href="https://julialang.org/">Julia Programming Language</a>.</p></nav></div><div class="modal" id="documenter-settings"><div class="modal-background"></div><div class="modal-card"><header class="modal-card-head"><p class="modal-card-title">Settings</p><button class="delete"></button></header><section class="modal-card-body"><p><label class="label">Theme</label><div class="select"><select id="documenter-themepicker"><option value="documenter-light">documenter-light</option><option value="documenter-dark">documenter-dark</option></select></div></p><hr/><p>This document was generated with <a href="https://github.com/JuliaDocs/Documenter.jl">Documenter.jl</a> on <span class="colophon-date" title="Friday 5 November 2021 09:29">Friday 5 November 2021</span>. Using Julia version 1.6.0.</p></section><footer class="modal-card-foot"></footer></div></div></div></body></html>
@info &quot;Deserialization took $t seconds&quot;</code></pre><pre class="documenter-example-output">[ Info: Deserialization took 0.002117404 seconds</pre><p>Notably, large and complicated models with thousands of reactions and annotations can take seconds to decode properly. Serialization allows you to almost completely remove this overhead, and scales well to tens of millions of reactions.</p><hr/><p><em>This page was generated using <a href="https://github.com/fredrikekre/Literate.jl">Literate.jl</a>.</em></p></article><nav class="docs-footer"><a class="docs-footer-prevpage" href="../">« All notebooks</a><a class="docs-footer-nextpage" href="../2_finding_balance/">Finding balance and variability of constraint-based models »</a><div class="flexbox-break"></div><p class="footer-message">Powered by <a href="https://github.com/JuliaDocs/Documenter.jl">Documenter.jl</a> and the <a href="https://julialang.org/">Julia Programming Language</a>.</p></nav></div><div class="modal" id="documenter-settings"><div class="modal-background"></div><div class="modal-card"><header class="modal-card-head"><p class="modal-card-title">Settings</p><button class="delete"></button></header><section class="modal-card-body"><p><label class="label">Theme</label><div class="select"><select id="documenter-themepicker"><option value="documenter-light">documenter-light</option><option value="documenter-dark">documenter-dark</option></select></div></p><hr/><p>This document was generated with <a href="https://github.com/JuliaDocs/Documenter.jl">Documenter.jl</a> on <span class="colophon-date" title="Friday 5 November 2021 10:13">Friday 5 November 2021</span>. Using Julia version 1.6.0.</p></section><footer class="modal-card-foot"></footer></div></div></div></body></html>
This diff is collapsed.
%% Cell type:markdown id: tags:
# Basic usage of `StandardModel`
%% Cell type:markdown id: tags:
In this tutorial we will use `COBREXA`'s `StandardModel` and functions that
specifically operate on it. As usual we will use the toy model of *E. coli*
for demonstration.
%% Cell type:code id: tags:
``` julia
!isfile("e_coli_core.json") &&
download("http://bigg.ucsd.edu/static/models/e_coli_core.json", "e_coli_core.json")
using COBREXA
```
%% Cell type:markdown id: tags:
## Loading a model
%% Cell type:code id: tags:
``` julia
model = load_model(StandardModel, "e_coli_core.json") # we specifically want to load a StandardModel from the model file
```
%% Output
Metabolic model of type StandardModel
⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠆⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠈⢄⠀⠀⠀⠀⠀⠀⠀⠈⠶⠴⡆⠀⠀⠀⠀⠀⠀
⡀⢐⣀⢀⡀⡒⢒⣐⠀⣂⣂⠀⣂⣂⢂⠀⢀⠀⠀⠀⠀⠀⢀⠄⠀⠀⠀⢂⠀⢂⣀⣐⡒⡀⠆⢙⣀⠀⡀⠀
⠀⠀⠀⠀⠀⠀⠁⠀⠀⠀⠀⠀⠀⠰⠀⠀⠀⠀⠀⠀⠀⠀⠀⠠⠀⠀⠀⠀⠀⡀⠀⠀⠀⠀⠈⢑⣀⣀⠀⠀
⠀⠀⠃⠀⠃⠀⠀⠀⠘⠀⡇⠀⠀⠀⠀⠀⢸⠀⠀⠀⠀⠀⠀⠀⠁⠀⠀⠀⠀⠀⡜⠀⡄⣤⢠⠘⠙⢣⡇⠘
⠀⠐⠀⡀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠄⡀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠐⠀⠀⠀⠀⠀⠐⠁⠉⠀⠀⠀⠀⠀⠘⠄
⠀⢐⠀⠂⠀⠄⠠⠠⠀⠠⠆⠀⠄⠀⠄⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠁⠀⠀⠠⠀⠠⠀⠀⢀⠀⠀⠠⠀⠀⠁
⢀⠐⠀⠨⢀⠁⠈⣈⠀⢁⣁⠀⠀⠀⠀⠈⠀⠀⠀⠀⠀⠀⠀⠀⠀⠄⠀⠁⢀⠀⢊⠉⠀⠀⠀⢀⠀⣀⠀⢀
⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⡈⠀⡀⠆⠀⠆⠀⡀⠀⠀⠀⠀⠀⠀⠀⠈⠀⠀⠆⠀⠀⠀⠀⠀⠀⠀⠀⠀⠆⠀
⠀⠀⠂⠀⡂⠀⠀⠁⠀⠀⠀⠈⠁⠀⠀⠀⠄⠄⢁⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠈⠀⠀⠀⠀⠀⠀
⠈⠀⠁⠀⠀⢀⡀⠀⠠⠁⠁⠀⠑⠀⠐⠲⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠂⠀⠂⠀⠀⠀⠀⠀⠀⠊⠀⠀⠀⠈
⠄⠠⢠⠀⠰⠀⠠⠀⠤⠦⠄⠈⠀⠀⠀⠠⠀⠁⠀⡀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠤⠄⠄⠠⠀⠀⠀⠀⠀
⠂⠐⠀⠀⠐⡠⢐⠘⢃⠒⠂⡀⠄⠀⠀⠐⠀⠀⠀⢀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠒⠀⢀⢀⠀⠀⣀⠀⢀
⠈⠀⠁⠀⡀⠀⠀⠀⠈⠁⠅⠀⠁⠀⢀⠈⠄⠔⠀⠀⠀⠀⠀⠀⠀⠀⠐⠀⠀⠀⠀⠀⠀⠀⠀⠈⠀⠀⠀⠈
⠣⠁⠀⠀⠀⠀⠀⠀⠀⠀⠁⠀⠀⠀⠈⠀⠁⠁⠀⠈⡀⠀⠀⠀⠀⠀⠐⢣⠈⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
⠀⡀⠀⠀⠀⠀⠀⠀⠀⠀⡄⠀⠀⠀⠀⠂⠄⠤⠀⠀⠈⠂⠀⠀⠀⠀⠠⠀⠊⠒⣠⠀⠀⠀⠀⠀⠀⠀⠀⠀
Number of reactions: 95
Number of metabolites: 72
%% Cell type:markdown id: tags:
When using `load_model(StandardModel, file_location)` the model at
`file_location` is first loaded into its inferred format and is then
converted to a `StandardModel` using the generic accessor interface.
Thus, data loss may occur. Always check your model to ensure that
nothing important has been lost.
%% Cell type:markdown id: tags:
## Basic analysis
%% Cell type:markdown id: tags:
As before, for optimization based analysis we need to load an optimizer. Here we
will use [`Tulip.jl`](https://github.com/ds4dm/Tulip.jl) to solve the linear
programs of this tutorial. Refer to the basic constraint-based analysis
tutorial for more informaiton.
%% Cell type:markdown id: tags:
All the normal analysis functions work on `StandardModel`, due to it also
having the same generic accessor interface as all the other model types.
%% Cell type:code id: tags:
``` julia
using Tulip
fluxes = flux_balance_analysis_dict(
model,
Tulip.Optimizer;
modifications = [
change_objective("BIOMASS_Ecoli_core_w_GAM"),
change_constraint("EX_glc__D_e"; lb = -12, ub = -12),
change_constraint("EX_o2_e"; lb = 0, ub = 0),
],
)
```
%% Output
Dict{String, Float64} with 95 entries:
"ACALD" => -9.78427
"PTAr" => 10.0729
"ALCD2x" => -9.78427
"PDH" => 1.98381e-9
"PYK" => 9.94501
"CO2t" => 0.487021
"EX_nh4_e" => -1.48633
"MALt2_2" => -0.0
"CS" => 0.294088
"PGM" => -22.8676
"TKT1" => -0.0487648
"EX_mal__L_e" => -0.0
"ACONTa" => 0.294088
"EX_pi_e" => -1.00274
"GLNS" => 0.069699
"ICL" => 5.34932e-11
"EX_o2_e" => -0.0
"FBA" => 11.7289
"EX_gln__L_e" => -0.0
⋮ => ⋮
%% Cell type:markdown id: tags:
This is not very exciting yet, since every other model type can also do this.
However, deeper inspection of flux results is possible when using
`StandardModel`.
%% Cell type:markdown id: tags:
## Inspecting the flux solution: `atom_fluxes`
%% Cell type:markdown id: tags:
It is sometimes interesting to keep track of the atoms entering and leaving
the system through boundary reactions. This can be inspected by calling
`atom_fluxes`. That gives you the flux of individual atoms getting
consumed and produced by all reactions, based on `fluxes`. We erase the
reaction that consumes the atoms for creating biomass, to see how much mass
the "rest" of the reaction produces for it:
%% Cell type:code id: tags:
``` julia
fluxes_without_biomass = copy(fluxes);
delete!(fluxes_without_biomass, "BIOMASS_Ecoli_core_w_GAM");
atom_fluxes(model, fluxes_without_biomass)
```
%% Output
Dict{String, Float64} with 6 entries:
"S" => 0.0
"C" => 11.5998
"N" => 1.48633
"P" => 1.00274
"H" => 20.7086
"O" => 12.995
%% Cell type:markdown id: tags:
## Inspecting the flux solution: `metabolite_fluxes`
%% Cell type:markdown id: tags:
Another useful flux result analysis function is `metabolite_fluxes`.
This function gives an overview of reactions consuming and producing each
metabolite.
%% Cell type:code id: tags:
``` julia
consuming, producing = metabolite_fluxes(model, fluxes)
consuming["atp_c"] # reactions consuming `atp_c`
```
%% Output
Dict{String, Float64} with 8 entries:
"PFK" => -11.7289
"BIOMASS_Ecoli_core_w_GAM" => -16.3031
"GLNS" => -0.069699
"ATPM" => -8.39
"ADK1" => -1.66663e-10
"PPCK" => -5.66231e-11
"PPS" => -1.66662e-10
"ATPS4r" => -6.80168
%% Cell type:markdown id: tags:
## Internals of `StandardModel`
%% Cell type:markdown id: tags:
Another benefit of `StandardModel` is that it supports a richer internal
infrastructure that can be used to manipulate internal model attributes in a
systematic way. Specifically, the genes, reactions, and metabolites with of a
model each have a type. This is particularly useful when modifying or even
constructing a model from scratch.
%% Cell type:markdown id: tags:
## `Gene`s, `Reaction`s, and `Metabolite`s
%% Cell type:markdown id: tags:
`StandardModel` is composed of ordered dictionaries of `Gene`s, `Metabolite`s
and `Reaction`s. Ordered dictionaries are used because the order of the
reactions and metabolites are important for constructing a stoichiometric
matrix since the rows and columns should correspond to the order of the metabolites
and reactions returned by calling the accessors `metabolites` and `reactions`.
%% Cell type:markdown id: tags:
Each `StandardModel` is composed of the following fields:
%% Cell type:code id: tags:
``` julia
fieldnames(StandardModel) # fields of a StandardModel
```
%% Output
(:id, :reactions, :metabolites, :genes)
%% Cell type:markdown id: tags:
The `:genes` field of a `StandardModel` contains an ordered dictionary of gene ids mapped to `Gene`s.
%% Cell type:code id: tags:
``` julia
model.genes # the keys of this dictionary are the same as genes(model)
```
%% Output
OrderedCollections.OrderedDict{String, Gene} with 137 entries:
"b1241" => Gene("b1241", Dict("original_bigg_ids"=>["b1241"]), Dict("sbo"=>["…
"b0351" => Gene("b0351", Dict("original_bigg_ids"=>["b0351"]), Dict("sbo"=>["…
"s0001" => Gene("s0001", Dict("original_bigg_ids"=>["s0001"]), Dict("sbo"=>["…
"b1849" => Gene("b1849", Dict("original_bigg_ids"=>["b1849"]), Dict("sbo"=>["…
"b3115" => Gene("b3115", Dict("original_bigg_ids"=>["b3115"]), Dict("sbo"=>["…
"b2296" => Gene("b2296", Dict("original_bigg_ids"=>["b2296"]), Dict("sbo"=>["…
"b1276" => Gene("b1276", Dict("original_bigg_ids"=>["b1276"]), Dict("sbo"=>["…
"b0118" => Gene("b0118", Dict("original_bigg_ids"=>["b0118"]), Dict("sbo"=>["…
"b0474" => Gene("b0474", Dict("original_bigg_ids"=>["b0474"]), Dict("sbo"=>["…
"b0116" => Gene("b0116", Dict("original_bigg_ids"=>["b0116"]), Dict("sbo"=>["…
"b0727" => Gene("b0727", Dict("original_bigg_ids"=>["b0727"]), Dict("sbo"=>["…
"b0726" => Gene("b0726", Dict("original_bigg_ids"=>["b0726"]), Dict("sbo"=>["…
"b2587" => Gene("b2587", Dict("original_bigg_ids"=>["b2587"]), Dict("sbo"=>["…
"b0356" => Gene("b0356", Dict("original_bigg_ids"=>["b0356"]), Dict("sbo"=>["…
"b1478" => Gene("b1478", Dict("original_bigg_ids"=>["b1478"]), Dict("sbo"=>["…
"b3734" => Gene("b3734", Dict("original_bigg_ids"=>["b3734"]), Dict("sbo"=>["…
"b3733" => Gene("b3733", Dict("original_bigg_ids"=>["b3733"]), Dict("sbo"=>["…
"b3736" => Gene("b3736", Dict("original_bigg_ids"=>["b3736"]), Dict("sbo"=>["…
"b3737" => Gene("b3737", Dict("original_bigg_ids"=>["b3737"]), Dict("sbo"=>["…
⋮ => ⋮
%% Cell type:markdown id: tags:
The `Gene` type is a struct that can be used to store information about genes
in a `StandardModel`. Each `Gene` is composed of the following fields:
%% Cell type:code id: tags:
``` julia
fieldnames(Gene)
```
%% Output
(:id, :notes, :annotations)
%% Cell type:markdown id: tags:
Use <tab> to quickly explore the fields of a struct. For example,
Gene.<tab> will list all the fields shown above.
%% Cell type:markdown id: tags:
The keys used in the ordered dictionaries in
`model.genes` are the ids returned using the generic accessor `genes`. `Gene`s
have pretty printing, as demonstrated below for a random gene drawn from the
model:
%% Cell type:code id: tags:
``` julia
random_gene_id = genes(model)[rand(1:n_genes(model))]
model.genes[random_gene_id]
```
%% Output
Gene.id: b1852
Gene.id: b4151
Gene.notes:
original_bigg_ids: ["b1852"]
original_bigg_ids: ["b4151"]
Gene.annotations:
sbo: ["SBO:0000243"]
uniprot: ["P0AC53"]
ecogene: ["EG11221"]
ncbigene: ["946370"]
ncbigi: ["16129805"]
refseq_locus_tag: ["b1852"]
refseq_name: ["zwf"]
asap: ["ABE-0006171"]
refseq_synonym: ["JW1841", "ECK1853"]
uniprot: ["P0A8Q3"]
ecogene: ["EG10333"]
ncbigene: ["948668"]
ncbigi: ["16131976"]
refseq_locus_tag: ["b4151"]
refseq_name: ["frdD"]
asap: ["ABE-0013595"]
refseq_synonym: ["JW4112", "ECK4147"]
%% Cell type:markdown id: tags:
The same idea holds for both metabolites (stored as `Metabolite`s) and
reactions (stored as `Reaction`s). This is demonstrated below.
%% Cell type:code id: tags:
``` julia
random_metabolite_id = metabolites(model)[rand(1:n_metabolites(model))]
model.metabolites[random_metabolite_id]
```
%% Output
Metabolite.id: h2o_c
Metabolite.formula: H2O1
Metabolite.charge: 0
Metabolite.id: mal__L_c
Metabolite.formula: C4H4O5
Metabolite.charge: -2
Metabolite.compartment: c
Metabolite.notes:
original_bigg_ids: ["h2o_c"]
original_bigg_ids: ["mal_L_c"]
Metabolite.annotations:
envipath: 650babc9-9d68-4b73-9...
kegg.drug: ["D00001", "D06322"]
kegg.compound: ["C00001", "C01328"]
sabiork: ["1918"]
kegg.compound: ["C00149"]
sbo: ["SBO:0000247"]
sabiork: ["40"]
biocyc: META:CPD-15815, ..., META:OH
chebi: CHEBI:13352, ..., CHEBI:44701
metanetx.chemical: ["MNXM2"]
inchi_key: XLYOFNOQVPJJNP-UHFFF...
hmdb: ["HMDB02111", "HMDB01039"]
bigg.metabolite: ["h2o"]
seed.compound: cpd27222, ..., cpd15275
reactome.compound: 113521, ..., 351603
biocyc: ["META:MAL"]
chebi: CHEBI:15589, ..., CHEBI:11066
metanetx.chemical: ["MNXM98"]
inchi_key: BJEPYKJPYRNKOW-REOHC...
hmdb: ["HMDB00156"]
bigg.metabolite: ["mal__L"]
seed.compound: ["cpd00130"]
reactome.compound: ["198498", "113544"]
%% Cell type:code id: tags:
``` julia
random_reaction_id = reactions(model)[rand(1:n_reactions(model))]
model.reactions[random_reaction_id]
```
%% Output
Reaction.id: ATPM
Reaction.metabolites: 1.0 h2o_c + 1.0 atp_c 1.0 adp_c + 1.0 pi_c + 1.0 h_c
Reaction.lb: 8.39
Reaction.id: GAPD
Reaction.metabolites: 1.0 nad_c + 1.0 g3p_c + 1.0 pi_c 1.0 13dpg_c + 1.0 h_c + 1.0 nadh_c
Reaction.lb: -1000.0
Reaction.ub: 1000.0
Reaction.grr: ---
Reaction.subsystem: Biomass and maintenance functions
Reaction.grr: (b1779)
Reaction.subsystem: Glycolysis/Gluconeogenesis
Reaction.notes:
original_bigg_ids: ["ATPM"]
original_bigg_ids: ["GAPD"]
Reaction.annotations:
bigg.reaction: ["ATPM"]
sabiork: ["75"]
metanetx.reaction: ["MNXR96131"]
rhea: 13066, ..., 13067
bigg.reaction: ["GAPD"]
sabiork: ["7844"]
metanetx.reaction: ["MNXR100040"]
rhea: 10303, ..., 10301
sbo: ["SBO:0000176"]
seed.reaction: rxn11300, ..., rxn00062
kegg.reaction: ["R00086"]
biocyc: ["META:ATPASE-RXN"]
ec-code: 3.6.1.5, ..., 3.6.3.49
seed.reaction: ["rxn00781"]
kegg.reaction: ["R01061"]
biocyc: META:GAPOXNPHOSPHN-R...
reactome.reaction: R-ATH-70482, ..., R-BTA-70482
ec-code: ["1.2.1.12", "1.2.1.59"]
Reaction.objective_coefficient: 0.0
%% Cell type:markdown id: tags:
`StandardModel` can be used to build your own metabolic model or modify an
existing one. One of the main use cases for `StandardModel` is that it can be
used to merge multiple models or parts of multiple models together. Since the
internals are uniform inside each `StandardModel`, attributes of other model
types are squashed into the required format (using the generic accessors).
This ensures that the internals of all `StandardModel`s are the same -
allowing easy systematic evaluation.
%% Cell type:markdown id: tags:
## Checking the internals of `StandardModel`s: `annotation_index`
%% Cell type:markdown id: tags:
Often when models are automatically reconstructed duplicate genes, reactions
or metabolites end up in a model. `COBREXA` exports `annotation_index` to
check for cases where the id of a struct may be different, but the annotations
the same (possibly suggesting a duplication). `annotation_index` builds a
dictionary mapping annotation features to the ids of whatever struct you are
inspecting. This makes it easy to find structs that share certain annotation features.
%% Cell type:code id: tags:
``` julia
rxn_annotations = annotation_index(model.reactions)
```
%% Output
Dict{String, Dict{String, Set{String}}} with 10 entries:
"ec-code" => Dict("3.6.3.37"=>Set(["ATPM"]), "3.6.3.42"=>Set(["ATPM…
"sabiork" => Dict("109"=>Set(["PGL"]), "762"=>Set(["GLUN"]), "155"=…
"metanetx.reaction" => Dict("MNXR104869"=>Set(["TKT2"]), "MNXR99715"=>Set(["E…
"rhea" => Dict("27626"=>Set(["TKT2"]), "10229"=>Set(["ACONTa"]),…
"sbo" => Dict("SBO:0000627"=>Set(["EX_for_e", "EX_nh4_e", "EX_p…
"seed.reaction" => Dict("rxn05297"=>Set(["GLUt2r"]), "rxn09717"=>Set(["PY…
"kegg.reaction" => Dict("R00114"=>Set(["GLUSy"]), "R00199"=>Set(["PPS"]),…
"biocyc" => Dict("META:TRANS-RXN-121B"=>Set(["FUMt2_2"]), "META:PE…
"reactome.reaction" => Dict("R-TGU-71397"=>Set(["PDH"]), "R-XTR-70449"=>Set([…
"bigg.reaction" => Dict("ACALD"=>Set(["ACALD"]), "PTAr"=>Set(["PTAr"]), "…
%% Cell type:code id: tags:
``` julia
rxn_annotations["ec-code"]
```
%% Output
Dict{String, Set{String}} with 141 entries:
"3.6.3.37" => Set(["ATPM"])
"3.6.3.42" => Set(["ATPM"])
"3.6.3.38" => Set(["ATPM"])
"3.6.3.19" => Set(["ATPM"])
"2.3.3.1" => Set(["CS"])
"1.6.1.2" => Set(["NADTRHD"])
"3.6.3.35" => Set(["ATPM"])
"6.2.1.5" => Set(["SUCOAS"])
"6.3.5.4" => Set(["GLUN"])
"3.6.3.49" => Set(["ATPM"])
"3.6.3.51" => Set(["ATPM"])
"1.2.1.12" => Set(["GAPD"])
"3.6.3.32" => Set(["ATPM"])
"2.3.3.3" => Set(["CS"])
"2.7.4.3" => Set(["ADK1"])
"6.3.5.5" => Set(["GLUN"])
"3.5.1.2" => Set(["GLUN"])
"1.1.1.49" => Set(["G6PDH2r"])
"5.3.1.9" => Set(["PGI"])
⋮ => ⋮
%% Cell type:markdown id: tags:
The `annotation_index` function can also be used on `Reaction`s and
`Gene`s in the same way.
%% Cell type:markdown id: tags:
## Checking the internals of `StandardModel`s: `check_duplicate_reaction`
%% Cell type:markdown id: tags:
Another useful function is `check_duplicate_reaction`, which checks for
reactions that have duplicate (or similar) reaction equations.
%% Cell type:code id: tags:
``` julia
pgm_duplicate = Reaction()
pgm_duplicate.id = "pgm2" # Phosphoglycerate mutase
pgm_duplicate.metabolites = Dict{String,Float64}("3pg_c" => 1, "2pg_c" => -1)
pgm_duplicate
```
%% Output
Reaction.id: pgm2
Reaction.metabolites: 1.0 2pg_c ↔ 1.0 3pg_c
Reaction.lb: -1000.0
Reaction.ub: 1000.0
Reaction.grr: ---
Reaction.subsystem: ---
Reaction.notes: ---
Reaction.annotations: ---
Reaction.objective_coefficient: 0.0
%% Cell type:code id: tags:
``` julia
check_duplicate_reaction(pgm_duplicate, model.reactions; only_metabolites = false) # can also just check if only the metabolites are the same but different stoichiometry is used
```
%% Output
"PGM"
%% Cell type:markdown id: tags:
## Checking the internals of `StandardModel`s: `reaction_mass_balanced`
%% Cell type:markdown id: tags:
Finally, `reaction_mass_balanced` can be used to check if a reaction is mass
balanced based on the formulas of the reaction equation.
%% Cell type:code id: tags:
``` julia
rxn_dict = Dict{String,Float64}("3pg_c" => 1, "2pg_c" => -1, "h2o_c" => 1)
reaction_mass_balanced(model, rxn_dict)
```
%% Output
false
%% Cell type:markdown id: tags:
Now to determine which atoms are unbalanced, you can use `reaction_atom_balance`
%% Cell type:code id: tags:
``` julia
reaction_atom_balance(model, rxn_dict)
```
%% Output
Dict{String, Float64} with 4 entries:
"C" => 0.0
"P" => 0.0
"H" => 2.0
"O" => 1.0
%% Cell type:markdown id: tags:
Note, since `pgm_duplicate` is not in the model, we cannot use the other variants of this
function because they find the reaction equation stored inside the `model`.
%% Cell type:markdown id: tags:
---
*This notebook was generated using [Literate.jl](https://github.com/fredrikekre/Literate.jl).*
This diff is collapsed.
This diff is collapsed.
%% Cell type:markdown id: tags:
# Exploring model variants with `screen`
%% Cell type:markdown id: tags:
This notebooks demonstrates a simple use of `screen` to explore large
number of model variants. On the toy *E. Coli* model, we try to map the
impact of knocking out single reactions and 2-reaction combinations.
%% Cell type:markdown id: tags:
First, let's download the data and load the packages and the model
%% Cell type:code id: tags:
``` julia
!isfile("e_coli_core.json") &&
download("http://bigg.ucsd.edu/static/models/e_coli_core.json", "e_coli_core.json");
using COBREXA, Tulip
model = load_model(StandardModel, "e_coli_core.json")
```
%% Output
Metabolic model of type StandardModel
⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠆⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠈⢄⠀⠀⠀⠀⠀⠀⠀⠈⠶⠴⡆⠀⠀⠀⠀⠀⠀
⡀⢐⣀⢀⡀⡒⢒⣐⠀⣂⣂⠀⣂⣂⢂⠀⢀⠀⠀⠀⠀⠀⢀⠄⠀⠀⠀⢂⠀⢂⣀⣐⡒⡀⠆⢙⣀⠀⡀⠀
⠀⠀⠀⠀⠀⠀⠁⠀⠀⠀⠀⠀⠀⠰⠀⠀⠀⠀⠀⠀⠀⠀⠀⠠⠀⠀⠀⠀⠀⡀⠀⠀⠀⠀⠈⢑⣀⣀⠀⠀
⠀⠀⠃⠀⠃⠀⠀⠀⠘⠀⡇⠀⠀⠀⠀⠀⢸⠀⠀⠀⠀⠀⠀⠀⠁⠀⠀⠀⠀⠀⡜⠀⡄⣤⢠⠘⠙⢣⡇⠘
⠀⠐⠀⡀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠄⡀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠐⠀⠀⠀⠀⠀⠐⠁⠉⠀⠀⠀⠀⠀⠘⠄
⠀⢐⠀⠂⠀⠄⠠⠠⠀⠠⠆⠀⠄⠀⠄⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠁⠀⠀⠠⠀⠠⠀⠀⢀⠀⠀⠠⠀⠀⠁
⢀⠐⠀⠨⢀⠁⠈⣈⠀⢁⣁⠀⠀⠀⠀⠈⠀⠀⠀⠀⠀⠀⠀⠀⠀⠄⠀⠁⢀⠀⢊⠉⠀⠀⠀⢀⠀⣀⠀⢀
⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⡈⠀⡀⠆⠀⠆⠀⡀⠀⠀⠀⠀⠀⠀⠀⠈⠀⠀⠆⠀⠀⠀⠀⠀⠀⠀⠀⠀⠆⠀
⠀⠀⠂⠀⡂⠀⠀⠁⠀⠀⠀⠈⠁⠀⠀⠀⠄⠄⢁⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠈⠀⠀⠀⠀⠀⠀
⠈⠀⠁⠀⠀⢀⡀⠀⠠⠁⠁⠀⠑⠀⠐⠲⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠂⠀⠂⠀⠀⠀⠀⠀⠀⠊⠀⠀⠀⠈
⠄⠠⢠⠀⠰⠀⠠⠀⠤⠦⠄⠈⠀⠀⠀⠠⠀⠁⠀⡀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠤⠄⠄⠠⠀⠀⠀⠀⠀
⠂⠐⠀⠀⠐⡠⢐⠘⢃⠒⠂⡀⠄⠀⠀⠐⠀⠀⠀⢀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠒⠀⢀⢀⠀⠀⣀⠀⢀
⠈⠀⠁⠀⡀⠀⠀⠀⠈⠁⠅⠀⠁⠀⢀⠈⠄⠔⠀⠀⠀⠀⠀⠀⠀⠀⠐⠀⠀⠀⠀⠀⠀⠀⠀⠈⠀⠀⠀⠈
⠣⠁⠀⠀⠀⠀⠀⠀⠀⠀⠁⠀⠀⠀⠈⠀⠁⠁⠀⠈⡀⠀⠀⠀⠀⠀⠐⢣⠈⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
⠀⡀⠀⠀⠀⠀⠀⠀⠀⠀⡄⠀⠀⠀⠀⠂⠄⠤⠀⠀⠈⠂⠀⠀⠀⠀⠠⠀⠊⠒⣠⠀⠀⠀⠀⠀⠀⠀⠀⠀
Number of reactions: 95
Number of metabolites: 72
%% Cell type:markdown id: tags:
## Preparing the functions
While we could use the `with_changed_bound` to limit the reaction rates,
but we will make a slightly more precise, usage-tailored modification. This
is a straightforward modification of the `with_changed_bound` that does
not set bounds "outside" of the original bounds:
%% Cell type:code id: tags:
``` julia
with_limited_rate(reaction_id::String, limit) =
model::StandardModel -> begin
m = copy(model)
m.reactions = copy(model.reactions)
r = m.reactions[reaction_id] = copy(model.reactions[reaction_id])
if -limit > r.lb
r.lb = -limit
end
if limit < r.ub
r.ub = limit
end
m
end
```
%% Output
with_limited_rate (generic function with 1 method)
%% Cell type:markdown id: tags:
## Knocking out single reactions
This can be applied to see how much biomass can the model produce with
certain reactions limited to almost zero:
%% Cell type:code id: tags:
``` julia
get_biomass(x) = isnothing(x) ? 0 : x["BIOMASS_Ecoli_core_w_GAM"]
productions = screen_variants(
model,
[[with_limited_rate(rxn, 0.1)] for rxn in reactions(model)],
model -> get_biomass(flux_balance_analysis_dict(model, Tulip.Optimizer)),
)
```
%% Output
95-element Vector{Real}:
0.7110773172306842
0.8739215069620168
0.8633809523181394
0.007974352115966855
0.8640171040038155
0.8739215063456838
0.87392150695555
0.009054524481803774
0.027183515911490083
0.8739215069216937
0.8739215022678488
0.8270283079105472
0.8739215065011818
0.8739215045533449
0.2134628028114079
0.8739215053667706
0.018339201041498398
0.21526265974680137
0.7975549891965422
%% Cell type:markdown id: tags:
This can be nicely plotted to give a more comprehensive overview of which
reactions are critical or not:
%% Cell type:code id: tags:
``` julia
using CairoMakie
disp_rxns = rand(1:95, 20) # only display 20 random fluxes to save space
barplot(
productions[disp_rxns],
direction = :x,
axis = (
yticks = (1:20, reactions(model)[disp_rxns]),
xlabel = "Flux [mmol/gDW/h]",
ylabel = "Reaction ID",
),
)
```
%% Output
FigureAxisPlot()
%% Cell type:markdown id: tags:
## Knocking out reaction combinations
It is very easy to prepare matrices of biomass productions from all possible
two-reaction knockouts. To make it more interesting, we will restrict one of
the reactions of the pair a bit less, to see more possible outcomes.
%% Cell type:markdown id: tags:
We do not process all reactions here to make the notebook rendering
efficient, but you can easily remove the restriction, and speed the process
up using parallel execution, by specifying `workers` argument (see
documentation of `screen` for details)
%% Cell type:code id: tags:
``` julia
rxns = reactions(model)
productions = screen_variants(
model,
[
[with_limited_rate(rxn1, 3), with_limited_rate(rxn2, 0.1)] for rxn1 in rxns,
rxn2 in rxns
],
model -> get_biomass(flux_balance_analysis_dict(model, Tulip.Optimizer)),
)
f = Figure()
ax = Axis(
f[1, 1],
ylabel = "Reaction KO",
xlabel = "Reaction KO",
yticks = (1:20, reactions(model)[disp_rxns]),
xticks = (1:20, reactions(model)[disp_rxns]),
xticklabelrotation = -pi / 4,
)
hm = heatmap!(ax, productions[disp_rxns, disp_rxns])
Colorbar(f[1, 2], hm, label = "Flux [mmol/gDW/h]")
f
```
%% Output
Figure()
%% Cell type:markdown id: tags:
---
*This notebook was generated using [Literate.jl](https://github.com/fredrikekre/Literate.jl).*
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment