Skip to content

Commit fbfa71e

Browse files
committed
feat: add override_precursor_charge setting (#137)
1 parent 9ed046d commit fbfa71e

File tree

6 files changed

+12
-3
lines changed

6 files changed

+12
-3
lines changed

Diff for: CHANGELOG.md

+1
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
77
## [v0.15.0-alpha] (unreleased)
88
### Added
99
- Initial support for searching diaPASEF data
10+
- `override_precursor_charge` setting that forces multiple charge states to be searched
1011
### Breaking Changes
1112
- `precursor_ppm` field reports the non-absoluted average mass error, rather than the absoluted average mass error.
1213
- Don't deisotope reporter ion regions if MS2-based TMT/iTRAQ is used

Diff for: Cargo.lock

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Diff for: crates/sage-cli/src/input.rs

+3
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ pub struct Search {
1818
pub precursor_tol: Tolerance,
1919
pub fragment_tol: Tolerance,
2020
pub precursor_charge: (u8, u8),
21+
pub override_precursor_charge: bool,
2122
pub isotope_errors: (i8, i8),
2223
pub deisotope: bool,
2324
pub chimera: bool,
@@ -55,6 +56,7 @@ pub struct Input {
5556
max_fragment_charge: Option<u8>,
5657
min_matched_peaks: Option<u16>,
5758
precursor_charge: Option<(u8, u8)>,
59+
override_precursor_charge: Option<bool>,
5860
isotope_errors: Option<(i8, i8)>,
5961
deisotope: Option<bool>,
6062
quant: Option<QuantOptions>,
@@ -298,6 +300,7 @@ impl Input {
298300
max_fragment_charge: self.max_fragment_charge,
299301
annotate_matches: self.annotate_matches.unwrap_or(false),
300302
precursor_charge: self.precursor_charge.unwrap_or((2, 4)),
303+
override_precursor_charge: self.override_precursor_charge.unwrap_or(false),
301304
isotope_errors: self.isotope_errors.unwrap_or((0, 0)),
302305
deisotope: self.deisotope.unwrap_or(true),
303306
chimera: self.chimera.unwrap_or(false),

Diff for: crates/sage-cli/src/main.rs

+1
Original file line numberDiff line numberDiff line change
@@ -262,6 +262,7 @@ impl Runner {
262262
max_isotope_err: self.parameters.isotope_errors.1,
263263
min_precursor_charge: self.parameters.precursor_charge.0,
264264
max_precursor_charge: self.parameters.precursor_charge.1,
265+
override_precursor_charge: self.parameters.override_precursor_charge,
265266
max_fragment_charge: self.parameters.max_fragment_charge,
266267
chimera: self.parameters.chimera,
267268
report_psms: self.parameters.report_psms,

Diff for: crates/sage-cli/tests/integration.rs

+1
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ fn integration() -> anyhow::Result<()> {
2626
max_isotope_err: 3,
2727
min_precursor_charge: 2,
2828
max_precursor_charge: 4,
29+
override_precursor_charge: false,
2930
max_fragment_charge: Some(1),
3031
chimera: false,
3132
report_psms: 1,

Diff for: crates/sage/src/scoring.rs

+5-2
Original file line numberDiff line numberDiff line change
@@ -182,6 +182,7 @@ pub struct Scorer<'db> {
182182
pub max_isotope_err: i8,
183183
pub min_precursor_charge: u8,
184184
pub max_precursor_charge: u8,
185+
pub override_precursor_charge: bool,
185186
pub max_fragment_charge: Option<u8>,
186187
pub chimera: bool,
187188
pub report_psms: usize,
@@ -346,12 +347,14 @@ impl<'db> Scorer<'db> {
346347
);
347348
self.trim_hits(&mut hits);
348349
hits
349-
} else if let Some(charge) = precursor.charge {
350+
} else if precursor.charge.is_some() && self.override_precursor_charge == false {
351+
let charge = precursor.charge.unwrap();
350352
// Charge state is already annotated for this precusor, only search once
351353
let precursor_mass = mz * charge as f32;
352354
self.matched_peaks(query, precursor_mass, charge, self.precursor_tol)
353355
} else {
354-
// Not all selected ion precursors have charge states annotated -
356+
// Not all selected ion precursors have charge states annotated (or user has set
357+
// `override_precursor_charge`)
355358
// assume it could be z=2, z=3, z=4 and search all three
356359
let mut hits = (self.min_precursor_charge..=self.max_precursor_charge).fold(
357360
InitialHits::default(),

0 commit comments

Comments
 (0)