@@ -23,12 +24,8 @@ Some of the features used in this package require external programs to be instal
* The Equilibrator interface requires that the Equilibrator-API has been installed and can be accessed through Julia's PyCall package. Refer to the [Equilibrator-API website](https://gitlab.com/equilibrator/equilibrator-api) for installation instructions. Within Julia, if you can call `pyimport("equilibrator_api")` successfully, then you will be able to use the functions exposed here. To actually use the functions insert `using PyCall` in your main level script (before or after `using CobraTools`).
* To extract turnover numbers, Km, Kcat/Km and Ki from the Brenda database, you will need to download the database as a txt file [available here](https://www.brenda-enzymes.org/download_brenda_without_registration.php)(~250 MB).
The optimization solvers are implemented through `JuMP` and thus this package should be solver agnostic. All tests are conducted using `Gurobi.jl` but other solvers should work.
The optimization solvers are implemented through `JuMP` and thus this package should be solver agnostic. All tests are conducted using `GLPK.jl` but other solvers should work (I use `Gurobi.jl` mostly).
Before reading or writing models, it is important to understand how they are represented internally.
Each model is a type of `CobraTools.Model`, which is composed of a model `id`, arrays of `Reaction`s, `Metabolite`s and `Gene`s, and a gene reaction rules (`grrs`) dictionary.
The fields of `Reaction`, `Metabolite`, `Gene` types are shown below.
When reading or writing, these fields are what is used by `CobraTools.jl`.
```@docs
Model
```
Note, the format of `grrs` in `CobraTools.Model` is a nested array, like [[g1, g2], [g3, g4], ...], indexed by a reaction `id` key.
Each sub-array, e.g. [g1, g2], is composed of essential genes for the reaction to function.
Thus, if rxn1 requires (g1 and g2) or (g3 and g4) to function, then this would be represented by rxn1 => [[g1, g2], [g3, g4]] in `grrs`.
```@docs
Reaction
```
Note, the format of `grr` in `Reaction` is a string like `"(g1 and g2) or (g3 and g4)"`.
This string is parsed into the format used by `grrs` in `CobraTools.Model`, as explained above.
Also note, the metabolites dictionary field of `Reaction` maps a `Metabolite` to its stoichiometrix coefficient.
```@docs
Metabolite
```
```@docs
Gene
```
FIY: `JuMP` also exports a `Model` type, so you need to qualify which `Model` you are referring to when making a new function.
## Reading constraint based models
Currently, SBML, JSON and Matlab formatted models can be imported.
adp = Metabolite("adp") # define another metabolite
metdict = Dict(atp => -1.0, adp => 1.0) # nb stoichiometries need to be floats
rxn = Reaction("dummy rxn", metdict, "for")
rxn.annotation["ec-code"] = ["0.0.0.0"]
rxn.grr = [[gene]] # only gene1 is required for this reaction to work
rxn # pretty printing
```
See the discussion in [Model Structure](@ref) about how to assign `grr` to a reaction.
Yet another way of defining a reaction is through overloading of the operators: `*, +, ∅, ⟶, →, ←, ⟵, ↔, ⟷`.
The longer and shorter arrows mean the same thing, i.e. `⟶` is the same as `→`, etc.
The other fields of the reaction still need to be set directly.
```@example
using CobraTools # hide
atp = Metabolite("atp") # hide
atp.name = "Adenosine triphosphate" # hide
atp.formula = "C10H12N5O13P3" # hide
atp.charge = -4 # hide
adp = Metabolite("adp") # hide
adp.formula = "C10H12N5O10P2" # hide
another_rxn = 2.0adp ⟶ 2.0*atp # forward reaction
another_rxn.id = "another dummy rxn"
another_rxn
```
When building exchange, demand, or sinks reactions the `∅` empty metabolite should be used to indicate that a metabolite is being created or destroyed.
```@example
using CobraTools # hide
adp = Metabolite("adp") # hide
adp.formula = "C10H12N5O10P2" # hide
ex_rxn = ∅ ⟷ adp # exchange reaction
```
It is also possible to check if a reaction is mass balanced by using `is_mass_balanced(rxn::Reaction)`.
Note, this function requires that all the metabolites in the reaction have formulas assigned to them to work properly.
function ⟶(substrates::Union{Metabolite,MetaboliteWithCoefficient,Array{MetaboliteWithCoefficient,1}},products::Union{Metabolite,MetaboliteWithCoefficient,Array{MetaboliteWithCoefficient,1}})
metdict=mkrxn(substrates,products)
returnReaction(metdict,"for")
returnReaction("",metdict,"for")
end
const→=⟶
...
...
@@ -65,7 +65,7 @@ Reverse only reaction.
"""
function ⟵(substrates::Union{Metabolite,MetaboliteWithCoefficient,Array{MetaboliteWithCoefficient,1}},products::Union{Metabolite,MetaboliteWithCoefficient,Array{MetaboliteWithCoefficient,1}})
function ⟷(substrates::Union{Metabolite,MetaboliteWithCoefficient,Array{MetaboliteWithCoefficient,1}},products::Union{Metabolite,MetaboliteWithCoefficient,Array{MetaboliteWithCoefficient,1}})