Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
VIGNET Pierre
cadbiom
Commits
5302b4a1
Commit
5302b4a1
authored
Oct 28, 2018
by
VIGNET Pierre
Browse files
Add entry point json_2_interaction_graph to the command_line module
parent
e5a1a074
Changes
2
Hide whitespace changes
Inline
Side-by-side
command_line/cadbiom_cmd/cadbiom_cmd.py
View file @
5302b4a1
...
...
@@ -93,6 +93,26 @@ def solutions_2_json(args):
conditions
=
not
params
[
'no_conditions'
],
# Reverse the param...
)
def
json_2_interaction_graph
(
args
):
"""Make an interaction weighted graph based on the searched molecule of interest.
Read decompiled solutions files (*.json* files produced by the
directive 'solutions_2_json') and make a graph of the relationships
between one or more molecules of interest, the genes and other
frontier places/boundaries found among all the solutions.
"""
# Module import
import
interaction_graph
params
=
args_to_param
(
args
)
interaction_graph
.
json_2_interaction_graph
(
params
[
'output'
],
params
[
'molecules_of_interest'
],
params
[
'path'
],
)
def
model_comparison
(
args
):
"""Isomorphism test.
...
...
@@ -308,6 +328,27 @@ def main():
parser_solutions_2_json
.
set_defaults
(
func
=
solutions_2_json
)
# subparser: Make an interaction weighted graph based on the searched
# molecule of interest
# Require JSON decompilated solutions files
parser_json_2_interaction_graph
=
subparsers
.
add_parser
(
'json_2_interaction_graph'
,
help
=
json_2_interaction_graph
.
__doc__
,
formatter_class
=
argparse
.
ArgumentDefaultsHelpFormatter
)
parser_json_2_interaction_graph
.
add_argument
(
'molecules_of_interest'
,
nargs
=
'+'
,
help
=
"One or multiple molecule of interest to search in the trajectories"
" of every solutions"
)
parser_json_2_interaction_graph
.
add_argument
(
'--path'
,
nargs
=
'?'
,
default
=
'decompiled_solutions/'
,
help
=
"JSON formated file containing all data from complete MAC files"
"(*cam_complete files) generated with the 'solutions_2_json' command."
)
parser_json_2_interaction_graph
.
add_argument
(
'--output'
,
action
=
ReadableDir
,
nargs
=
'?'
,
default
=
'graphs/'
,
help
=
"Directory for the newly created file."
)
parser_json_2_interaction_graph
.
set_defaults
(
func
=
json_2_interaction_graph
)
# subparser: Merge solutions to a csv file
# Solution file (cam)
# Output (csv)
...
...
command_line/cadbiom_cmd/interaction_graph.py
View file @
5302b4a1
...
...
@@ -31,6 +31,7 @@ from __future__ import unicode_literals
from
__future__
import
print_function
# Standard imports
import
time
import
json
import
os
import
glob
...
...
@@ -103,12 +104,7 @@ def get_solutions_and_related_places_from_file(file_path):
def
get_solutions_and_related_places
(
path
):
"""Entry point for
Read decompiled solutions files (\*.json\* files produced by the
directive ``solutions_2_json``) and make a graph of the relationships
between one or more molecules of interest, the genes and other
frontier places/boundaries found among all the solutions.
"""Read decompiled solutions files (\*.json\* files)
This functions tests if the given path is a directory or a file.
...
...
@@ -435,5 +431,32 @@ def build_graph(all_genes, all_stimuli, unique_genes_interactions,
nx
.
write_graphml
(
G
,
"test.graphml"
)
def
json_2_interaction_graph
(
output_dir
,
molecules_of_interest
,
path
):
"""Entry point for json_2_interaction_graph
Read decompiled solutions files (\*.json\* files produced by the
directive ``solutions_2_json``) and make a graph of the relationships
between one or more molecules of interest, the genes and other
frontier places/boundaries found among all the solutions.
More information about the graph and its legend:
:meth:`~cadbiom_cmd.interaction_graph.build_graph`.
"""
chrono_start
=
time
.
time
()
# get_solutions_and_related_places: trajectories
# filter_trajectories: filtered_macs, binary_interactions
# build_interactions: data to unpack for build_graph
build_graph
(
*
build_interactions
(
*
filter_trajectories
(
get_solutions_and_related_places
(
path
),
molecules_of_interest
)
)
)
LOGGER
.
info
(
"Graph generated in %s"
,
time
.
time
()
-
chrono_start
)
nx
.
write_graphml
(
G
,
"test.graphml"
)
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a 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