From e7539413c5a633fdee53a7c9a4d65b42dca16024 Mon Sep 17 00:00:00 2001 From: Maarten van Gompel Date: Wed, 2 Feb 2022 14:59:35 +0100 Subject: [PATCH] fix auto-detection of frequency information in parsing variant lists --- Cargo.toml | 2 +- bindings/python/Cargo.toml | 4 ++-- src/lib.rs | 10 ++++++---- 3 files changed, 9 insertions(+), 7 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index b35f4f1..0b02d1f 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -10,7 +10,7 @@ license = "GPL-3.0+" name = "analiticcl" readme = "README.md" repository = "https://github.com/proycon/analiticcl" -version = "0.3.1" +version = "0.3.2" [[bench]] harness = false diff --git a/bindings/python/Cargo.toml b/bindings/python/Cargo.toml index 9dbe29b..37cabca 100644 --- a/bindings/python/Cargo.toml +++ b/bindings/python/Cargo.toml @@ -9,7 +9,7 @@ license = "GPL-3.0+" name = "analiticcl-python" readme = "README.md" repository = "https://github.com/proycon/analiticcl" -version = "0.3.1" #also change version in dependencies below +version = "0.3.2" #also change version in dependencies below [lib] name = "analiticcl" @@ -18,7 +18,7 @@ crate-type = ["cdylib"] [dependencies] pyo3 = "0.13.2" rayon = "1.5.0" -analiticcl = "0.3.1" +analiticcl = "0.3.2" #compile against version in same repo: (doesn't work when building with maturin for pypi) #[dependencies.analiticcl] diff --git a/src/lib.rs b/src/lib.rs index 537a511..0606710 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -521,9 +521,11 @@ impl VariantModel { //autodetect whether we have frequency information or not if (fields.len() - 2) % 3 == 0 { let freq = fields.get(1).expect("second field"); - has_freq = Some(true); match freq.parse::() { - Ok(freq) => Some(freq), + Ok(freq) => { + has_freq = Some(true); + Some(freq) + }, _ => None } } else { @@ -543,7 +545,7 @@ impl VariantModel { if has_freq == Some(true) { iter.next(); iter.next(); while let (Some(variant), Some(score), Some(freq)) = (iter.next(), iter.next(), iter.next()) { - let score = score.parse::().expect(format!("Variant scores must be a floating point value (line {} of {})", linenr, filename).as_str()); + let score = score.parse::().expect(format!("Variant scores must be a floating point value (line {} of {}, got {} instead), also parsing frequency", linenr, filename, score).as_str()); let freq = freq.parse::().expect(format!("Variant frequency must be an integer (line {} of {}), got {} instead", linenr, filename, freq).as_str()); if self.add_variant(ref_id, variant, score, Some(freq), if transparent { &transparent_params } else { ¶ms } ) { count += 1; @@ -552,7 +554,7 @@ impl VariantModel { } else { iter.next(); while let (Some(variant), Some(score)) = (iter.next(), iter.next()) { - let score = score.parse::().expect(format!("Variant scores must be a floating point value (line {} of {})", linenr, filename).as_str()); + let score = score.parse::().expect(format!("Variant scores must be a floating point value (line {} of {}, got {}), no frequency information", linenr, filename, score).as_str()); if self.add_variant(ref_id, variant, score, None, if transparent { &transparent_params } else { ¶ms } ) { count += 1; }