Attention une mise à jour du service Gitlab va être effectuée le mardi 30 novembre entre 17h30 et 18h00. Cette mise à jour va générer une interruption du service dont nous ne maîtrisons pas complètement la durée mais qui ne devrait pas excéder quelques minutes. Cette mise à jour intermédiaire en version 14.0.12 nous permettra de rapidement pouvoir mettre à votre disposition une version plus récente.

Commit 8630cb0f authored by VIGNET Pierre's avatar VIGNET Pierre
Browse files

[cmd] Fix paths and trailing '/'

parent 79256a8c
......@@ -34,6 +34,25 @@ import cadbiom.commons as cm
LOGGER = cm.logger()
def check_output_dir(function):
"""Decorator used process some arguments from argparse"""
def modified_func(*args, **kwargs):
"""Fix paths in arguments (add trailing '/')"""
output_dir = args[0]['output']
output_dir = output_dir if output_dir[-1] == '/' else output_dir + '/'
# Compatibility for output and output_dir
args[0]['output'] = output_dir
args[0]['output_dir'] = output_dir
return function(*args, **kwargs)
return modified_func
@check_output_dir
def solutions_search(args):
"""Launch the search for Minimum Activation Conditions (MAC) for entities
of interest.
......@@ -56,6 +75,7 @@ def solutions_sort(args):
solution_sort.solutions_sort(args['path'])
@check_output_dir
def solutions_2_graph(args):
"""Create GraphML formated files containing a representation of the
trajectories for every solution in complete MAC files (*mac_complete files).
......@@ -73,6 +93,7 @@ def solutions_2_graph(args):
)
@check_output_dir
def solutions_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
......@@ -92,6 +113,7 @@ def solutions_2_json(args):
)
@check_output_dir
def json_2_interaction_graph(args):
"""Make an interaction weighted graph based on the searched molecule of interest.
......@@ -110,6 +132,7 @@ def json_2_interaction_graph(args):
)
@check_output_dir
def solutions_2_common_graph(args):
"""Create a GraphML formated file containing a representation of **all**
trajectories for **all** solutions in complete MAC files (*mac_complete files).
......@@ -127,6 +150,7 @@ def solutions_2_common_graph(args):
)
@check_output_dir
def solutions_2_occcurrences_matrix(args):
"""Create a matrix of occurrences counting entities in the solutions found in
*mac.txt files in the given path.
......@@ -154,6 +178,7 @@ def identifiers_mapping(args):
solution_repr.identifiers_mapping(**args)
@check_output_dir
def model_comparison(args):
"""Isomorphism test.
......@@ -163,8 +188,6 @@ def model_comparison(args):
# Module import
import solution_repr
args['output'] = args['output'] if args['output'][-1] == '/' \
else args['output'] + '/'
solution_repr.graph_isomorph_test(
args['model_file_1'],
args['model_file_2'],
......@@ -174,6 +197,7 @@ def model_comparison(args):
)
@check_output_dir
def model_info(args):
"""Provide several levels of information about the structure of the model
and its places/entities.
......@@ -181,11 +205,10 @@ def model_info(args):
# Module import
import solution_repr
args['output_dir'] = args['output'] if args['output'][-1] == '/' \
else args['output'] + '/'
solution_repr.model_info(**args)
@check_output_dir
def model_graph(args):
"""Information about the graph based on the model.
......@@ -195,11 +218,10 @@ def model_graph(args):
# Module import
import solution_repr
args['output_dir'] = args['output'] if args['output'][-1] == '/' \
else args['output'] + '/'
solution_repr.model_graph(**args)
@check_output_dir
def merge_macs(args):
"""Merge solutions to a csv file."""
......
......@@ -709,9 +709,7 @@ def compute_macs(params):
model_filename = os.path.basename(os.path.splitext(params["chart_file"])[0])
# FILES
# Add trailing '/' if not present
output = params["output"] if params["output"][-1] == "/" else params["output"] + "/"
mac_file_prefix = output + model_filename + "_" + params["final_prop"] + "_mac"
mac_file_prefix = params["output"] + model_filename + "_" + params["final_prop"] + "_mac"
# mac_file
mac_file = mac_file_prefix + ".txt"
# mac_step_file
......
......@@ -204,8 +204,7 @@ def solutions_2_json(output_dir, model_file, path, conditions=True):
elif os.path.isdir(path):
# The given path is a directory
path = path if path[-1] == '/' \
else path + '/'
path = path if path[-1] == '/' else path + '/'
# Decompilation of all files in the directory
file_number = 0
......@@ -258,8 +257,7 @@ def solutions_2_graph(output_dir, model_file, path):
elif os.path.isdir(path):
# The given path is a directory
path = path if path[-1] == '/' \
else path + '/'
path = path if path[-1] == '/' else path + '/'
# Decompilation of all files in the directory
file_number = 0
......@@ -377,8 +375,7 @@ def solutions_2_common_graph(output_dir, model_file, path):
elif os.path.isdir(path):
# The given path is a directory
path = path if path[-1] == '/' \
else path + '/'
path = path if path[-1] == '/' else path + '/'
# Decompilation of all files in the directory
file_number = 0
......@@ -454,7 +451,6 @@ def solutions_2_occcurrences_matrix(output_dir, model_file, path,
assert os.path.isdir(path)
path = path if path[-1] == '/' else path + '/'
output_dir = output_dir if output_dir[-1] == '/' else output_dir + '/'
# Make matrix
occurrence_matrix(output_dir, model_file, path)
......
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