Skip to content

Commit

Permalink
feat: add max_time_hr option for wall-time allocation
Browse files Browse the repository at this point in the history
This commit introduces a new optional parameter, `max_time_hr`, in
the config file. Users can specify an integer value representing the
maximum wall-time allocation in hours. This feature is particularly
beneficial for the time-intensive rules `population_level_ibd` and
`sample_concordance_plink`, allowing users to manage resource limitations
on their clusters effectively.
  • Loading branch information
jaamarks committed Sep 28, 2024
1 parent a16d334 commit f699252
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 6 deletions.
1 change: 0 additions & 1 deletion src/cgr_gwas_qc/models/config/software_params.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ class SoftwareParams(BaseModel):
pi_hat_threshold: 0.2
autosomal_het_threshold: 0.1
"""

strand: str = Field(
Expand Down
8 changes: 8 additions & 0 deletions src/cgr_gwas_qc/models/config/workflow_params.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import time
from typing import Optional

from pydantic import BaseModel, Field

Expand All @@ -23,6 +24,7 @@ class WorkflowParams(BaseModel):
lims_upload: true
lims_output_dir: /DCEG/CGF/Laboratory/LIMS/drop-box-prod/gwas_primaryqc/
case_control_gwas: false
max_time_hr:
time_start:
"""

Expand Down Expand Up @@ -87,6 +89,12 @@ class WorkflowParams(BaseModel):
False,
description="A plink logistic regression gwas will be performed with case_control phenotype.",
)

max_time_hr: Optional[int] = Field(
None,
description="Allocates the specified number of hours for the execution of the ``sample_concordance_plink`` and ``population_level_ibd`` rules.",
)

time_start: str = Field(
timestr,
description="Date and time at which the workflow starts. This creates a unique id for the run.",
Expand Down
4 changes: 2 additions & 2 deletions src/cgr_gwas_qc/workflow/sub_workflows/sample_qc.smk
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ from cgr_gwas_qc import load_config

cfg = load_config()

BIG_TIME = {1: 10, 2: 48, 3: 96}

mtime = cfg.config.workflow_params.max_time_hr
BIG_TIME = {1: mtime} if mtime else {1: 10, 2: 48, 3: 96}

use_contamination = (
cfg.config.user_files.idat_pattern
Expand Down
6 changes: 3 additions & 3 deletions src/cgr_gwas_qc/workflow/sub_workflows/subject_qc.smk
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ import math

cfg = load_config()

PLINK_BIG_MEM = {1: 1024 * 4, 2: 1024 * 64, 3: 1024 * 250}
BIG_TIME = {1: 8, 2: 24, 3: 48}
mtime = cfg.config.workflow_params.max_time_hr
BIG_TIME = {1: mtime} if mtime else {1: 8, 2: 24, 3: 48}


localrules:
Expand Down Expand Up @@ -280,7 +280,7 @@ use rule genome from plink as population_level_ibd with:
output:
"subject_level/{population}/subjects_maf{maf}_ld{ld}_ibd.genome",
resources:
mem_mb=lambda wildcards, attempt: PLINK_BIG_MEM[attempt],
mem_mb=lambda wildcards, attempt, input: max((attempt + 1) * input.size_mb, 1024),
time_hr=lambda wildcards, attempt: BIG_TIME[attempt],


Expand Down

0 comments on commit f699252

Please sign in to comment.