|
11 | 11 | function Reaction(rate, subs, prods, substoich, prodstoich;
|
12 | 12 | netstoich=nothing, only_use_rate=false, kwargs...)
|
13 | 13 |
|
14 |
| - subsv,substoichv = isnothing(subs) ? (Vector{Operation}(),Int[]) : (subs,substoich) |
15 |
| - prodsv,prodstoichv = isnothing(prods) ? (Vector{Operation}(),Int[]) : (prods,prodstoich) |
16 |
| - ns = isnothing(netstoich) ? get_netstoich(subsv, prodsv, substoichv, prodstoichv) : netstoich |
17 |
| - Reaction(rate, subsv, prodsv, substoichv, prodstoichv, ns, only_use_rate) |
| 14 | + (isnothing(prods)&&isnothing(subs)) && error("A reaction requires a non-nothing substrate or product vector.") |
| 15 | + if isnothing(subs) |
| 16 | + subs = Vector{Operation}() |
| 17 | + (substoich!=nothing) && error("If substrates are nothing, substrate stiocihometries have to be so too.") |
| 18 | + substoich = (prodstoich == nothing) ? nothing : typeof(prodstoich)() |
| 19 | + end |
| 20 | + if isnothing(prods) |
| 21 | + prods = Vector{Operation}() |
| 22 | + (prodstoich!=nothing) && error("If products are nothing, product stiocihometries have to be so too.") |
| 23 | + prodstoich = (substoich == nothing) ? nothing : typeof(substoich)() |
| 24 | + end |
| 25 | + ns = isnothing(netstoich) ? get_netstoich(subs, prods, substoich, prodstoich) : netstoich |
| 26 | + Reaction(rate, subs, prods, substoich, prodstoich, ns, only_use_rate) |
18 | 27 | end
|
19 | 28 |
|
| 29 | +a =[1.,2.3,4.] |
| 30 | +typeof(a)() |
| 31 | + |
20 | 32 | # three argument constructor assumes stoichiometric coefs are one and integers
|
21 | 33 | function Reaction(rate, subs, prods; kwargs...)
|
22 | 34 |
|
23 |
| - sstoich = isnothing(subs) ? Int[] : ones(Int,length(subs)) |
24 |
| - pstoich = isnothing(prods) ? Int[] : ones(Int,length(prods)) |
| 35 | + sstoich = isnothing(subs) ? nothing : ones(Int,length(subs)) |
| 36 | + pstoich = isnothing(prods) ? nothing : ones(Int,length(prods)) |
25 | 37 | Reaction(rate, subs, prods, sstoich, pstoich; kwargs...)
|
26 | 38 | end
|
27 | 39 |
|
|
0 commit comments