BALSAMIC.utils package

Submodules

BALSAMIC.utils.cli module

class BALSAMIC.utils.cli.CaptureStdout[source]

Bases: list

Captures stdout.

class BALSAMIC.utils.cli.SnakeMake[source]

Bases: object

To build a snakemake command using cli options

Params:

case_name - analysis case name working_dir - working directory for snakemake configfile - sample configuration file (json) output of balsamic-config-sample run_mode - run mode - cluster or local shell run cluster_config - cluster config json file scheduler - slurm command constructor log_path - log file path script_path - file path for slurm scripts result_path - result directory qos - QOS for sbatch jobs account - scheduler(e.g. slurm) account mail_user - email to account to send job run status forceall - To add ‘–forceall’ option for snakemake run_analysis - To run pipeline use_singularity - To use singularity singularity_bind- Singularity bind path singularity_arg - Singularity arguments to pass to snakemake sm_opt - snakemake additional options

build_cmd()[source]
BALSAMIC.utils.cli.add_doc(docstring)[source]

A decorator for adding docstring. Taken shamelessly from stackexchange.

BALSAMIC.utils.cli.convert_defaultdict_to_regular_dict(inputdict: dict)[source]

Recursively convert defaultdict to dict.

BALSAMIC.utils.cli.createDir(path, interm_path=[])[source]

Creates directories by recursively checking if it exists, otherwise increments the number

BALSAMIC.utils.cli.find_file_index(file_path)[source]
BALSAMIC.utils.cli.get_config(config_name)[source]

Return a string path for config file.

BALSAMIC.utils.cli.get_file_extension(file_path)[source]
BALSAMIC.utils.cli.get_file_status_string(file_to_check)[source]

Checks if file exsits. and returns a string with checkmark or redcorss mark if it exists or doesn’t exist respectively. Always assume file doesn’t exist, unless proven otherwise.

BALSAMIC.utils.cli.get_from_two_key(input_dict, from_key, by_key, by_value, default=None)[source]

Given two keys with list of values of same length, find matching index of by_value in from_key from by_key.

from_key and by_key should both exist

BALSAMIC.utils.cli.get_package_split(condas)[source]

Get a list of conda env files, and extract pacakges

input: conda env files output: dict of packages and their version

BALSAMIC.utils.cli.get_packages(yaml_file)[source]

return packages found in a conda yaml file

input: conda yaml file path output: list of packages

BALSAMIC.utils.cli.get_ref_path(input_json)[source]

Set full path to reference files Input: reference config file Return: json file with abspath

BALSAMIC.utils.cli.get_schedulerpy()[source]

Returns a string path for scheduler.py

BALSAMIC.utils.cli.get_snakefile(analysis_type, sequencing_type='targeted')[source]

Return a string path for variant calling snakefile.

BALSAMIC.utils.cli.iterdict(dic)[source]

dictionary iteration - returns generator

BALSAMIC.utils.cli.merge_dict_on_key(dict_1, dict_2, by_key)[source]

Merge two list of dictionaries based on key

BALSAMIC.utils.cli.recursive_default_dict()[source]

Recursivly create defaultdict.

BALSAMIC.utils.cli.write_json(json_out, output_config)[source]

BALSAMIC.utils.exc module

exception BALSAMIC.utils.exc.BalsamicError(message)[source]

Bases: Exception

Base exception for the BALSAMIC.

BALSAMIC.utils.rule module

BALSAMIC.utils.rule.get_chrom(panelfile)[source]

input: a panel bedfile output: list of chromosomes in the bedfile

BALSAMIC.utils.rule.get_conda_env(yaml_file, pkg)[source]

input: balsamic_env output: string of conda env where packge is in

BALSAMIC.utils.rule.get_picard_mrkdup(config)[source]

input: sample config file output from BALSAMIC output: mrkdup or rmdup strings

BALSAMIC.utils.rule.get_result_dir(config)[source]

input: sample config file from BALSAMIC output: string of result directory path

BALSAMIC.utils.rule.get_sample_type(sample, bio_type)[source]

input: sample dictionary from BALSAMIC’s config file output: list of sample type id

BALSAMIC.utils.rule.get_script_path(script_name: str)[source]

Retrieves script path where name is matching {{script_name}}.

BALSAMIC.utils.rule.get_threads(cluster_config, rule_name='__default__')[source]

To retrieve threads from cluster config or return default value of 8

BALSAMIC.utils.rule.get_vcf(config, var_caller, sample)[source]

input: BALSAMIC config file output: retrieve list of vcf files

Module contents