Skip to content

Commit

Permalink
fix auto-detection of frequency information in parsing variant lists
Browse files Browse the repository at this point in the history
  • Loading branch information
proycon committed Feb 2, 2022
1 parent 7fc1498 commit e753941
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 7 deletions.
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions bindings/python/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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]
Expand Down
10 changes: 6 additions & 4 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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::<u32>() {
Ok(freq) => Some(freq),
Ok(freq) => {
has_freq = Some(true);
Some(freq)
},
_ => None
}
} else {
Expand All @@ -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::<f64>().expect(format!("Variant scores must be a floating point value (line {} of {})", linenr, filename).as_str());
let score = score.parse::<f64>().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::<u32>().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 { &params } ) {
count += 1;
Expand All @@ -552,7 +554,7 @@ impl VariantModel {
} else {
iter.next();
while let (Some(variant), Some(score)) = (iter.next(), iter.next()) {
let score = score.parse::<f64>().expect(format!("Variant scores must be a floating point value (line {} of {})", linenr, filename).as_str());
let score = score.parse::<f64>().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 { &params } ) {
count += 1;
}
Expand Down

0 comments on commit e753941

Please sign in to comment.