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
9b236914
Unverified
Commit
9b236914
authored
3 years ago
by
Miroslav Kratochvil
Committed by
GitHub
3 years ago
Browse files
Options
Downloads
Plain Diff
Merge pull request #429 from LCSB-BioCore/mo-undo-accident
Add `back stoichiometry_string`
parents
60a1abab
0c72a4bf
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/base/utils/Reaction.jl
+33
-0
33 additions, 0 deletions
src/base/utils/Reaction.jl
test/base/utils/reaction.jl
+6
-0
6 additions, 0 deletions
test/base/utils/reaction.jl
with
39 additions
and
0 deletions
src/base/utils/Reaction.jl
+
33
−
0
View file @
9b236914
...
...
@@ -100,3 +100,36 @@ reaction_mass_balanced(model::StandardModel, rxn::Reaction) =
reaction_mass_balanced
(
model
::
StandardModel
,
reaction_dict
::
Dict
{
String
,
Float64
})
=
all
(
values
(
reaction_atom_balance
(
model
,
reaction_dict
))
.==
0
)
"""
stoichiometry_string(rxn_dict::Dict{String, Float64}; format_id = x -> x)
Return the reaction equation as a string. The metabolite strings can be manipulated by
setting `format_id`.
# Example
```
julia> req = Dict("
coa_c
" => -1, "
for_c
" => 1, "
accoa_c
" => 1, "
pyr_c
" => -1)
julia> stoichiometry_string(req)
"
coa_c
+
pyr_c
=
for_c
+
accoa_c
"
julia> stoichiometry_string(req; format_id = x -> x[1:end-2])
"
coa
+
pyr
=
for
+
accoa
"
```
"""
function
stoichiometry_string
(
req
;
format_id
=
x
->
x
)
count_prefix
(
n
)
=
abs
(
n
)
==
1
?
""
:
string
(
abs
(
n
),
" "
)
substrates
=
join
((
string
(
count_prefix
(
n
),
format_id
(
met
))
for
(
met
,
n
)
in
req
if
n
<
0
),
" + "
)
products
=
join
((
string
(
count_prefix
(
n
),
format_id
(
met
))
for
(
met
,
n
)
in
req
if
n
>=
0
),
" + "
)
return
substrates
*
" = "
*
products
end
"""
stoichiometry_string(rxn::Reaction; kwargs)
Alternative of [`stoichiometry_string`](@ref) take takes a `Reaction` as an argument.
"""
stoichiometry_string
(
rxn
::
Reaction
;
kwargs
...
)
=
stoichiometry_string
(
rxn
.
metabolites
;
kwargs
...
)
This diff is collapsed.
Click to expand it.
test/base/utils/reaction.jl
+
6
−
0
View file @
9b236914
...
...
@@ -38,4 +38,10 @@
atol
=
TEST_TOLERANCE
,
)
@test
reaction_atom_balance
(
model
,
Dict
(
"h_c"
=>
-
1.0
,
"h2o_c"
=>
1.0
))[
"H"
]
==
1.0
# test if reaction equation can be built back into a sensible reaction string
req
=
Dict
(
"coa_c"
=>
-
1
,
"for_c"
=>
1
,
"accoa_c"
=>
1
,
"pyr_c"
=>
-
1
)
rstr_out
=
stoichiometry_string
(
req
)
@test
occursin
(
"coa_c"
,
split
(
rstr_out
,
" = "
)[
1
])
@test
occursin
(
"for"
,
split
(
rstr_out
,
" = "
)[
2
])
end
This diff is collapsed.
Click to expand it.
cylon-x
@cylon-x
mentioned in commit
6eac034d
·
3 years ago
mentioned in commit
6eac034d
mentioned in commit 6eac034d10f5be32fa97ed9a55ab6888852f4fa2
Toggle commit list
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