Skip to content

Commit

Permalink
feat: add override_precursor_charge setting (#137)
Browse files Browse the repository at this point in the history
  • Loading branch information
lazear committed Jul 25, 2024
1 parent 9ed046d commit fbfa71e
Show file tree
Hide file tree
Showing 6 changed files with 12 additions and 3 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
## [v0.15.0-alpha] (unreleased)
### Added
- Initial support for searching diaPASEF data
- `override_precursor_charge` setting that forces multiple charge states to be searched
### Breaking Changes
- `precursor_ppm` field reports the non-absoluted average mass error, rather than the absoluted average mass error.
- Don't deisotope reporter ion regions if MS2-based TMT/iTRAQ is used
Expand Down
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions crates/sage-cli/src/input.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ pub struct Search {
pub precursor_tol: Tolerance,
pub fragment_tol: Tolerance,
pub precursor_charge: (u8, u8),
pub override_precursor_charge: bool,
pub isotope_errors: (i8, i8),
pub deisotope: bool,
pub chimera: bool,
Expand Down Expand Up @@ -55,6 +56,7 @@ pub struct Input {
max_fragment_charge: Option<u8>,
min_matched_peaks: Option<u16>,
precursor_charge: Option<(u8, u8)>,
override_precursor_charge: Option<bool>,
isotope_errors: Option<(i8, i8)>,
deisotope: Option<bool>,
quant: Option<QuantOptions>,
Expand Down Expand Up @@ -298,6 +300,7 @@ impl Input {
max_fragment_charge: self.max_fragment_charge,
annotate_matches: self.annotate_matches.unwrap_or(false),
precursor_charge: self.precursor_charge.unwrap_or((2, 4)),
override_precursor_charge: self.override_precursor_charge.unwrap_or(false),
isotope_errors: self.isotope_errors.unwrap_or((0, 0)),
deisotope: self.deisotope.unwrap_or(true),
chimera: self.chimera.unwrap_or(false),
Expand Down
1 change: 1 addition & 0 deletions crates/sage-cli/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -262,6 +262,7 @@ impl Runner {
max_isotope_err: self.parameters.isotope_errors.1,
min_precursor_charge: self.parameters.precursor_charge.0,
max_precursor_charge: self.parameters.precursor_charge.1,
override_precursor_charge: self.parameters.override_precursor_charge,
max_fragment_charge: self.parameters.max_fragment_charge,
chimera: self.parameters.chimera,
report_psms: self.parameters.report_psms,
Expand Down
1 change: 1 addition & 0 deletions crates/sage-cli/tests/integration.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ fn integration() -> anyhow::Result<()> {
max_isotope_err: 3,
min_precursor_charge: 2,
max_precursor_charge: 4,
override_precursor_charge: false,
max_fragment_charge: Some(1),
chimera: false,
report_psms: 1,
Expand Down
7 changes: 5 additions & 2 deletions crates/sage/src/scoring.rs
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,7 @@ pub struct Scorer<'db> {
pub max_isotope_err: i8,
pub min_precursor_charge: u8,
pub max_precursor_charge: u8,
pub override_precursor_charge: bool,
pub max_fragment_charge: Option<u8>,
pub chimera: bool,
pub report_psms: usize,
Expand Down Expand Up @@ -346,12 +347,14 @@ impl<'db> Scorer<'db> {
);
self.trim_hits(&mut hits);
hits
} else if let Some(charge) = precursor.charge {
} else if precursor.charge.is_some() && self.override_precursor_charge == false {
let charge = precursor.charge.unwrap();
// Charge state is already annotated for this precusor, only search once
let precursor_mass = mz * charge as f32;
self.matched_peaks(query, precursor_mass, charge, self.precursor_tol)
} else {
// Not all selected ion precursors have charge states annotated -
// Not all selected ion precursors have charge states annotated (or user has set
// `override_precursor_charge`)
// assume it could be z=2, z=3, z=4 and search all three
let mut hits = (self.min_precursor_charge..=self.max_precursor_charge).fold(
InitialHits::default(),
Expand Down

0 comments on commit fbfa71e

Please sign in to comment.