Skip to content

Commit 12e7b2b

Browse files
committed
add validation
1 parent 94a27c9 commit 12e7b2b

File tree

1 file changed

+18
-1
lines changed

1 file changed

+18
-1
lines changed

src/network_analysis.jl

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -215,6 +215,13 @@ end
215215
**Warning**: Unlike other Catalyst functions, the `fluxmat` function will return a `Matrix{Num}` in the symbolic case. This is to allow easier computation of the matrix decomposition of the ODEs, and to ensure that multiplying the sparse form of the matrix will work.
216216
"""
217217
function fluxmat(rn::ReactionSystem, pmap::Dict = Dict(); sparse=false)
218+
deps = Set()
219+
for (i, rx) in enumerate(reactions(rn))
220+
empty!(deps)
221+
get_variables!(deps, rx.rate, species(rn))
222+
(!isempty(deps)) && (error("Reaction $rx's rate constant depends on species $(join(deps, ", ")). `adjacencymat` cannot support rate constants of this form."))
223+
end
224+
218225
rates = if isempty(pmap)
219226
reactionrates(rn)
220227
else
@@ -290,6 +297,10 @@ function massactionvector(rn::ReactionSystem, scmap::Dict = Dict(); combinatoric
290297
rxs = reactions(rn)
291298
sm = speciesmap(rn)
292299

300+
for rx in rxs
301+
!ismassaction(rx, rn) && error("The supplied ReactionSystem has non-mass action reaction $rx. The `massactionvector` can only be constructed for mass action networks.")
302+
end
303+
293304
specs = if isempty(scmap)
294305
species(rn)
295306
else
@@ -1001,7 +1012,6 @@ function iscomplexbalanced(rs::ReactionSystem, parametermap::Dict; sparse = fals
10011012
error("The supplied ReactionSystem has reactions that are not ismassaction. Testing for being complex balanced is currently only supported for pure mass action networks.")
10021013
end
10031014

1004-
L = laplacianmat(rs, parametermap; sparse)
10051015
D = incidencemat(rs; sparse)
10061016
S = netstoichmat(rs; sparse)
10071017

@@ -1053,6 +1063,13 @@ end
10531063
- In `adjacencymat`, the rows and columns both represent complexes, and an entry (c1, c2) is non-zero if there is a reaction c1 --> c2.
10541064
"""
10551065
function adjacencymat(rn::ReactionSystem, pmap::Dict = Dict(); sparse = false)
1066+
deps = Set()
1067+
for (i, rx) in enumerate(reactions(rn))
1068+
empty!(deps)
1069+
get_variables!(deps, rx.rate, species(rn))
1070+
(!isempty(deps)) && (error("Reaction $rx's rate constant depends on species $(join(deps, ", ")). `adjacencymat` cannot support rate constants of this form."))
1071+
end
1072+
10561073
rates = if isempty(pmap)
10571074
reactionrates(rn)
10581075
else

0 commit comments

Comments
 (0)