Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
38 commits
Select commit Hold shift + click to select a range
ae6e82a
fasten and github actions
lskatz Apr 7, 2025
1325b40
bioconda
lskatz Apr 7, 2025
03ccf5b
conda-forge
lskatz Apr 7, 2025
52b8fbc
better snakemake checks
lskatz Apr 7, 2025
3a9678d
use snakemake workflow in github actions
lskatz Apr 7, 2025
48f9045
m
lskatz Apr 7, 2025
5154dbf
hardcode for now
lskatz Apr 7, 2025
ae6b281
softcode
lskatz Apr 7, 2025
52a40e8
trying advanced syntax with json
lskatz Apr 7, 2025
238d25e
back to conda
lskatz Apr 7, 2025
a292b3f
avoid pulp solver
lskatz Apr 7, 2025
41c31af
I'm being told that simple isn't correct. Greedy it is.
lskatz Apr 7, 2025
7c2ee56
hardcode 1 core in case it's resource limited
lskatz Apr 7, 2025
e0e8418
trying with compressed dirty file. DEBUG: taking percentage of file
lskatz Apr 7, 2025
e337add
m
lskatz Apr 7, 2025
ff0b1b7
m
lskatz Apr 7, 2025
39aacfb
back to basics and fix fasten command
lskatz Apr 8, 2025
45ebba2
limit the size of the input file
lskatz Apr 8, 2025
2350f7c
zcat -> gunzip -c
lskatz Apr 8, 2025
757d168
2442190 \
lskatz Apr 8, 2025
ecb17a9
tmpfile param
lskatz Apr 8, 2025
0b04add
tmpfile param
lskatz Apr 8, 2025
08f7579
random fastq instead of downloading
lskatz Apr 8, 2025
0473a51
copying seems to work
lskatz Apr 8, 2025
f278df8
local fastq.gz
lskatz Apr 8, 2025
3639765
Refactor a little bit, add config file
boulund Jun 4, 2025
56e8393
Clean up envs, remove defaults
boulund Jun 4, 2025
a7431fb
Try snakemake-minimal and rearranging channels
boulund Jun 4, 2025
663c53c
create separate env
boulund Jun 4, 2025
d83e963
activate
boulund Jun 4, 2025
0584c73
Activate when needed, sed config
boulund Jun 4, 2025
ec53cab
use conda-incubator/setup-miniconda
boulund Jun 4, 2025
123b6bb
Only run 1 replicate in CI
boulund Jun 4, 2025
7c99855
Improve variable naming
boulund Jun 4, 2025
a1d9489
Update README
boulund Jun 4, 2025
7c86297
Move CI env to envs dir to get rid of errors
boulund Jun 5, 2025
51d3d08
Update all tools to latest versions
boulund Jun 5, 2025
f7491f5
Add latest plots
boulund Jun 5, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 36 additions & 0 deletions .github/workflows/benchmark.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
on: push

jobs:
benchmark:
name: Benchmark
runs-on: ubuntu-latest
strategy:
fail-fast: true
defaults:
run:
shell: bash -el {0}
steps:
- uses: actions/checkout@v4
- uses: conda-incubator/setup-miniconda@v3
with:
python-version: 3.12
environment-file: workflow/envs/github.yaml
- name: test env
run: |
conda info
conda list
which snakemake
snakemake --help
snakemake --version
- name: benchmarks
run: |
sed -i 's/threads: 8/threads: 2/' config/config.yaml
sed -i 's/replicates: 3/replicates: 1/' config/config.yaml
snakemake --use-conda --scheduler greedy --cores 2
- uses: actions/upload-artifact@v4
with:
name: benchmarks
path: |
output/plots/*
output/grades/*

2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
.snakemake
output
9 changes: 6 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,18 @@ The following tools are compared:
- [Cutadapt](https://cutadapt.readthedocs.io/en/stable/)
- [Fastp](https://github.com/OpenGene/fastp)
- [Trimmomatic](http://www.usadellab.org/cms/?page=trimmomatic)
- [Fasten](https://github.com/lskatz/fasten)

## Fake adapters, "gruseq"
The comparison adds fake truseq adapters, "gruseq", provided by Brian Bushnell,
downloaded from:
http://seqanswers.com/forums/attachment.php?attachmentid=2993&d=1398383571

## Test data
A single sample is downloaded from SRA. Feel free to replace it with whatever
you want.
A subset of a single sample is from SRA is provided in the repo.
Comment/uncomment the `download_FASTQ` setting in the `config/config.yaml` to
download the complete sample from SRA instead. Feel free to replace the URL
with whatever FASTQ file you want.

## Results
These plots are produced by the workflow, one for benchmarking results
Expand All @@ -32,6 +35,6 @@ and one plot with adapter removal performance.
# Running
Run the benchmarking workflow with something like:
```bash
snakemake --use-conda --jobs 10
snakemake --use-conda --cores 8
```

6 changes: 6 additions & 0 deletions config/config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# Config file for Snakemake workflow adapter_benchmark

download_FASTQ: False
#download_FASTQ: "ftp://ftp.sra.ebi.ac.uk/vol1/fastq/SRR921/004/SRR9218144/SRR9218144.fastq.gz"
replicates: 3
threads: 8
Binary file added data/SRR9218144.888888.fastq.gz
Binary file not shown.
Binary file modified plots/benchmarks.pdf
Binary file not shown.
Binary file modified plots/benchmarks.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified plots/grades.pdf
Binary file not shown.
Binary file modified plots/grades.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
86 changes: 63 additions & 23 deletions workflow/Snakefile
Original file line number Diff line number Diff line change
Expand Up @@ -6,35 +6,53 @@
# http://seqanswers.com/forums/attachment.php?attachmentid=2993&d=1398383571
# Fredrik Boulund 2019

import random
import gzip
import os

configfile: "config/config.yaml"

TOOLS=[
"cutadapt",
"trimmomatic",
"bbduk",
"fastp",
"adapterremoval",
"fasten",
]
FASTQ="ftp://ftp.sra.ebi.ac.uk/vol1/fastq/SRR921/004/SRR9218144/SRR9218144.fastq.gz"

rule all:
input:
expand("output/grades/{tool}.grade.txt", tool=TOOLS),
expand("output/plots/{plot}.pdf", plot=["benchmarks", "grades"]),


rule download_fastq:
output:
"output/data.fastq.gz"
conda: "envs/main.yaml"
params:
fastq=FASTQ
shell:
"""
wget --output-document {output} {params.fastq}
"""

## Download data if requested by config, else use provided example testing data.
example_data_path = "../data/SRR9218144.888888.fastq.gz"
input_data_path = "output/data.fastq.gz"
if config["download_FASTQ"]:
rule download_fastq:
output:
input_data_path
conda: "envs/main.yaml"
params:
fastq=config["download_FASTQ"]
shell:
"""
wget --output-document {output} {params.fastq}
"""
else:
if os.path.isfile(input_data_path):
print(f"DEBUG: download_FASTQ is set to False and '{input_data_path}' already exists, doing nothing.")
else:
print(f"INFO: Symlinking example FASTQ {example_data_path} to {input_data_path}.")
os.makedirs("output", exist_ok=True)
os.symlink(example_data_path, input_data_path)


rule add_adapters:
input:
fastq=rules.download_fastq.output,
fastq="output/data.fastq.gz",
adapters="gruseq.fa",
output:
"output/dirty.fq"
Expand All @@ -60,9 +78,9 @@ rule cutadapt:
"output/processed/cutadapt.fq"
log: "output/logs/cutadapt.log"
conda: "envs/cutadapt.yaml"
threads: 10
threads: config["threads"]
benchmark:
repeat("output/benchmarks/cutadapt.benchmark.txt", 3)
repeat("output/benchmarks/cutadapt.benchmark.txt", config["replicates"])
shell:
"""
cutadapt \
Expand Down Expand Up @@ -105,9 +123,9 @@ rule trimmomatic:
"output/processed/trimmomatic.fq"
conda: "envs/trimmomatic.yaml"
log: "output/logs/trimmomatic.log"
threads: 10
threads: config["threads"]
benchmark:
repeat("output/benchmarks/trimmomatic.benchmark.txt", 3)
repeat("output/benchmarks/trimmomatic.benchmark.txt", config["replicates"])
shell:
"""
trimmomatic \
Expand All @@ -130,9 +148,9 @@ rule bbduk:
"output/processed/bbduk.fq"
conda: "envs/main.yaml"
log: "output/logs/bbduk.log"
threads: 10
threads: config["threads"]
benchmark:
repeat("output/benchmarks/bbduk.benchmark.txt", 3)
repeat("output/benchmarks/bbduk.benchmark.txt", config["replicates"])
shell:
"""
bbduk.sh \
Expand All @@ -157,9 +175,9 @@ rule fastp:
json="output/processed/fastp.json",
conda: "envs/fastp.yaml"
log: "output/logs/fastp.log"
threads: 10
threads: config["threads"]
benchmark:
repeat("output/benchmarks/fastp.benchmark.txt", 3)
repeat("output/benchmarks/fastp.benchmark.txt", config["replicates"])
shell:
"""
fastp \
Expand All @@ -181,10 +199,10 @@ rule adapterremoval:
fq="output/processed/adapterremoval.fq",
conda: "envs/adapterremoval.yaml"
log: "output/logs/adapterremoval.log"
threads: 10
threads: config["threads"]
shadow: "shallow"
benchmark:
repeat("output/benchmarks/adapterremoval.benchmark.txt", 3)
repeat("output/benchmarks/adapterremoval.benchmark.txt", config["replicates"])
shell:
"""
AdapterRemoval \
Expand All @@ -195,6 +213,27 @@ rule adapterremoval:
2> {log}
"""

rule fasten:
input:
fastq=rules.add_adapters.output,
adapters="gruseq.fa",
output:
"output/processed/fasten.fq"
conda: "envs/fasten.yaml"
log: "output/logs/fasten.log"
threads: config["threads"]
benchmark:
repeat("output/benchmarks/fasten.benchmark.txt", config["replicates"])
shell:
"""
fasten_trim \
--adapterseqs {input.adapters} \
--numcpus {threads} \
< {input.fastq} \
> {output} \
2> {log};
"""

rule grade:
input:
"output/processed/{tool}.fq"
Expand Down Expand Up @@ -227,3 +266,4 @@ rule plot:
{input.grades}
"""


3 changes: 1 addition & 2 deletions workflow/envs/adapterremoval.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,5 @@ name: adapterremoval
channels:
- conda-forge
- bioconda
- default
dependencies:
- adapterremoval=2.3.3
- adapterremoval=2.3.4
3 changes: 1 addition & 2 deletions workflow/envs/cutadapt.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,5 @@ name: cutadapt
channels:
- conda-forge
- bioconda
- default
dependencies:
- cutadapt=4.7
- cutadapt=5.1
6 changes: 6 additions & 0 deletions workflow/envs/fasten.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
name: fasten
channels:
- conda-forge
- bioconda
dependencies:
- fasten=0.8.7
3 changes: 1 addition & 2 deletions workflow/envs/fastp.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,5 @@ name: fastp
channels:
- conda-forge
- bioconda
- default
dependencies:
- fastp=0.23.4
- fastp=0.25.0
6 changes: 6 additions & 0 deletions workflow/envs/github.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
name: smk
channels:
- conda-forge
- bioconda
dependencies:
- snakemake-minimal
1 change: 0 additions & 1 deletion workflow/envs/main.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ name: adaptertest
channels:
- conda-forge
- bioconda
- default
dependencies:
- wget=1.20.1
- bbmap=38.62
Expand Down
1 change: 0 additions & 1 deletion workflow/envs/trimmomatic.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,5 @@ name: trimmomatic
channels:
- conda-forge
- bioconda
- default
dependencies:
- trimmomatic=0.39
Loading