From e29ec91736ae197a03852681f95ca21518ef4939 Mon Sep 17 00:00:00 2001 From: Thomas Cokelaer Date: Fri, 7 Jul 2023 09:57:07 +0200 Subject: [PATCH] automatically set the index algorithm --- README.rst | 2 ++ sequana_pipelines/variant_calling/main.py | 22 ++++++++++++++----- .../variant_calling/variant_calling.rules | 4 ++-- setup.py | 2 +- 4 files changed, 22 insertions(+), 8 deletions(-) diff --git a/README.rst b/README.rst index a9fc8e4..02a2987 100644 --- a/README.rst +++ b/README.rst @@ -130,6 +130,8 @@ Changelog ========= ====================================================================== Version Description ========= ====================================================================== +1.0.1 * automatically fill the bwa index algorithm and fix bwa_index rule to + use the options in the config file (not the harcoded one) 1.0.0 * use last warppers and graphviz apptainer 0.12.0 * set all apptainers containers and add vcf to bcf conversions * Update rule sambamba to use latest wrappers diff --git a/sequana_pipelines/variant_calling/main.py b/sequana_pipelines/variant_calling/main.py index 6870b70..1d94609 100755 --- a/sequana_pipelines/variant_calling/main.py +++ b/sequana_pipelines/variant_calling/main.py @@ -63,11 +63,11 @@ def __init__(self, prog=NAME, epilog=None): help="The annotation for snpeff" ) pipeline_group.add_argument("--threads", dest="threads", default=4, type=int) - pipeline_group.add_argument("--do-coverage", dest="do_coverage", - action="store_true", + pipeline_group.add_argument("--do-coverage", dest="do_coverage", + action="store_true", help="perform the coverage analysis using sequana_coverage") - pipeline_group.add_argument("--do-joint-calling", dest="do_joint_calling", - action="store_true", + pipeline_group.add_argument("--do-joint-calling", dest="do_joint_calling", + action="store_true", help="do the joint calling analysise") pipeline_group.add_argument("-o", "--circular", action="store_true") @@ -136,12 +136,24 @@ def main(args=None): cfg['sequana_coverage']["circular"] = options.circular cfg['joint_freebayes']['do'] = options.do_joint_calling cfg['bwa_mem']['threads'] = options.threads + + cfg['freebayes']['ploidy'] = options.freebayes_ploidy cfg.reference_file = os.path.abspath(options.reference) manager.exists(cfg.reference_file) - # coverage + # Given the reference, let us compute its length and st the index algorithm + from sequana import FastA + f = FastA(options.reference) + N = f.get_stats()['total_length'] + + # seems to be a hardcoded values in bwa according to the documentation + if N >= 2000000000: + cfg['bwa_mem']['index_algorithm'] = "bwtsw" + else: + cfg['bwa_mem']['index_algorithm'] = "is" + # finalise the command and save it; copy the snakemake. update the config diff --git a/sequana_pipelines/variant_calling/variant_calling.rules b/sequana_pipelines/variant_calling/variant_calling.rules index bb9cb0f..67203f8 100644 --- a/sequana_pipelines/variant_calling/variant_calling.rules +++ b/sequana_pipelines/variant_calling/variant_calling.rules @@ -116,8 +116,8 @@ if not config["input_pattern"].endswith("bam"): log: "reference/build.log" params: - options="", - index_algorithm="is" + options=config['bwa_mem'].get('index_options', ""), + index_algorithm=config['bwa_mem'].get('index_algorithm', "is") container: config['apptainers']['sequana_tools'] threads: 2 diff --git a/setup.py b/setup.py index 926c20a..d62d301 100644 --- a/setup.py +++ b/setup.py @@ -6,7 +6,7 @@ _MAJOR = 1 _MINOR = 0 -_MICRO = 0 +_MICRO = 1 version = '%d.%d.%d' % (_MAJOR, _MINOR, _MICRO) release = '%d.%d' % (_MAJOR, _MINOR)