structs.jl 1.76 KB
Newer Older
1

Miroslav Kratochvil's avatar
Miroslav Kratochvil committed
2
"""
Miroslav Kratochvil's avatar
Miroslav Kratochvil committed
3
Part of a measurement unit definition that corresponds to the SBML definition
Miroslav Kratochvil's avatar
Miroslav Kratochvil committed
4
of `Unit`. For example, the unit "per square megahour", Mh^(-2), is written as:
Miroslav Kratochvil's avatar
Miroslav Kratochvil committed
5

Miroslav Kratochvil's avatar
Miroslav Kratochvil committed
6
7
8
9
10
11
12
13
    UnitPart("second",  # base SI unit, this says we are measuring time
             -2,        # exponent, says "per square"
             6,         # log-10 scale of the unit, says "mega"
             1/3600)    # second-to-hour multiplier

Compound units (such as "volt-amperes" and "dozens of yards per ounce") are
built from multiple `UnitPart`s; see the definition of field `units` in
[`Model`](@ref).
Miroslav Kratochvil's avatar
Miroslav Kratochvil committed
14
"""
15
16
17
18
19
20
21
22
struct UnitPart
    kind::String
    exponent::Int
    scale::Int
    multiplier::Float64
    UnitPart(k, e, s, m) = new(k, e, s, m)
end

Miroslav Kratochvil's avatar
Miroslav Kratochvil committed
23
24
"""
Reaction with stoichiometry that assigns reactants and products their relative
Miroslav Kratochvil's avatar
Miroslav Kratochvil committed
25
26
27
consumption/production rates (accessible in field `stoichiometry`), lower/upper
bounds (in tuples `lb` and `ub`, with unit names), and objective coefficient
(`oc`).
Miroslav Kratochvil's avatar
Miroslav Kratochvil committed
28
"""
29
30
31
32
33
34
35
36
struct Reaction
    stoichiometry::Dict{String,Float64}
    lb::Tuple{Float64,String}
    ub::Tuple{Float64,String}
    oc::Float64
    Reaction(s, l, u, o) = new(s, l, u, o)
end

Miroslav Kratochvil's avatar
Miroslav Kratochvil committed
37
"""
Miroslav Kratochvil's avatar
Miroslav Kratochvil committed
38
39
Species metadata -- contains a human-readable `name`, and a `compartment`
identifier
Miroslav Kratochvil's avatar
Miroslav Kratochvil committed
40
"""
41
42
43
struct Species
    name::String
    compartment::String
44
45
    formula::String
    Species(n, c, f) = new(n, c, f)
46
47
end

Miroslav Kratochvil's avatar
Miroslav Kratochvil committed
48
"""
Miroslav Kratochvil's avatar
Miroslav Kratochvil committed
49
50
51
Structure that collects the model-related data. Contains `units`,
`compartments`, `species` and `reactions`. The contained dictionaries are
indexed by identifiers of the corresponding objects.
Miroslav Kratochvil's avatar
Miroslav Kratochvil committed
52
"""
53
struct Model
St. Elmo's avatar
St. Elmo committed
54
    params::Dict{String,Float64}
55
56
57
58
    units::Dict{String,Vector{UnitPart}}
    compartments::Vector{String}
    species::Dict{String,Species}
    reactions::Dict{String,Reaction}
St. Elmo's avatar
St. Elmo committed
59
    Model(p, u, c, s, r) = new(p, u, c, s, r)
60
end