Commit aefe4708 authored by Miroslav Kratochvil's avatar Miroslav Kratochvil
Browse files

add space for kineticLaw math rules

parent 8d14fb90
...@@ -6,6 +6,7 @@ using SparseArrays ...@@ -6,6 +6,7 @@ using SparseArrays
include("structs.jl") include("structs.jl")
include("version.jl") include("version.jl")
include("readsbml.jl") include("readsbml.jl")
include("math.jl")
include("utils.jl") include("utils.jl")
sbml = (sym::Symbol) -> dlsym(SBML_jll.libsbml_handle, sym) sbml = (sym::Symbol) -> dlsym(SBML_jll.libsbml_handle, sym)
......
"""
parseMath(ast::VPtr)::Math
This attempts to parse out a decent Julia-esque ([`Math`](@ref) AST from a
pointer to `ASTNode_t`.
"""
function parseMath(ast::VPtr)::Math
@info "got $ast"
MathIdent("placeholder")
end
...@@ -216,6 +216,7 @@ function extractModel(mdl::VPtr)::Model ...@@ -216,6 +216,7 @@ function extractModel(mdl::VPtr)::Model
lb = (-Inf, "") # (bound value, unit id) lb = (-Inf, "") # (bound value, unit id)
ub = (Inf, "") ub = (Inf, "")
oc = 0.0 oc = 0.0
math = nothing
# kinetic laws store a second version of the bounds and objectives # kinetic laws store a second version of the bounds and objectives
kl = ccall(sbml(:Reaction_getKineticLaw), VPtr, (VPtr,), re) kl = ccall(sbml(:Reaction_getKineticLaw), VPtr, (VPtr,), re)
...@@ -233,6 +234,10 @@ function extractModel(mdl::VPtr)::Model ...@@ -233,6 +234,10 @@ function extractModel(mdl::VPtr)::Model
oc = pval() oc = pval()
end end
end end
if ccall(sbml(:KineticLaw_isSetMath), Cint, (VPtr,), kl) != 0
math = parseMath(ccall(sbml(:KineticLaw_getMath), VPtr, (VPtr,), kl))
end
end end
# TRICKY: SBML spec is completely silent about what should happen if # TRICKY: SBML spec is completely silent about what should happen if
...@@ -272,6 +277,7 @@ function extractModel(mdl::VPtr)::Model ...@@ -272,6 +277,7 @@ function extractModel(mdl::VPtr)::Model
add_stoi(sr, 1) add_stoi(sr, 1)
end end
# gene product associations
association = nothing association = nothing
if re_fbc != C_NULL if re_fbc != C_NULL
gpa = ccall( gpa = ccall(
...@@ -294,6 +300,7 @@ function extractModel(mdl::VPtr)::Model ...@@ -294,6 +300,7 @@ function extractModel(mdl::VPtr)::Model
ub, ub,
haskey(objectives_fbc, reid) ? objectives_fbc[reid] : oc, haskey(objectives_fbc, reid) ? objectives_fbc[reid] : oc,
association, association,
math,
getNotes(re), getNotes(re),
getAnnotation(re), getAnnotation(re),
) )
......
...@@ -55,6 +55,33 @@ struct GPAOr <: GeneProductAssociation ...@@ -55,6 +55,33 @@ struct GPAOr <: GeneProductAssociation
terms::Vector{GeneProductAssociation} terms::Vector{GeneProductAssociation}
end end
"""
A simplified representation of MathML-specified math AST
"""
abstract type Math end
"""
A literal value (usually a numeric constant) in mathematical expression
"""
struct MathVal{T} <: Math where {T}
val::T
end
"""
An identifier (usually a variable name) in mathematical expression
"""
struct MathIdent <: Math
id::String
end
"""
Function application ("call by name", no tricks allowed) in mathematical expression
"""
struct MathApply <: Math
fn::String
attributes::Dict{String,String}
args::Vector{Math}
end
""" """
Reaction with stoichiometry that assigns reactants and products their relative Reaction with stoichiometry that assigns reactants and products their relative
...@@ -68,9 +95,10 @@ struct Reaction ...@@ -68,9 +95,10 @@ struct Reaction
ub::Tuple{Float64,String} ub::Tuple{Float64,String}
oc::Float64 oc::Float64
gene_product_association::Maybe{GeneProductAssociation} gene_product_association::Maybe{GeneProductAssociation}
kinetic_math::Maybe{Math}
notes::Maybe{String} notes::Maybe{String}
annotation::Maybe{String} annotation::Maybe{String}
Reaction(s, l, u, o, as, n = nothing, an = nothing) = new(s, l, u, o, as, n, an) Reaction(s, l, u, o, as, km, n = nothing, an = nothing) = new(s, l, u, o, as, km, n, an)
end 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