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
412efe1f
Commit
412efe1f
authored
Dec 11, 2018
by
VIGNET Pierre
Browse files
[command_line] Change of notation: cam -> mac
parent
36e94e87
Changes
7
Hide whitespace changes
Inline
Side-by-side
command_line/cadbiom_cmd/cadbiom_cmd.py
View file @
412efe1f
...
...
@@ -48,7 +48,7 @@ def solutions_search(args):
def
solutions_sort
(
args
):
"""Read a solution file or a directory containing MAC solutions files
(*
cam
* files), and sort all frontier places/boundaries in alphabetical order.
(*
mac
* files), and sort all frontier places/boundaries in alphabetical order.
"""
# Module import
...
...
@@ -59,7 +59,7 @@ def solutions_sort(args):
def
solutions_2_graph
(
args
):
"""Create GraphML formated files containing a representation of the
trajectories for every solution in complete MAC files (*
cam
_complete files).
trajectories for every solution in complete MAC files (*
mac
_complete files).
This is a function to visualize paths taken by the solver from the boundaries
to the entities of interest.
...
...
@@ -77,7 +77,7 @@ def solutions_2_graph(args):
def
solutions_2_json
(
args
):
"""Create a JSON formated file containing all data from complete MAC files
(*
cam
_complete files). The file will contain frontier places/boundaries
(*
mac
_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
...
...
@@ -116,7 +116,7 @@ def json_2_interaction_graph(args):
def
solutions_2_common_graph
(
args
):
"""Create a GraphML formated file containing a representation of **all**
trajectories for **all** solutions in complete MAC files (*
cam
_complete files).
trajectories for **all** solutions in complete MAC files (*
mac
_complete files).
This is a function to visualize paths taken by the solver from the boundaries
to the entities of interest.
...
...
@@ -134,7 +134,7 @@ def solutions_2_common_graph(args):
def
solutions_2_occcurrences_matrix
(
args
):
"""Create a matrix of occurrences counting entities in the solutions found in
*
cam
.txt files in the given path.
*
mac
.txt files in the given path.
"""
# Module import
...
...
@@ -211,13 +211,13 @@ def model_graph(args):
solution_repr
.
model_graph
(
**
params
)
def
merge_
cam
s
(
args
):
def
merge_
mac
s
(
args
):
"""Merge solutions to a csv file."""
# Module import
import
solution_merge
params
=
args_to_param
(
args
)
solution_merge
.
merge_
cam
s_to_csv
(
params
[
'solutions_directory'
],
solution_merge
.
merge_
mac
s_to_csv
(
params
[
'solutions_directory'
],
params
[
'output'
])
...
...
@@ -332,13 +332,13 @@ def main():
help
=
solutions_sort
.
__doc__
)
parser_solutions_sort
.
add_argument
(
'path'
,
help
=
"Solution file or directory with MAC solutions files "
"(*
cam
* files) generated with the 'solutions_search' command."
)
"(*
mac
* files) generated with the 'solutions_search' command."
)
parser_solutions_sort
.
set_defaults
(
func
=
solutions_sort
)
# subparser: Representation of the trajectories of MACs in a complete file.
# Model file (xml : cadbiom language)
# Solution file (
cam
_complete)
# Solution file (
mac
_complete)
parser_trajectories
=
subparsers
.
add_parser
(
'solutions_2_graph'
,
help
=
solutions_2_graph
.
__doc__
,
...
...
@@ -347,7 +347,7 @@ def main():
help
=
"bcx model file."
)
parser_trajectories
.
add_argument
(
'path'
,
help
=
"Complete solution file or directory with MAC solutions files "
"(*
cam
_complete.txt files) generated with the 'compute_macs' command."
)
"(*
mac
_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."
)
...
...
@@ -356,7 +356,7 @@ def main():
# subparser: Decompilation of trajectories of MACs in a complete file/dir.
# Model file (xml : cadbiom language)
# Solution file (
cam
_complete)
# Solution file (
mac
_complete)
parser_solutions_2_json
=
subparsers
.
add_parser
(
'solutions_2_json'
,
help
=
solutions_2_json
.
__doc__
,
...
...
@@ -365,7 +365,7 @@ def main():
help
=
"bcx model file."
)
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."
)
"(*
mac
_complete.txt files) generated with the 'compute_macs' command."
)
parser_solutions_2_json
.
add_argument
(
'--output'
,
action
=
ReadableDir
,
nargs
=
'?'
,
default
=
'decompiled_solutions/'
,
help
=
"Directory for newly created files."
)
...
...
@@ -389,7 +389,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"
"(*
cam
_complete files) generated with the 'solutions_2_json' command."
)
"(*
mac
_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."
)
...
...
@@ -398,7 +398,7 @@ def main():
# subparser: Common representation of the trajectories of MACs in a complete file.
# Model file (xml : cadbiom language)
# Solution file (
cam
_complete)
# Solution file (
mac
_complete)
parser_trajectories
=
subparsers
.
add_parser
(
'solutions_2_common_graph'
,
help
=
solutions_2_common_graph
.
__doc__
,
...
...
@@ -407,7 +407,7 @@ def main():
help
=
"bcx model file."
)
parser_trajectories
.
add_argument
(
'path'
,
help
=
"Complete solution file or directory with MAC solutions files "
"(*
cam
_complete.txt files) generated with the 'compute_macs' command."
)
"(*
mac
_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."
)
...
...
@@ -416,7 +416,7 @@ def main():
# subparser: Create a matrix of occurrences counting entities in the solutions.
# Model file (xml : cadbiom language)
# Solution file (
cam
.txt)
# Solution file (
mac
.txt)
parser_occurrences_matrix
=
subparsers
.
add_parser
(
'solutions_2_occcurrences_matrix'
,
help
=
solutions_2_occcurrences_matrix
.
__doc__
,
...
...
@@ -425,7 +425,7 @@ def main():
help
=
"bcx model file."
)
parser_occurrences_matrix
.
add_argument
(
'path'
,
help
=
"Directory with MAC solutions files "
"(*
cam
.txt files) generated with the 'compute_macs' command."
)
"(*
mac
.txt files) generated with the 'compute_macs' command."
)
parser_occurrences_matrix
.
add_argument
(
'--output'
,
action
=
ReadableDir
,
nargs
=
'?'
,
default
=
'./'
,
help
=
"Output directory for CSV files."
)
...
...
@@ -435,19 +435,19 @@ def main():
# subparser: Merge solutions to a csv file
# Solution file (
cam
)
# Solution file (
mac
)
# Output (csv)
parser_merge_
cam
s
=
subparsers
.
add_parser
(
'merge_
cam
s'
,
help
=
merge_
cam
s
.
__doc__
,
parser_merge_
mac
s
=
subparsers
.
add_parser
(
'merge_
mac
s'
,
help
=
merge_
mac
s
.
__doc__
,
formatter_class
=
argparse
.
ArgumentDefaultsHelpFormatter
)
parser_merge_
cam
s
.
add_argument
(
'solutions_directory'
,
nargs
=
'?'
,
parser_merge_
mac
s
.
add_argument
(
'solutions_directory'
,
nargs
=
'?'
,
default
=
'result/'
)
parser_merge_
cam
s
.
add_argument
(
'--output'
,
nargs
=
'?'
,
default
=
'result/merged_
cam
s.csv'
,
help
=
"CSV file: <Final property formula>;<
cam
>"
)
parser_merge_
cam
s
.
set_defaults
(
func
=
merge_
cam
s
)
parser_merge_
mac
s
.
add_argument
(
'--output'
,
nargs
=
'?'
,
default
=
'result/merged_
mac
s.csv'
,
help
=
"CSV file: <Final property formula>;<
mac
>"
)
parser_merge_
mac
s
.
set_defaults
(
func
=
merge_
mac
s
)
## Model-related commands ##################################################
...
...
command_line/cadbiom_cmd/solution_merge.py
View file @
412efe1f
...
...
@@ -28,8 +28,8 @@ import glob
import
csv
import
itertools
as
it
def
merge_
cam
s_to_csv
(
directory
,
csvfile
=
'merged_
cam
s.csv'
):
"""Merge \*
cam
.txt files from a directory to a csv file.
def
merge_
mac
s_to_csv
(
directory
,
csvfile
=
'merged_
mac
s.csv'
):
"""Merge \*
mac
.txt files from a directory to a csv file.
:Structure of the CSV file:
...
...
@@ -43,17 +43,17 @@ def merge_cams_to_csv(directory, csvfile='merged_cams.csv'):
csv_data
=
list
()
# Read all files in the given directory
for
filename
in
glob
.
glob
(
directory
+
'*_
cam
.txt'
):
for
filename
in
glob
.
glob
(
directory
+
'*_
mac
.txt'
):
#print(filename)
# Extract the formula from the filename
# ex:
# # ['./result/model_name', 'TGFB1', '
cam
.txt']
# # ['./result/model_name', 'TGFB1', '
mac
.txt']
formula
=
''
.
join
(
filename
.
split
(
'_'
)[
1
:
-
1
])
# Read the content of the
cam
file & memorize this content
# Read the content of the
mac
file & memorize this content
with
open
(
filename
)
as
f_d
:
# Add the formula column, before each
cam
to futur csv file
# Add the formula column, before each
mac
to futur csv file
csv_data
.
append
([[
formula
]
+
[
line
.
rstrip
(
'
\n
'
)]
for
line
in
f_d
])
# Write the final csv
...
...
@@ -64,4 +64,4 @@ def merge_cams_to_csv(directory, csvfile='merged_cams.csv'):
if
__name__
==
"__main__"
:
merge_
cam
s_to_csv
(
'result'
)
merge_
mac
s_to_csv
(
'result'
)
command_line/cadbiom_cmd/solution_repr.py
View file @
412efe1f
...
...
@@ -158,8 +158,6 @@ def draw_graph(output_dir, solution, solution_index, G,
plt
.
show
()
def
test_main
():
"""Test"""
...
...
command_line/cadbiom_cmd/solution_search.py
View file @
412efe1f
...
...
@@ -118,16 +118,16 @@ def make_logical_formula(previous_frontier_places, start_prop):
return
prev_frontier_places_formula
return
start_prop
cam
_list
=
[
logical_and
(
frontier_places
)
mac
_list
=
[
logical_and
(
frontier_places
)
for
frontier_places
in
previous_frontier_places
]
if
cam
_list
:
if
mac
_list
:
# Logical or between each line
return
add_start_prop
(
'not('
+
logical_or
(
cam
_list
)
+
')'
)
return
add_start_prop
(
'not('
+
logical_or
(
mac
_list
)
+
')'
)
return
add_start_prop
(
''
)
def
main2
(
chart_file
,
cam
_file
,
cam
_step_file
,
cam
_complete_file
,
cam
_strong_file
,
def
main2
(
chart_file
,
mac
_file
,
mac
_step_file
,
mac
_complete_file
,
mac
_strong_file
,
steps
,
final_prop
,
start_prop
,
inv_prop
,
all_macs
,
continue_run
):
"""
...
...
@@ -183,14 +183,14 @@ def main2(chart_file, cam_file, cam_step_file, cam_complete_file, cam_strong_fil
if
continue_run
:
# Reload previous working files
try
:
previous_frontier_places
=
read_
cam
_file
(
cam
_file
)
previous_frontier_places
=
read_
mac
_file
(
mac
_file
)
current_start_prop
=
make_logical_formula
(
previous_frontier_places
,
start_prop
)
LOGGER
.
info
(
"%s:: Reload previous frontier places: %s"
,
final_prop
,
len
(
previous_frontier_places
))
except
IOError
:
LOGGER
.
warning
(
"%s::
cam
file not found!"
,
final_prop
)
LOGGER
.
warning
(
"%s::
mac
file not found!"
,
final_prop
)
previous_frontier_places
=
set
()
current_start_prop
=
start_prop
else
:
...
...
@@ -205,7 +205,7 @@ def main2(chart_file, cam_file, cam_step_file, cam_complete_file, cam_strong_fil
print
(
"START PROP:"
,
current_start_prop
)
ret
=
\
find_mac
(
mcla
,
cam
_file
,
cam
_step_file
,
cam
_complete_file
,
mac
_file
,
mac
_step_file
,
mac
_complete_file
,
steps
,
final_prop
,
current_start_prop
,
inv_prop
)
# EXIT
# i += 1
...
...
@@ -243,7 +243,7 @@ def main2(chart_file, cam_file, cam_step_file, cam_complete_file, cam_strong_fil
def
find_macs
(
mcla
,
cam
_file
,
cam
_step_file
,
cam
_complete_file
,
mac
_file
,
mac
_step_file
,
mac
_complete_file
,
steps
,
final_prop
,
start_prop
,
inv_prop
):
"""__mac_exhaustive_search, on cherche d´abord des solutions non minimales
(lfsol = self.__sq_dimacs_frontier_solutions(query, nb_step, 2))
...
...
@@ -271,24 +271,24 @@ def find_macs(mcla,
# Save MAC and timings
LOGGER
.
debug
(
"%s:: Save MAC and timings..."
,
final_prop
)
with
open
(
cam
_complete_file
,
'a'
)
as
file
:
with
open
(
mac
_complete_file
,
'a'
)
as
file
:
next_mac_object
.
save
(
file
)
# Save MAC
next_mac
=
next_mac_object
.
activated_frontier
LOGGER
.
debug
(
"%s:: Save next MAC: %s"
,
final_prop
,
next_mac
)
with
open
(
cam
_file
,
'a'
)
as
file
:
with
open
(
mac
_file
,
'a'
)
as
file
:
file
.
write
(
'
\t
'
.
join
(
next_mac
)
+
'
\n
'
)
# Save min steps
min_step
=
mcla
.
unfolder
.
get_current_step
()
-
1
# Magic number !
LOGGER
.
debug
(
"%s:: Save minimal steps: %s"
,
final_prop
,
min_step
)
with
open
(
cam
_step_file
,
'a'
)
as
file
:
with
open
(
mac
_step_file
,
'a'
)
as
file
:
file
.
write
(
str
(
min_step
)
+
'
\n
'
)
def
find_mac
(
mcla
,
cam
_file
,
cam
_step_file
,
cam
_complete_file
,
mac
_file
,
mac
_step_file
,
mac
_complete_file
,
steps
,
final_prop
,
start_prop
,
inv_prop
):
"""
list, min step
...
...
@@ -319,19 +319,19 @@ def find_mac(mcla,
# Save MAC and timings
LOGGER
.
debug
(
"%s:: Save MAC and timings..."
,
final_prop
)
with
open
(
cam
_complete_file
,
'a'
)
as
file
:
with
open
(
mac
_complete_file
,
'a'
)
as
file
:
next_mac_object
.
save
(
file
)
# Save MAC (in alphabetic order...)
next_mac
=
sorted
(
next_mac_object
.
activated_frontier
)
LOGGER
.
debug
(
"%s:: Save next MAC: %s"
,
final_prop
,
next_mac
)
with
open
(
cam
_file
,
'a'
)
as
file
:
with
open
(
mac
_file
,
'a'
)
as
file
:
file
.
write
(
" "
.
join
(
sorted
(
next_mac
,
key
=
lambda
s
:
s
.
lower
()))
+
'
\n
'
)
# Save min steps
min_step
=
mcla
.
unfolder
.
get_current_step
()
-
1
# Magic number !
LOGGER
.
debug
(
"%s:: Save minimal steps: %s"
,
final_prop
,
min_step
)
with
open
(
cam
_step_file
,
'a'
)
as
file
:
with
open
(
mac
_step_file
,
'a'
)
as
file
:
file
.
write
(
str
(
min_step
)
+
'
\n
'
)
return
next_mac
,
min_step
...
...
@@ -374,25 +374,25 @@ def detect_model_type(mclanalyser, filepath):
return
build_func
[
extension
]
#def main(chart_file,
cam
_file,
cam
_step_file,
cam
_complete_file,
cam
_strong_file,
#def main(chart_file,
mac
_file,
mac
_step_file,
mac
_complete_file,
mac
_strong_file,
# steps, final_prop, start_prop, inv_prop, all_macs):
#
# LOGGER.debug("Params: start: {}, inv: {}, final: {}".format(start_prop,
# inv_prop,
# final_prop))
#
#
cam
_p = None
# # forbid previous
cam
#
mac
_p = None
# # forbid previous
mac
# try :
#
cam
_p = camFile2notOr(
cam
_file)
# print("
cam
file:",
cam
_p)
#
mac
_p = camFile2notOr(
mac
_file)
# print("
mac
file:",
mac
_p)
# except :
# print('error in camFile2notOr')
#
# if start_prop and
cam
_p :
# start_prop += ' and ('+
cam
_p+')'
# elif
cam
_p :
# start_prop =
cam
_p
# if start_prop and
mac
_p :
# start_prop += ' and ('+
mac
_p+')'
# elif
mac
_p :
# start_prop =
mac
_p
#
# # BUILD MCLA
# error_reporter = ErrorRep()
...
...
@@ -420,15 +420,15 @@ def detect_model_type(mclanalyser, filepath):
## print("DEBUG:: ", len( lsol))
#
# # minimal activation conditions
# # on_
cam
function:
##
cam
_list = self.mcla.mac_search(query, self.max_step)
## if len(
cam
_list)==0 :
# # on_
mac
function:
##
mac
_list = self.mcla.mac_search(query, self.max_step)
## if len(
mac
_list)==0 :
## ok_warn("The solver returns an empty list" +
## "\n"+" you should refine your query")
#
# # OPTIMIZE STEP RESEARCH
# if os.path.isfile(
cam
_step_file):
# min_step = int(get_last_line(
cam
_step_file))
# if os.path.isfile(
mac
_step_file):
# min_step = int(get_last_line(
mac
_step_file))
# print("min_step opti:", min_step)
# query.set_steps_before_reach(min_step-1)
#
...
...
@@ -446,18 +446,18 @@ def detect_model_type(mclanalyser, filepath):
# if next_mac_object:
#
# # SAVE MAC AND TIMING
# with open(
cam
_complete_file, 'a') as file:
# with open(
mac
_complete_file, 'a') as file:
# next_mac_object.save(file)
#
# # SAVE MAC
# next_mac = next_mac_object.activated_frontier
# print("save next mac:", next_mac)
# write_list(next_mac,
cam
_file)
# write_list(next_mac,
mac
_file)
#
# # SAVE STEP
# min_step = mcla.unfolder.get_current_step()
# print("save min step:", min_step)
# with open(
cam
_step_file, 'a') as file:
# with open(
mac
_step_file, 'a') as file:
# file.write(str(min_step)+'\n')
#
# return 0
...
...
@@ -619,16 +619,16 @@ def compute_macs(params):
# Add trailing '/' if not present
output
=
params
[
'output'
]
if
params
[
'output'
][
-
1
]
==
'/'
\
else
params
[
'output'
]
+
'/'
cam
_file_prefix
=
output
+
model_filename
+
\
'_'
+
params
[
'final_prop'
]
+
'_
cam
'
#
cam
_file
cam
_file
=
cam
_file_prefix
+
".txt"
#
cam
_step_file
cam
_step_file
=
cam
_file_prefix
+
"_step.txt"
#
cam
_complete_file
cam
_complete_file
=
cam
_file_prefix
+
"_complete.txt"
#
cam
_strong_file
cam
_strong_file
=
cam
_file_prefix
+
"_strongA.txt"
mac
_file_prefix
=
output
+
model_filename
+
\
'_'
+
params
[
'final_prop'
]
+
'_
mac
'
#
mac
_file
mac
_file
=
mac
_file_prefix
+
".txt"
#
mac
_step_file
mac
_step_file
=
mac
_file_prefix
+
"_step.txt"
#
mac
_complete_file
mac
_complete_file
=
mac
_file_prefix
+
"_complete.txt"
#
mac
_strong_file
mac
_strong_file
=
mac
_file_prefix
+
"_strongA.txt"
def
remove_file
(
file
):
"""Reset files"""
...
...
@@ -640,25 +640,25 @@ def compute_macs(params):
if
not
params
[
'continue'
]:
# Reset previous working files
# PS: the reload is done in main2() function
remove_file
(
cam
_file
)
remove_file
(
cam
_step_file
)
remove_file
(
cam
_complete_file
)
remove_file
(
cam
_strong_file
)
remove_file
(
mac
_file
)
remove_file
(
mac
_step_file
)
remove_file
(
mac
_complete_file
)
remove_file
(
mac
_strong_file
)
# MAC research
main2
(
params
[
'chart_file'
],
# chart_file
cam
_file
,
#
cam
_file
cam
_step_file
,
#
cam
_step_file
cam
_complete_file
,
#
cam
_complete_file
cam
_strong_file
,
#
cam
_strong_file
mac
_file
,
#
mac
_file
mac
_step_file
,
#
mac
_step_file
mac
_complete_file
,
#
mac
_complete_file
mac
_strong_file
,
#
mac
_strong_file
params
[
'steps'
],
params
[
'final_prop'
],
params
[
'start_prop'
],
params
[
'inv_prop'
],
params
[
'all_macs'
],
params
[
'continue'
],
)
def
read_
cam
_file
(
file
):
"""Return a list a fontier places already found in
cam
file
def
read_
mac
_file
(
file
):
"""Return a list a fontier places already found in
mac
file
.. note:: use make_logical_formula() to get the new start_prop of the run.
...
...
command_line/cadbiom_cmd/solution_sort.py
View file @
412efe1f
...
...
@@ -81,7 +81,7 @@ import networkx as nx
from
tools.solutions
import
get_solutions
from
tools.models
import
get_transitions_from_model_file
from
tools.solutions
import
load_solutions
,
convert_solutions_to_json
,
\
get_query_from_filename
,
get_
cam
_lines
get_query_from_filename
,
get_
mac
_lines
from
tools.graphs
import
export_graph
,
build_graph
import
cadbiom.commons
as
cm
...
...
@@ -130,7 +130,7 @@ def sort_solutions_in_file(filepath):
def
solutions_sort
(
path
):
"""Entry point for sorting solutions.
Read a solution(s) file(s) (\*
cam
\* files) and sort all
Read a solution(s) file(s) (\*
mac
\* files) and sort all
frontier places/boundaries in alphabetical order.
This functions tests if the given path is a directory or a file.
...
...
@@ -145,10 +145,10 @@ def solutions_sort(path):
assert
os
.
path
.
isfile
(
path
)
or
os
.
path
.
isdir
(
path
)
if
os
.
path
.
isdir
(
path
):
# Recursive search of *
cam
* files
# (
cam
.txt,
cam
_complete.txt,
cam
_step.txt)
# Recursive search of *
mac
* files
# (
mac
.txt,
mac
_complete.txt,
mac
_step.txt)
path
=
path
if
path
[
-
1
]
==
'/'
else
path
+
'/'
[
sort_solutions_in_file
(
file
)
for
file
in
glob
.
glob
(
path
+
'*
cam
*'
)]
[
sort_solutions_in_file
(
file
)
for
file
in
glob
.
glob
(
path
+
'*
mac
*'
)]
else
:
sort_solutions_in_file
(
path
)
...
...
@@ -158,7 +158,7 @@ def solutions_2_json(output_dir, model_file, path, conditions=True):
"""Entry point for solutions_2_json
Create a JSON formated file containing all data from complete MAC files
(\*
cam
_complete files). The file will contain frontier places/boundaries
(\*
mac
_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
...
...
@@ -210,7 +210,7 @@ def solutions_2_json(output_dir, model_file, path, conditions=True):
# Decompilation of all files in the directory
file_number
=
0
for
file_number
,
solution_file
in
\
enumerate
(
glob
.
glob
(
path
+
'*
cam
_complete.txt'
),
1
):
enumerate
(
glob
.
glob
(
path
+
'*
mac
_complete.txt'
),
1
):
decomp_solutions
=
convert_solutions_to_json
(
load_solutions
(
solution_file
),
...
...
@@ -226,7 +226,7 @@ def solutions_2_graph(output_dir, model_file, path):
"""Entry point for solutions_2_graph
Create GraphML formated files containing a representation of the
trajectories for every solution in complete MAC files (\*
cam
_complete files).
trajectories for every solution in complete MAC files (\*
mac
_complete files).
This is a function to visualize paths taken by the solver from the boundaries
to the entities of interest.
...
...
@@ -263,7 +263,7 @@ def solutions_2_graph(output_dir, model_file, path):
# Decompilation of all files in the directory
file_number
=
0
for
file_number
,
solution_file
in
\
enumerate
(
glob
.
glob
(
path
+
'*
cam
_complete.txt'
),
1
):
enumerate
(
glob
.
glob
(
path
+
'*
mac
_complete.txt'
),
1
):
convert_solution_file_to_graphs
(
output_dir
,
...
...
@@ -322,7 +322,7 @@ def solutions_2_common_graph(output_dir, model_file, path):
"""Entry point for solutions_2_common_graph
Create a GraphML formated file containing a representation of **all**
trajectories for **all** solutions in complete MAC files (\*
cam
_complete files).
trajectories for **all** solutions in complete MAC files (\*
mac
_complete files).
This is a function to visualize paths taken by the solver from the boundaries
to the entities of interest.
...
...
@@ -381,7 +381,7 @@ def solutions_2_common_graph(output_dir, model_file, path):
# Decompilation of all files in the directory
file_number
=
0
for
file_number
,
solution_file
in
\
enumerate
(
glob
.
glob
(
path
+
'*
cam
_complete.txt'
),
1
):
enumerate
(
glob
.
glob
(
path
+
'*
mac
_complete.txt'
),
1
):
# Get query string from the name of the solution file
query
=
get_query_from_filename
(
model_file
,
solution_file
)
...
...
@@ -465,9 +465,9 @@ def occurrence_matrix(output_dir, model_file, path,
matrix_filename
=
'occurrence_matrix.csv'
):
"""Make a matrix of occurrences for the solutions in the given path.
- Compute occurrences of each place in all `
cam
.txt` files.
- Compute occurrences of each place in all `
mac
.txt` files.
- Save the matrix in csv format with the following columns:
Fieldnames: "patterns (number)/places (number);
cam
_number;frontier places"
Fieldnames: "patterns (number)/places (number);
mac
_number;frontier places"
Each request (pattern) is accompanied by the number of solutions found.
.. todo:: Split the creation and writing of the matrix in 2 functions.
...
...
@@ -488,38 +488,38 @@ def occurrence_matrix(output_dir, model_file, path,
# Key: Logical formula as input of Cadbiom
# Value: Number of each place in all solutions of the current file
matrix
=
defaultdict
(
Counter
)
# All frontier places in all
cam
files
# All frontier places in all
mac
files
all_frontier_places
=
set
()
# Compute occurrences of each place in all
cam
files
# Compute occurrences of each place in all
mac
files
file_number
=
0
for
file_number
,
filepath
in
enumerate
(
glob
.
glob
(
path
+
'*
cam
.txt'
),
1
):
for
file_number
,
filepath
in
enumerate
(
glob
.
glob
(
path
+
'*
mac
.txt'
),
1
):
# gene pattern
# pattern = {gene for gene in genes if gene in
cam
}
# pattern = {gene for gene in genes if gene in
mac
}
# Get query string from the name of the solution file
# From: 'MODEL_NAME_PLACE1 and not PLACE2 and not PLACE3_
cam
.txt'
# From: 'MODEL_NAME_PLACE1 and not PLACE2 and not PLACE3_
mac
.txt'
# Get: 'PLACE1 and not PLACE2 and not PLACE3'
query
=
get_query_from_filename
(
model_file
,
filepath
)
cam
_number
=
0
for
cam
_number
,
cam
_line
in
enumerate
(
get_
cam
_lines
(
filepath
),
1
):
mac
_number
=
0
for
mac
_number
,
mac
_line
in
enumerate
(
get_
mac
_lines
(
filepath
),
1
):
frontier_places
=
set
(
cam
_line
.
split
(
' '
))
frontier_places
=
set
(
mac
_line
.
split
(
' '
))
# Update set of all frontier places
all_frontier_places
.
update
(
frontier_places
)
# Update counter of places => compute frequencies
matrix
[
query
]
+=
Counter
(
frontier_places
)
# Set the
cam
_number for future standardization
matrix
[
query
][
"
cam
_number"
]
=
cam
_number
# Set the
mac
_number for future standardization
matrix
[
query
][
"
mac
_number"
]
=
mac
_number
LOGGER
.
info
(
"Files processed: %s"
,
file_number
)
# Save the matrix
# columns: "patterns (number)/places (number);
cam
_number;frontier places"
# columns: "patterns (number)/places (number);
mac
_number;frontier places"
with
open
(
output_dir
+
matrix_filename
,
'w'
)
as
f_d
:
# Forge header
...
...
@@ -531,7 +531,7 @@ def occurrence_matrix(output_dir, model_file, path,
f_d
,
delimiter
=
str
(
';'
),
restval
=
0
,
# default value for frequency
fieldnames
=
[
header
,
"
cam
_number"
]
+
list
(
all_frontier_places
))
fieldnames
=
[
header
,
"
mac
_number"
]
+
list
(
all_frontier_places
))
writer
.
writeheader
()
# Add a last line in the csv: total of occurrences for each place
...
...
@@ -540,7 +540,7 @@ def occurrence_matrix(output_dir, model_file, path,