Skip to content

Commit

Permalink
Merge pull request #522 from LCSB-BioCore/mk-grr-naming
Browse files Browse the repository at this point in the history
naming & tests for grr vector function
  • Loading branch information
htpusa committed Nov 22, 2021
2 parents 87a7db0 + cfc1b5d commit 94c4361
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 6 deletions.
7 changes: 4 additions & 3 deletions src/base/types/CoreModel.jl
Original file line number Diff line number Diff line change
Expand Up @@ -103,11 +103,12 @@ reaction_stoichiometry(m::CoreModel, ridx)::Dict{String,Float64} =
Dict(m.mets[k] => v for (k, v) in zip(findnz(m.S[:, ridx])...))

"""
grrs(a::CoreModel)::Vector{Maybe{GeneAssociation}}
reaction_gene_association_vec(model::CoreModel)::Vector{Maybe{GeneAssociation}}
Get the gene associations in a [`CoreModel`](@ref).
Retrieve a vector of all gene associations in a [`CoreModel`](@ref), in the
same order as `reactions(model)`.
"""
grrs(a::CoreModel)::Vector{Maybe{GeneAssociation}} = a.grrs
reaction_gene_association_vec(model::CoreModel)::Vector{Maybe{GeneAssociation}} = model.grrs

"""
reaction_gene_association(model::CoreModel, ridx::Int)::Maybe{GeneAssociation}
Expand Down
8 changes: 5 additions & 3 deletions src/base/types/CoreModelCoupled.jl
Original file line number Diff line number Diff line change
Expand Up @@ -109,11 +109,13 @@ function reaction_stoichiometry(m::CoreModelCoupled, ridx)::Dict{String,Float64}
end

"""
grrs(a::CoreModelCoupled)::Vector{Maybe{GeneAssociation}}
reaction_gene_association_vec(model::CoreModelCoupled)::Vector{Maybe{GeneAssociation}}
Get the gene associations in a [`CoreModelCoupled`](@ref).
Retrieve a vector of gene associations in a [`CoreModelCoupled`](@ref), in the
same order as `reactions(model)`.
"""
grrs(a::CoreModelCoupled)::Vector{Maybe{GeneAssociation}} = a.lm.grrs
reaction_gene_association_vec(model::CoreModelCoupled)::Vector{Maybe{GeneAssociation}} =
reaction_gene_association_vec(model.lm)

"""
reaction_gene_association(model::CoreModelCoupled, ridx::Int)::Maybe{GeneAssociation}
Expand Down
11 changes: 11 additions & 0 deletions test/base/types/CoreModelCoupled.jl
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,15 @@ end

@test reaction_gene_association(sm, reactions(sm)[1]) ==
reaction_gene_association(cm, reactions(sm)[1])

@test reaction_gene_association_vec(cm)[1:3] == [
[["b3916"], ["b1723"]],
[
["b0902", "b0903", "b2579"],
["b0902", "b0903"],
["b0902", "b3114"],
["b3951", "b3952"],
],
[["b4025"]],
]
end

0 comments on commit 94c4361

Please sign in to comment.