Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
LCSB-BioCore
SBML.jl
Commits
3ee30322
Unverified
Commit
3ee30322
authored
Jul 03, 2021
by
Miroslav Kratochvil
🚴
Committed by
GitHub
Jul 03, 2021
Browse files
Merge pull request #107 from LCSB-BioCore/mk-cleaning-055
0.5.5 release prep (cleaning)
parents
9604c34a
d62072fd
Changes
8
Hide whitespace changes
Inline
Side-by-side
docs/src/index.md
View file @
3ee30322
...
...
@@ -59,6 +59,13 @@ julia> Matrix(S)
# Function reference
## Helper types
```
@autodocs
Modules = [SBML]
Pages = ["types.jl"]
```
## Data structures
```
@autodocs
...
...
src/SBML.jl
View file @
3ee30322
...
...
@@ -4,14 +4,15 @@ using SBML_jll, Libdl
using
SparseArrays
using
Symbolics
include
(
"types.jl"
)
include
(
"structs.jl"
)
include
(
"version.jl"
)
include
(
"utils.jl"
)
include
(
"readsbml.jl"
)
include
(
"converters.jl"
)
include
(
"math.jl"
)
include
(
"readsbml.jl"
)
include
(
"symbolics.jl"
)
include
(
"utils.jl"
)
sbml
(
sym
::
Symbol
)
=
dlsym
(
SBML_jll
.
libsbml_handle
,
sym
)
...
...
src/converters.jl
View file @
3ee30322
...
...
@@ -6,11 +6,18 @@ A converter to pass into [`readSBML`](@ref) that enforces certain SBML level
and version.
"""
set_level_and_version
(
level
,
version
)
=
doc
->
check_errors
(
ccall
(
sbml
(
:
SBMLDocument_setLevelAndVersion
),
Cint
,
(
VPtr
,
Cint
,
Cint
),
doc
,
level
,
version
),
doc
,
ErrorException
(
"Setting of level and version did not succeed"
))
doc
->
check_errors
(
ccall
(
sbml
(
:
SBMLDocument_setLevelAndVersion
),
Cint
,
(
VPtr
,
Cint
,
Cint
),
doc
,
level
,
version
,
),
doc
,
ErrorException
(
"Setting of level and version did not succeed"
),
)
"""
libsbml_convert(conversion_options::Vector{Pair{String, Dict{String, String}}})
...
...
@@ -38,8 +45,11 @@ libsbml_convert(
opt
,
)
end
check_errors
(
ccall
(
sbml
(
:
SBMLDocument_convert
),
Cint
,
(
VPtr
,
VPtr
),
doc
,
props
),
doc
,
ErrorException
(
"Conversion returned errors"
))
check_errors
(
ccall
(
sbml
(
:
SBMLDocument_convert
),
Cint
,
(
VPtr
,
VPtr
),
doc
,
props
),
doc
,
ErrorException
(
"Conversion returned errors"
),
)
end
end
...
...
src/readsbml.jl
View file @
3ee30322
...
...
@@ -93,8 +93,7 @@ end)
function
readSBML
(
fn
::
String
,
sbml_conversion
=
document
->
nothing
)
::
SBML
.
Model
doc
=
ccall
(
sbml
(
:
readSBML
),
VPtr
,
(
Cstring
,),
fn
)
try
get_error_messages
(
doc
,
AssertionError
(
"Opening SBML document has reported errors"
))
get_error_messages
(
doc
,
AssertionError
(
"Opening SBML document has reported errors"
))
sbml_conversion
(
doc
)
...
...
src/structs.jl
View file @
3ee30322
"""
Maybe{X}
Type shortcut for "
`X`
or
nothing
" or "
nullable
`X`
" in javaspeak. Name
got inspired by our functional friends.
"""
const
Maybe
{
X
}
=
Union
{
Nothing
,
X
}
"""
Part of a measurement unit definition that corresponds to the SBML definition
of `Unit`. For example, the unit "
per
square
megahour
", Mh^(-2), is written as:
...
...
src/types.jl
0 → 100644
View file @
3ee30322
"""
Maybe{X}
Type shortcut for "
`X`
or
nothing
" or "
nullable
`X`
" in javaspeak. Name
got inspired by our functional friends.
"""
const
Maybe
{
X
}
=
Union
{
Nothing
,
X
}
"""
VPtr
A convenience wrapper for "
any
" (C `void`) pointer.
"""
const
VPtr
=
Ptr
{
Cvoid
}
src/utils.jl
View file @
3ee30322
const
VPtr
=
Ptr
{
Cvoid
}
"""
function getS(m::SBML.Model; zeros=spzeros)::Tuple{Vector{String},Vector{String},AbstractMatrix{Float64}}
...
...
@@ -142,7 +140,7 @@ Show the error messages reported by SBML in the `doc` document and throw the
function
get_error_messages
(
doc
::
VPtr
,
error
::
Exception
)
n_errs
=
ccall
(
sbml
(
:
SBMLDocument_getNumErrors
),
Cuint
,
(
VPtr
,),
doc
)
for
i
=
1
:
n_errs
err
=
ccall
(
sbml
(
:
SBMLDocument_getError
),
VPtr
,
(
VPtr
,
Cuint
),
doc
,
i
-
1
)
err
=
ccall
(
sbml
(
:
SBMLDocument_getError
),
VPtr
,
(
VPtr
,
Cuint
),
doc
,
i
-
1
)
msg
=
string
(
strip
(
get_string
(
err
,
:
XMLError_getMessage
)))
@error
"SBML reported error:
$(msg)
"
end
...
...
test/loadmodels.jl
View file @
3ee30322
...
...
@@ -134,7 +134,7 @@ end
@test
isequal
(
convert
(
Num
,
m
.
reactions
[
"J29"
]
.
kinetic_math
),
2.0
*
S29
*
S29b
)
end
@testset
"converters fail gracefully"
begin
@testset
"converters
work and
fail gracefully"
begin
@test_logs
(
:
error
,
r
"^SBML reported error:"
)
(
:
error
,
r
"^SBML reported error:"
)
@test_throws
ErrorException
readSBML
(
joinpath
(
@__DIR__
,
"data"
,
"sbml01289.xml"
),
doc
->
begin
...
...
@@ -142,4 +142,13 @@ end
convert_simplify_math
(
doc
)
end
,
)
test_math
=
readSBML
(
joinpath
(
@__DIR__
,
"data"
,
"sbml01565.xml"
),
libsbml_convert
(
"expandInitialAssignments"
),
)
.
reactions
[
"J31"
]
.
kinetic_math
@test
test_math
.
args
[
2
]
.
fn
==
"sin"
@test
test_math
.
args
[
2
]
.
args
[
1
]
.
val
==
2.1
end
cylon-x
🤖
@cylon-x
mentioned in commit
fc54aa92
·
Jul 03, 2021
mentioned in commit
fc54aa92
mentioned in commit fc54aa92ef5ca3b0d17a8a8ee9d12894336a94eb
Toggle commit list
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment