Commit 442d5aa0 authored by VIGNET Pierre's avatar VIGNET Pierre
Browse files

[cmd] Refactor rename some functions

parent 360e82bf
......@@ -96,7 +96,7 @@ def solutions_2_graphs(args):
@check_output_dir
def solutions_2_json(args):
def queries_2_json(args):
"""Create a JSON formated file containing all data from complete MAC files
(*mac_complete files). The file will contain frontier places/boundaries
and decompiled steps with their respective events for each solution.
......@@ -107,7 +107,7 @@ def solutions_2_json(args):
# Module import
import solution_sort
solution_sort.solutions_2_json(
solution_sort.queries_2_json(
args['output'],
args['model_file'],
args['path'],
......@@ -120,7 +120,7 @@ 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
directive 'queries_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.
"""
......@@ -154,14 +154,14 @@ def solutions_2_common_graph(args):
@check_output_dir
def solutions_2_occcurrences_matrix(args):
def queries_2_occcurrence_matrix(args):
"""Create a matrix of occurrences counting entities in the solutions found in
*mac.txt files in the given path.
"""
# Module import
import solution_sort
solution_sort.solutions_2_occcurrences_matrix(
solution_sort.queries_2_occcurrence_matrix(
args['output'],
args['model_file'],
args['path'],
......@@ -426,23 +426,23 @@ def main():
# subparser: Decompilation of trajectories of MACs in a complete file/dir.
# Model file (xml : cadbiom language)
# Solution file (mac_complete)
parser_solutions_2_json = subparsers.add_parser(
'solutions_2_json',
help=solutions_2_json.__doc__,
parser_queries_2_json = subparsers.add_parser(
'queries_2_json',
help=queries_2_json.__doc__,
formatter_class=argparse.ArgumentDefaultsHelpFormatter)
parser_solutions_2_json.add_argument('model_file',
parser_queries_2_json.add_argument('model_file',
help="bcx model file.")
parser_solutions_2_json.add_argument('path',
parser_queries_2_json.add_argument('path',
help="Complete solution file or directory with MAC solutions files "
"(*mac_complete.txt files) generated with the 'compute_macs' command.")
parser_solutions_2_json.add_argument('--output', action=ReadableDir,
parser_queries_2_json.add_argument('--output', action=ReadableDir,
nargs='?', default='decompiled_solutions/',
help="Directory for newly created files.")
parser_solutions_2_json.add_argument('--no_conditions', action='store_true',
parser_queries_2_json.add_argument('--no_conditions', action='store_true',
help="Don't export conditions of transitions. This allows "
"to have only places/entities that are used inside trajectories; "
"thus, inhibitors nodes are not present in the json file")
parser_solutions_2_json.set_defaults(func=solutions_2_json)
parser_queries_2_json.set_defaults(func=queries_2_json)
# subparser: Make an interaction weighted graph based on the searched
......@@ -458,7 +458,7 @@ def main():
parser_json_2_interaction_graph.add_argument('--path',
nargs='?', default='decompiled_solutions/',
help="JSON formated file containing all data from complete MAC files"
"(*mac_complete files) generated with the 'solutions_2_json' command.")
"(*mac_complete files) generated with the 'queries_2_json' command.")
parser_json_2_interaction_graph.add_argument('--output', action=ReadableDir,
nargs='?', default='graphs/',
help="Directory for the newly created file.")
......@@ -487,8 +487,8 @@ def main():
# Model file (xml : cadbiom language)
# Solution file (mac.txt)
parser_occurrences_matrix = subparsers.add_parser(
'solutions_2_occcurrences_matrix',
help=solutions_2_occcurrences_matrix.__doc__,
'queries_2_occcurrence_matrix',
help=queries_2_occcurrence_matrix.__doc__,
formatter_class=argparse.ArgumentDefaultsHelpFormatter)
parser_occurrences_matrix.add_argument('model_file',
help="bcx model file.")
......@@ -500,7 +500,7 @@ def main():
help="Output directory for CSV files.")
parser_occurrences_matrix.add_argument('--transpose_csv', action='store_true',
help="Transpose the final matrix (switch columns and rows).")
parser_occurrences_matrix.set_defaults(func=solutions_2_occcurrences_matrix)
parser_occurrences_matrix.set_defaults(func=queries_2_occcurrence_matrix)
# subparser: Merge solutions to a csv file
......
......@@ -454,7 +454,7 @@ 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
directive ``queries_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.
......
......@@ -28,7 +28,7 @@ files of Cadbiom.
Entry points:
* :meth:`~cadbiom_cmd.solution_sort.solutions_2_json`
* :meth:`~cadbiom_cmd.solution_sort.queries_2_json`
* :meth:`~cadbiom_cmd.solution_sort.solutions_2_graphs`
* :meth:`~cadbiom_cmd.solution_sort.solutions_2_common_graph`
......@@ -156,7 +156,7 @@ def solutions_sort(path):
def write_json(output_dir, file_path, file_suffix, data):
"""Write decompiled solutions to a JSON formated file
Called by :meth:`solutions_2_json TODO` and :meth:`queries_2_common_graph`
Called by :meth:`queries_2_json TODO` and :meth:`queries_2_common_graph`
:param output_dir: Output directory
:param file_path: Filepath of the original solution file.
......@@ -176,8 +176,8 @@ def write_json(output_dir, file_path, file_suffix, data):
json.dump(data, f_d, sort_keys=True, indent=2)
## query - json
def solutions_2_json(output_dir, model_file, path, conditions=True):
"""Entry point for solutions_2_json
def queries_2_json(output_dir, model_file, path, conditions=True):
"""Entry point for queries_2_json
Create a JSON formated file containing all data from complete MAC files
(\*mac_complete files). The file will contain frontier places/boundaries
......@@ -233,6 +233,7 @@ def solutions_2_json(output_dir, model_file, path, conditions=True):
LOGGER.info("Files processed: %s", file_number)
assert file_number != 0, "No *mac_complete.txt files found!"
################################################################################
def solutions_2_graphs(output_dir, model_file, path):
"""Entry point for solutions_2_graphs
......@@ -329,6 +330,7 @@ def save_solutions_to_graphs(output_dir, sol_steps, transitions):
export_graph(output_dir, sol, sol_index,
build_graph(sol, steps, transitions)[0])
################################################################################
def get_solution_graphs(sol_steps, transitions):
"""Generator that yields the graphs of the given solutions.
......@@ -530,9 +532,9 @@ def queries_2_common_graph(output_dir, model_file, path,
## Matrices of occurrences #####################################################
def solutions_2_occcurrences_matrix(output_dir, model_file, path,
def queries_2_occcurrence_matrix(output_dir, model_file, path,
transposed=False, normalized=False):
"""Entry point for solutions_2_occcurrences_matrix
"""Entry point for queries_2_occcurrence_matrix
See :meth:`~cadbiom_cmd.solution_sort.occurrence_matrix`.
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment