diff --git a/Cargo.toml b/Cargo.toml index 64ddafa..bb58c37 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "ms2rescore-rs" -version = "0.2.0" +version = "0.2.1" edition = "2021" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html @@ -11,4 +11,4 @@ crate-type = ["cdylib"] [dependencies] pyo3 = "0.20.0" mzdata = "0.20.0" -timsrust = "0.2.4" +timsrust = "0.3.0" diff --git a/src/parse_timsrust.rs b/src/parse_timsrust.rs index 9543548..bf7fc69 100644 --- a/src/parse_timsrust.rs +++ b/src/parse_timsrust.rs @@ -3,20 +3,20 @@ use std::collections::HashMap; use crate::ms2_spectrum::MS2Spectrum; use crate::precursor::Precursor; -impl From for Precursor { - fn from(precursor: timsrust::Precursor) -> Self { +impl From for Precursor { + fn from(precursor: timsrust::ms_data::Precursor) -> Self { Precursor { mz: precursor.mz, rt: precursor.rt, im: precursor.im, - charge: precursor.charge, - intensity: precursor.intensity, + charge: precursor.charge.unwrap_or(0), + intensity: precursor.intensity.unwrap_or(0.0), } } } -impl From for MS2Spectrum { - fn from(spectrum: timsrust::Spectrum) -> Self { +impl From for MS2Spectrum { + fn from(spectrum: timsrust::ms_data::Spectrum) -> Self { MS2Spectrum::new( spectrum.index.to_string(), spectrum.mz_values.iter().map(|mz| *mz as f32).collect(), @@ -25,10 +25,7 @@ impl From for MS2Spectrum { .iter() .map(|intensity| *intensity as f32) .collect(), - match spectrum.precursor { - timsrust::QuadrupoleEvent::Precursor(precursor) => Some(Precursor::from(precursor)), - _ => None, - }, + Some(Precursor::from(spectrum.precursor)), ) } } @@ -46,13 +43,13 @@ pub fn parse_precursor_info( .filter(|spectrum| { matches!( spectrum.precursor, - timsrust::QuadrupoleEvent::Precursor { .. } + timsrust::ms_data::Precursor { .. } ) }) .map(|spectrum| { ( spectrum.index.to_string(), - Precursor::from(spectrum.precursor.unwrap_as_precursor()), + Precursor::from(spectrum.precursor), ) }) .collect::>()) diff --git a/tests/test_lib.py b/tests/test_lib.py index dea310f..7b093c9 100644 --- a/tests/test_lib.py +++ b/tests/test_lib.py @@ -26,7 +26,7 @@ def test_get_precursor_info_bruker_tdf(): assert precursor.charge == 2 assert precursor.intensity == 10 assert precursor.rt == pytest.approx(0.4, 0.001) - assert precursor.im == 1.4989212513484358 + assert precursor.im == 1.25 def test_get_precursor_info_bruker_minitdf():