From f0017e420481238ca0386dced72e90ae00bfa70b Mon Sep 17 00:00:00 2001 From: Brent Pedersen Date: Tue, 15 Mar 2022 15:37:28 +0100 Subject: [PATCH] pre-allocate variable vectors for fasteval so they don't move this was causing bugs where the expression values were not filled correctly for each variant because the addresses were changed. --- CHANGES.md | 4 ++++ Cargo.toml | 2 +- src/commands/annotate_cmd.rs | 4 ++-- src/lib/echtvar.rs | 5 +++-- 4 files changed, 10 insertions(+), 5 deletions(-) diff --git a/CHANGES.md b/CHANGES.md index 8db6631..8f24814 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -1,3 +1,7 @@ +v0.1.4 +====== ++ fix bug with filter not removing (not filtering) variants correctly. + v0.1.3 ====== + exit with error on multi-allelics (previously, only first allele was used) ( #11) diff --git a/Cargo.toml b/Cargo.toml index 7b60b8e..69f7988 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "echtvar" -version = "0.1.3" +version = "0.1.4" edition = "2018" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html diff --git a/src/commands/annotate_cmd.rs b/src/commands/annotate_cmd.rs index f3698e7..7c5a911 100644 --- a/src/commands/annotate_cmd.rs +++ b/src/commands/annotate_cmd.rs @@ -38,11 +38,11 @@ pub fn annotate_main( let parser = fasteval::Parser::new(); let mut slab = fasteval::Slab::new(); let mut ns = fasteval::EmptyNamespace; - let mut expr_values = vec![]; + let mut expr_values = Vec::with_capacity(echts.len()); for (i, e) in echts.iter().enumerate() { // a vector within expr_values for each echtvar file. - expr_values.push(vec![]); + expr_values.push(Vec::with_capacity(e.fields.len())); // handle the expression stuff. for (j, fld) in e.fields.iter().enumerate() { expr_values[i].push(0.0 as f64); diff --git a/src/lib/echtvar.rs b/src/lib/echtvar.rs index 6fe92ab..6fdb1d1 100644 --- a/src/lib/echtvar.rs +++ b/src/lib/echtvar.rs @@ -341,10 +341,11 @@ impl EchtVars { let alleles = variant.alleles(); if alleles.len() != 2 { panic!( - "[echtvar] variants must be decomposed before running. got variant with {} alleles at {}:{}", + "[echtvar] variants must be decomposed before running. got variant with {} alleles at {}:{} ({:?})", alleles.len() - 1, variant.chrom(), - variant.position() + 1 + variant.position() + 1, + variant.alleles() ); } let eidx = if alleles[0].len() + alleles[1].len() <= crate::var32::MAX_COMBINED_LEN {