From d5eb775bd1ccc3f7512fcd3d4b69709255ab013f Mon Sep 17 00:00:00 2001 From: Mirek Kratochvil Date: Mon, 10 Jun 2024 20:28:38 +0200 Subject: [PATCH] fixup the grr handler code --- src/interface.jl | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/src/interface.jl b/src/interface.jl index 72c8315..4cb299b 100644 --- a/src/interface.jl +++ b/src/interface.jl @@ -77,13 +77,25 @@ function A.coupling_bounds(m::MATFBCModel)::Tuple{Vector{Float64},Vector{Float64 end end -A.reaction_gene_products_available(model::MATFBCModel, rid::String, available::Function) = - A.reaction_gene_products_available_from_dnf(model, rid, available) +function A.reaction_gene_products_available( + m::MATFBCModel, + rid::String, + available::Function, +) + any(haskey(m.mat, x) for x in key_names.grrs) || return nothing + grr = m.mat[guesskeys(:grrs, m)][findfirst(==(rid), A.reactions(m))] + typeof(grr) == String || return nothing + grrexp = parse_gene_association(grr) + grrexp == nothing && return nothing + return eval_gene_association(grrexp, available) +end function A.reaction_gene_association_dnf(m::MATFBCModel, rid::String) any(haskey(m.mat, x) for x in key_names.grrs) || return nothing grr = m.mat[guesskeys(:grrs, m)][findfirst(==(rid), A.reactions(m))] - typeof(grr) == String ? parse_grr(grr) : nothing + grrexp = parse_gene_association(grr) + grrexp == nothing && return nothing + return flatten_gene_association(grrexp, available) end function A.metabolite_formula(m::MATFBCModel, mid::String)