Configuration API¶
Configuration Manager¶
-
class
cgr_gwas_qc.config.ConfigMgr(root: pathlib.Path, user_config: pathlib.Path, sample_sheet_file: pathlib.Path)[source] Manage all things config.
Example
>>> from cgr_gwas_qc import load_config >>> cfg = load_config() # must have ``config.yml`` and ``cgr_sample_sheet.csv`` in current directory.
-
CONDA_DIR: pathlib.Path = PosixPath('/home/runner/work/GwasQcPipeline/GwasQcPipeline/src/cgr_gwas_qc/workflow/conda') The absolute path to the
workflow/conda.
-
DD_DIR: pathlib.Path = PosixPath('/home/runner/work/GwasQcPipeline/GwasQcPipeline/src/cgr_gwas_qc/reporting/QC_Report_Data_Dictionary.xlsx') The absolute path to the
reporting/QC_Report_Data_Dictionary.xlsx.
-
MODULE_DIR: pathlib.Path = PosixPath('/home/runner/work/GwasQcPipeline/GwasQcPipeline/src/cgr_gwas_qc/workflow/modules') The absolute path to the
workflow/modules.
-
SCRIPTS_DIR: pathlib.Path = PosixPath('/home/runner/work/GwasQcPipeline/GwasQcPipeline/src/cgr_gwas_qc/workflow/scripts') The absolute path to the
workflow/scripts.
-
SNAKEFILE: pathlib.Path = PosixPath('/home/runner/work/GwasQcPipeline/GwasQcPipeline/src/cgr_gwas_qc/workflow/Snakefile') The absolute path to the
workflow/Snakefile.
-
SRC_DIR: pathlib.Path = PosixPath('/home/runner/work/GwasQcPipeline/GwasQcPipeline/src/cgr_gwas_qc') The absolute path to
cgr_gwas_qcsource code.
-
SUBWORKFLOW_DIR: pathlib.Path = PosixPath('/home/runner/work/GwasQcPipeline/GwasQcPipeline/src/cgr_gwas_qc/workflow/sub_workflows') The absolute path to the
workflow/sub_workflows.
-
TEMPLATE_DIR: pathlib.Path = PosixPath('/home/runner/work/GwasQcPipeline/GwasQcPipeline/src/cgr_gwas_qc/reporting/templates') The absolute path to the
reporting/templates.
-
WORKFLOW_DIR: pathlib.Path = PosixPath('/home/runner/work/GwasQcPipeline/GwasQcPipeline/src/cgr_gwas_qc/workflow') The absolute path to the
workflowsource code.
-
property
cluster_groups List of the cluster group names from
cgr_sample_sheet.csv.Example
>>> cfg = load_config() >>> cfg.cluster_groups ["cgroup1", "cgroup2"]
-
classmethod
conda(filename: str) → str[source] Return path to a conda env file.
Given a conda env file_name, prepends the full path to that file.
-
property
config The user’s config settings from
config.yml.Example
>>> from cgr_gwas_qc import load_config >>> cfg = load_config() >>> cfg.config.software_params.maf_for_ibd 0.2
-
property
data_dictionary Return the path to the qc report data dictioanry.
-
property
docx_template Return the path to the docx template.
-
expand(file_pattern: str, combination: Callable = <class 'zip'>, query: Optional[str] = None) → List[str][source] Use sample sheet columns to fill in file pattern
- Parameters:
file_pattern – A snakemake compatible file name pattern.
combination – The combinatorial method to use (see snakemake.rules.expand). Defaults to zip.
query – A pandas.DataFrame.query to use to filter before expansion. Defaults to None.
- Returns:
A list of expanded file names.
Example
>>> cfg = load_config() # assuming ``cgr_sample_sheet.csv`` contains 3 samples SP00{1,2,3} >>> cfg.expand("{Sample_ID}.txt") ["SP001.txt", "SP002.txt", "SP003.txt"] >>> cfg.expand("{Sample_ID}.txt", query="Sample_ID == 'SP002'") [SP002.txt"]
-
classmethod
instance(pytest=False)[source] Returns the active ConfigMgr instance.
This ensures that only 1 ConfigMgr is created per python session.
-
classmethod
modules(filename: str) → str[source] Return the path to a module file.
Given a rule file_name, prepends the full path to that module.
-
root: Path The current working directory.
-
sample_sheet_file: Path The
cgr_sample_sheet.csv`in the current working directory.
-
classmethod
scripts(filename: str) → str[source] Return the path to an internal script.
Given a script file_name, prepends the full path to that script.
-
property
ss The user’s sample sheet data.
Example
>>> cfg = load_config() >>> cfg.ss.head(2) Sample_ID Subject_ID ... SP001 SB001 ... SP002 SB002 ...
-
classmethod
subworkflow(workflow: str) → str[source] Return the path to a sub-workflow.
Given a sub-workflow name, give the full path to the snakefile.
-
user_config: Path The
config.yml`in the current working directory.
-