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
d7e390cf
Unverified
Commit
d7e390cf
authored
3 years ago
by
Miroslav Kratochvil
Browse files
Options
Downloads
Patches
Plain Diff
document GPAs
parent
cedc80e1
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/gene_associations.jl
+32
-7
32 additions, 7 deletions
src/base/utils/gene_associations.jl
with
32 additions
and
7 deletions
src/base/utils/gene_associations.jl
+
32
−
7
View file @
d7e390cf
#TODO: convert the string-GeneAssociation formatting to this too
"""
_parse_grr(gpa::SBML.GeneProductAssociation)::GeneAssociation
Parse `SBML.GeneProductAssociation` structure to the simpler GeneAssociation.
The input must be (implicitly) in a positive DNF.
"""
function
_parse_grr
(
gpa
::
SBML
.
GeneProductAssociation
)
::
GeneAssociation
parse_ref
(
x
)
=
typeof
(
x
)
==
SBML
.
GPARef
?
x
.
gene_product
:
nothing
parse_ands
(
x
)
=
...
...
@@ -10,6 +14,14 @@ function _parse_grr(gpa::SBML.GeneProductAssociation)::GeneAssociation
return
parse_or
(
gpa
)
end
"""
_unparse_grr(
::Type{SBML.GeneProductAssociation},
x::GeneAssociation,
)::SBML.GeneAssociation
Convert a GeneAssociation to the corresponding `SBML.jl` structure.
"""
function
_unparse_grr
(
::
Type
{
SBML
.
GeneProductAssociation
},
x
::
GeneAssociation
,
...
...
@@ -18,12 +30,19 @@ function _unparse_grr(
end
"""
parsegrr(string
_rule)
_
parse
_
grr(s
::S
tring
)::GeneAssociation
Parse a gene reaction rule string `string_rule` into a nested string gene reaction rule array `Vector{Vector{String}}`.
Parse a DNF gene association rule in format `(YIL010W and YLR043C) or (YIL010W
and YGR209C)` to `GeneAssociation. Also accepts `OR`, `|`, `||`, `AND`, `&`,
and `&&`.
Format: (YIL010W and YLR043C) or (YIL010W and YGR209C) where `or` can also be `OR, |, ||` and where `and` can also be `AND, &, &&`.
So `"
(
YIL010W
and
YLR043C
)
or
(
YIL010W
and
YGR209C
)
"`` becomes `[[YIL010W, YLR043C], [YIL010W, YGR209C]]`` as a nested string array.
# Example
```
julia> _parse_grr("
(
YIL010W
and
YLR043C
)
or
(
YIL010W
and
YGR209C
)
")
2-element Array{Array{String,1},1}:
["
YIL010W
", "
YLR043C
"]
["
YIL010W
", "
YGR209C
"]
```
"""
function
_parse_grr
(
s
::
String
)
::
GeneAssociation
# first get the gene id list in string format
...
...
@@ -39,8 +58,14 @@ end
"""
unparse_grr(grr::Vector{Vector{Gene}}
Converts a nested string gene reaction array back into a gene reaction rule string.
So `[[YIL010W, YLR043C], [YIL010W, YGR209C]]`` becomes `"
(
YIL010W
and
YLR043C
)
or
(
YIL010W
and
YGR209C
)
"``.
Converts a nested string gene reaction array back into a gene reaction rule
string.
# Example
```
julia> _unparse_grr(String, [["
YIL010W
", "
YLR043C
"], ["
YIL010W
", "
YGR209C
"]])
"
(
YIL010W
and
YLR043C
)
or
(
YIL010W
and
YGR209C
)
"
```
"""
function
_unparse_grr
(
::
Type
{
String
},
grr
::
GeneAssociation
)
::
String
grr_strings
=
String
[]
...
...
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