Skip to content

Commit 1d36bce

Browse files
committed
add option to adapt samples prior to running pipeline
1 parent 6f3b316 commit 1d36bce

File tree

4 files changed

+34
-26
lines changed

4 files changed

+34
-26
lines changed

custom_files/pipeline_project_map_specifications.yaml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,19 @@ epi2me-human-variation:
22
nf-long-reads:
33
is_inputType_path: False
44
bed_file_as_arg: True
5+
adapt_samples: True
56
epi2me-basecalling:
67
genomrep-support:
78
is_inputType_path: False
89
bed_file_as_arg: False
10+
adapt_samples: False
911
epi2me-somatic-variation:
1012
mopopgen-support:
1113
is_inputType_path: True
1214
bed_file_as_arg: False
15+
adapt_samples: False
1316
nfcore-rnaseq:
1417
nf-tp53:
1518
is_inputType_path: True
1619
bed_file_as_arg: False
20+
adapt_samples: False

pages/run_pipeline.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,13 @@ def reset_button_state():
7474
st.write("Your custom samples:", custom_sample_list)
7575
ss_set("custom_sample_list", custom_sample_list)
7676

77+
adapt_samples = False
78+
if(map_pipeline_project[PIPELINE][PROJECT]["adapt_samples"]):
79+
adapt_samples = st.checkbox("Adapt samples prior to running nextflow",
80+
value=False,
81+
help="If you are not sure, check if your samples are available in /data/rds/DGE/DUDGE/OGENETIC/Data/Nanopore/samples"
82+
)
83+
7784
use_bed_file = map_pipeline_project[PIPELINE][PROJECT]["bed_file_as_arg"]#bool
7885
# Optional BED file path
7986
BED_FILE = st.text_input(
@@ -98,7 +105,8 @@ def reset_button_state():
98105
output_dir=OUTPUT_DIR,
99106
custom_sample_list=custom_sample_list,
100107
bed_file=BED_FILE,
101-
dry_run=dry_run
108+
dry_run=dry_run,
109+
adapt_samples=adapt_samples
102110
)
103111
save_in_ss(
104112
{

shared/command_helper.py

Lines changed: 17 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,25 @@
11
import os
2-
from pathlib import Path
2+
from typing import Tuple, Optional
33

4-
def get_path_to_script(selected_pipeline, selected_project, selected="all"):
4+
def get_path_to_script(
5+
selected_pipeline: str,
6+
selected_project: str,
7+
selected: str = ""
8+
):
59
NX_SHARED_PATH = "/data/scratch/shared/RSE/NF-project-configurations"
6-
# e.g., /data/scratch/shared/RSE/NF-project-configurations/epi2me-human-variation/nf-long-reads/scripts
7-
base_path = os.path.join(NX_SHARED_PATH, selected_pipeline, selected_project, "scripts")
10+
base_path = os.path.join(NX_SHARED_PATH, selected_pipeline, selected_project)
811

912
script_mapping = {
10-
"all": "launch_samples.sh",
11-
"demo": "launch_demo.sh",
12-
"customised": "launch_samples.sh",
13+
"demo": "scripts/launch_demo.sh",
14+
"customised": "scripts/launch_samples.sh"
1315
}
1416

15-
if selected in script_mapping:
16-
return os.path.join(base_path, script_mapping[selected])
17+
if selected not in script_mapping:
18+
raise ValueError(f"Invalid selection '{selected}'. Only 'customised', 'demo' are supported.")
1719

18-
raise ValueError(f"Invalid selection '{selected}'. Only 'customised' and 'demo' are supported.")
20+
primary_script = os.path.join(base_path, script_mapping.get(selected, ""))
1921

22+
return primary_script
2023

2124
# launch command based on the project
2225
def pipe_cmd(
@@ -29,7 +32,8 @@ def pipe_cmd(
2932
output_dir="output",
3033
custom_sample_list=[],
3134
bed_file="",
32-
dry_run=False
35+
dry_run=False,
36+
adapt_samples=False
3337
):
3438
def get_pipeline_command():
3539
"""Generate the pipeline execution command based on the sample selection."""
@@ -46,18 +50,6 @@ def get_pipeline_command():
4650
base_cmd = f"sbatch -o {log_out} -e {log_err}"
4751
args += [path_to_script, work_dir, output_dir]
4852

49-
elif selected_samples == "all":#I removed this option
50-
#./your_script.sh --env "/my/custom/env" --work-dir "my_work" --outdir "my_output" --config "my_config" --params "parans.json" --bed file.bed
51-
if dry_run:
52-
args.append("--dry-run")
53-
54-
args += [
55-
"--work-dir", work_dir,
56-
"--outdir", output_dir,
57-
]
58-
if bed_file:
59-
args += ["--bed", bed_file]
60-
6153
elif selected_samples == "customised":
6254
if not custom_sample_list:
6355
raise ValueError("custom_sample_list cannot be empty")
@@ -68,6 +60,8 @@ def get_pipeline_command():
6860
"--outdir", output_dir,
6961
"--samples", "\t".join(custom_sample_list),
7062
]
63+
if adapt_samples:
64+
args += ["--adapt-samples"]
7165
if bed_file:
7266
args += ["--bed", bed_file]
7367

tabs/tab_command.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,8 @@ def tab(
1616
output_dir="output",
1717
custom_sample_list=[],
1818
bed_file="",
19-
dry_run=False
19+
dry_run=False,
20+
adapt_samples=False
2021
):
2122
# --- Initialize session state ---
2223
st.session_state.setdefault("username", username)
@@ -49,7 +50,8 @@ def run_nextflow():
4950
work_dir=work_dir,
5051
custom_sample_list=custom_sample_list,
5152
bed_file=bed_file,
52-
dry_run=dry_run
53+
dry_run=dry_run,
54+
adapt_samples=adapt_samples
5355
)
5456
st.code(cmd_pipeline)
5557
result = MY_SSH.run_cmd(cmd_pipeline)

0 commit comments

Comments
 (0)