Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

perf: skip adapter trimming if nothing specified in unit sheet #93

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
24 changes: 16 additions & 8 deletions workflow/rules/common.smk
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ def get_recalibrate_quality_input(wildcards, bai=False):
return "results/mapped/{}.sorted.{}".format(wildcards.sample, ext)


def get_cutadapt_input(wildcards):
def get_cutadapt_input(wildcards, reads=["fq1", "fq2"]):
unit = units.loc[wildcards.sample].loc[wildcards.unit]

if pd.isna(unit["fq1"]):
Expand All @@ -145,7 +145,7 @@ def get_cutadapt_input(wildcards):
"pipe/cutadapt/{S}/{U}.{{read}}.fastq{E}".format(
S=unit.sample_name, U=unit.unit_name, E=ending
),
read=["fq1", "fq2"],
read=reads,
)


Expand Down Expand Up @@ -545,12 +545,20 @@ def get_tabix_params(wildcards):


def get_fastqs(wc):
return expand(
"results/trimmed/{sample}/{unit}_{read}.fastq.gz",
unit=units.loc[wc.sample, "unit_name"],
sample=wc.sample,
read=wc.read,
)
unit = units.loc[wc.sample]
if pd.isna(unit["adapters"]).all():
# no adapter trimming configured, skipping cutadapt for unit
if wc.read == "single":
return get_cutadapt_input(wc)
else:
return get_cutadapt_input(wc, reads=["fq1"] if wc.read == "R1" else ["fq2"])
else:
return expand(
"results/trimmed/{sample}/{unit}_{read}.fastq.gz",
unit=unit["unit_name"],
sample=wc.sample,
read=wc.read,
)


def get_vembrane_expression(wc):
Expand Down
10 changes: 5 additions & 5 deletions workflow/rules/trimming.smk
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ rule cutadapt_pipe:
output:
pipe("pipe/cutadapt/{sample}/{unit}.{fq}.{ext}"),
log:
"logs/pipe-fastqs/catadapt/{sample}-{unit}.{fq}.{ext}.log",
"logs/pipe-fastqs/cutadapt/{sample}-{unit}.{fq}.{ext}.log",
wildcard_constraints:
ext=r"fastq|fastq\.gz",
threads: 0 # this does not need CPU
Expand All @@ -26,8 +26,8 @@ rule cutadapt_pe:
input:
get_cutadapt_input,
output:
fastq1="results/trimmed/{sample}/{unit}_R1.fastq.gz",
fastq2="results/trimmed/{sample}/{unit}_R2.fastq.gz",
fastq1=temp("results/trimmed/{sample}/{unit}_R1.fastq.gz"),
fastq2=temp("results/trimmed/{sample}/{unit}_R2.fastq.gz"),
qc="results/trimmed/{sample}/{unit}.paired.qc.txt",
log:
"logs/cutadapt/{sample}-{unit}.log",
Expand All @@ -43,8 +43,8 @@ rule cutadapt_se:
input:
get_cutadapt_input,
output:
fastq="results/trimmed/{sample}/{unit}.single.fastq.gz",
qc="results/trimmed/{sample}/{unit}.single.qc.txt",
fastq=temp("results/trimmed/{sample}/{unit}_single.fastq.gz"),
qc="results/trimmed/{sample}/{unit}_single.qc.txt",
log:
"logs/cutadapt/{sample}-{unit}.log",
params:
Expand Down