Skip to content

Commit

Permalink
Add check for sample names with space
Browse files Browse the repository at this point in the history
This fixes issue #27
  • Loading branch information
Redmar-van-den-Berg committed Sep 26, 2024
1 parent d0abd53 commit d78eaeb
Show file tree
Hide file tree
Showing 13 changed files with 112 additions and 5 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,8 @@ cases, this can be a csv file with one line per read-pair, as can be seen
Any number of samples can be processed in a single execution, and each sample
may have any number of read pairs, and HAMLET will handle those properly.

**Note that spaces in sample names are not supported**

## Execution
If running in a cluster, you may also want to define the resource configurations in another YAML file. Read more about
this type of configuration on the official [Snakemake
Expand Down
5 changes: 5 additions & 0 deletions common.smk
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,11 @@ pepfile: config["pepfile"]

samples = pep.sample_table["sample_name"]

for s in samples:
if " " in s:
raise RuntimeError(f'Spaces in samples are not supported ("{s}")')


containers = {
"hamlet-scripts": "docker://quay.io/redmar_van_den_berg/hamlet-scripts:0.3",
"multiqc": "docker://quay.io/biocontainers/multiqc:1.22.1--pyhdfd78af_0",
Expand Down
5 changes: 0 additions & 5 deletions includes/fusion/Snakefile
Original file line number Diff line number Diff line change
@@ -1,11 +1,6 @@
include: "common.smk"


# Put each sample name in a SimpleNamespace to mimic Snakemake wildcard usage
# (e.g {wildcards.sample}). This is only used in the 'all' rule.
samples = [SimpleNamespace(sample=sample) for sample in pep.sample_table["sample_name"]]


rule all:
input:
arriba=[module_output.arriba(sample) for sample in samples],
Expand Down
9 changes: 9 additions & 0 deletions includes/fusion/common.smk
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,15 @@ from types import SimpleNamespace
pepfile: config["pepfile"]


# Put each sample name in a SimpleNamespace to mimic Snakemake wildcard usage
# (e.g {wildcards.sample}). This is only used in the 'all' rule.
samples = [SimpleNamespace(sample=sample) for sample in pep.sample_table["sample_name"]]

for s in samples:
if " " in s.sample:
raise RuntimeError(f'Spaces in samples are not supported ("{s.sample}")')


containers = {
"arriba": "docker://quay.io/biocontainers/arriba:2.4.0--h0033a41_2",
"poppler": "docker://quay.io/biocontainers/keggcharter:0.6.0--hdfd78af_0",
Expand Down
9 changes: 9 additions & 0 deletions includes/itd/common.smk
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,15 @@ from types import SimpleNamespace
pepfile: config["pepfile"]


# Put each sample name in a SimpleNamespace to mimic Snakemake wildcard usage
# (e.g {wildcards.sample}). This is only used in the 'all' rule.
samples = [SimpleNamespace(sample=sample) for sample in pep.sample_table["sample_name"]]

for s in samples:
if " " in s.sample:
raise RuntimeError(f'Spaces in samples are not supported ("{s.sample}")')


containers = {
"bwa-0.7.17-samtools-1.3.1-picard-2.9.2": "docker://quay.io/biocontainers/mulled-v2-1c6be8ad49e4dfe8ab70558e8fb200d7b2fd7509:5900b4e68c4051137fffd99165b00e98f810acae-0",
"rose": "docker://quay.io/redmar_van_den_berg/rose-dt:0.4",
Expand Down
4 changes: 4 additions & 0 deletions includes/qc-seq/common.smk
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@ pepfile: config["pepfile"]
# (e.g {wildcards.sample}). This is only used in the 'all' rule.
samples = [SimpleNamespace(sample=sample) for sample in pep.sample_table["sample_name"]]

for s in samples:
if " " in s.sample:
raise RuntimeError(f'Spaces in samples are not supported ("{s.sample}")')


def get_input_fastq(sample, pair):
"""Get all fastq files for the specified sample"""
Expand Down
4 changes: 4 additions & 0 deletions includes/snv-indels/common.smk
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,10 @@ containers = {
# (e.g {wildcards.sample}). This is only used in the 'all' rule.
samples = [SimpleNamespace(sample=sample) for sample in pep.sample_table["sample_name"]]

for s in samples:
if " " in s.sample:
raise RuntimeError(f'Spaces in samples are not supported ("{s.sample}")')


def get_forward(wildcards):
return pep.sample_table.loc[wildcards.sample, "R1"]
Expand Down
3 changes: 3 additions & 0 deletions test/pep/invalid.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
sample_name,R1,R2
SRR 8615687,test/data/fastq/SRR8615687_flt3_1.fastq.gz,test/data/fastq/SRR8615687_flt3_2.fastq.gz
SRR 8616218,test/data/fastq/SRR8616218_KMT2A_1.fastq.gz,test/data/fastq/SRR8616218_KMT2A_2.fastq.gz
15 changes: 15 additions & 0 deletions test/test_fusion.yml
Original file line number Diff line number Diff line change
Expand Up @@ -89,3 +89,18 @@
- sanity
- fusion
command: snakefmt --check includes/fusion

- name: test-fusion-sample-with-space
tags:
- sanity
- fusion
command: >
snakemake
--snakefile includes/fusion/Snakefile
--workflow-profile test
--configfile test/data/config/fusion.json
--config pepfile=test/pep/invalid.csv
exit_code: 1
stderr:
contains:
- 'RuntimeError: Spaces in samples are not supported ("SRR 8615687")'
15 changes: 15 additions & 0 deletions test/test_hamlet.yml
Original file line number Diff line number Diff line change
Expand Up @@ -170,3 +170,18 @@
- sanity
- hamlet
command: snakefmt --check .

- name: test-sample-with-space
tags:
- sanity
- hamlet
command: >
snakemake
--snakefile Snakefile
--workflow-profile test
--configfile test/data/config/hamlet-dry.json
--config pepfile=test/pep/invalid.csv
exit_code: 1
stderr:
contains:
- 'RuntimeError: Spaces in samples are not supported ("SRR 8615687")'
16 changes: 16 additions & 0 deletions test/test_itd.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@
contains_regex:
- "singularity(-ce)? version 3"


# ITD pipeline should run successfully and actually create the specified files
- name: test-itd
tags:
Expand Down Expand Up @@ -165,3 +166,18 @@
- sanity
- itd
command: snakefmt --check includes/itd

- name: test-itd-sample-with-space
tags:
- sanity
- itd
command: >
snakemake
--snakefile includes/itd/Snakefile
--workflow-profile test
--configfile test/data/config/itd.json
--config pepfile=test/pep/invalid.csv
exit_code: 1
stderr:
contains:
- 'RuntimeError: Spaces in samples are not supported ("SRR 8615687")'
15 changes: 15 additions & 0 deletions test/test_qc_seq.yml
Original file line number Diff line number Diff line change
Expand Up @@ -92,3 +92,18 @@
- sanity
- qc-seq
command: snakefmt --check includes/qc-seq/

- name: test-qc-seq-sample-with-space
tags:
- sanity
- qc-seq
command: >
snakemake
--snakefile includes/qc-seq/Snakefile
--workflow-profile test
--configfile test/data/config/qc-seq.json
--config pepfile=test/pep/invalid.csv
exit_code: 1
stderr:
contains:
- 'RuntimeError: Spaces in samples are not supported ("SRR 8615687")'
15 changes: 15 additions & 0 deletions test/test_snv_indels.yml
Original file line number Diff line number Diff line change
Expand Up @@ -188,3 +188,18 @@
- sanity
- snv-indels
command: snakefmt --check includes/snv-indels/

- name: test-snv-indels-sample-with-space
tags:
- sanity
- snv-indels
command: >
snakemake
--snakefile includes/snv-indels/Snakefile
--workflow-profile test
--configfile test/data/config/snv-indels.json
--config pepfile=test/pep/invalid.csv
exit_code: 1
stderr:
contains:
- 'RuntimeError: Spaces in samples are not supported ("SRR 8615687")'

0 comments on commit d78eaeb

Please sign in to comment.