Commit b0cc9362 authored by VIGNET Pierre's avatar VIGNET Pierre
Browse files

Rename traj_2_json to solutions_2_json; Update doc

parent fe29de5e
......@@ -72,10 +72,10 @@ def traj_2_graph(args):
params['sol_file']
)
def traj_2_json(args):
def solutions_2_json(args):
"""Create a JSON formated file containing all data from complete MAC files
(frontier places/boundaries and decompiled steps with their respective
events).
(*cam_complete files). The file will contain frontier places/boundaries
and decompiled steps with their respective events for each solution.
This is a function to quickly search all transition attributes involved
in a solution.
......@@ -86,11 +86,11 @@ def traj_2_json(args):
params = args_to_param(args)
params['output'] = params['output'] if params['output'][-1] == '/' \
else params['output'] + '/'
solution_repr.traj_2_json(
solution_repr.solutions_2_json(
params['output'],
params['chart_file'],
params['path'],
conditions=not params['no_conditions'], # Inv the param...
conditions=not params['no_conditions'], # Reverse the param...
)
def model_comp(args):
......@@ -256,14 +256,15 @@ def main():
parser_input_file.set_defaults(func=launch_researchs)
## Solutions-related commands ##############################################
# subparser: Sort solutions in alphabetical order in place
# Solution file (complete or not)
parser_solutions_sort = subparsers.add_parser('sort_solutions',
help=launch_sort.__doc__)
parser_solutions_sort.add_argument('path',
help="Solution file or directory with solution files " + \
"(output of 'compute_macs' command).")
help="Solution file or directory with MAC solutions files "
"(*cam* files) generated with the 'compute_macs' command.")
parser_solutions_sort.set_defaults(func=launch_sort)
......@@ -277,8 +278,8 @@ def main():
parser_trajectories.add_argument('chart_file',
help="bcx model file.")
parser_trajectories.add_argument('sol_file',
help="Complete solution file or directory with solution files " + \
"(output of 'compute_macs' command).")
help="Complete solution file or directory with MAC solutions files "
"(*cam_complete.txt files) generated with the 'compute_macs' command.")
parser_trajectories.add_argument('--output', action=ReadableDir,
nargs='?', default='graphs/',
help="Output directory for GraphML files.")
......@@ -288,23 +289,23 @@ def main():
# subparser: Decompilation of trajectories of MACs in a complete file/dir.
# Model file (xml : cadbiom language)
# Solution file (cam_complete)
parser_traj_2_json = subparsers.add_parser(
'traj_2_json',
help=traj_2_json.__doc__,
parser_solutions_2_json = subparsers.add_parser(
'solutions_2_json',
help=solutions_2_json.__doc__,
formatter_class=argparse.ArgumentDefaultsHelpFormatter)
parser_traj_2_json.add_argument('chart_file',
parser_solutions_2_json.add_argument('chart_file',
help="bcx model file.")
parser_traj_2_json.add_argument('path',
help="Complete solution file or directory with solution files " + \
parser_solutions_2_json.add_argument('path',
help="Complete solution file or directory with MAC solutions files "
"(*cam_complete.txt files) generated with the 'compute_macs' command.")
parser_traj_2_json.add_argument('--output', action=ReadableDir,
parser_solutions_2_json.add_argument('--output', action=ReadableDir,
nargs='?', default='decompiled_solutions/',
help="Directory for newly created files.")
parser_traj_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; " + \
parser_solutions_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_traj_2_json.set_defaults(func=traj_2_json)
parser_solutions_2_json.set_defaults(func=solutions_2_json)
# subparser: Merge solutions to a csv file
......@@ -322,6 +323,7 @@ def main():
help="CSV file: <Final property formula>;<cam>")
parser_merge_cams.set_defaults(func=merge_cams)
## Model-related commands ##################################################
# subparser: Model comparison
# 2 models
......
......@@ -281,11 +281,21 @@ def test_main():
print(transitions)
def traj_2_json(output_dir, model_file, solution_path, conditions=True):
"""Entry point for traj_2_json
def solutions_2_json(output_dir, model_file, solution_path, conditions=True):
"""Entry point for solutions_2_json
.. note:: This functions tests if the solution_path is a directory
or just a file.
This functions tests if the given path is a directory or a file.
:param output_dir: Output path.
:param model_file: Filepath of the model.
:param solution_path: Filepath/directory of a complete solution file.
:param conditions: (Optional) If False, conditions of transitions will not
be present in the JSON file. This allows to have only places/entities
used inside trajectories; thus, inhibitors are avoided.
:type output_dir: <str>
:type model_file: <str>
:type solution_path: <str>
:type conditions: <boolean>
"""
def write_json_file(decompiled_filename, decomp_solutions):
......
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