structs.jl 2.72 KB
Newer Older
1

Miroslav Kratochvil's avatar
Miroslav Kratochvil committed
2
3
4
5
6
7
"""
    Maybe{X}

Type shortcut for "`X` or nothing" or "nullable `X`" in javaspeak. Name
got inspired by our functional friends.
"""
8
9
const Maybe{X} = Union{Nothing,X}

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

Miroslav Kratochvil's avatar
Miroslav Kratochvil committed
14
15
16
17
18
19
20
21
    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
22
"""
23
24
25
26
27
28
29
30
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
31
32
"""
Reaction with stoichiometry that assigns reactants and products their relative
Miroslav Kratochvil's avatar
Miroslav Kratochvil committed
33
34
consumption/production rates (accessible in field `stoichiometry`), lower/upper
bounds (in tuples `lb` and `ub`, with unit names), and objective coefficient
Miroslav Kratochvil's avatar
Miroslav Kratochvil committed
35
(`oc`). Also may contains `notes` and `annotation`.
Miroslav Kratochvil's avatar
Miroslav Kratochvil committed
36
"""
37
38
39
40
41
struct Reaction
    stoichiometry::Dict{String,Float64}
    lb::Tuple{Float64,String}
    ub::Tuple{Float64,String}
    oc::Float64
42
    notes::Maybe{String}
43
44
    annotation::Maybe{String}
    Reaction(s, l, u, o, n = nothing, a = nothing) = new(s, l, u, o, n, a)
45
46
end

Miroslav Kratochvil's avatar
Miroslav Kratochvil committed
47
"""
Miroslav Kratochvil's avatar
Miroslav Kratochvil committed
48
49
Species metadata -- contains a human-readable `name`, a `compartment`
identifier, `formula`, `charge`, and additional `notes` and `annotation`.
Miroslav Kratochvil's avatar
Miroslav Kratochvil committed
50
"""
51
52
53
struct Species
    name::String
    compartment::String
54
    formula::Maybe{String}
55
56
    charge::Maybe{Int}
    notes::Maybe{String}
57
58
    annotation::Maybe{String}
    Species(na, co, f, ch, no = nothing, a = nothing) = new(na, co, f, ch, no, a)
59
60
end

Miroslav Kratochvil's avatar
Miroslav Kratochvil committed
61
62
63
64
65
66
67
68
69
70
71
"""
Gene product metadata.
"""
struct GeneProduct
    name::Maybe{String}
    label::Maybe{String}
    notes::Maybe{String}
    annotation::Maybe{String}
    GeneProduct(na, l, no = nothing, a = nothing) = new(na, l, no, a)
end

Miroslav Kratochvil's avatar
Miroslav Kratochvil committed
72
"""
Miroslav Kratochvil's avatar
Miroslav Kratochvil committed
73
74
75
76
77
Structure that collects the model-related data. Contains `parameters`, `units`,
`compartments`, `species` and `reactions` and `gene_products`, and additional
`notes` and `annotation` (also present internally in some of the data fields).
The contained dictionaries are indexed by identifiers of the corresponding
objects.
Miroslav Kratochvil's avatar
Miroslav Kratochvil committed
78
"""
79
struct Model
Miroslav Kratochvil's avatar
Miroslav Kratochvil committed
80
    parameters::Dict{String,Float64}
81
82
83
84
    units::Dict{String,Vector{UnitPart}}
    compartments::Vector{String}
    species::Dict{String,Species}
    reactions::Dict{String,Reaction}
Miroslav Kratochvil's avatar
Miroslav Kratochvil committed
85
    gene_products::Dict{String,GeneProduct}
86
    notes::Maybe{String}
87
    annotation::Maybe{String}
Miroslav Kratochvil's avatar
Miroslav Kratochvil committed
88
    Model(p, u, c, s, r, g, n = nothing, a = nothing) = new(p, u, c, s, r, g, n, a)
89
end