Skip to content

Commit 245b12d

Browse files
committed
save progress
1 parent 9ba924a commit 245b12d

File tree

2 files changed

+65
-1
lines changed

2 files changed

+65
-1
lines changed

src/network_analysis.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -727,7 +727,7 @@ function cache_conservationlaw_eqs!(rn::ReactionSystem, N::AbstractMatrix, col_o
727727
@parameters $(CONSERVED_CONSTANT_SYMBOL)[1:nullity] [conserved=true])))
728728

729729
# Computes the equations for (examples uses simple two-state system, `X1 <--> X2`):
730-
# - The species eliminated through conservation laws (`conservedeqs`). E.g. `[X2 ~ X1 - Γ[1]]`.
730+
# - The species eliminated through conservation laws (`conservedeqs`). E.g. `[X2 ~ Γ[1] - X1]`.
731731
# - The conserved quantity parameters (`constantdefs`). E.g. `[Γ[1] ~ X1 + X2]`.
732732
conservedeqs = Equation[]
733733
constantdefs = Equation[]

src/reactionsystem.jl

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,25 +76,89 @@ Base.Sort.defalg(::ReactionComplex) = Base.DEFAULT_UNSTABLE
7676

7777
#! format: off
7878
# Internal cache for various ReactionSystem calculated properties
79+
# All related functionality is in the "network_analysis.jl" file. However, this must be declared
80+
# here as the structure is part of the `ReactionSystem` structure.
7981
Base.@kwdef mutable struct NetworkProperties{I <: Integer, V <: BasicSymbolic{Real}}
82+
"""Flag which is switched to `true` once any field is updated."""
8083
isempty::Bool = true
8184
netstoichmat::Union{Matrix{Int}, SparseMatrixCSC{Int, Int}} = Matrix{Int}(undef, 0, 0)
8285
conservationmat::Matrix{I} = Matrix{I}(undef, 0, 0)
8386
col_order::Vector{Int} = Int[]
87+
"""
88+
The reaction networks *rank* (i.e. the span of the columns of its net stoichiometry matrix,
89+
or its number of independent species).
90+
"""
8491
rank::Int = 0
8592
nullity::Int = 0
93+
"""
94+
The set of *independent species* of the reaction system (i.e. species that will not be
95+
eliminated when we eliminate the conserved quantities.
96+
"""
8697
indepspecs::Set{V} = Set{V}()
98+
"""
99+
The set of *dependent species* of the reaction system. These species are eliminated when
100+
we eliminated the conserved quantities. In the resulting `ODESystem` these become
101+
observables, not unknowns.
102+
"""
87103
depspecs::Set{V} = Set{V}()
104+
"""
105+
The equations for the (dependent) species eliminated by any conservation laws. I.e. for
106+
the two simple two state system (`X1 <--> X2`) `X2` becomes a dependant species with the
107+
conserved equation `X2 ~ Γ[1] - X1`.
108+
"""
88109
conservedeqs::Vector{Equation} = Equation[]
110+
"""
111+
The equations for the conserved quantity parameters. I.e. for the two simple two state
112+
system (`X1 <--> X2`) there is one conserved quantity with the equation `Γ[1] ~ X1 + X2`.
113+
"""
89114
constantdefs::Vector{Equation} = Equation[]
90115
speciesmap::Dict{V, Int} = Dict{V, Int}()
116+
"""
117+
A dictionary from each reaction complex to the reactions they participate it. The value
118+
mapped from each reaction complex is a pair from the reaction's index to a value which is
119+
`-1` if the complex is a substrate and `+1` if the complex is a product.
120+
"""
91121
complextorxsmap::OrderedDict{ReactionComplex{Int}, Vector{Pair{Int, Int}}} = OrderedDict{ReactionComplex{Int},Vector{Pair{Int,Int}}}()
122+
""" A vector with all the reaction system's reaction complexes """
92123
complexes::Vector{ReactionComplex{Int}} = Vector{ReactionComplex{Int}}(undef, 0)
124+
"""
125+
An MxN matrix where M is the number of reaction complexes and N the number of reactions.
126+
Element i,j is:
127+
-1 if the i'th complex is a substrate of the j'th reaction.
128+
+1 if the i'th complex is a product of the j'th reaction.
129+
0 if the i'th complex is not part of the j'th reaction.
130+
"""
93131
incidencemat::Union{Matrix{Int}, SparseMatrixCSC{Int, Int}} = Matrix{Int}(undef, 0, 0)
132+
"""
133+
An MxN matrix where M is the number of species and N the number of reaction complexes.
134+
Element i,j is the coefficient of the i'th species in the j'th complex (0 entries denote
135+
species that are not part of the corresponding complex). Whether the matrix is sparse
136+
is designated when it is created.
137+
"""
94138
complexstoichmat::Union{Matrix{Int}, SparseMatrixCSC{Int, Int}} = Matrix{Int}(undef, 0, 0)
139+
"""
140+
An MxN matrix where M is the number of reaction complexes and N the number of reactions.
141+
Element i,j is -1 if i'th complex is a substrate of the j'th reaction (and 0 otherwise).
142+
"""
95143
complexoutgoingmat::Union{Matrix{Int}, SparseMatrixCSC{Int, Int}} = Matrix{Int}(undef, 0, 0)
144+
"""
145+
A (directed) graph, with nodes corresponding to reaction complexes and edges to reactions.
146+
There is an edge from complex i to complex j if there is a reaction converting complex
147+
i to complex j.
148+
"""
96149
incidencegraph::Graphs.SimpleDiGraph{Int} = Graphs.DiGraph()
150+
"""
151+
A vector of the connected components of the incidence graph. Each element of the
152+
`linkageclasses` corresponds to a connected component, and is a vector listing all the
153+
reaction complexes in that connected component.
154+
"""
97155
linkageclasses::Vector{Vector{Int}} = Vector{Vector{Int}}(undef, 0)
156+
"""
157+
The networks deficiency. It is computed as *n - l - r*, where *n* is the number of reaction
158+
complexes, *l* is the number of linkage classes (i.e. the number of connected components
159+
in the incidence graph), and *r* is the reaction networks *rank* (i.e. the span of the columns
160+
of its net stoichiometry matrix, or its number of independent species).
161+
"""
98162
deficiency::Int = 0
99163
end
100164
#! format: on

0 commit comments

Comments
 (0)