Skip to content

Commit

Permalink
Tried fixing formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
vBassewitz committed Jun 8, 2024
1 parent 1ad9234 commit 2bb77e1
Show file tree
Hide file tree
Showing 4 changed files with 55 additions and 30 deletions.
61 changes: 40 additions & 21 deletions workflow/rules/common.smk
Original file line number Diff line number Diff line change
Expand Up @@ -156,8 +156,16 @@ def is_ion_torrent(wildcards, sample=None):
def has_pseudo_assembly(wildcards, sample=None):
"""Returns if a pseudo-assembly should be created for the sample."""
if sample is None:
return is_illumina(wildcards) or is_ion_torrent(wildcards) or is_illumina_se(wildacrds)
return is_illumina(None, sample) or is_ion_torrent(None, sample) or is_illumina_se(None, sample)
return (
is_illumina(wildcards)
or is_ion_torrent(wildcards)
or is_illumina_se(wildacrds)
)
return (
is_illumina(None, sample)
or is_ion_torrent(None, sample)
or is_illumina_se(None, sample)
)


def has_consensus_assembly(wildcards, sample=None):
Expand All @@ -170,8 +178,14 @@ def has_consensus_assembly(wildcards, sample=None):
def is_single_end(wildcards, sample=None):
"""Returns if the sample was sequenced with single end technology."""
if sample is None:
return is_ont(wildcards) or is_ion_torrent(wildcards) or is_illumina_se(wildacrds)
return is_ont(None, sample) or is_ion_torrent(None, sample) or is_illumina_se(None, sample)
return (
is_ont(wildcards) or is_ion_torrent(wildcards) or is_illumina_se(wildacrds)
)
return (
is_ont(None, sample)
or is_ion_torrent(None, sample)
or is_illumina_se(None, sample)
)


def get_fastqs(wildcards):
Expand Down Expand Up @@ -363,9 +377,11 @@ def get_non_cov2_calls(from_caller="pangolin"):
pattern = (
"results/benchmarking/tables/strain-calls/non-cov2-{accession}.polished.strains.pangolin.csv"
if from_caller == "pangolin"
else "results/benchmarking/tables/strain-calls/non-cov2-{accession}.strains.kallisto.tsv"
if from_caller == "kallisto"
else []
else (
"results/benchmarking/tables/strain-calls/non-cov2-{accession}.strains.kallisto.tsv"
if from_caller == "kallisto"
else []
)
)

if not pattern:
Expand Down Expand Up @@ -421,7 +437,7 @@ def get_reads(wildcards):
"results/{date}/trimmed/fastp-pe/{sample}.{read}.fastq.gz",
read=[1, 2],
**wildcards,
)
)

illumina_se_pattern = expand(
"results/{date}/trimmed/fastp-se/{sample}.fastq.gz",
Expand Down Expand Up @@ -862,9 +878,7 @@ def get_varlociraptor_bias_flags(wildcards):
)
if is_amplicon_data(wildcards.sample):
# no bias detection possible
return (
"--omit-strand-bias --omit-read-orientation-bias --omit-read-position-bias --omit-softclip-bias"
)
return "--omit-strand-bias --omit-read-orientation-bias --omit-read-position-bias --omit-softclip-bias"
return ""


Expand Down Expand Up @@ -1145,18 +1159,22 @@ def get_fallbacks_for_report(fallback_type):
if fallback_type == "pseudo":
path = "results/{{date}}/contigs/pseudoassembled/{sample}.fasta"
return [
path.format(sample=sample)
if has_pseudo_assembly(None, sample)
else "resources/genomes/main.fasta"
(
path.format(sample=sample)
if has_pseudo_assembly(None, sample)
else "resources/genomes/main.fasta"
)
for sample in get_samples_for_date(wildcards.date)
]

elif fallback_type == "consensus":
path = "results/{{date}}/contigs/masked/consensus/{sample}.fasta"
return [
path.format(sample=sample)
if has_consensus_assembly(None, sample)
else "resources/genomes/main.fasta"
(
path.format(sample=sample)
if has_consensus_assembly(None, sample)
else "resources/genomes/main.fasta"
)
for sample in samples
]

Expand Down Expand Up @@ -1446,9 +1464,11 @@ def get_kallisto_quant_extra(wildcards, input):
return get_if_testing("--single --fragment-length 250 --sd 47301")

return (
f"--single --fragment-length {get_first_line(input.fragment_length)} --sd {get_first_line(input.standard_deviation)}"
if is_single_end(wildcards)
else "",
(
f"--single --fragment-length {get_first_line(input.fragment_length)} --sd {get_first_line(input.standard_deviation)}"
if is_single_end(wildcards)
else ""
),
)


Expand Down Expand Up @@ -1747,4 +1767,3 @@ wildcard_constraints:
list(map(re.escape, config["variant-calling"]["filters"])) + ["nofilter"]
),
varrange="structural|small|homopolymer-medaka|homopolymer-longshot|lineage-variants",

8 changes: 5 additions & 3 deletions workflow/rules/generate_output.smk
Original file line number Diff line number Diff line change
Expand Up @@ -381,9 +381,11 @@ rule snakemake_reports_patient:
"results/{date}/qc/laboratory/multiqc.html",
"results/{date}/plots/coverage-reference-genome.png",
"results/{date}/plots/coverage-assembled-genome.png",
lambda wildcards: "results/{date}/plots/primer-clipping-intervals.svg"
if any_sample_is_amplicon(wildcards)
else [],
lambda wildcards: (
"results/{date}/plots/primer-clipping-intervals.svg"
if any_sample_is_amplicon(wildcards)
else []
),
# 4. Assembly
"results/{date}/filter-overview",
"results/{date}/pangolin-call-overview",
Expand Down
8 changes: 5 additions & 3 deletions workflow/rules/ref.smk
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,11 @@ rule get_genome:
"resources/genomes/{accession}.fasta",
params:
accession=(
lambda w: config["virus-reference-genome"]
if w.accession == "main"
else w.accession
lambda w: (
config["virus-reference-genome"]
if w.accession == "main"
else w.accession
)
),
log:
"logs/genomes/get-genome/{accession}.log",
Expand Down
8 changes: 5 additions & 3 deletions workflow/rules/variant_calling.smk
Original file line number Diff line number Diff line change
Expand Up @@ -75,9 +75,11 @@ rule longshot:
"results/{date}/candidate-calls/ref~{reference}/{sample}.homopolymer-longshot.vcf"
),
params:
reference_name=lambda w: config["virus-reference-genome"]
if w.reference == "main"
else f"{w.reference}.1",
reference_name=lambda w: (
config["virus-reference-genome"]
if w.reference == "main"
else f"{w.reference}.1"
),
log:
"logs/{date}/longshot/ref~{reference}/{sample}.log",
conda:
Expand Down

0 comments on commit 2bb77e1

Please sign in to comment.