Skip to content

Commit

Permalink
pre-allocate variable vectors for fasteval so they don't move
Browse files Browse the repository at this point in the history
this was causing bugs where the expression values were not filled
correctly for each variant because the addresses were changed.
  • Loading branch information
brentp committed Mar 15, 2022
1 parent 00baa1f commit f0017e4
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 5 deletions.
4 changes: 4 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
@@ -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)
Expand Down
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -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
Expand Down
4 changes: 2 additions & 2 deletions src/commands/annotate_cmd.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
5 changes: 3 additions & 2 deletions src/lib/echtvar.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down

0 comments on commit f0017e4

Please sign in to comment.