From 3964e4eef5dc4a2de779a3f3b1695af3e747a3a6 Mon Sep 17 00:00:00 2001 From: Ricardo Wurmus Date: Tue, 21 May 2024 18:15:31 +0200 Subject: [PATCH] Let script write to stdout, redirect to output file. The output of "translate_sample_sheet_for_report" is generated in the current working directory with respect to the script. Depending on how it is executed, the file may end up in an unexpected location, causing Snakemake to wonder where the file went. The confusion disappears when writing to standard output and redirecting explicitly to the output file. This ensures that the working directory is irrelevant. --- scripts/translate_sample_sheet_for_report.R | 2 +- snakefile.py | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/scripts/translate_sample_sheet_for_report.R b/scripts/translate_sample_sheet_for_report.R index c2331bb..7c3dd4f 100644 --- a/scripts/translate_sample_sheet_for_report.R +++ b/scripts/translate_sample_sheet_for_report.R @@ -28,5 +28,5 @@ s = data.frame(data.table::fread(sample_sheet), check.names = F) rownames(s) = s$name s$group = s$sample_type s = s[colnames(s)[-grep("name|reads", colnames(s))]] -write.table(s, "colData.tsv", sep="\t") +write.table(s, "", sep="\t") diff --git a/snakefile.py b/snakefile.py index 234e885..f165605 100644 --- a/snakefile.py +++ b/snakefile.py @@ -305,8 +305,8 @@ def lookup(column, predicate, fields=[]): rule translate_sample_sheet_for_report: input: SAMPLE_SHEET_FILE - output: os.path.join(os.getcwd(), "colData.tsv") - shell: "{RSCRIPT_EXEC} {SCRIPTS_DIR}/translate_sample_sheet_for_report.R {input}" + output: os.path.join(OUTPUT_DIR, "colData.tsv") + shell: "{RSCRIPT_EXEC} {SCRIPTS_DIR}/translate_sample_sheet_for_report.R {input} > {output}" # determine if the sample library is single end or paired end def isSingleEnd(args):