Unverified Commit 553ed70c authored by Miroslav Kratochvil's avatar Miroslav Kratochvil Committed by GitHub
Browse files

Merge pull request #544 from LCSB-BioCore/mk-sbml-091

use the keyword arguments in new version of SBML
parents 39f8d880 9629381a
Pipeline #51061 passed with stages
in 28 minutes and 15 seconds
......@@ -133,6 +133,7 @@ windows10:julia1.7:
mac:julia1.7:
stage: test-compat
allow_failure: true
<<: *global_trigger_compat_tests
<<: *global_julia17
<<: *global_env_mac
......@@ -151,6 +152,7 @@ windows10:julia1.6:
mac:julia1.6:
stage: test-compat
allow_failure: true
<<: *global_trigger_compat_tests
<<: *global_julia16
<<: *global_env_mac
......
......@@ -28,7 +28,7 @@ MAT = "0.10"
MacroTools = "0.5.6"
OSQP = "0.6"
OrderedCollections = "1.4"
SBML = "0.7, 0.8.2"
SBML = "0.9.1"
StableRNGs = "1.0"
Tulip = "0.7"
julia = "1.5"
......
......@@ -165,65 +165,54 @@ function Base.convert(::Type{SBMLModel}, mm::MetabolicModel)
rxns = reactions(mm)
stoi = stoichiometry(mm)
(lbs, ubs) = bounds(mm)
ocs = objective(mm)
comps = _default.("", metabolite_compartment.(Ref(mm), mets))
compss = Set(comps)
return SBMLModel(
SBML.Model(
Dict(), # parameters
Dict("" => 1), # units
Dict(
comp =>
SBML.Compartment(nothing, nothing, nothing, nothing, nothing, nothing)
for comp in compss
),
Dict(
units = Dict("" => []), # units
compartments = Dict(comp => SBML.Compartment() for comp in compss),
species = Dict(
mid => SBML.Species(
nothing, # name
_default("", comps[mi]), # compartment
nothing, # no information about boundary conditions
metabolite_formula(mm, mid),
metabolite_charge(mm, mid),
nothing, # initial amount
nothing, # initial concentration
nothing, # only substance unit flags
_sbml_export_notes(metabolite_notes(mm, mid)),
_sbml_export_annotation(metabolite_annotations(mm, mid)),
compartment = _default("", comps[mi]), # compartment
formula = metabolite_formula(mm, mid),
charge = metabolite_charge(mm, mid),
notes = _sbml_export_notes(metabolite_notes(mm, mid)),
annotation = _sbml_export_annotation(metabolite_annotations(mm, mid)),
) for (mi, mid) in enumerate(mets)
),
Dict(
reactions = Dict(
rid => SBML.Reaction(
Dict(
reactants = Dict(
mets[i] => -stoi[i, ri] for
i in SparseArrays.nonzeroinds(stoi[:, ri]) if stoi[i, ri] <= 0
),
Dict(
products = Dict(
mets[i] => stoi[i, ri] for
i in SparseArrays.nonzeroinds(stoi[:, ri]) if stoi[i, ri] > 0
),
(lbs[ri], ""),
(ubs[ri], ""),
ocs[ri],
_maybemap(
kinetic_parameters = Dict(
"LOWER_BOUND" => (lbs[ri], ""),
"UPPER_BOUND" => (ubs[ri], ""),
),
gene_product_association = _maybemap(
x -> _unparse_grr(SBML.GeneProductAssociation, x),
reaction_gene_association(mm, rid),
),
nothing, # no kinetic math
true, # reversible by default
_sbml_export_notes(reaction_notes(mm, rid)),
_sbml_export_annotation(reaction_annotations(mm, rid)),
reversible = true,
notes = _sbml_export_notes(reaction_notes(mm, rid)),
annotation = _sbml_export_annotation(reaction_annotations(mm, rid)),
) for (ri, rid) in enumerate(rxns)
),
Dict(
gene_products = Dict(
gid => SBML.GeneProduct(
nothing,
nothing,
_sbml_export_notes(gene_notes(mm, gid)),
_sbml_export_annotation(gene_annotations(mm, gid)),
notes = _sbml_export_notes(gene_notes(mm, gid)),
annotation = _sbml_export_annotation(gene_annotations(mm, gid)),
) for gid in genes(mm)
),
Dict(), # function definitions
objective = Dict(
rid => oc for (rid, oc) in zip(rxns, objective(mm)) if oc != 0
),
),
)
end
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment