Skip to content

Commit

Permalink
Maybe that gets the tests happy?
Browse files Browse the repository at this point in the history
  • Loading branch information
tbooth committed Oct 7, 2024
1 parent 7e5c5fc commit 5628b21
Show file tree
Hide file tree
Showing 7 changed files with 16 additions and 8 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/code-test-mac.yml
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ jobs:
run: |
wget --progress=dot:mega \
https://github.com/user-attachments/files/16439467/data-for-snakemake-novice-bioinformatics.tar.xz.gz
gunzip data-for-snakemake-novice-bioinformatics.tar.xz
gunzip data-for-snakemake-novice-bioinformatics.tar.xz.gz
md5sum -c <<<"4522e76f9dddda13e55f7d283638e628 data-for-snakemake-novice-bioinformatics.tar.xz"
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/code-test-ubuntu.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ jobs:
run: |
wget --progress=dot:mega \
https://github.com/user-attachments/files/16439467/data-for-snakemake-novice-bioinformatics.tar.xz.gz
gunzip data-for-snakemake-novice-bioinformatics.tar.xz
gunzip data-for-snakemake-novice-bioinformatics.tar.xz.gz
md5sum -c <<<"4522e76f9dddda13e55f7d283638e628 data-for-snakemake-novice-bioinformatics.tar.xz"
Expand Down
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
/tmp/

# sandpaper files
episodes/*html
site/*
Expand Down
2 changes: 1 addition & 1 deletion .test/ep11.test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ dependencies:
export SALMON_NO_VERSION_CHECK=1
snakemake -j1 --sdm conda -p salmon.etoh60_1

conda env list 2>&1
# A conda env should have been created
set -x
conda env list | grep -F /.snakemake/

# But remove it
Expand Down
6 changes: 4 additions & 2 deletions .test/ep13.test.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
echo "Test for episodes/files/ep13.Snakefile"

cp -vf episodes/files/ep13.Snakefile snakemake_data/yeast/Snakefile
rm -f snakemake_data/yeast/Snakefile
cp -v episodes/files/ep13.Snakefile snakemake_data/yeast/Snakefile
cd snakemake_data/yeast

# This assumes renames are applied
Expand All @@ -17,8 +18,9 @@ res2=$( snakemake -Fn -p multiqc | \

# Protected files don't show in the dry-run, so we actually have to make the Kallisto index
# and then check the perms on it. Then delete it so we don't upset later tests.
set -x
rm -f Saccharomyces_cerevisiae.R64-1-1.kallisto_index
snakemake -j1 -p Saccharomyces_cerevisiae.R64-1-1.kallisto_index
( umask 0022 ; snakemake -j1 -p Saccharomyces_cerevisiae.R64-1-1.kallisto_index )
perms=$(stat --format %A Saccharomyces_cerevisiae.R64-1-1.kallisto_index)
[[ "$perms" == "-r--r--r--" ]]
rm -vf Saccharomyces_cerevisiae.R64-1-1.kallisto_index
8 changes: 6 additions & 2 deletions episodes/13-cleaning_up.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ exercises: 15

::::::::::::::::::::::::::::::::::::::: objectives

- Understand the function of *temporary* outputs.
- Understand how Snakemake manages *temporary* outputs
- Learn about running in *\--touch* mode
- Learn about *shadow* mode rules

Expand All @@ -15,7 +15,7 @@ exercises: 15
:::::::::::::::::::::::::::::::::::::::: questions

- How do I save disk space by removing temporary files?
- How do I protect important outputs from deletion?
- How do I isolate the interim files created by jobs from each other?

::::::::::::::::::::::::::::::::::::::::::::::::::

Expand Down Expand Up @@ -182,6 +182,9 @@ A related feature is the `protected()` function. This is rather like the opposit
In practise, Snakemake does this by revoking write permissions on the files
(as in `chmod -w {output}`).

We can do this for the Salmon and Kallisto indexes, for example, as these should only ever need to
be generated once.

This works, but can be annoying because Snakemake will refuse to run if it believes it needs to
re-create a file which is protected. An alternative suggestion is, once you have generated
an important output file, move or copy the file away from your working directory. That way it will
Expand Down Expand Up @@ -279,6 +282,7 @@ this episode.*

- Cleaning up working files is good practise
- Make use of the `temporary()` function on outputs you don't need to keep
- Protect outputs which are expensive to reproduce
- Shadow rules can solve issues with commands that produce unwanted files

::::::::::::::::::::::::::::::::::::::::::::::::::
Expand Down
2 changes: 1 addition & 1 deletion episodes/files/ep13.Snakefile
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ rule kallisto_quant:

rule kallisto_index:
output:
idx = "{strain}.kallisto_index",
idx = protected("{strain}.kallisto_index"),
input:
fasta = "transcriptome/{strain}.cdna.all.fa.gz",
log: "{strain}.kallisto_log"
Expand Down

0 comments on commit 5628b21

Please sign in to comment.