Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,5 @@ thermo = ["mzdata/thermo"]

[dependencies]
pyo3 = { version = "0.23.3", features = ["anyhow"] }
mzdata = "0.39.0"
mzdata = "0.48.3"
timsrust = "0.4.1"
31 changes: 16 additions & 15 deletions src/parse_mzdata.rs
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ fn get_charge_from_spectrum(spectrum: &mzdata::spectrum::MultiLayerSpectrum) ->
.precursor
.as_ref()
.and_then(|p| p.ions.first())
.and_then(|i| i.charge.map(|c| c as usize))
.and_then(|i| i.charge.map(|c| c.unsigned_abs() as usize))
.or_else(|| {
spectrum
.description
Expand All @@ -98,6 +98,9 @@ fn get_charge_from_spectrum(spectrum: &mzdata::spectrum::MultiLayerSpectrum) ->
fn get_im_from_spectrum_description(
spectrum: &mzdata::spectrum::MultiLayerSpectrum,
) -> Option<f64> {
if let Some(im) = spectrum.ion_mobility() {
return Some(im)
}
spectrum
.description
.params
Expand All @@ -112,21 +115,19 @@ fn get_im_from_spectrum_description(

/// Try to get ion mobility from the selected ion parameters.
fn get_im_from_selected_ion(spectrum: &mzdata::spectrum::MultiLayerSpectrum) -> Option<f64> {
spectrum
.description
.precursor
.as_ref()
.and_then(|p| p.ions.first())
.and_then(|i| i.params.as_ref())
.and_then(|p| {
p.iter()
.find(|p| {
(p.name == "ion_mobility")
|| (p.name == "inverse reduced ion mobility")
|| (p.name == "reverse ion mobility")
})
.and_then(|p| p.value.to_f64().ok())
if let Some(ion) = spectrum.precursor().and_then(|p| p.ions.first()) {
if let Some(im) = ion.ion_mobility() {
return Some(im)
}
ion.params().iter().find(|p| {
(p.name == "ion_mobility")
|| (p.name == "inverse reduced ion mobility")
|| (p.name == "reverse ion mobility")
})
.and_then(|p| p.value.to_f64().ok())
} else {
None
}
}

/// Try to get ion mobility from the first scan parameters.
Expand Down
Loading