Skip to content

Commit

Permalink
Merge pull request #259 from sebapersson/master
Browse files Browse the repository at this point in the history
Add support for specie conversionFactor
  • Loading branch information
exaexa authored Nov 16, 2023
2 parents 62ab21b + e0a6254 commit 64ec00b
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 1 deletion.
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name = "SBML"
uuid = "e5567a89-2604-4b09-9718-f5f78e97c3bb"
authors = ["Mirek Kratochvil <[email protected]>", "LCSB R3 team <[email protected]>"]
version = "1.5.0"
version = "1.5.1"

[deps]
DocStringExtensions = "ffbed154-4ef7-542d-bbb7-c09d3a79fcae"
Expand Down
5 changes: 5 additions & 0 deletions src/readsbml.jl
Original file line number Diff line number Diff line change
Expand Up @@ -412,6 +412,11 @@ function get_model(mdl::VPtr)::SBML.Model
ccall(sbml(:Species_getInitialConcentration), Cdouble, (VPtr,), sp)
end,
substance_units = get_optional_string(sp, :Species_getSubstanceUnits),
conversion_factor = if (
ccall(sbml(:Species_getConversionFactor), Cstring, (VPtr,), sp) != C_NULL
)
get_string(sp, :Species_getConversionFactor)
end,
only_substance_units = get_optional_bool(
sp,
:Species_isSetHasOnlySubstanceUnits,
Expand Down
1 change: 1 addition & 0 deletions src/structs.jl
Original file line number Diff line number Diff line change
Expand Up @@ -354,6 +354,7 @@ Base.@kwdef struct Species
initial_amount::Maybe{Float64} = nothing
initial_concentration::Maybe{Float64} = nothing
substance_units::Maybe{String} = nothing
conversion_factor::Maybe{String} = nothing
only_substance_units::Maybe{Bool} = nothing
constant::Maybe{Bool} = nothing
metaid::Maybe{String} = nothing
Expand Down
1 change: 1 addition & 0 deletions src/writesbml.jl
Original file line number Diff line number Diff line change
Expand Up @@ -415,6 +415,7 @@ function model_to_sbml!(doc::VPtr, mdl::Model)::VPtr
species.initial_concentration,
)
set_string!(species_ptr, :Species_setSubstanceUnits, species.substance_units)
set_string!(species_ptr, :Species_setConversionFactor, species.conversion_factor)
set_bool!(
species_ptr,
:Species_setHasOnlySubstanceUnits,
Expand Down
12 changes: 12 additions & 0 deletions test/loadmodels.jl
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,15 @@ sbmlfiles = [
3,
fill(Inf, 3),
),
# has conversionFactor species attribute
(
joinpath(@__DIR__, "data", "00976-sbml-l3v2.xml"),
SBML.test_suite_url(976, level = 3, version = 2),
"6cec83157cd81a585597c02f225e814a9ce2a1c9255a039b3083c97cfe02dd00",
2,
3,
fill(Inf, 3),
),
# has the Avogadro "constant"
(
joinpath(@__DIR__, "data", "01323-sbml-l3v2.xml"),
Expand Down Expand Up @@ -426,6 +435,9 @@ end
@test isnothing(m.time_units)
@test isnothing(m.volume_units)
@test isnothing(m.active_objective)

m = readSBML(joinpath(@__DIR__, "data", "00976-sbml-l3v2.xml"))
@test m.species["S1"].conversion_factor == "S1conv"
end

@testset "names and identifiers of objects" begin
Expand Down

2 comments on commit 64ec00b

@exaexa
Copy link
Collaborator Author

@exaexa exaexa commented on 64ec00b Nov 16, 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/95464

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 v1.5.1 -m "<description of version>" 64ec00b69130a70cf75775792e76c7db6003b1c3
git push origin v1.5.1

Please sign in to comment.