Skip to content

Commit 9d9110c

Browse files
committed
add function that checks sample names, because we assume that sample names do not contain empty spaces
1 parent 9f3078b commit 9d9110c

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

workflow/rules/common.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,16 @@
1515
def biokit_sample_annotation_filename(biokit_outdir):
1616
return(join(biokit_outdir, 'samples.txt'))
1717

18+
19+
def check_sample_names(sample_names):
20+
"""
21+
Check that sample names do not contain invalid characters
22+
"""
23+
if(any(" " in s for s in sample_names)):
24+
raise ValueError("Sample names must not contain empty spaces")
25+
return True
26+
27+
1828
def parse_sample_annotation(sample_annotation_file):
1929
"""
2030
Parse biokit sample annotation file into sample names and FASTQ dicts
@@ -29,6 +39,7 @@ def parse_sample_annotation(sample_annotation_file):
2939

3040
annotation = read_table(sample_annotation_file)
3141
samples = [str(s) for s in annotation.iloc[:, 0]]
42+
check_sample_names(samples)
3243
fq1s = annotation.iloc[:, 2]
3344
fq2s = annotation.iloc[:, 3]
3445

0 commit comments

Comments
 (0)