Skip to content

Commit 88d59ae

Browse files
committed
[long-reads]: add customised input option
1 parent 4ee9524 commit 88d59ae

File tree

8 files changed

+66
-26
lines changed

8 files changed

+66
-26
lines changed

custom_files/pipeline_project_map.json

Lines changed: 0 additions & 5 deletions
This file was deleted.
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
epi2me-human-variation:
2+
nf-long-reads:
3+
is_inputType_path: False
4+
epi2me-somatic-variation:
5+
mopopgen-support:
6+
is_inputType_path: True
7+
nfcore-rnaseq:
8+
nf-tp53:
9+
is_inputType_path: True

pages/run_pipeline.py

Lines changed: 29 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import streamlit as st
2+
import yaml
23

34
import tabs.tab_command as tt
45
from pipeline_project_map import map_pipeline_project
@@ -33,29 +34,48 @@ def reset_button_state():
3334
OUTPUT_DIR = ss_values["OUTPUT_DIR"]
3435
run_pipeline_clicked = ss_values["run_pipeline_clicked"]
3536
button_clicked = ss_values["button_clicked"]
37+
custom_sample_list = ss_values["custom_sample_list"] # only availanle if custom sample is selected
3638

37-
samples = ["all", "demo"] # , "customised"]
39+
samples = ["test", "all", "demo", "customised"]
3840

3941
# Create the selectbox and update session state
40-
options = ["select"] + list(map_pipeline_project.keys())
41-
index = options.index(PIPELINE)
42-
PIPELINE = st.selectbox("Select a pipeline", options=options, index=index) # , key="PIPELINE")
42+
pipeline_options = ["select"] + list(map_pipeline_project.keys())
43+
index = pipeline_options.index(PIPELINE)
44+
PIPELINE = st.selectbox("Select a pipeline", options=pipeline_options, index=index) # , key="PIPELINE")
4345
# adding "select" as the first and default choice
4446
if PIPELINE != "select":
47+
project_options = list(map_pipeline_project[PIPELINE].keys())
48+
4549
PROJECT = st.selectbox(
4650
"Select your project",
47-
options=map_pipeline_project[PIPELINE],
48-
index=map_pipeline_project[PIPELINE].index(PIPELINE) if PIPELINE in map_pipeline_project[PIPELINE] else 0,
51+
options=project_options,
52+
index=project_options.index(PIPELINE) if PIPELINE in project_options else 0,
4953
on_change=reset_button_state,
5054
)
51-
55+
# samples here depend on the pipeline: human variation requires bam files, rnaseq requires a samplesheet
5256
SAMPLE = st.selectbox(
5357
"Select your samples",
5458
options=samples,
5559
index=samples.index(SAMPLE) if SAMPLE in samples else 0,
5660
on_change=reset_button_state,
5761
)
5862

63+
# If "customised" is selected, show additional input
64+
if SAMPLE == "customised":
65+
is_input_type_path = map_pipeline_project[PIPELINE][PROJECT]["is_inputType_path"]
66+
msg = "Enter your sample names (comma-separated)"
67+
if is_input_type_path:
68+
msg = "Enter path to samplesheet"
69+
custom_samples = st.text_input(msg, key="custom_samples", value=",".join(custom_sample_list))
70+
71+
# Optionally process the input into a list
72+
if custom_samples:
73+
custom_sample_list = [s.strip() for s in custom_samples.split(",") if s.strip()]
74+
75+
st.write("Your custom samples:", custom_sample_list)
76+
ss_set("custom_sample_list", custom_sample_list)
77+
78+
# for tp53, we need to provide a sample sheet while for human-variation a simple sample list if enough
5979
WORK_DIR = st.text_input("Working directory", value=SCRATCH)
6080
OUTPUT_DIR = st.text_input("Output directory", value=SCRATCH)
6181

@@ -69,6 +89,7 @@ def reset_button_state():
6989
selected_samples=SAMPLE,
7090
work_dir=WORK_DIR,
7191
output_dir=OUTPUT_DIR,
92+
custom_sample_list=custom_sample_list,
7293
)
7394
save_in_ss(
7495
{
@@ -89,6 +110,7 @@ def reset_button_state():
89110
"OUTPUT_DIR": OUTPUT_DIR,
90111
"run_pipeline_clicked": run_pipeline_clicked,
91112
"button_clicked": button_clicked,
113+
"custom_sample_list": custom_sample_list,
92114
}
93115
)
94116
else:

pipeline_project_map.py

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,6 @@
1-
import json
1+
import yaml
22

3+
file_path = "custom_files/pipeline_project_map_specifications.yaml"
34

4-
def load_json_to_dict(file_path):
5-
with open(file_path, "r") as file:
6-
data = json.load(file)
7-
return data
8-
9-
10-
file_path = "custom_files/pipeline_project_map.json"
11-
map_pipeline_project = load_json_to_dict(file_path)
5+
with open(file_path, "r") as f:
6+
map_pipeline_project = yaml.safe_load(f)

shared/command_helper.py

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,13 @@ def get_path_to_script(selected_pipeline, selected_project, selected="all"):
99
script_mapping = {
1010
"all": "launch_samples.sh",
1111
"demo": "launch_demo.sh",
12-
"single": "launch_sample_analysis.sh", # not yet supported
12+
"customised": "launch_samples.sh",
1313
}
1414

1515
if selected in script_mapping:
1616
return os.path.join(base_path, script_mapping[selected])
1717

18-
raise ValueError(f"Invalid selection '{selected}'. Only 'all' and 'demo' are supported.")
18+
raise ValueError(f"Invalid selection '{selected}'. Only 'customised' and 'demo' are supported.")
1919

2020

2121
# launch command based on the project
@@ -27,6 +27,7 @@ def pipe_cmd(
2727
selected_samples="all",
2828
work_dir="work",
2929
output_dir="output",
30+
custom_sample_list=[],
3031
):
3132
def get_pipeline_command():
3233
"""Generate the pipeline execution command based on the sample selection."""
@@ -42,7 +43,7 @@ def get_pipeline_command():
4243

4344
if selected_samples == "demo":
4445
cmd_pipeline += f"sbatch -o {log_out} -e {log_err} {path_to_script} {work_dir} {output_dir}"
45-
elif selected_samples == "all":
46+
elif selected_samples == "all": # this has no more sense since we have to specify the sample name index
4647
cmd_pipeline += f"sbatch -o {log_out} -e {log_err} {path_to_script} --work-dir {work_dir} --outdir {output_dir}"
4748
##./your_script.sh --env "/my/custom/env" --work-dir "my_work" --outdir "my_output" --config "my_config" --params "parans.json"
4849
# Usage:
@@ -52,7 +53,14 @@ def get_pipeline_command():
5253
# --env "/data/rds/DIT/SCICOM/SCRSE/shared/conda/nextflow_env" \
5354
# --params "/data/params/parameters.json" \
5455
# --config "custom_config.config"
56+
elif selected_samples == "customised":
57+
if not len(custom_sample_list):
58+
print("custom_sample_list cannot be empty")
5559

60+
tab_separated_string = "\t".join(custom_sample_list)
61+
cmd_pipeline += f"sbatch -o {log_out} -e {log_err} {path_to_script} --work-dir {work_dir} --outdir {output_dir} --samples {tab_separated_string}"
62+
elif selected_samples == "test":
63+
cmd_pipeline += f"sbatch -o {log_out} -e {log_err} /data/scratch/DCO/DIGOPS/SCIENCOM/msarkis/NF-project-configurations/test.sh --work-dir {work_dir} --outdir {output_dir}"
5664
return cmd_pipeline.strip()
5765

5866
# Command mappings

shared/ss_defaults.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,3 +17,4 @@ keys_defaults:
1717
group_selection: "Select an option"
1818
WORK_DIR: None
1919
OUTPUT_DIR: None
20+
custom_sample_list: []

tabs/tab_command.py

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
WORKDIR = ss_values["WORK_DIR"]
2525
OUTPUT_DIR = ss_values["OUTPUT_DIR"]
2626
run_pipeline_clicked = ss_values["run_pipeline_clicked"]
27+
custom_sample_list = ss_values["custom_sample_list"] # only availanle if custom sample is selected
2728

2829

2930
def display_log(title, log_path, output_container):
@@ -37,7 +38,16 @@ def display_log(title, log_path, output_container):
3738
st.error(f"Failed to read {title.lower()} log: {e}")
3839

3940

40-
def tab(username, MY_SSH, selected_pipeline, selected_project, selected_samples="all", work_dir="work", output_dir="output"):
41+
def tab(
42+
username,
43+
MY_SSH,
44+
selected_pipeline,
45+
selected_project,
46+
selected_samples="all",
47+
work_dir="work",
48+
output_dir="output",
49+
custom_sample_list=[],
50+
):
4151
JOB_ID = ss_values["JOB_ID"]
4252

4353
cols = st.columns([1, 1, 1])
@@ -58,6 +68,7 @@ def run_nextflow():
5868
selected_samples=selected_samples,
5969
output_dir=output_dir,
6070
work_dir=work_dir,
71+
custom_sample_list=custom_sample_list,
6172
)
6273
st.code(cmd_pipeline)
6374
_dict = MY_SSH.run_cmd(cmd_pipeline)

tabs/tab_logon.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,6 @@ def create_radio(GROUPS):
8080
OK, MY_SSH, msg, GROUPS = handle_login(server, sftp_server, username, password)
8181
if OK:
8282
st.success(msg)
83-
create_radio(GROUPS)
8483
else:
8584
st.error(msg)
8685

0 commit comments

Comments
 (0)