Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feat/ims lfq #166

Open
wants to merge 11 commits into
base: master
Choose a base branch
from
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [v0.15.0-alpha] (unreleased)
### Added
- Initial support for LFQ on data with ion mobility.
- Speedup on the generation of databases when large number of peptides are redundant.
- Initial support for searching diaPASEF data
- `override_precursor_charge` setting that forces multiple charge states to be searched
### Breaking Changes
Expand Down
11 changes: 11 additions & 0 deletions crates/sage-cli/src/input.rs
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ pub struct LfqOptions {
pub integration: Option<sage_core::lfq::IntegrationStrategy>,
pub spectral_angle: Option<f64>,
pub ppm_tolerance: Option<f32>,
pub mobility_pct_tolerance: Option<f32>,
pub combine_charge_states: Option<bool>,
}

Expand All @@ -91,13 +92,22 @@ impl From<LfqOptions> for LfqSettings {
integration: value.integration.unwrap_or(default.integration),
spectral_angle: value.spectral_angle.unwrap_or(default.spectral_angle).abs(),
ppm_tolerance: value.ppm_tolerance.unwrap_or(default.ppm_tolerance).abs(),
mobility_pct_tolerance: value
.mobility_pct_tolerance
.unwrap_or(default.mobility_pct_tolerance),
combine_charge_states: value
.combine_charge_states
.unwrap_or(default.combine_charge_states),
};
if settings.ppm_tolerance > 20.0 {
log::warn!("lfq_settings.ppm_tolerance is higher than expected");
}
if settings.mobility_pct_tolerance > 4.0 {
log::warn!("lfq_settings.mobility_pct_tolerance is higher than expected");
}
if settings.mobility_pct_tolerance < 0.05 {
log::warn!("lfq_settings.mobility_pct_tolerance is smaller than expected");
}
if settings.spectral_angle < 0.50 {
log::warn!("lfq_settings.spectral_angle is lower than expected");
}
Expand Down Expand Up @@ -221,6 +231,7 @@ impl Input {
fn check_tolerances(tolerance: &Tolerance) {
let (lo, hi) = match tolerance {
Tolerance::Ppm(lo, hi) => (*lo, *hi),
Tolerance::Pct(_, _) => unreachable!("Pct tolerance should never be used on mz"),
Tolerance::Da(lo, hi) => (*lo, *hi),
};
if hi.abs() > lo.abs() {
Expand Down
58 changes: 54 additions & 4 deletions crates/sage-cli/src/output.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
use rayon::prelude::*;
use sage_core::spectrum::ProcessedSpectrum;
use sage_core::spectrum::MS1Spectra;
use sage_core::{scoring::Feature, tmt::TmtQuant};

#[derive(Default)]
pub struct SageResults {
pub ms1: Vec<ProcessedSpectrum>,
pub ms1: MS1Spectra,
pub features: Vec<Feature>,
pub quant: Vec<TmtQuant>,
}
Expand All @@ -19,7 +19,34 @@ impl FromParallelIterator<SageResults> for SageResults {
.reduce(SageResults::default, |mut acc, x| {
acc.features.extend(x.features);
acc.quant.extend(x.quant);
acc.ms1.extend(x.ms1);
match (acc.ms1, x.ms1) {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we can make this a "method" for the enum instead of being here, and repeated with the serial implementation.

(MS1Spectra::NoMobility(mut a), MS1Spectra::NoMobility(b)) => {
a.extend(b);
acc.ms1 = MS1Spectra::NoMobility(a);
}
(MS1Spectra::WithMobility(mut a), MS1Spectra::WithMobility(b)) => {
a.extend(b);
acc.ms1 = MS1Spectra::WithMobility(a);
}
(MS1Spectra::Empty, MS1Spectra::Empty) => {
acc.ms1 = MS1Spectra::Empty;
}
(MS1Spectra::Empty, MS1Spectra::WithMobility(a))
| (MS1Spectra::WithMobility(a), MS1Spectra::Empty) => {
acc.ms1 = MS1Spectra::WithMobility(a);
}
(MS1Spectra::Empty, MS1Spectra::NoMobility(a))
| (MS1Spectra::NoMobility(a), MS1Spectra::Empty) => {
acc.ms1 = MS1Spectra::NoMobility(a);
}
_ => {
// In theory this can happen if someone is searching
// together files of different types, mixing the ones
// that support IMS and the ones that dont.
// ... I dont think this should be run-time recoverable.
unreachable!("Found combination of MS1 spectra with and without mobility.")
}
};
acc
})
}
Expand All @@ -35,7 +62,30 @@ impl FromIterator<SageResults> for SageResults {
.fold(SageResults::default(), |mut acc, x| {
acc.features.extend(x.features);
acc.quant.extend(x.quant);
acc.ms1.extend(x.ms1);
match (acc.ms1, x.ms1) {
(MS1Spectra::NoMobility(mut a), MS1Spectra::NoMobility(b)) => {
a.extend(b);
acc.ms1 = MS1Spectra::NoMobility(a);
}
(MS1Spectra::WithMobility(mut a), MS1Spectra::WithMobility(b)) => {
a.extend(b);
acc.ms1 = MS1Spectra::WithMobility(a);
}
(MS1Spectra::Empty, MS1Spectra::Empty) => {
acc.ms1 = MS1Spectra::Empty;
}
(MS1Spectra::Empty, MS1Spectra::WithMobility(a))
| (MS1Spectra::WithMobility(a), MS1Spectra::Empty) => {
acc.ms1 = MS1Spectra::WithMobility(a);
}
(MS1Spectra::Empty, MS1Spectra::NoMobility(a))
| (MS1Spectra::NoMobility(a), MS1Spectra::Empty) => {
acc.ms1 = MS1Spectra::NoMobility(a);
}
_ => {
unreachable!("Found combination of MS1 spectra with and without mobility.")
}
};
acc
})
}
Expand Down
Loading