Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Gitlab will go into maintenance Friday 3rd February from 9:00 to 10:00
Open sidebar
LCSB-BioCore
SBML.jl
Commits
19945dde
Unverified
Commit
19945dde
authored
Mar 17, 2021
by
Laurent Heirendt
✈
Committed by
GitHub
Mar 17, 2021
Browse files
Merge pull request #28 from LCSB-BioCore/mk-associations
parents
744310aa
26c13d0a
Changes
2
Hide whitespace changes
Inline
Side-by-side
src/readsbml.jl
View file @
19945dde
...
...
@@ -51,6 +51,38 @@ getNotes(x::VPtr)::Maybe{String} = getOptionalString(x, :SBase_getNotesString)
getAnnotation
(
x
::
VPtr
)
::
Maybe
{
String
}
=
getOptionalString
(
x
,
:
SBase_getAnnotationString
)
"""
function getAssociation(x::VPtr)::GeneProductAssociation
Convert a pointer to SBML `FbcAssociation_t` to the `GeneProductAssociation`
tree structure.
"""
function
getAssociation
(
x
::
VPtr
)
::
GeneProductAssociation
# libsbml C API is currently missing functions to check this in a normal
# way, so we use a bit of a hack.
typecode
=
ccall
(
sbml
(
:
SBase_getTypeCode
),
Cint
,
(
VPtr
,),
x
)
if
typecode
==
808
# SBML_FBC_GENEPRODUCTREF
return
GPARef
(
unsafe_string
(
ccall
(
sbml
(
:
GeneProductRef_getGeneProduct
),
Cstring
,
(
VPtr
,),
x
)),
)
elseif
typecode
==
809
# SBML_FBC_AND
return
GPAAnd
([
getAssociation
(
ccall
(
sbml
(
:
FbcAnd_getAssociation
),
VPtr
,
(
VPtr
,
Cuint
),
x
,
i
-
1
),
)
for
i
=
1
:
ccall
(
sbml
(
:
FbcAnd_getNumAssociations
),
Cuint
,
(
VPtr
,),
x
)
])
elseif
typecode
==
810
# SBML_FBC_OR
return
GPAOr
([
getAssociation
(
ccall
(
sbml
(
:
FbcOr_getAssociation
),
VPtr
,
(
VPtr
,
Cuint
),
x
,
i
-
1
),
)
for
i
=
1
:
ccall
(
sbml
(
:
FbcOr_getNumAssociations
),
Cuint
,
(
VPtr
,),
x
)
])
else
throw
(
ErrorException
(
"Unsupported FbcAssociation type"
))
end
end
""""
function
extractModel
(
mdl
::
VPtr
)
::
Model
Take
the
`SBMLModel_t`
pointer
and
extract
all
information
required
to
make
a
...
...
@@ -152,7 +184,6 @@ function extractModel(mdl::VPtr)::Model
mdl_fbc,
i - 1,
)
for j = 1:ccall(sbml(:Objective_getNumFluxObjectives), Cuint, (VPtr,), o)
fo = ccall(sbml(:Objective_getFluxObjective), VPtr, (VPtr, Cuint), o, j - 1)
objectives_fbc[unsafe_string(
...
...
@@ -231,12 +262,28 @@ function extractModel(mdl::VPtr)::Model
add_stoi(sr, 1)
end
association = nothing
if re_fbc != C_NULL
gpa = ccall(
sbml(:FbcReactionPlugin_getGeneProductAssociation),
VPtr,
(VPtr,),
re_fbc,
)
if gpa != C_NULL
a = ccall(sbml(:GeneProductAssociation_getAssociation), VPtr, (VPtr,), gpa)
a != C_NULL
association = getAssociation(a)
end
end
reid = unsafe_string(ccall(sbml(:Reaction_getId), Cstring, (VPtr,), re))
reactions[reid] = Reaction(
stoi,
lb,
ub,
haskey(objectives_fbc, reid) ? objectives_fbc[reid] : oc,
association,
getNotes(re),
getAnnotation(re),
)
...
...
src/structs.jl
View file @
19945dde
...
...
@@ -28,6 +28,34 @@ struct UnitPart
UnitPart
(
k
,
e
,
s
,
m
)
=
new
(
k
,
e
,
s
,
m
)
end
"""
Abstract type for all kinds of gene product associations
"""
abstract type
GeneProductAssociation
end
"""
Gene product reference in the association expression
"""
struct
GPARef
<:
GeneProductAssociation
gene_product
::
String
end
"""
Boolean binary "
and
" in the association expression
"""
struct
GPAAnd
<:
GeneProductAssociation
terms
::
Vector
{
GeneProductAssociation
}
end
"""
Boolean binary "
or
" in the association expression
"""
struct
GPAOr
<:
GeneProductAssociation
terms
::
Vector
{
GeneProductAssociation
}
end
"""
Reaction with stoichiometry that assigns reactants and products their relative
consumption/production rates (accessible in field `stoichiometry`), lower/upper
...
...
@@ -39,9 +67,10 @@ struct Reaction
lb
::
Tuple
{
Float64
,
String
}
ub
::
Tuple
{
Float64
,
String
}
oc
::
Float64
gene_product_association
::
Maybe
{
GeneProductAssociation
}
notes
::
Maybe
{
String
}
annotation
::
Maybe
{
String
}
Reaction
(
s
,
l
,
u
,
o
,
n
=
nothing
,
a
=
nothing
)
=
new
(
s
,
l
,
u
,
o
,
n
,
a
)
Reaction
(
s
,
l
,
u
,
o
,
as
,
n
=
nothing
,
a
n
=
nothing
)
=
new
(
s
,
l
,
u
,
o
,
as
,
n
,
a
n
)
end
"""
...
...
cylon-x
🤖
@cylon-x
mentioned in commit
1b45f917
·
Mar 17, 2021
mentioned in commit
1b45f917
mentioned in commit 1b45f917e5f17a0e05550b8a904e509f68961ef5
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