From d8e19ca02890d8ebb1989ef3f9117c8239c1e414 Mon Sep 17 00:00:00 2001 From: Matthew Colpus Date: Mon, 18 May 2026 09:49:29 +0000 Subject: [PATCH] fix: for asseess_genome_creation when there are no variants --- CHANGELOG.md | 6 +++++- Cargo.lock | 2 +- Cargo.toml | 2 +- process/consensus.nf | 8 ++++---- process/variant_calling.nf | 10 +++++----- pyproject.toml | 4 ++-- src/helper_scripts/assess_genome_creation.py | 18 +++++++++++++----- test_data/clair3_consensus/expected.vcf | 2 +- test_data/single_consensus/expected.vcf | 2 +- test_data/support_consensus/expected.vcf | 2 +- test_data/write_vcf.vcf | 2 +- 11 files changed, 35 insertions(+), 23 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index e2ee920..1b94306 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,10 @@ +## 1.1.2 + +- fix for assess_genome_creation when vcf tables is empty + ## 1.1.1 -- fix for asseess_genome_creation when there are no indels +- fix for assess_genome_creation when there are no indels ## 1.1.0 diff --git a/Cargo.lock b/Cargo.lock index 41a10f2..2003477 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -653,7 +653,7 @@ checksum = "dc897dd8d9e8bd1ed8cdad82b5966c3e0ecae09fb1907d58efaa013543185d0a" [[package]] name = "rundial" -version = "1.1.1" +version = "1.1.2" dependencies = [ "clap", "indexmap", diff --git a/Cargo.toml b/Cargo.toml index 9f60d7f..b6f5354 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "rundial" -version = "1.1.1" +version = "1.1.2" edition = "2024" rust-version = "1.93" diff --git a/process/consensus.nf b/process/consensus.nf index af66846..b690001 100644 --- a/process/consensus.nf +++ b/process/consensus.nf @@ -1,7 +1,7 @@ process apply_filters { publishDir "${params.publish_dir}", enabled: params.publish_dir != "", mode: "copy", saveAs: { filename -> sample_name + "." + filename } container { - params.test_container_rundial == "" ? params.container_prefix + '/gpas/rundial:1.1.1' : params.test_container_rundial + params.test_container_rundial == "" ? params.container_prefix + '/gpas/rundial:1.1.2' : params.test_container_rundial } cpus 1 @@ -29,7 +29,7 @@ process apply_filters { process make_consensus { publishDir "${params.publish_dir}", enabled: params.publish_dir != "", mode: "copy", saveAs: { filename -> sample_name + "." + filename } container { - params.test_container_rundial == "" ? params.container_prefix + '/gpas/rundial:1.1.1' : params.test_container_rundial + params.test_container_rundial == "" ? params.container_prefix + '/gpas/rundial:1.1.2' : params.test_container_rundial } cpus 1 memory "4 GB" @@ -75,7 +75,7 @@ process make_consensus { process make_clair3_consensus { publishDir "${params.publish_dir}", enabled: params.publish_dir != "", mode: "copy", saveAs: { filename -> sample_name + "." + filename } container { - params.test_container_rundial == "" ? params.container_prefix + '/gpas/rundial:1.1.1' : params.test_container_rundial + params.test_container_rundial == "" ? params.container_prefix + '/gpas/rundial:1.1.2' : params.test_container_rundial } cpus 1 memory "3 GB" @@ -123,7 +123,7 @@ process make_clair3_consensus { process reassess_genome_creation { publishDir "${params.publish_dir}", enabled: params.publish_dir != "", mode: "copy", saveAs: { filename -> sample_name + "." + filename } container { - params.test_container_rundial == "" ? params.container_prefix + '/gpas/rundial:1.1.1' : params.test_container_rundial + params.test_container_rundial == "" ? params.container_prefix + '/gpas/rundial:1.1.2' : params.test_container_rundial } cpus 1 diff --git a/process/variant_calling.nf b/process/variant_calling.nf index ec2cafc..ebb8a3c 100644 --- a/process/variant_calling.nf +++ b/process/variant_calling.nf @@ -3,7 +3,7 @@ params.test_cpus = "" process minimap2 { publishDir "${params.publish_dir}", enabled: params.publish_dir != "", mode: "copy", saveAs: { filename -> sample_name + "." + filename } container { - params.test_container_rundial == "" ? params.container_prefix + '/gpas/rundial:1.1.1' : params.test_container_rundial + params.test_container_rundial == "" ? params.container_prefix + '/gpas/rundial:1.1.2' : params.test_container_rundial } cpus { params.testing == "" ? 4 : params.test_cpus @@ -32,7 +32,7 @@ process minimap2 { process call_snps { publishDir "${params.publish_dir}", enabled: params.publish_dir != "", mode: "copy", saveAs: { filename -> sample_name + "." + filename } container { - params.test_container_rundial == "" ? params.container_prefix + '/gpas/rundial:1.1.1' : params.test_container_rundial + params.test_container_rundial == "" ? params.container_prefix + '/gpas/rundial:1.1.2' : params.test_container_rundial } cpus { params.testing == "" ? 4 : params.test_cpus @@ -78,7 +78,7 @@ process call_snps { process call_all { publishDir "${params.publish_dir}", enabled: params.publish_dir != "", mode: "copy", saveAs: { filename -> sample_name + "." + filename } container { - params.test_container_rundial == "" ? params.container_prefix + '/gpas/rundial:1.1.1' : params.test_container_rundial + params.test_container_rundial == "" ? params.container_prefix + '/gpas/rundial:1.1.2' : params.test_container_rundial } cpus { params.testing == "" ? 4 : params.test_cpus @@ -132,7 +132,7 @@ process call_all { process get_clair3_model { container { - params.test_container_rundial == "" ? params.container_prefix + '/gpas/rundial:1.1.1' : params.test_container_rundial + params.test_container_rundial == "" ? params.container_prefix + '/gpas/rundial:1.1.2' : params.test_container_rundial } pod label: "name", value: "rundial:get_clair3_model" @@ -155,7 +155,7 @@ process get_clair3_model { process clair3 { publishDir "${params.publish_dir}", enabled: params.publish_dir != "", mode: "copy", saveAs: { filename -> sample_name + "." + filename } container { - params.test_container_rundial == "" ? params.container_prefix + '/gpas/rundial:1.1.1' : params.test_container_rundial + params.test_container_rundial == "" ? params.container_prefix + '/gpas/rundial:1.1.2' : params.test_container_rundial } cpus { params.testing == "" ? 4 : params.test_cpus diff --git a/pyproject.toml b/pyproject.toml index 9ad8f84..c8d44c7 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta" [project] name = "rundial" -version = "1.1.1" +version = "1.1.2" description = "Reference based assembly of ONT reads." classifiers = [ "Environment :: Console", @@ -37,7 +37,7 @@ version_scheme = "semver" version_provider = "pep621" [tool.version_bumper] -active_version = "1.1.1" +active_version = "1.1.2" version_files = [ "process/variant_calling.nf", "process/consensus.nf", diff --git a/src/helper_scripts/assess_genome_creation.py b/src/helper_scripts/assess_genome_creation.py index 215e2cc..cdaf715 100644 --- a/src/helper_scripts/assess_genome_creation.py +++ b/src/helper_scripts/assess_genome_creation.py @@ -203,9 +203,14 @@ def get_depths(row) -> tuple[list[int] | None, list[int] | None, list[int], int] f"Could not find suitable depth fields for row with FORMAT {row['FORMAT']}.\nrow={row}" ) - vcf[["ADF", "ADR", "COV", "HQ_DP"]] = vcf.apply( - get_depths, axis=1, result_type="expand" - ) + if vcf.empty: + vcf[["ADF", "ADR", "COV", "HQ_DP"]] = pd.DataFrame( + [[None, None, [0], 0]], index=vcf.index + ) + else: + vcf[["ADF", "ADR", "COV", "HQ_DP"]] = vcf.apply( + get_depths, axis=1, result_type="expand" + ) return vcf @@ -239,7 +244,10 @@ def is_het(row) -> bool: return False return True - vcf["is_het"] = vcf.apply(is_het, axis=1) + if vcf.empty: + vcf["is_het"] = False + else: + vcf["is_het"] = vcf.apply(is_het, axis=1) return vcf @@ -267,7 +275,7 @@ def in_mask(contig, pos, mask_set, ref): mask_set = set(zip(mask["contig"], mask["position"])) - if mask_set: + if mask_set and not vcf.empty: vcf["is_masked"] = vcf.apply( lambda row: in_mask(row["CHROM"], row["POS"], mask_set, row["REF"]), axis=1 ) diff --git a/test_data/clair3_consensus/expected.vcf b/test_data/clair3_consensus/expected.vcf index bb14ec0..4fd7423 100644 --- a/test_data/clair3_consensus/expected.vcf +++ b/test_data/clair3_consensus/expected.vcf @@ -1,5 +1,5 @@ ##fileformat=VCFv4.2 -##rundial_consensus_version=1.1.1 +##rundial_consensus_version=1.1.2 ##FILTER= ##FILTER= ##FILTER= diff --git a/test_data/single_consensus/expected.vcf b/test_data/single_consensus/expected.vcf index ee3bded..a58c11f 100644 --- a/test_data/single_consensus/expected.vcf +++ b/test_data/single_consensus/expected.vcf @@ -1,5 +1,5 @@ ##fileformat=VCFv4.2 -##rundial_consensus_version=1.1.1 +##rundial_consensus_version=1.1.2 ##FILTER= ##FILTER= ##FILTER= diff --git a/test_data/support_consensus/expected.vcf b/test_data/support_consensus/expected.vcf index a2983d8..f166cd1 100644 --- a/test_data/support_consensus/expected.vcf +++ b/test_data/support_consensus/expected.vcf @@ -1,5 +1,5 @@ ##fileformat=VCFv4.2 -##rundial_consensus_version=1.1.1 +##rundial_consensus_version=1.1.2 ##FILTER= ##FILTER= ##FILTER= diff --git a/test_data/write_vcf.vcf b/test_data/write_vcf.vcf index 214d9c1..018e1ae 100644 --- a/test_data/write_vcf.vcf +++ b/test_data/write_vcf.vcf @@ -1,5 +1,5 @@ ##fileformat=VCFv4.2 -##rundial_consensus_version=1.1.1 +##rundial_consensus_version=1.1.2 ##FILTER= ##FILTER= ##FILTER=