Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
COBREXA.jl
Manage
Activity
Members
Plan
External wiki
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
LCSB-BioCore
COBREXA.jl
Commits
ed880cab
Commit
ed880cab
authored
3 years ago
by
Miroslav Kratochvil
Browse files
Options
Downloads
Patches
Plain Diff
clean up, remove obsolete tests
parent
6efe3d61
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/reconstruction/Reaction.jl
+32
-18
32 additions, 18 deletions
src/reconstruction/Reaction.jl
test/reconstruction/Reaction.jl
+0
-5
0 additions, 5 deletions
test/reconstruction/Reaction.jl
with
32 additions
and
23 deletions
src/reconstruction/Reaction.jl
+
32
−
18
View file @
ed880cab
...
...
@@ -2,34 +2,48 @@
"""
A small helper type for constructing reactions inline
"""
struct
MetaboliteWithCoefficient
coeff
::
Float64
metabolite
::
Metabolite
struct
_Stoichiometry
s
::
Dict
{
String
,
Float64
}
end
const
_Stoichiometry
=
Vector
{
MetaboliteWithCoefficient
}
const
_Stoichiometrizable
=
Union
{
Metabolite
,
Vector
{
MetaboliteWithCoefficient
}}
const
_Stoichiometrizable
=
Union
{
Metabolite
,
_Stoichiometry
}
Base
.
convert
(
::
Type
{
_Stoichiometry
},
x
::
Metabolite
)
=
[
MetaboliteWithCoefficient
(
1.0
,
x
)]
Base
.
convert
(
::
Type
{
_Stoichiometry
},
::
Nothing
)
=
_Stoichiometry
(
Dict
())
Base
.
convert
(
::
Type
{
_Stoichiometry
},
m
::
Metabolite
)
=
_Stoichiometry
(
Dict
(
m
.
id
=>
1.0
))
Base
.:*
(
a
::
Real
,
m
::
Metabolite
)
=
[
MetaboliteWithCoefficient
(
float
(
a
),
m
)]
Base
.:*
(
a
::
Real
,
m
::
Metabolite
)
=
_Stoichiometry
(
Dict
(
m
.
id
=>
a
))
Base
.:+
(
a
::
_Stoichiometrizable
,
b
::
_Stoichiometrizable
)
=
vcat
(
convert
(
_Stoichiometry
,
a
),
convert
(
_Stoichiometry
,
b
))
"""
metabolite1 + metabolite2
_make_reaction_dict
(
l
,
r
)
=
Dict
{
String
,
Float64
}(
vcat
(
[
mc
.
metabolite
.
id
=>
-
mc
.
coeff
for
mc
in
convert
(
_Stoichiometry
,
l
)],
[
mc
.
metabolite
.
id
=>
mc
.
coeff
for
mc
in
convert
(
_Stoichiometry
,
l
)],
),
)
Add 2 groups of [`Metabolite`](@ref)s together to form reactions inline. Use
with `+`, `*`, [`→`](@ref) and similar operators.
"""
function
Base.:+
(
a
::
_Stoichiometrizable
,
b
::
_Stoichiometrizable
)
ad
=
convert
(
_Stoichiometry
,
a
)
.
s
bd
=
convert
(
_Stoichiometry
,
b
)
.
s
_Stoichiometry
(
Dict
(
mid
=>
get
(
ad
,
mid
,
0.0
)
+
get
(
bd
,
mid
,
0.0
)
for
mid
in
union
(
keys
(
ad
),
keys
(
bd
))
),
)
end
function
_make_reaction_dict
(
r
,
p
)
rd
=
convert
(
_Stoichiometry
,
r
)
.
s
pd
=
convert
(
_Stoichiometry
,
p
)
.
s
return
Dict
{
String
,
Float64
}(
mid
=>
get
(
pd
,
mid
,
0.0
)
-
get
(
rd
,
mid
,
0.0
)
for
mid
in
union
(
keys
(
rd
),
keys
(
pd
))
)
end
"""
substrates → products
Make a forward-only [`Reaction`](@ref) from `substrates` and `products`.
"""
→
(
substrates
::
_Stoichiometrizable
,
products
::
_Stoichiometrizable
)
=
→
(
substrates
::
Maybe
{
_Stoichiometrizable
}
,
products
::
Maybe
{
_Stoichiometrizable
}
)
=
Reaction
(
""
,
_make_reaction_dict
(
substrates
,
products
),
:
forward
)
"""
...
...
@@ -37,7 +51,7 @@ Make a forward-only [`Reaction`](@ref) from `substrates` and `products`.
Make a reverse-only [`Reaction`](@ref) from `substrates` and `products`.
"""
←
(
substrates
::
_Stoichiometrizable
,
products
::
_Stoichiometrizable
)
=
←
(
substrates
::
Maybe
{
_Stoichiometrizable
}
,
products
::
Maybe
{
_Stoichiometrizable
}
)
=
Reaction
(
""
,
_make_reaction_dict
(
substrates
,
products
),
:
reverse
)
"""
...
...
@@ -46,5 +60,5 @@ Make a reverse-only [`Reaction`](@ref) from `substrates` and `products`.
Make a bidirectional (reversible) [`Reaction`](@ref) from `substrates` and
`products`.
"""
↔
(
substrates
::
_Stoichiometrizable
,
products
::
_Stoichiometrizable
)
=
↔
(
substrates
::
Maybe
{
_Stoichiometrizable
}
,
products
::
Maybe
{
_Stoichiometrizable
}
)
=
Reaction
(
""
,
_make_reaction_dict
(
substrates
,
products
),
:
bidirectional
)
This diff is collapsed.
Click to expand it.
test/reconstruction/Reaction.jl
+
0
−
5
View file @
ed880cab
...
...
@@ -33,9 +33,4 @@
rxn
=
nadh
+
4.0
*
h_c
+
1.0
*
q8
→
1.0
*
q8h2
+
1.0
*
nad
+
3.0
*
h_p
@test
rxn
.
lb
==
0.0
&&
rxn
.
ub
>
0.0
@test
length
(
h_p
+
h_p
)
==
2
@test
length
(
h_p
+
h_p
+
h_p
)
==
3
@test
length
(
+
([
2.0
q8
,
1.0
nad
],
nadh
))
==
3
end
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
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!
Save comment
Cancel
Please
register
or
sign in
to comment