diff --git a/Cargo.toml b/Cargo.toml index f3c162a..cbbc6ca 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.4.3" +version = "0.4.4" [[bench]] harness = false diff --git a/bindings/python/Cargo.toml b/bindings/python/Cargo.toml index ce50129..338aff5 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.4.3" #also change version in dependencies below +version = "0.4.4" #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.4.3" +analiticcl = "0.4.4" #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 30dc021..1d1f0e0 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -516,12 +516,26 @@ impl VariantModel { let score = score.unwrap(); let tag: Vec<&str> = match fields.get(2) { - Some(s) => s.split(";").map(|w| w.trim()).collect(), + Some(s) => s.split(";").filter_map(|w| { + let w = w.trim(); + if w.is_empty() { + None + } else { + Some(w) + } + }).collect(), None => Vec::new() }; let mut tagoffset: Vec<&str> = match fields.get(3) { - Some(s) => s.split(";").map(|w| w.trim()).collect(), + Some(s) => s.split(";").filter_map(|w| { + let w = w.trim(); + if w.is_empty() { + None + } else { + Some(w) + } + }).collect(), None => Vec::new() }; @@ -556,7 +570,11 @@ impl VariantModel { } } + let mut errmsg: Option<&str> = None; let tag: Vec = tag.iter().map(|tag| { + if tag.is_empty() { + errmsg = Some("tag is empty"); + } let mut pos = None; for (i, t) in self.tags.iter().enumerate() { if t == tag { @@ -571,6 +589,10 @@ impl VariantModel { pos.unwrap() } }).collect(); + + if let Some(errmsg) = errmsg { + return Err(std::io::Error::new(std::io::ErrorKind::Other, errmsg)); + } let mut error: Option<&str> = None; let mut tagoffset: Vec<(u8,u8)> = tagoffset.iter().map(|s| {