Skip to content

[INTERNAL] OpenSwath diaPASEF Speedup #1

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

Draft
wants to merge 99 commits into
base: develop
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
99 commits
Select commit Hold shift + click to select a range
f29eb55
First attempt at modifying DIA scores
jcharkow Nov 2, 2022
627f807
[TEST] fix tests and bugs with window integration
jcharkow Nov 2, 2022
c13055b
[TEST] fix DIAScoring and DIAPrescoring tests
jcharkow Nov 2, 2022
8417f9b
[TEST] fix tests with new function signatures
jcharkow Nov 3, 2022
eb6074e
[FIX] check boundaries of vector when integrating
jcharkow Nov 3, 2022
74b76af
remove unnccessary files
jcharkow Nov 3, 2022
ef4c2df
[FIX] bug in swathMapMassCorrection
jcharkow Nov 3, 2022
189feab
remove debug print statement
jcharkow Nov 3, 2022
6269a64
[INTERNAL] adapt speedup changes to IM scoring
jcharkow Nov 3, 2022
4ec14fb
[FIX][TEST] OSW 17 test
jcharkow Nov 4, 2022
187a3a4
[INTERNAL] removed unused functions
jcharkow Nov 9, 2022
9bcba37
Merge branch 'develop' into feature/oswSpeedUp
jcharkow Nov 10, 2022
930cc75
[TEST] fix fetchSpectrumSwath() test
jcharkow Nov 10, 2022
5d7da16
[TEST] fix SONAR tests
jcharkow Nov 11, 2022
3e8d226
remove unused variables
jcharkow Nov 11, 2022
a9de4d3
remove files was suppose to ignore
jcharkow Nov 11, 2022
3b6e547
Force returned IM value to be -1
jcharkow Nov 11, 2022
f2917c6
[TEST] updates to tests to include IM
jcharkow Nov 11, 2022
2c7d629
[TEST] rewrite integrate window tests
jcharkow Nov 12, 2022
7015911
Merge branch 'develop' into feature/oswSpeedUp
jcharkow Nov 13, 2022
85989cb
[TEST] fix broken SwathMassMapCorrection test
jcharkow Nov 14, 2022
d561d0c
[TEST] OpenSwathWorkflow test with -add_up_spectra
jcharkow Nov 16, 2022
9b7f374
[TEST] remove test 17_c
jcharkow Nov 17, 2022
de4cd85
Merge branch 'develop' into feature/oswSpeedUp
jcharkow Nov 17, 2022
f9e4ed8
Apply Some suggestions from hroest code review
jcharkow Nov 21, 2022
1690a00
More changes with hroest suggestions
jcharkow Nov 22, 2022
a8afc52
Merge branch 'feature/oswSpeedUp' of github.com:jcharkow/OpenMS into …
jcharkow Nov 22, 2022
a470bf6
[TEST] remove test IM correction on MS1 with no map
jcharkow Nov 22, 2022
4d188ab
[TEST] remove ms1 from OSW test 17
jcharkow Nov 22, 2022
226318c
Apply more hroest suggestions and other minor fixes
jcharkow Nov 23, 2022
7517159
Merge branch 'develop' into feature/oswSpeedUp
jcharkow Nov 23, 2022
008ec14
[TEST][PYOPENMS] fix pyopenms tests
jcharkow Nov 24, 2022
147d4f9
Merge branch 'feature/oswSpeedUp' of github.com:jcharkow/OpenMS into …
jcharkow Nov 24, 2022
36a6bf1
Merge branch 'develop' into feature/oswSpeedUp
jcharkow Nov 29, 2022
23dd79c
Address Hannes suggestions
jcharkow Nov 29, 2022
4f14714
Merge branch 'develop' into feature/oswSpeedUp
jcharkow Dec 19, 2022
94c5daa
Merge branch 'feature/oswSpeedUp' of github.com:jcharkow/OpenMS into …
jcharkow Dec 19, 2022
c500075
[TEST] revert OpenSwathWorkflow_17 test
jcharkow Jan 4, 2023
02f8878
[TEST] enable ms1 ion mobility for OpenSwathTest_23
jcharkow Jan 4, 2023
7906cd6
Merge branch 'develop' of github.com:OpenMS/OpenMS into feature/oswSp…
jcharkow Jan 4, 2023
82fedf9
Replace im and mz boundaries with Range objects
jcharkow Jan 25, 2023
f67ef0a
[TEST] fix tests with new function signatures
jcharkow Jan 26, 2023
bfd79e3
[TEST] fix DIAHelper, IonMobilityScoring, SpectrumHelpers
jcharkow Jan 27, 2023
9edea4c
[TEST] fix failing OpenSwathWorkflow tests
jcharkow Jan 27, 2023
ce7a8c1
Merge branch 'develop' into feature/oswSpeedUp
poshul Feb 14, 2023
54855d4
Address more code suggestions
jcharkow Feb 1, 2023
555ae95
[TEST] add new tests for fetchSpectrumSwath()
jcharkow Feb 13, 2023
999e20f
Address comments
jcharkow Feb 13, 2023
7a0aeb9
[TEST] add tests for DIA scoring functions with IM
jcharkow Feb 13, 2023
b1ca260
Apply more cbielow suggestions
jcharkow Feb 13, 2023
d185ddb
implement constant for "Ion Mobility" description
jcharkow Feb 14, 2023
ad7ad44
Move _fetchMultipleSpectra() ISpectrumAcccess
jcharkow Feb 14, 2023
0833166
[INTERNAL] move functions around
jcharkow Feb 15, 2023
e8dacf9
[pyopenms] fix pyopenms bindings
jcharkow Feb 16, 2023
d37e36e
Code cleanup
jcharkow Apr 4, 2023
68c11cf
[FIX] compile error
jcharkow Apr 4, 2023
ba9e133
Merge branch 'develop' into feature/oswSpeedUp
jcharkow Apr 4, 2023
085a9a5
Update src/openms/include/OpenMS/ANALYSIS/OPENSWATH/OpenSwathScoring.h
cbielow May 17, 2023
b32ee73
Update src/openms/include/OpenMS/ANALYSIS/OPENSWATH/OpenSwathScoring.h
cbielow May 17, 2023
cb32052
Update src/openswathalgo/include/OpenMS/OPENSWATHALGO/DATAACCESS/ISpe…
cbielow May 19, 2023
7655ee7
Update src/openswathalgo/include/OpenMS/OPENSWATHALGO/DATAACCESS/ISpe…
cbielow May 19, 2023
914654c
Merge branch 'develop' into feature/oswSpeedUp
jcharkow Jul 25, 2023
779fbbe
Apply suggestions from code review
jcharkow Jul 25, 2023
4b7543c
Resolve merge conflicts and apply more suggestions
jcharkow Jul 25, 2023
9e8e753
Apply more cbielow suggestions
jcharkow Jul 26, 2023
98b6066
More suggestions
jcharkow Jul 26, 2023
603419a
Merge remote-tracking branch 'origin' into HEAD
jcharkow Aug 24, 2023
3517522
Merge branch 'develop' into feature/oswSpeedUp
jcharkow Aug 25, 2023
ee7bdcb
add openms DLLAPI
jcharkow Aug 26, 2023
ff99108
Merge branch 'feature/oswSpeedUp' of github.com:jcharkow/OpenMS into …
jcharkow Aug 26, 2023
d0eafad
Fix DLLAPI changes
jcharkow Aug 27, 2023
8a2613f
Fix nullptr test
jcharkow Aug 27, 2023
3ff7bac
Add more OPENMS_DLLAPI instances
jcharkow Aug 28, 2023
0c2e11e
Remove OPENMS_DLLAPI
jcharkow Aug 28, 2023
9d1a8b0
remove openms_DLLAPI
jcharkow Aug 28, 2023
ba79e25
Merge branch 'develop' into feature/oswSpeedUp
jpfeuffer Aug 28, 2023
1ac77a6
Update src/openms/include/OpenMS/ANALYSIS/OPENSWATH/DIAHelper.h
jpfeuffer Aug 30, 2023
1610849
Update src/tests/class_tests/openms/source/OpenSwathScoring_test.cpp
jpfeuffer Aug 30, 2023
1801275
Fix python bindings
jcharkow Aug 30, 2023
019595a
Merge remote-tracking branch 'jcharkow/feature/oswSpeedUp' into featu…
jcharkow Aug 30, 2023
9f17158
Merge remote-tracking branch 'origin' into feature/oswSpeedUp_NEW
jcharkow Oct 2, 2023
149a7d2
Merge branch 'develop' into feature/oswSpeedUp
timosachsenberg Oct 4, 2023
ceb19c7
Merge branch 'develop' into feature/oswSpeedUp_NEW
jcharkow Nov 30, 2023
df763f5
[FIX][TEST] fix failing tests because of merge
jcharkow Nov 30, 2023
a10e9fd
[FIX][TEST] fix failing tests in debug mode
jcharkow Nov 30, 2023
8c86429
Speedup spectrum sort by mz
jcharkow Dec 1, 2023
562e281
Merge branch 'develop' into feature/oswSpeedUp
jcharkow Dec 7, 2023
b5d11ba
apply first batch of @cbielow suggestions
jcharkow Dec 15, 2023
6d9642d
address non constant parameters
jcharkow Dec 15, 2023
7ac72b6
apply more suggestions
jcharkow Dec 19, 2023
2d2291a
define SpectrumSequence only in ISpectrumAccess
jcharkow Dec 19, 2023
2f4f908
Apply more suggestions
jcharkow Dec 19, 2023
7423fa4
more suggestions
jcharkow Dec 19, 2023
f64476a
Merge branch 'feature/oswSpeedUp' of github.com:jcharkow/OpenMS into …
jcharkow Dec 19, 2023
8cf7a7a
Merge branch 'develop' into feature/oswSpeedUp
jcharkow Dec 19, 2023
de51549
apply more suggestions
jcharkow Dec 21, 2023
52e966f
Merge branch 'feature/oswSpeedUp' of github.com:jcharkow/OpenMS into …
jcharkow Dec 21, 2023
ceebcb1
Merge branch 'develop' into feature/oswSpeedUp
jcharkow Dec 21, 2023
916d676
Update src/openms/include/OpenMS/ANALYSIS/OPENSWATH/DIAHelper.h
cbielow Dec 22, 2023
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
92 changes: 62 additions & 30 deletions src/openms/include/OpenMS/ANALYSIS/OPENSWATH/DIAHelper.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,61 +10,74 @@

#include <OpenMS/CHEMISTRY/AASequence.h>
#include <OpenMS/OPENSWATHALGO/DATAACCESS/DataStructures.h>

#include <OpenMS/OPENSWATHALGO/DATAACCESS/ISpectrumAccess.h>
#include <vector>

namespace OpenMS
{
struct RangeMZ;
struct RangeMobility;
class TheoreticalSpectrumGenerator;
namespace DIAHelpers
{

/**
@brief Helper functions for the DIA scoring of OpenSWATH
*/
///@{

/**
@brief Integrate intensity in a spectrum from start to end

This function will integrate the intensity in a spectrum between mz_start
and mz_end, returning the total intensity and an intensity-weighted m/z
value.
@brief Integrate intensity in a spectrum from in @p mz_range (and @p im_range if defined)
returning the intensity-weighted m/z and im values as well as the total intensity.

@note If there is no signal, mz will be set to -1 and intensity to 0
@note If there is no signal, @p mz and @p im will be set to -1 and intensity to 0
@return Returns true if a signal was found (and false if no signal was found)

*/
OPENMS_DLLAPI bool integrateWindow(const OpenSwath::SpectrumPtr& spectrum, double mz_start,
double mz_end, double& mz, double& intensity, bool centroided = false);
OPENMS_DLLAPI bool integrateWindow(const OpenSwath::SpectrumPtr& spectrum,
double& mz, double& im, double& intensity, const RangeMZ& mz_range, const RangeMobility& im_range, bool centroided = false);

/**
@brief Integrate intensities in a spectrum from start to end
@brief Integrate intensity in SpectrumSequence in range @p mz_range (and @p im_range if defined)
returning the intensity-weighted m/z and im values as well as the total intensity.

@note If there is no signal, @p mz and @p im will be set to -1 and intensity to 0
@return Returns true if a signal was found (and false if no signal was found)
*/
OPENMS_DLLAPI bool integrateWindow(const SpectrumSequence& spectrum,
double& mz, double& im, double& intensity, const RangeMZ& mz_range, const RangeMobility& im_range, bool centroided = false);

/**
@brief Integrate intensities in a spectrum in range @p im_range (if defined) for multiple windows.
@param windows_center is a vector of the center location of the windows.
@param width is the width of the windows across mz
@param im_range is the range of the IM dimension (if defined)
@param remove_zero is a flag indicating whether to remove zero intensity windows

Returns:
@param[out] integrated_windows_intensity is a vector of the integrated intensity for each window
@param[out] integrated_windows_mz is a vector of the integrated intensity-weighted m/z for each window
@param[out] integrated_windows_im is a vector of the integrated intensity-weighted im for each window
*/
OPENMS_DLLAPI void integrateWindows(const OpenSwath::SpectrumPtr& spectrum, //!< [in] Spectrum
const std::vector<double>& windows_center, //!< [in] center location
double width,
std::vector<double>& integrated_windows_intensity,
std::vector<double>& integrated_windows_mz,
std::vector<double>& integrated_windows_im,
const RangeMobility& im_range,
bool remove_zero = false);

/**
@brief Integrate intensity in an ion mobility spectrum from start to end

This function will integrate the intensity in a spectrum between mz_start
and mz_end, returning the total intensity and an intensity-weighted drift
time value.

@note If there is no signal, mz will be set to -1 and intensity to 0
/**
@brief Integrate intensities of a SpectrumSequence in range @p im_range for multiple windows.
*/
OPENMS_DLLAPI void integrateDriftSpectrum(const OpenSwath::SpectrumPtr& spectrum,
double mz_start,
double mz_end,
double & im,
double & intensity,
double drift_start,
double drift_end);

OPENMS_DLLAPI void integrateWindows(const SpectrumSequence& spectrum, //!< [in] Spectrum
const std::vector<double>& windows_center, //!< [in] center location
double width,
std::vector<double>& integrated_windows_intensity,
std::vector<double>& integrated_windows_mz,
std::vector<double>& integrated_windows_im,
const RangeMobility& im_range,
bool remove_zero = false);
/**
@brief Adjust left/right window based on window and whether its ppm or not
*/
Expand Down Expand Up @@ -136,8 +149,27 @@ namespace OpenMS
OPENMS_DLLAPI void extractFirst(const std::vector<std::pair<double, double> >& peaks, std::vector<double>& mass);
/// extract second from vector of pairs
OPENMS_DLLAPI void extractSecond(const std::vector<std::pair<double, double> >& peaks, std::vector<double>& mass);


/** @brief optionally convert a DIA extraction window from ppm to m/z
@param dia_extraction_window - how wide the extraction window is total (can be in m/z or ppm)
@param ppm - whether the extraction window is in ppm or not
@return the extraction window in m/z
*/
OPENMS_DLLAPI RangeMZ createMZRangePPM(double mz_ref, double dia_extraction_window, const bool ppm);


/**
@brief Helper function for integrating a spectrum.
*/
OPENMS_DLLAPI void integrateWindow_(const OpenSwath::SpectrumPtr& spectrum,
double & mz,
double & im,
double & intensity,
const RangeMZ & mz_range,
const RangeMobility & im_range,
bool centroided);
}

///}@
}
}
} //namespace OpenMS

6 changes: 4 additions & 2 deletions src/openms/include/OpenMS/ANALYSIS/OPENSWATH/DIAPrescoring.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
#include <OpenMS/OPENSWATHALGO/DATAACCESS/TransitionExperiment.h>

#include <OpenMS/DATASTRUCTURES/DefaultParamHandler.h>
#include <OpenMS/ANALYSIS/OPENSWATH/DIAHelper.h>

namespace OpenMS
{
Expand Down Expand Up @@ -53,8 +54,9 @@ namespace OpenMS
and compute manhattan distance and dotprod score between spectrum intensities
and simulated spectrum.
*/
void score(OpenSwath::SpectrumPtr spec,
void score(const SpectrumSequence& spec,
const std::vector<OpenSwath::LightTransition>& lt,
const RangeMobility& im_range,
double& dotprod,
double& manhattan) const;

Expand All @@ -63,7 +65,7 @@ namespace OpenMS
the SpectrumAccessPtr for all transitions groups in the LightTargetedExperiment.
*/
void operator()(const OpenSwath::SpectrumAccessPtr& swath_ptr,
OpenSwath::LightTargetedExperiment& transition_exp_used,
OpenSwath::LightTargetedExperiment& transition_exp_used, const RangeMobility& range_im,
OpenSwath::IDataFrameWriter* ivw) const;
};

Expand Down
39 changes: 21 additions & 18 deletions src/openms/include/OpenMS/ANALYSIS/OPENSWATH/DIAScoring.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@
#include <OpenMS/OPENSWATHALGO/DATAACCESS/ITransition.h>
#include <OpenMS/OPENSWATHALGO/DATAACCESS/TransitionExperiment.h>

#include <OpenMS/KERNEL/RangeManager.h>

namespace OpenMS
{
class TheoreticalSpectrumGenerator;
Expand Down Expand Up @@ -82,15 +84,17 @@ namespace OpenMS
//@{
/// Isotope scores, see class description
void dia_isotope_scores(const std::vector<TransitionType>& transitions,
SpectrumPtrType spectrum,
SpectrumSequence& spectrum,
OpenSwath::IMRMFeature* mrmfeature,
const RangeMobility& im_range,
double& isotope_corr,
double& isotope_overlap) const;

/// Massdiff scores, see class description
void dia_massdiff_score(const std::vector<TransitionType>& transitions,
const SpectrumPtrType& spectrum,
const SpectrumSequence& spectrum,
const std::vector<double>& normalized_library_intensity,
const RangeMobility& im_range,
double& ppm_score,
double& ppm_score_weighted,
std::vector<double>& diff_ppm) const;
Expand All @@ -103,23 +107,23 @@ namespace OpenMS
@param ppm_score Resulting score
@return False if no signal was found (and no sensible score calculated), true otherwise
*/
bool dia_ms1_massdiff_score(double precursor_mz, SpectrumPtrType spectrum,
bool dia_ms1_massdiff_score(double precursor_mz, const SpectrumSequence& spectrum, const RangeMobility& im_range,
double& ppm_score) const;

/// Precursor isotope scores for precursors (peptides and metabolites)
void dia_ms1_isotope_scores_averagine(double precursor_mz, const SpectrumPtrType& spectrum,
double& isotope_corr, double& isotope_overlap, int charge_state) const;
void dia_ms1_isotope_scores(double precursor_mz, const SpectrumPtrType& spectrum,
void dia_ms1_isotope_scores_averagine(double precursor_mz, const SpectrumSequence& spectrum, int charge_state, RangeMobility& im_range,
double& isotope_corr, double& isotope_overlap) const;
void dia_ms1_isotope_scores(double precursor_mz, const std::vector<SpectrumPtrType>& spectrum, RangeMobility& im_range,
double& isotope_corr, double& isotope_overlap, const EmpiricalFormula& sum_formula) const;


/// b/y ion scores
void dia_by_ion_score(const SpectrumPtrType& spectrum, AASequence& sequence,
int charge, double& bseries_score, double& yseries_score) const;
void dia_by_ion_score(const SpectrumSequence& spectrum, AASequence& sequence,
int charge, const RangeMobility& im_range, double& bseries_score, double& yseries_score) const;

/// Dotproduct / Manhattan score with theoretical spectrum
void score_with_isotopes(SpectrumPtrType spectrum,
void score_with_isotopes(SpectrumSequence& spectrum,
const std::vector<TransitionType>& transitions,
const RangeMobility& im_range,
double& dotprod,
double& manhattan) const;
//@}
Expand All @@ -137,8 +141,9 @@ namespace OpenMS

/// Subfunction of dia_isotope_scores
void diaIsotopeScoresSub_(const std::vector<TransitionType>& transitions,
const SpectrumPtrType& spectrum,
const SpectrumSequence& spectrum,
std::map<std::string, double>& intensities,
const RangeMobility& im_range,
double& isotope_corr,
double& isotope_overlap) const;

Expand All @@ -152,8 +157,8 @@ namespace OpenMS
private:

/**
@brief Determine whether the current m/z value is a monoisotopic peak
@brief Determine whether the current m/z value is a monoisotopic peak

This function will try to determine whether the current peak is a
monoisotopic peak or not. It will do so by searching for an intense peak
at a lower m/z that could explain the current peak as part of a isotope
Expand All @@ -166,7 +171,7 @@ namespace OpenMS
@param nr_occurrences Will contain the maximum ratio of a peaks intensity compared to the monoisotopic peak intensity how often a peak is found at lower m/z than mono_mz with an intensity higher than mono_int. Multiple charge states are tested, see class parameter dia_nr_charges_

*/
void largePeaksBeforeFirstIsotope_(const SpectrumPtrType& spectrum, double mono_mz, double mono_int, int& nr_occurrences, double& max_ratio) const;
void largePeaksBeforeFirstIsotope_(const SpectrumSequence& spectrum, double mono_mz, double mono_int, int& nr_occurrences, double& max_ratio, const RangeMobility& im_range) const;

/**
@brief Compare an experimental isotope pattern to a theoretical one
Expand Down Expand Up @@ -202,9 +207,8 @@ namespace OpenMS

/// Get the intensities of isotopes around @p precursor_mz in experimental @p spectrum
/// and fill @p isotopes_int.
void getIsotopeIntysFromExpSpec_(double precursor_mz, const SpectrumPtrType& spectrum,
std::vector<double>& isotopes_int,
int charge_state) const;
void getIsotopeIntysFromExpSpec_(double precursor_mz, const SpectrumSequence& spectrum, int charge_state, const RangeMobility& im_range,
std::vector<double>& isotopes_int) const;

// Parameters
double dia_extract_window_;
Expand All @@ -219,4 +223,3 @@ namespace OpenMS
TheoreticalSpectrumGenerator * generator;
};
}

Loading