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
c5421284
Commit
c5421284
authored
Jul 19, 2021
by
Miroslav Kratochvil
🚴
Browse files
reformat code before release
parent
4164057d
Changes
4
Hide whitespace changes
Inline
Side-by-side
src/converters.jl
View file @
c5421284
...
...
@@ -73,10 +73,10 @@ readSBML("example.xml", libsbml_convert("stripPackage", package="layout"))
```
"""
libsbml_convert
(
converter
::
String
,
report_severities
=
[
"Fatal"
,
"Error"
];
kwargs
...
)
=
libsbml_convert
(
[
converter
=>
Dict
{
String
,
String
}(
string
(
k
)
=>
string
(
v
)
for
(
k
,
v
)
in
kwargs
),
]
,
report_severities
)
libsbml_convert
(
[
converter
=>
Dict
{
String
,
String
}(
string
(
k
)
=>
string
(
v
)
for
(
k
,
v
)
in
kwargs
)
]
,
report_severities
,
)
"""
convert_simplify_math
...
...
src/readsbml.jl
View file @
c5421284
...
...
@@ -149,7 +149,8 @@ readSBMLFromString(
str
::
AbstractString
,
sbml_conversion
=
document
->
nothing
;
report_severities
=
[
"Fatal"
,
"Error"
],
)
::
SBML
.
Model
=
_readSBML
(
:
readSBMLFromString
,
String
(
str
),
sbml_conversion
,
report_severities
)
)
::
SBML
.
Model
=
_readSBML
(
:
readSBMLFromString
,
String
(
str
),
sbml_conversion
,
report_severities
)
get_notes
(
x
::
VPtr
)
::
Maybe
{
String
}
=
get_optional_string
(
x
,
:
SBase_getNotesString
)
get_annotation
(
x
::
VPtr
)
::
Maybe
{
String
}
=
get_optional_string
(
x
,
:
SBase_getAnnotationString
)
...
...
src/utils.jl
View file @
c5421284
...
...
@@ -32,8 +32,7 @@ are accompanied with the unit of the corresponding value (this behavior is based
specification).
"""
flux_bounds
(
m
::
SBML
.
Model
)
::
NTuple
{
2
,
Vector
{
Tuple
{
Float64
,
String
}}}
=
(
broadcast
(
x
->
x
.
lb
,
values
(
m
.
reactions
)),
broadcast
(
x
->
x
.
ub
,
values
(
m
.
reactions
)))
(
broadcast
(
x
->
x
.
lb
,
values
(
m
.
reactions
)),
broadcast
(
x
->
x
.
ub
,
values
(
m
.
reactions
)))
"""
flux_objective(m::SBML.Model)::Vector{Float64}
...
...
@@ -244,13 +243,14 @@ get_unit(u::VPtr) =
sbml
(
:
UnitKind_toString
),
Cstring
,
(
Cint
,),
ccall
(
sbml
(
:
Unit_getKind
),
Cint
,
(
VPtr
,),
u
)
)
)]
^
ccall
(
sbml
(
:
Unit_getExponent
),
Cint
,
(
VPtr
,),
u
)
*
ccall
(
sbml
(
:
Unit_getKind
),
Cint
,
(
VPtr
,),
u
)
,
)
,
)]
^
ccall
(
sbml
(
:
Unit_getExponent
),
Cint
,
(
VPtr
,),
u
)
*
exp10
(
ccall
(
sbml
(
:
Unit_getScale
),
Cint
,
(
VPtr
,),
u
))
*
ccall
(
sbml
(
:
Unit_getMultiplier
),
Cdouble
,
(
VPtr
,),
u
)
# Get `Unitful` quantity out of a `UnitDefinition_t`.
get_units
(
ud
::
VPtr
)
=
prod
(
get_unit
(
ccall
(
sbml
(
:
UnitDefinition_getUnit
),
VPtr
,
(
VPtr
,
Cuint
),
ud
,
j
-
1
))
for
j
=
1
:
ccall
(
sbml
(
:
UnitDefinition_getNumUnits
),
Cuint
,
(
VPtr
,),
ud
))
get_units
(
ud
::
VPtr
)
=
prod
(
get_unit
(
ccall
(
sbml
(
:
UnitDefinition_getUnit
),
VPtr
,
(
VPtr
,
Cuint
),
ud
,
j
-
1
))
for
j
=
1
:
ccall
(
sbml
(
:
UnitDefinition_getNumUnits
),
Cuint
,
(
VPtr
,),
ud
)
)
test/loadmodels.jl
View file @
c5421284
...
...
@@ -74,7 +74,10 @@ sbmlfiles = [
),
]
@testset
"Loading of models from various sources -
$(reader)
"
for
reader
in
(
readSBML
,
readSBMLFromString
)
@testset
"Loading of models from various sources -
$(reader)
"
for
reader
in
(
readSBML
,
readSBMLFromString
,
)
for
(
sbmlfile
,
url
,
hash
,
expected_mets
,
expected_rxns
)
in
sbmlfiles
if
!
isfile
(
sbmlfile
)
Downloads
.
download
(
url
,
sbmlfile
)
...
...
@@ -103,7 +106,9 @@ sbmlfiles = [
end
@testset
"readSBMLFromString"
begin
@test_logs
(
:
error
,
r
"^SBML reported error"
)
@test_throws
AssertionError
readSBMLFromString
(
""
)
@test_logs
(
:
error
,
r
"^SBML reported error"
)
@test_throws
AssertionError
readSBMLFromString
(
""
,
)
end
@testset
"Time variables in math"
begin
...
...
@@ -187,9 +192,11 @@ end
@test
test_math
.
args
[
2
]
.
fn
==
"sin"
@test
test_math
.
args
[
2
]
.
args
[
1
]
.
val
==
2.1
@test_logs
(
:
warn
,)
(
:
warn
,)
(
:
warn
,)
(
:
warn
,)
readSBML
(
joinpath
(
@__DIR__
,
"data"
,
"01234-sbml-l3v2.xml"
),
doc
->
libsbml_convert
(
"expandInitialAssignments"
,
[
"Fatal"
,
"Error"
,
"Warning"
])(
doc
)
)
@test_logs
(
:
warn
,)
(
:
warn
,)
(
:
warn
,)
(
:
warn
,)
readSBML
(
joinpath
(
@__DIR__
,
"data"
,
"01234-sbml-l3v2.xml"
),
doc
->
libsbml_convert
(
"expandInitialAssignments"
,
[
"Fatal"
,
"Error"
,
"Warning"
])(
doc
),
)
end
@testset
"relational operators are decoded correctly"
begin
...
...
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