structs.jl 1.46 KB
Newer Older
1

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

    UnitPart("second", # base unit of time
             -2, # exponent, says "per square"
             6, # scale in powers of 10, says "mega"
             1/3600) # second-to-hour multiplier
"""
11
12
13
14
15
16
17
18
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
19
20
"""
Reaction with stoichiometry that assigns reactants and products their relative
Miroslav Kratochvil's avatar
Miroslav Kratochvil committed
21
22
23
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
24
"""
25
26
27
28
29
30
31
32
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
33
34
35
"""
Species metadata -- human-readable name and compartment identifier
"""
36
37
38
39
40
41
struct Species
    name::String
    compartment::String
    Species(n, c) = new(n, c)
end

Miroslav Kratochvil's avatar
Miroslav Kratochvil committed
42
"""
Miroslav Kratochvil's avatar
Miroslav Kratochvil committed
43
44
45
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
46
"""
47
48
49
50
51
52
53
struct Model
    units::Dict{String,Vector{UnitPart}}
    compartments::Vector{String}
    species::Dict{String,Species}
    reactions::Dict{String,Reaction}
    Model(u, c, s, r) = new(u, c, s, r)
end