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
591a1ece
Commit
591a1ece
authored
Feb 06, 2021
by
Miroslav Kratochvil
🚴
Browse files
tests now do tests
parent
77b605d4
Changes
4
Hide whitespace changes
Inline
Side-by-side
Project.toml
View file @
591a1ece
...
...
@@ -7,4 +7,5 @@ version = "0.1.0"
Libdl
=
"8f399da3-3557-5675-b5ff-fb832c97cbdb"
Pkg
=
"44cfe95a-1eb2-52ea-b672-e2afdf69b78f"
SBML_jll
=
"bb12108a-f4ef-5f88-8ef3-0b33ff7017f1"
SHA
=
"ea8e919c-243c-51af-8825-aaa63cd721ce"
Test
=
"8dfed614-e22c-5e08-85e1-65c5234f0b40"
src/readsbml.jl
View file @
591a1ece
...
...
@@ -11,13 +11,11 @@ function readSBML(fn::String)::Model
try
n_errs
=
ccall
(
sbml
(
:
SBMLDocument_getNumErrors
),
Cuint
,
(
VPtr
,),
doc
)
if
n_errs
>
0
@error
"SBML loading failed"
throw
(
:
IOError
)
throw
(
SystemError
(
"Opening SBML document has failed"
))
end
if
0
==
ccall
(
sbml
(
:
SBMLDocument_isSetModel
),
Cint
,
(
VPtr
,),
doc
)
@error
"SBML document does not contain a model"
throw
(
:
ValueError
)
throw
(
AssertionError
(
"SBML document contains no model"
))
end
model
=
ccall
(
sbml
(
:
SBMLDocument_getModel
),
VPtr
,
(
VPtr
,),
doc
)
...
...
test/loadEColi.jl
View file @
591a1ece
...
...
@@ -5,15 +5,53 @@ if !isfile(sbmlfile)
download
(
"https://systemsbiology.ucsd.edu/sites/systemsbiology.ucsd.edu/files/Attachments/Images/InSilicoOrganisms/Ecoli/Ecoli_SBML/Ec_core_flux1.xml"
,
sbmlfile
)
end
if
bytes2hex
(
sha256
(
sbmlfile
))
!=
"e3d18499660a0f7fc15a5a44f33f001c7881ac99a2e8a6a461edf1cf3d69a537"
@warn
"The downloaded E Coli core flux model seems to be different from the expected one. Tests will likely fail."
end
@testset
"SBML model loading"
begin
m
=
readSBML
(
sbmlfile
)
m
dl
=
readSBML
(
sbmlfile
)
@test
typeof
(
mdl
)
==
Model
@test_throws
:
IO
Error
readSBML
(
sbmlfile
*
".does.not.really.exist"
)
@test_throws
System
Error
readSBML
(
sbmlfile
*
".does.not.really.exist"
)
@test
length
(
mdl
.
compartments
)
==
2
mets
,
rxns
,
S
=
getS
(
mdl
)
@test
length
(
mets
)
==
77
@test
length
(
rxns
)
==
77
@test
size
(
S
)
==
(
length
(
mets
),
length
(
rxns
))
# totally arbitrary value tests
@test
isapprox
(
sum
(
S
),
42.1479
)
@test
mets
[
10
:
12
]
==
[
"M_akg_e"
,
"M_fum_c"
,
"M_pyr_c"
]
@test
rxns
[
10
:
12
]
==
[
"R_H2Ot"
,
"R_PGL"
,
"R_EX_glc_e_"
]
lbs
=
getLBs
(
mdl
)
ubs
=
getUBs
(
mdl
)
ocs
=
getOCs
(
mdl
)
@test
length
(
ocs
)
==
length
(
mets
)
@test
ocs
[
40
]
==
1.0
deleteat!
(
ocs
,
40
)
@test
all
(
ocs
.==
0.0
)
@test
length
(
getLBs
(
mdl
))
==
length
(
rxns
)
@test
length
(
getUBs
(
mdl
))
==
length
(
rxns
)
getunit
=
(
val
,
unit
)
::
Tuple
->
unit
@test
all
([
broadcast
(
getunit
,
lbs
)
broadcast
(
getunit
,
ubs
)]
.==
"mmol_per_gDW_per_hr"
)
getval
=
(
val
,
unit
)
::
Tuple
->
val
lvals
=
broadcast
(
getval
,
lbs
)
uvals
=
broadcast
(
getval
,
ubs
)
@test
isapprox
(
lvals
[
27
],
uvals
[
27
])
@test
isapprox
(
lvals
[
27
],
7.6
)
@test
isapprox
(
lvals
[
12
],
-
10
)
@test
count
(
isapprox
.
(
lvals
,
-
999999
))
==
40
@test
count
(
isapprox
.
(
lvals
,
0
))
==
35
@test
count
(
isapprox
.
(
uvals
,
999999
))
==
76
end
test/runtests.jl
View file @
591a1ece
using
Test
using
Test
,
SHA
using
SBML
import
Pkg
include
(
"version.jl"
)
include
(
"loadEColi.jl"
)
@testset
"SBML test suite"
begin
include
(
"version.jl"
)
include
(
"loadEColi.jl"
)
end
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