Skip to content

Commit

Permalink
Update to timsrust 0.3.0
Browse files Browse the repository at this point in the history
  • Loading branch information
RalfG committed Jul 16, 2024
1 parent 25717ba commit 4be43f1
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 15 deletions.
4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -11,4 +11,4 @@ crate-type = ["cdylib"]
[dependencies]
pyo3 = "0.20.0"
mzdata = "0.20.0"
timsrust = "0.2.4"
timsrust = "0.3.0"
21 changes: 9 additions & 12 deletions src/parse_timsrust.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,20 @@ use std::collections::HashMap;
use crate::ms2_spectrum::MS2Spectrum;
use crate::precursor::Precursor;

impl From<timsrust::Precursor> for Precursor {
fn from(precursor: timsrust::Precursor) -> Self {
impl From<timsrust::ms_data::Precursor> 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<timsrust::Spectrum> for MS2Spectrum {
fn from(spectrum: timsrust::Spectrum) -> Self {
impl From<timsrust::ms_data::Spectrum> 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(),
Expand All @@ -25,10 +25,7 @@ impl From<timsrust::Spectrum> 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)),
)
}
}
Expand All @@ -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::<HashMap<String, Precursor>>())
Expand Down
2 changes: 1 addition & 1 deletion tests/test_lib.py
Original file line number Diff line number Diff line change
Expand Up @@ -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():
Expand Down

0 comments on commit 4be43f1

Please sign in to comment.