Skip to content

Commit

Permalink
Let script write to stdout, redirect to output file.
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
rekado committed May 21, 2024
1 parent 2e29399 commit 3964e4e
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion scripts/translate_sample_sheet_for_report.R
Original file line number Diff line number Diff line change
Expand Up @@ -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")

4 changes: 2 additions & 2 deletions snakefile.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down

0 comments on commit 3964e4e

Please sign in to comment.