Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
VIGNET Pierre
cadbiom
Commits
b81de0e5
Commit
b81de0e5
authored
Oct 30, 2018
by
VIGNET Pierre
Browse files
Add get_query_from_filename : standardized way to get the query from a filename
parent
ae4c920c
Changes
1
Hide whitespace changes
Inline
Side-by-side
command_line/cadbiom_cmd/tools/solutions.py
View file @
b81de0e5
...
...
@@ -41,6 +41,29 @@ import cadbiom.commons as cm
LOGGER
=
cm
.
logger
()
## Generic #####################################################################
def
get_query_from_filename
(
model_file
,
solution_file
):
"""Return the query string according to the given model and solution filenames
:param model_file: Path of a bcx model.
:param solution_file: Path of a solution file (\*cam\* file).
:type model_file: <str>
:type solution_file: <str>
"""
model_filename
=
os
.
path
.
basename
(
os
.
path
.
splitext
(
model_file
)[
0
])
solution_filename
=
os
.
path
.
basename
(
os
.
path
.
splitext
(
solution_file
)[
0
])
solution_filename
=
solution_filename
.
replace
(
model_filename
,
''
)
if
'_cam_complete'
in
solution_filename
:
# remove _cam_complete
return
solution_filename
[:
-
13
]
elif
'_cam'
in
solution_filename
:
# remove _cam
return
solution_filename
[:
-
4
]
## Handle *cam_complete.txt files ##############################################
def
load_solutions
(
file
):
...
...
@@ -251,7 +274,7 @@ def get_solutions(file_descriptor):
"""Generator of solution lines and corresponding stripped lines for
*cam* file.
.. note:: This function do not return events! It is just original lines and
.. note:: This function do
es
not return events! It is just original lines and
cleaned lines containing solutions (i.e sets of frontier
places/boundaries).
...
...
Write
Preview
Supports
Markdown
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