@@ -1653,6 +1653,9 @@ function validate(rs::ReactionSystem, info::String = "")
1653
1653
validated
1654
1654
end
1655
1655
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
+
1656
1659
"""
1657
1660
iscomplexbalanced(rs::ReactionSystem, rates::Vector)
1658
1661
@@ -1696,44 +1699,14 @@ function iscomplexbalanced(rs::ReactionSystem, rates::Dict{Any, Float64})
1696
1699
@assert isapprox (L* ρ, zeros (nc), atol= 1e-12 )
1697
1700
1698
1701
# 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 ) , ρ)
1700
1703
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
1702
1705
else
1703
1706
return false
1704
1707
end
1705
1708
end
1706
1709
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
-
1737
1710
function ratematrix (rs:: ReactionSystem , rates:: Dict{Any, Float64} )
1738
1711
if length (rates) != numparams (rs)
1739
1712
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})
1746
1719
1747
1720
for r in 1 : length (rxns)
1748
1721
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])
1751
1724
ratematrix[s, p] = rates[rxn. rate]
1752
1725
end
1753
1726
ratematrix
@@ -1781,7 +1754,7 @@ function matrixtree(g::SimpleDiGraph, distmx::Matrix)
1781
1754
trees = filter! (t-> isempty (Graphs. cycle_basis (t)), trees)
1782
1755
# trees = spanningtrees(g)
1783
1756
1784
- # constructed rooted trees for every edge , compute sum
1757
+ # constructed rooted trees for every vertex , compute sum
1785
1758
for v in 1 : n
1786
1759
rootedTrees = [reverse (Graphs. bfs_tree (t, v, dir= :in )) for t in trees]
1787
1760
π[v] = sum ([treeweight (t, g, distmx) for t in rootedTrees])
@@ -1805,16 +1778,4 @@ function spanningtrees(g::SimpleGraph)
1805
1778
1806
1779
end
1807
1780
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