Skip to content

Commit dffc2ef

Browse files
committed
some edits
1 parent 710b164 commit dffc2ef

File tree

1 file changed

+9
-48
lines changed

1 file changed

+9
-48
lines changed

src/networkapi.jl

Lines changed: 9 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -1653,6 +1653,9 @@ function validate(rs::ReactionSystem, info::String = "")
16531653
validated
16541654
end
16551655

1656+
# Checks if a unit consist of exponents with base 1 (and is this unitless).
1657+
unitless_exp(u) = istree(u) && (operation(u) == ^) && (arguments(u)[1] == 1)
1658+
16561659
"""
16571660
iscomplexbalanced(rs::ReactionSystem, rates::Vector)
16581661
@@ -1696,44 +1699,14 @@ function iscomplexbalanced(rs::ReactionSystem, rates::Dict{Any, Float64})
16961699
@assert isapprox(L*ρ, zeros(nc), atol=1e-12)
16971700

16981701
# Determine if 1) ρ is positive and 2) D^T Ln ρ lies in the image of S^T
1699-
if all(x -> x > 0, ρ)
1702+
if all(>(0), ρ)
17001703
img = D'*log.(ρ)
1701-
if rank(S') == rank(hcat(S', img)) return true else return false end
1704+
rank(S') == rank(hcat(S', img)) ? return true : return false
17021705
else
17031706
return false
17041707
end
17051708
end
17061709

1707-
# """
1708-
# rateweightedgraph(rs::ReactionSystem, rates::Vector)
1709-
#
1710-
# Generate an annotated reaction complex graph of a reaction system, where the nodes are annotated with the reaction complex they correspond to and the edges are annotated with the reaction they correspond to and the rate of the reaction.
1711-
# """
1712-
#
1713-
# function rateweightedgraph(rs::ReactionSystem, rates::Dict{Any, Float64})
1714-
# if length(rates) != numparams(rs)
1715-
# error("The number of reaction rates must be equal to the number of parameters")
1716-
# end
1717-
#
1718-
# complexes, D = reactioncomplexes(rs)
1719-
# rxns = reactions(rs)
1720-
#
1721-
# g = incidencematgraph(rs)
1722-
# rwg = MetaDiGraph(g)
1723-
#
1724-
# for v in vertices(rwg)
1725-
# set_prop!(rwg, v, :complex, complexes[v])
1726-
# end
1727-
#
1728-
# for (i, e) in collect(enumerate(edges(rwg)))
1729-
# rxn = rxns[i]
1730-
# set_prop!(rwg, Graphs.src(e), Graphs.dst(e), :reaction, rxn)
1731-
# set_prop!(rwg, Graphs.src(e), Graphs.dst(e), :rate, rates[rxn.rate])
1732-
# end
1733-
#
1734-
# rwg
1735-
# end
1736-
17371710
function ratematrix(rs::ReactionSystem, rates::Dict{Any, Float64})
17381711
if length(rates) != numparams(rs)
17391712
error("The number of reaction rates must be equal to the number of parameters")
@@ -1746,8 +1719,8 @@ function ratematrix(rs::ReactionSystem, rates::Dict{Any, Float64})
17461719

17471720
for r in 1:length(rxns)
17481721
rxn = rxns[r]
1749-
s = findfirst(x->x==-1, D[:,r])
1750-
p = findfirst(x->x==1, D[:,r])
1722+
s = findfirst(==(-1), @view D[:,r])
1723+
p = findfirst(==(1), @view D[:,r])
17511724
ratematrix[s, p] = rates[rxn.rate]
17521725
end
17531726
ratematrix
@@ -1781,7 +1754,7 @@ function matrixtree(g::SimpleDiGraph, distmx::Matrix)
17811754
trees = filter!(t->isempty(Graphs.cycle_basis(t)), trees)
17821755
# trees = spanningtrees(g)
17831756

1784-
# constructed rooted trees for every edge, compute sum
1757+
# constructed rooted trees for every vertex, compute sum
17851758
for v in 1:n
17861759
rootedTrees = [reverse(Graphs.bfs_tree(t, v, dir=:in)) for t in trees]
17871760
π[v] = sum([treeweight(t, g, distmx) for t in rootedTrees])
@@ -1805,16 +1778,4 @@ function spanningtrees(g::SimpleGraph)
18051778

18061779
end
18071780

1808-
# Checks if a unit consist of exponents with base 1 (and is this unitless).
1809-
unitless_exp(u) = istree(u) && (operation(u) == ^) && (arguments(u)[1] == 1)
1810-
1811-
rxn = reactions(rs)[rxn_idx]
1812-
sm = speciesmap(rs)
1813-
rate = rxn.rate
1814-
1815-
species = rxn.substrates
1816-
stoich = rxn.substoich
1817-
species_idx = [sm[s] for s in species]
1818-
1819-
dir * rate * prod(conc[species_idx].^stoich)
1820-
end
1781+
sm = speciesmap(rs)

0 commit comments

Comments
 (0)