From 2bb77e13cffbae13704135058ba32b71159169ba Mon Sep 17 00:00:00 2001 From: vBassewitz Date: Sat, 8 Jun 2024 13:19:21 +0000 Subject: [PATCH] Tried fixing formatting --- workflow/rules/common.smk | 61 ++++++++++++++++++++---------- workflow/rules/generate_output.smk | 8 ++-- workflow/rules/ref.smk | 8 ++-- workflow/rules/variant_calling.smk | 8 ++-- 4 files changed, 55 insertions(+), 30 deletions(-) diff --git a/workflow/rules/common.smk b/workflow/rules/common.smk index 44268e0f8..179799818 100644 --- a/workflow/rules/common.smk +++ b/workflow/rules/common.smk @@ -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): @@ -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): @@ -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: @@ -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", @@ -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 "" @@ -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 ] @@ -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 "" + ), ) @@ -1747,4 +1767,3 @@ wildcard_constraints: list(map(re.escape, config["variant-calling"]["filters"])) + ["nofilter"] ), varrange="structural|small|homopolymer-medaka|homopolymer-longshot|lineage-variants", - diff --git a/workflow/rules/generate_output.smk b/workflow/rules/generate_output.smk index 11899c101..e62863720 100644 --- a/workflow/rules/generate_output.smk +++ b/workflow/rules/generate_output.smk @@ -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", diff --git a/workflow/rules/ref.smk b/workflow/rules/ref.smk index 6c0131c85..9d91921fc 100644 --- a/workflow/rules/ref.smk +++ b/workflow/rules/ref.smk @@ -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", diff --git a/workflow/rules/variant_calling.smk b/workflow/rules/variant_calling.smk index 8682bc980..fdd358c17 100644 --- a/workflow/rules/variant_calling.smk +++ b/workflow/rules/variant_calling.smk @@ -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: