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

fix: add sleep rule before start #1311

Merged
merged 12 commits into from
Jan 29, 2024
1 change: 1 addition & 0 deletions BALSAMIC/constants/rules.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@

SNAKEMAKE_RULES: Dict[str, Dict[str, list]] = {
"common": {
"misc": ["snakemake_rules/misc/sleep.rule"],
"qc": [
"snakemake_rules/quality_control/fastqc.rule",
"snakemake_rules/quality_control/multiqc.rule",
Expand Down
2 changes: 2 additions & 0 deletions BALSAMIC/constants/workflow_params.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,8 @@
},
}

SLEEP_BEFORE_START = 300

WORKFLOW_PARAMS = {
"common": {
"pcr_model": "NONE",
Expand Down
15 changes: 15 additions & 0 deletions BALSAMIC/snakemake_rules/misc/sleep.rule
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@

rule sleep_before_start:
"""Wait the specified number of seconds before starting any processing to avoid key_error issue."""
output:
wake_up = result_dir + "start_analysis"
params:
sleep_seconds = SLEEP_BEFORE_START
threads: get_threads(cluster_config, "sleep_before_start")
message:
"Sleeping for {params.sleep_seconds} seconds before starting analysis."
shell:
"""
sleep {params.sleep_seconds}
echo "Waited: {params.sleep_seconds} seconds. Now starting analysis." >> {output.wake_up}
"""
1 change: 1 addition & 0 deletions BALSAMIC/snakemake_rules/quality_control/fastp_tga.rule
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
rule fastp_umi_trim:
"""Fastq TGA data pre-processing to remove UMIs."""
input:
wake_up = result_dir + "start_analysis",
fastq_r1 = lambda wildcards: config_model.get_fastq_by_fastq_pattern(wildcards.fastq_pattern, FastqName.FWD),
fastq_r2 = lambda wildcards: config_model.get_fastq_by_fastq_pattern(wildcards.fastq_pattern, FastqName.REV)
output:
Expand Down
1 change: 1 addition & 0 deletions BALSAMIC/snakemake_rules/quality_control/fastp_wgs.rule
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
rule fastp_quality_trim_wgs:
"""Fastq data pre-processing for WGS."""
input:
wake_up = result_dir + "start_analysis",
fastq_r1 = lambda wildcards: config_model.get_fastq_by_fastq_pattern(wildcards.fastq_pattern, FastqName.FWD),
fastq_r2 = lambda wildcards: config_model.get_fastq_by_fastq_pattern(wildcards.fastq_pattern, FastqName.REV)
output:
Expand Down
1 change: 1 addition & 0 deletions BALSAMIC/snakemake_rules/quality_control/fastqc.rule
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
rule fastqc:
"""Perform quality control checks on raw sequence data."""
input:
wake_up = result_dir + "start_analysis",
fastq = input_fastq_dir + "{fastq_file_names}.fastq.gz"
output:
fastqc_zip = fastqc_dir + "{fastq_file_names}_fastqc.zip"
Expand Down
1 change: 1 addition & 0 deletions BALSAMIC/snakemake_rules/umi/concatenation_umi.rule
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

rule concatenate_umi_reads:
input:
wake_up = result_dir + "start_analysis",
fastqs_fwd=lambda wildcards: config_model.get_all_fastqs_for_sample(
sample_name=wildcards.sample, fastq_types=[FastqName.FWD]
),
Expand Down
4 changes: 3 additions & 1 deletion BALSAMIC/workflows/PON.smk
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,14 @@ from typing import Dict, List

from BALSAMIC.constants.analysis import FastqName, Gender, PONWorkflow, SampleType, SequencingType
from BALSAMIC.constants.paths import BALSAMIC_DIR
from BALSAMIC.constants.workflow_params import WORKFLOW_PARAMS
from BALSAMIC.constants.workflow_params import WORKFLOW_PARAMS, SLEEP_BEFORE_START
from BALSAMIC.models.config import ConfigModel
from BALSAMIC.models.params import BalsamicWorkflowConfig
from BALSAMIC.utils.exc import BalsamicError
from BALSAMIC.utils.io import write_finish_file
from BALSAMIC.utils.rule import get_fastp_parameters, get_result_dir, get_threads


# Initialize ConfigModel
config_model = ConfigModel.model_validate(config)

Expand Down Expand Up @@ -81,6 +82,7 @@ if not Path(config["SENTIEON_EXEC"]).exists():

sequence_type = config['analysis']["sequencing_type"]
rules_to_include = []
rules_to_include.append("snakemake_rules/misc/sleep.rule")
if sequence_type == SequencingType.TARGETED:
rules_to_include.append("snakemake_rules/quality_control/fastp_tga.rule")
else:
Expand Down
5 changes: 3 additions & 2 deletions BALSAMIC/workflows/QC.smk
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ from typing import Dict, List
from BALSAMIC.constants.analysis import AnalysisType, FastqName, SampleType
from BALSAMIC.constants.paths import BALSAMIC_DIR
from BALSAMIC.constants.rules import SNAKEMAKE_RULES
from BALSAMIC.constants.workflow_params import WORKFLOW_PARAMS
from BALSAMIC.constants.workflow_params import WORKFLOW_PARAMS, SLEEP_BEFORE_START
from BALSAMIC.models.config import ConfigModel
from BALSAMIC.models.params import BalsamicWorkflowConfig
from BALSAMIC.utils.cli import check_executable, generate_h5
Expand Down Expand Up @@ -112,9 +112,10 @@ sequence_type = config['analysis']["sequencing_type"]
rules_to_include = []
for workflow_type, value in SNAKEMAKE_RULES.items():
if workflow_type in ["common", analysis_type + "_" + sequence_type]:
rules_to_include.extend(value.get("qc", []) + value.get("align", []))
rules_to_include.extend(value.get("qc", []) + value.get("align", []) + value.get("misc", []))
rules_to_include = [rule for rule in rules_to_include if "umi" not in rule and "report" not in rule]


# Somalier only implemented for hg38 and hg19
if "canfam3" in config["reference"]["reference_genome"]:
rules_to_include.remove("snakemake_rules/quality_control/somalier.rule")
Expand Down
3 changes: 1 addition & 2 deletions BALSAMIC/workflows/balsamic.smk
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ from BALSAMIC.constants.variant_filters import (
SVDB_FILTER_SETTINGS,
VARDICT_SETTINGS,
)
from BALSAMIC.constants.workflow_params import VARCALL_PARAMS, WORKFLOW_PARAMS
from BALSAMIC.constants.workflow_params import VARCALL_PARAMS, WORKFLOW_PARAMS, SLEEP_BEFORE_START
from BALSAMIC.models.config import ConfigModel
from BALSAMIC.models.params import BalsamicWorkflowConfig, VarCallerFilter
from BALSAMIC.utils.cli import check_executable, generate_h5
Expand Down Expand Up @@ -83,7 +83,6 @@ delivery_dir: str = Path(result_dir, "delivery").as_posix() + "/"
umi_dir: str = Path(result_dir, "umi").as_posix() + "/"
umi_qc_dir: str = Path(qc_dir, "umi_qc").as_posix() + "/"


# Annotations
research_annotations = []
clinical_annotations = []
Expand Down
9 changes: 9 additions & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
[13.0.1]
-------

Added:
^^^^^^
* Sleep rule before start to fix key_error https://github.com/Clinical-Genomics/BALSAMIC/pull/1310
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
* Sleep rule before start to fix key_error https://github.com/Clinical-Genomics/BALSAMIC/pull/1310
* Sleep rule before start to fix key_error https://github.com/Clinical-Genomics/BALSAMIC/pull/1311



[13.0.0]
-------

Expand Down Expand Up @@ -35,6 +43,7 @@ Added:
* `wkhtmltopdf` to system requirements https://github.com/Clinical-Genomics/BALSAMIC/pull/1339
* Store WGS CNV report plots https://github.com/Clinical-Genomics/BALSAMIC/pull/1347


Changed:
^^^^^^^^
* Changed CN header field in cnvpytor in cnvpytor_tumor_only to be Float instead of Integer https://github.com/Clinical-Genomics/BALSAMIC/pull/1182
Expand Down