Skip to content

Commit

Permalink
fix and test forgotten objective_coefficient conversion
Browse files Browse the repository at this point in the history
  • Loading branch information
exaexa committed Dec 9, 2023
1 parent 7b35cbf commit 12ae908
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 3 deletions.
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name = "AbstractFBCModels"
uuid = "5a4f3dfa-1789-40f8-8221-69268c29937c"
authors = ["Authors of AbstractFBCModels.jl"]
version = "0.2.0"
version = "0.2.1"

[deps]
DocStringExtensions = "ffbed154-4ef7-542d-bbb7-c09d3a79fcae"
Expand Down
6 changes: 6 additions & 0 deletions docs/src/canonical.jl
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ m.reactions["forward"] = Reaction(
name = "import",
stoichiometry = Dict("m1" => -1.0, "m2" => 1.0),
gene_association_dnf = [["g1"], ["g2"]],
objective_coefficient = 1.0,
)
m.reactions["and_back"] =
Reaction(name = "export", stoichiometry = Dict("m2" => -1.0, "m1" => 1.0))
Expand All @@ -98,10 +99,15 @@ show_contains(x, y) = contains(sprint(show, MIME"text/plain"(), x), y) #src
@test show_contains(m.reactions["forward"], "\"g1\"") #src
@test show_contains(m.metabolites["m1"], "\"inside\"") #src
@test show_contains(m.genes["g1"], "name = nothing") #src
@test show_contains(m.genes["g1"], "name = nothing") #src

# We should immediately find the basic accessors working:
A.stoichiometry(m)

#

A.objective(m)

# We can check various side things, such as which reactions would and would not work given all gene products disappear:
products_available = [
A.reaction_gene_products_available(m, rid, _ -> false) for
Expand Down
5 changes: 3 additions & 2 deletions src/canonical.jl
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ A.metabolite_formula(m::Model, id::String) = m.metabolites[id].formula
A.metabolite_charge(m::Model, id::String) = m.metabolites[id].charge
A.metabolite_compartment(m::Model, id::String) = m.metabolites[id].compartment

A.load(::Type{Model}, path::String)::Model = S.deserialize(path)
A.load(::Type{Model}, path::String) = S.deserialize(path)
A.save(m::Model, path::String) = S.serialize(path, m)
A.filename_extensions(::Type{Model}) = ["canonical-serialized-fbc"]

Expand All @@ -155,10 +155,11 @@ function Base.convert(::Type{Model}, x::A.AbstractFBCModel)
lower_bound = lb,
upper_bound = ub,
stoichiometry = A.reaction_stoichiometry(x, r),
objective_coefficient = o,
gene_association_dnf = A.reaction_gene_association_dnf(x, r),
annotations = A.reaction_annotations(x, r),
notes = A.reaction_notes(x, r),
) for (r, lb, ub) in zip(A.reactions(x), lbs, ubs)
) for (r, o, lb, ub) in zip(A.reactions(x), os, lbs, ubs)
),
metabolites = Dict(
m => Metabolite(
Expand Down
3 changes: 3 additions & 0 deletions src/testing.jl
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,9 @@ function run_fbcmodel_file_tests(
@test issetequal(mets, metabolites(m))
@test issetequal(gens, genes(m))

@test Dict(rxns .=> collect(obj)) ==
Dict(reactions(m) .=> collect(objective(m)))

# TODO eventually add stricter equality tests
end

Expand Down

3 comments on commit 12ae908

@exaexa
Copy link
Member Author

@exaexa exaexa commented on 12ae908 Dec 9, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@JuliaRegistrator
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Registration pull request created: JuliaRegistries/General/96815

Tip: Release Notes

Did you know you can add release notes too? Just add markdown formatted text underneath the comment after the text
"Release notes:" and it will be added to the registry PR, and if TagBot is installed it will also be added to the
release that TagBot creates. i.e.

@JuliaRegistrator register

Release notes:

## Breaking changes

- blah

To add them here just re-invoke and the PR will be updated.

Tagging

After the above pull request is merged, it is recommended that a tag is created on this repository for the registered package version.

This will be done automatically if the Julia TagBot GitHub Action is installed, or can be done manually through the github interface, or via:

git tag -a v0.2.1 -m "<description of version>" 12ae9080b9f4a714f8b7fdfdddcfe17ed2b15258
git push origin v0.2.1

@exaexa
Copy link
Member Author

@exaexa exaexa commented on 12ae908 Dec 9, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@stelmo btw wow look at this. 😁

Please sign in to comment.