Skip to content
GitLab
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
f1f067c5
Commit
f1f067c5
authored
Mar 04, 2020
by
VIGNET Pierre
Browse files
[cmd] command line interface: partial black
parent
ae6363b8
Changes
1
Hide whitespace changes
Inline
Side-by-side
command_line/cadbiom_cmd/cadbiom_cmd.py
View file @
f1f067c5
...
...
@@ -43,12 +43,12 @@ def check_output_dir(function):
@
wraps
(
function
)
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
+
'/'
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
args
[
0
][
"
output
"
]
=
output_dir
args
[
0
][
"
output_dir
"
]
=
output_dir
return
function
(
*
args
,
**
kwargs
)
...
...
@@ -63,9 +63,10 @@ def solutions_search(args):
# Module import
import
solution_search
# Temporary fix: all_macs is always activated in the new API
args
[
"all_macs"
]
=
True
solution_search
.
solutions_search
(
args
)
# !
solution_search
.
solutions_search
(
args
)
# !
def
solutions_sort
(
args
):
...
...
@@ -75,7 +76,8 @@ def solutions_sort(args):
# Module import
import
solution_sort
solution_sort
.
solutions_sort
(
args
[
'path'
])
solution_sort
.
solutions_sort
(
args
[
"path"
])
@
check_output_dir
...
...
@@ -89,11 +91,8 @@ def solutions_2_graphs(args):
# Module import
import
solution_sort
solution_sort
.
solutions_2_graphs
(
args
[
'output'
],
args
[
'model_file'
],
args
[
'path'
]
)
solution_sort
.
solutions_2_graphs
(
args
[
"output"
],
args
[
"model_file"
],
args
[
"path"
])
@
check_output_dir
...
...
@@ -108,11 +107,12 @@ def queries_2_json(args):
# Module import
import
solution_sort
solution_sort
.
queries_2_json
(
args
[
'
output
'
],
args
[
'
model_file
'
],
args
[
'
path
'
],
conditions
=
not
args
[
'
no_conditions
'
],
# Reverse the param...
args
[
"
output
"
],
args
[
"
model_file
"
],
args
[
"
path
"
],
conditions
=
not
args
[
"
no_conditions
"
],
# Reverse the param...
)
...
...
@@ -128,10 +128,9 @@ def json_2_interaction_graph(args):
# Module import
import
interaction_graph
interaction_graph
.
json_2_interaction_graph
(
args
[
'output'
],
args
[
'molecules_of_interest'
],
args
[
'path'
],
args
[
"output"
],
args
[
"molecules_of_interest"
],
args
[
"path"
]
)
...
...
@@ -147,6 +146,7 @@ def queries_2_common_graph(args):
# Module import
import
solution_sort
if
not
any
((
args
[
"graphs"
],
args
[
"csv"
],
args
[
"json"
])):
parser
.
error
(
"at least one flag is required"
)
solution_sort
.
queries_2_common_graph
(
**
args
)
...
...
@@ -160,11 +160,12 @@ def queries_2_occcurrence_matrix(args):
# Module import
import
solution_sort
solution_sort
.
queries_2_occcurrence_matrix
(
args
[
'
output
'
],
args
[
'
model_file
'
],
args
[
'
path
'
],
transposed
=
args
[
'
transpose_csv
'
]
args
[
"
output
"
],
args
[
"
model_file
"
],
args
[
"
path
"
],
transposed
=
args
[
"
transpose_csv
"
],
)
...
...
@@ -177,6 +178,7 @@ def model_identifier_mapping(args):
# Module import
import
models
models
.
model_identifier_mapping
(
**
args
)
...
...
@@ -190,12 +192,13 @@ def model_comparison(args):
# Module import
import
models
models
.
graph_isomorph_test
(
args
[
'
model_file_1
'
],
args
[
'
model_file_2
'
],
args
[
'
output
'
],
args
[
'
graphs
'
],
args
[
'
json
'
],
args
[
"
model_file_1
"
],
args
[
"
model_file_2
"
],
args
[
"
output
"
],
args
[
"
graphs
"
],
args
[
"
json
"
],
)
...
...
@@ -207,6 +210,7 @@ def model_info(args):
# Module import
import
models
models
.
model_info
(
**
args
)
...
...
@@ -220,6 +224,7 @@ def model_graph(args):
# Module import
import
models
models
.
model_graph
(
**
args
)
...
...
@@ -229,8 +234,8 @@ def merge_macs(args):
# Module import
import
solution_merge
solution_merge
.
merge_macs_to_csv
(
args
[
'solutions_directory'
],
args
[
'
output
'
])
solution_merge
.
merge_macs_to_csv
(
args
[
"solutions_directory"
],
args
[
"
output
"
])
def
analytics
(
params
):
...
...
@@ -250,8 +255,11 @@ def analytics(params):
)
# {"1":["key","val"],}
cvar
=
{
str
(
i
):
[
key
,
val
]
for
i
,
(
key
,
val
)
in
enumerate
(
params
.
items
(),
1
)
if
val
is
not
None
and
key
in
white_list
}
cvar
=
{
str
(
i
):
[
key
,
val
]
for
i
,
(
key
,
val
)
in
enumerate
(
params
.
items
(),
1
)
if
val
is
not
None
and
key
in
white_list
}
data
=
{
"url"
:
"http://cadbiom.genouest.org/"
,
"_rcn"
:
"cadbiom"
,
...
...
@@ -260,20 +268,20 @@ def analytics(params):
"apiv"
:
1
,
"send_image"
:
0
,
"rec"
:
1
,
"_id"
:
"0000"
+
''
.
join
(
re
.
findall
(
'
..
'
,
'
%0012x
'
%
getnode
()))[:
16
],
"_id"
:
"0000"
+
""
.
join
(
re
.
findall
(
"
..
"
,
"
%0012x
"
%
getnode
()))[:
16
],
"_cvar"
:
json
.
dumps
(
cvar
).
encode
(
"utf8"
),
"ua"
:
platform
,
}
data
=
urlencode
(
data
).
encode
(
"ascii"
)
page
=
urlopen
(
"http://cadbiom.genouest.org/lytic.html"
,
data
=
data
).
read
()
m
=
re
.
search
(
"
.*URL=(.*)
\
"
>
"
,
page
)
m
=
re
.
search
(
'
.*URL=(.*)">
'
,
page
)
if
m
:
urlopen
(
m
.
group
(
1
),
data
=
data
)
def
args_to_param
(
args
):
"""Return argparse namespace as a dict {variable name: value}"""
return
{
k
:
v
for
k
,
v
in
vars
(
args
).
items
()
if
k
!=
'
func
'
}
return
{
k
:
v
for
k
,
v
in
vars
(
args
).
items
()
if
k
!=
"
func
"
}
def
ensure_dir_presence
(
path
):
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new 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