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
mmassaviol
WAWmassaviol
Commits
8e978b89
Commit
8e978b89
authored
Jun 05, 2020
by
mmassaviol
Committed by
mmassaviol
Aug 25, 2020
Browse files
Update generators scripts to fit step_name param
parent
6264df62
Changes
4
Expand all
Hide whitespace changes
Inline
Side-by-side
generate_sag_yaml.py
View file @
8e978b89
...
...
@@ -58,7 +58,7 @@ def get_params_to_remove(pipeline):
to_remove
.
append
(
line
[
"param_B"
])
return
to_remove
def
generate_tool
(
toolname
,
pipeline
):
def
generate_tool
(
toolname
,
pipeline
,
step_name
):
to_remove
=
get_params_to_remove
(
pipeline
)
template
=
yaml
.
load
(
tool_template
,
Loader
=
yaml
.
FullLoader
)
tool
=
read_yaml
(
"tools/"
+
toolname
+
"/"
+
toolname
+
".yaml"
)
...
...
@@ -70,6 +70,7 @@ def generate_tool(toolname, pipeline):
for
option
in
command
[
"options"
]:
if
option
not
in
template
[
"content"
]:
if
option
[
"name"
]
not
in
to_remove
:
option
[
"name"
]
=
step_name
+
"__"
+
option
[
"name"
]
template
[
"content"
].
append
(
option
)
template
[
"content"
].
append
(
...
...
@@ -180,7 +181,7 @@ def generate_sag_yaml(pipeline, template, outdir):
# for each tool in a step, create a box
for
tool
in
step
[
"tools"
]:
# predefined boxes
template
[
"App"
][
"pages"
][
page_number
][
"boxes"
].
append
(
generate_tool
(
tool
,
pipeline
))
template
[
"App"
][
"pages"
][
page_number
][
"boxes"
].
append
(
generate_tool
(
tool
,
pipeline
,
step
[
"name"
]
))
page_number
+=
1
return
template
...
...
generate_tool_snakefile.py
View file @
8e978b89
...
...
@@ -29,9 +29,9 @@ def generate(name):
for
cmd
in
yaml
[
'commands'
]:
result
+=
"rule "
+
cmd
[
'name'
]
+
":
\n
"
result
+=
"rule
<step_name>__
"
+
cmd
[
'name'
]
+
":
\n
"
rule_dir
=
"config[
\"
"
+
cmd
[
'name'
]
+
"_output_dir
\"
]"
rule_dir
=
"config[
\"
<step_name>__
"
+
cmd
[
'name'
]
+
"_output_dir
\"
]"
# input
...
...
@@ -44,7 +44,7 @@ def generate(name):
size_inputs
=
len
(
cmd_inputs
)
#if(size_inputs == 0):
result
+=
"
\t\t
**"
+
name
+
"_inputs(),
\n
"
result
+=
"
\t\t
**
<step_name>__
"
+
name
+
"_inputs(),
\n
"
for
input
in
cmd_inputs
:
...
...
@@ -75,7 +75,7 @@ def generate(name):
if
option
[
'type'
]
==
"input_file"
:
if
"name"
in
option
:
result
+=
"
\t\t
"
+
option
[
'name'
].
replace
(
cmd
[
"name"
]
+
"_"
,
""
).
replace
(
name
+
"_"
,
""
)
+
" = "
+
"config[
\"
"
+
option
[
'name'
]
+
"
\"
],
\n
"
result
+=
"
\t\t
"
+
option
[
'name'
].
replace
(
cmd
[
"name"
]
+
"_"
,
""
).
replace
(
name
+
"_"
,
""
)
+
" = "
+
"config[
\"
<step_name>__
"
+
option
[
'name'
]
+
"
\"
],
\n
"
#result += "\t\tinput_file_p" + str(count_input) + " = " + "config[\"" + option['name'] + "\"],\n"
count_input
+=
1
...
...
@@ -116,6 +116,9 @@ def generate(name):
result
+=
"
\t\t
output_dir = "
+
result_dir
+
" +
\"
/
\"
+ "
+
rule_dir
+
"+
\"
/"
+
sample_output
+
"
\"
,
\n
"
if
"command"
in
cmd
:
result
+=
"
\t\t
command = config[
\"
<step_name>__"
+
cmd
[
'name'
]
+
"_command
\"
],
\n
"
if
"options"
in
cmd
:
cmd_options
=
cmd
[
'options'
]
...
...
@@ -128,8 +131,7 @@ def generate(name):
if
"_threads"
not
in
option
[
'name'
]:
result
+=
"
\t\t
"
+
option
[
'name'
].
replace
(
cmd
[
"name"
]
+
"_"
,
""
).
replace
(
name
+
"_"
,
""
)
+
" = "
+
"config[
\"
"
+
option
[
'name'
]
+
"
\"
],
\n
"
result
+=
"
\t\t
"
+
option
[
'name'
].
replace
(
cmd
[
"name"
]
+
"_"
,
""
).
replace
(
name
+
"_"
,
""
)
+
" = "
+
"config[
\"
<step_name>__"
+
option
[
'name'
]
+
"
\"
],
\n
"
# log
...
...
@@ -137,7 +139,7 @@ def generate(name):
result
+=
"
\n\t
log:
\n
"
result
+=
"
\t\t
"
+
result_dir
+
" +
\"
/logs/"
+
cmd
[
'name'
]
+
"/"
+
sample
+
cmd
[
'name'
]
+
"_log.txt
\"\n
"
result
+=
"
\t\t
"
+
result_dir
+
" +
\"
/logs/
\
"
+
"
+
rule_dir
+
"
+
\
"
/"
+
sample
+
cmd
[
'name'
]
+
"_log.txt
\"\n
"
# threads
...
...
@@ -150,7 +152,7 @@ def generate(name):
if
"name"
in
option
:
if
"_threads"
in
option
[
'name'
]:
result
+=
"
\n\t\t
config[
\"
"
+
option
[
'name'
]
+
"
\"
]
\n
"
result
+=
"
\n\t\t
config[
\"
<step_name>__
"
+
option
[
'name'
]
+
"
\"
]
\n
"
count_thread
+=
1
if
count_thread
==
0
:
...
...
@@ -167,7 +169,7 @@ def generate(name):
#for shell in cmd_shell:
# result += "\t\t\"" + shell + "\"\n"
result
+=
"
\t\t\"
"
+
cmd_shell
+
"
\"\n
"
result
+=
"
\t\t\"
{params.command}
\"\n
"
# End cmd
...
...
@@ -176,7 +178,7 @@ def generate(name):
# End loop cmd
#
print(result)
#print(result)
path_snakefile
=
PATH_INPUT
+
"/"
+
name
+
"/"
+
name
+
".rule.snakefile"
f
=
open
(
path_snakefile
,
"w"
)
...
...
generate_workflow.py
View file @
8e978b89
This diff is collapsed.
Click to expand it.
generate_workflow_snakefile.py
View file @
8e978b89
...
...
@@ -70,15 +70,15 @@ def generate(name):
if
"rule_name"
in
step
:
result
+=
"def "
+
step
[
"rule_name"
]
+
"_inputs():
\n
"
result
+=
"def "
+
step
[
"step_name"
]
+
"__"
+
step
[
"rule_name"
]
+
"_inputs():
\n
"
result
+=
"
\t
inputs = dict()
\n
"
if
"params"
in
step
:
for
param
in
step
[
"params"
]:
if
"raw_"
in
param
[
"origin_command"
]
:
result
+=
"
\t
inputs[
\"
"
+
param
[
"input_name"
]
+
"
\"
] = "
+
param
[
"origin_command"
]
+
"[
\"
"
+
param
[
"origin_name"
]
+
"
\"
]
\n
"
result
+=
"
\t
inputs[
\"
"
+
param
[
"input_name"
]
+
"
\"
] = "
+
param
[
"origin_command"
]
+
"[
\"
"
+
param
[
"origin_name"
]
+
"
\"
]
\n
"
else
:
result
+=
"
\t
inputs[
\"
"
+
param
[
"input_name"
]
+
"
\"
] = rules."
+
param
[
"origin_command"
]
+
".output."
+
param
[
"origin_name"
]
+
"
\n
"
result
+=
"
\t
inputs[
\"
"
+
param
[
"input_name"
]
+
"
\"
] = rules."
+
param
[
"origin_step"
]
+
"__"
+
param
[
"origin_command"
]
+
".output."
+
param
[
"origin_name"
]
+
"
\n
"
result
+=
"
\t
return inputs
\n
"
result
+=
"
\n
"
...
...
@@ -111,7 +111,7 @@ def generate(name):
if
(
"_PE"
in
step
[
"rule_name"
]):
add
=
"and config['SeOrPe'] == 'PE'"
result
+=
"
\t
if (step ==
\"
"
+
step
[
"step_name"
]
+
"
\"
"
+
add
+
" ):
\n
"
result
+=
"
\t\t
outputs = rules."
+
step
[
"rule_name"
]
+
".output
\n
"
result
+=
"
\t\t
outputs = rules."
+
step
[
"step_name"
]
+
"__"
+
step
[
"rule_name"
]
+
".output
\n
"
result
+=
"
\t\t\n
"
...
...
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