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
Gitlab will go in to maintenance on Friday 5:30pm since SIU is doing Isilon maintenance and we use isilon shares on the Gitlab
You are on a read-only GitLab instance.
Show more breadcrumbs
LCSB-BioCore
COBREXA.jl
Commits
936cb0ce
Unverified
Commit
936cb0ce
authored
3 years ago
by
St. Elmo
Committed by
Miroslav Kratochvil
3 years ago
Browse files
Options
Downloads
Patches
Plain Diff
improved check_duplicate_reaction
parent
56ec8b3e
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/base/utils/Reaction.jl
+18
-12
18 additions, 12 deletions
src/base/utils/Reaction.jl
with
18 additions
and
12 deletions
src/base/utils/Reaction.jl
+
18
−
12
View file @
936cb0ce
"""
check_duplicate_reaction(rxn::Reaction, rxns::Dict{String, Reaction})
check_duplicate_reaction(rxn::Reaction, rxns::Dict{String, Reaction}
; only_metabolites=true
)
Check if `rxn` already exists in `rxns` but has another `id`.
Looks through all the reaction equations of `rxns` and compares
metabolite `id`s
and
their stoichiometric coefficients to those of `rxn`.
If `only_metabolites` is `true` then only the
metabolite `id`s
are checked.
Otherwise, compares metabolite `id`s and the absolute value of
their stoichiometric coefficients to those of `rxn`.
If `rxn` has the same reaction equation as another reaction in `rxns`, the return the `id`.
Otherwise return `nothing`.
See also: [`is_mass_balanced`](@ref)
"""
function
check_duplicate_reaction
(
crxn
::
Reaction
,
rxns
::
OrderedDict
{
String
,
Reaction
})
function
check_duplicate_reaction
(
crxn
::
Reaction
,
rxns
::
OrderedDict
{
String
,
Reaction
}
;
only_metabolites
=
true
)
for
(
k
,
rxn
)
in
rxns
if
rxn
.
id
!=
crxn
.
id
# skip if same ID
reaction_checker
=
true
for
(
kk
,
vv
)
in
rxn
.
metabolites
# get reaction stoich
if
get
(
crxn
.
metabolites
,
kk
,
0
)
!=
vv
# if at least one stoich doesn't match
reaction_checker
=
false
break
if
only_metabolites
# only check if metabolites are the same
if
issetequal
(
collect
(
keys
(
crxn
.
metabolites
)),
collect
(
keys
(
rxn
)))
return
k
end
else
# also check the stoichiometric coefficients
reaction_checker
=
true
for
(
kk
,
vv
)
in
rxn
.
metabolites
# get reaction stoich
if
abs
(
get
(
crxn
.
metabolites
,
kk
,
0
))
!=
abs
(
vv
)
# if at least one stoich doesn't match
reaction_checker
=
false
break
end
end
if
reaction_checker
# was a match found
return
k
end
end
if
reaction_checker
return
k
end
end
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