-
Notifications
You must be signed in to change notification settings - Fork 5
Precomputation for DIAScoring and DIAHelper #99
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
base: develop
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -36,6 +36,7 @@ | |
|
|
||
| #include <OpenMS/CHEMISTRY/AASequence.h> | ||
| #include <OpenMS/OPENSWATHALGO/DATAACCESS/DataStructures.h> | ||
| #include <OpenMS/FILTERING/DATAREDUCTION/IsotopeDistributionCache.h> | ||
|
|
||
| #include <vector> | ||
|
|
||
|
|
@@ -110,14 +111,16 @@ namespace OpenMS | |
| UInt charge = 1u); | ||
|
|
||
| /// get averagine distribution given mass | ||
| OPENMS_DLLAPI void getAveragineIsotopeDistribution(const double product_mz, | ||
| std::vector<std::pair<double, double> >& isotopesSpec, | ||
| const double charge = 1., | ||
| const int nr_isotopes = 4, | ||
| const double mannmass = 1.00048); | ||
| OPENMS_DLLAPI void getAveragineIsotopeDistribution(IsotopeDistributionCache& iso, | ||
| const double product_mz, | ||
| std::vector<std::pair<double, double> >& isotopesSpec, | ||
| const double charge = 1., | ||
| const int nr_isotopes = 4, | ||
| const double mannmass = 1.00048); | ||
|
|
||
| /// simulate spectrum from AASequence | ||
| OPENMS_DLLAPI void simulateSpectrumFromAASequence(const AASequence& aa, | ||
| OPENMS_DLLAPI void simulateSpectrumFromAASequence(IsotopeDistributionCache& iso, | ||
| const AASequence& aa, | ||
|
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. it is probably a bit more intuitive to swap argument 1 and 2... because AASequence is the primary input |
||
| std::vector<double>& firstIsotopeMasses, //[out] | ||
| std::vector<std::pair<double, double> >& isotopeMasses, //[out] | ||
| TheoreticalSpectrumGenerator const * g, | ||
|
|
@@ -137,7 +140,7 @@ namespace OpenMS | |
| double charge = 1.); | ||
|
|
||
| /// given an experimental spectrum add isotope pattern. | ||
| OPENMS_DLLAPI void addIsotopes2Spec(const std::vector<std::pair<double, double> >& spec, | ||
| OPENMS_DLLAPI void addIsotopes2Spec(IsotopeDistributionCache& iso, const std::vector<std::pair<double, double> >& spec, | ||
| std::vector<std::pair<double, double> >& isotopeMasses, //[out] | ||
| double charge = 1.); | ||
|
|
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -44,6 +44,7 @@ | |
| #include <OpenMS/OPENSWATHALGO/DATAACCESS/TransitionExperiment.h> | ||
|
|
||
| #include <OpenMS/DATASTRUCTURES/DefaultParamHandler.h> | ||
| #include <OpenMS/ANALYSIS/OPENSWATH/DIAScoring.h> | ||
|
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. no need for this header. |
||
|
|
||
| namespace OpenMS | ||
| { | ||
|
|
@@ -84,7 +85,8 @@ namespace OpenMS | |
| and compute manhattan distance and dotprod score between spectrum intensities | ||
| and simulated spectrum. | ||
| */ | ||
| void score(OpenSwath::SpectrumPtr spec, | ||
| void score(IsotopeDistributionCache& iso, | ||
| OpenSwath::SpectrumPtr spec, | ||
| const std::vector<OpenSwath::LightTransition>& lt, | ||
| double& dotprod, | ||
| double& manhattan); | ||
|
|
@@ -93,7 +95,8 @@ namespace OpenMS | |
| @brief Compute manhattan and dotprod score for all spectra which can be accessed by | ||
| the SpectrumAccessPtr for all transitions groups in the LightTargetedExperiment. | ||
| */ | ||
| void operator()(OpenSwath::SpectrumAccessPtr swath_ptr, | ||
| void operator()(IsotopeDistributionCache& iso, | ||
| OpenSwath::SpectrumAccessPtr swath_ptr, | ||
| OpenSwath::LightTargetedExperiment& transition_exp_used, | ||
| OpenSwath::IDataFrameWriter* ivw); | ||
| }; | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -36,6 +36,7 @@ | |
|
|
||
| #include <OpenMS/KERNEL/StandardTypes.h> | ||
| #include <OpenMS/TRANSFORMATIONS/FEATUREFINDER/FeatureFinderAlgorithmPickedHelperStructs.h> | ||
| #include <OpenMS/CHEMISTRY/ISOTOPEDISTRIBUTION/IsotopeDistribution.h> | ||
|
|
||
| namespace OpenMS | ||
| { | ||
|
|
@@ -47,16 +48,37 @@ namespace OpenMS | |
| public: | ||
| typedef FeatureFinderAlgorithmPickedHelperStructs::TheoreticalIsotopePattern TheoreticalIsotopePattern; | ||
|
|
||
| IsotopeDistributionCache(double max_mass, double mass_window_width, double intensity_percentage = 0, double intensity_percentage_optional = 0); | ||
| /// @name Constructors and Destructors | ||
| //@{ | ||
| /** Default constructor | ||
| */ | ||
| IsotopeDistributionCache(); | ||
|
|
||
| /// Destructor | ||
| ~IsotopeDistributionCache() = default; | ||
| //@} | ||
|
|
||
|
|
||
| void precalculateDistributionCache(Size num_begin, Size index); | ||
|
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. can you document what the function does and what the parameters mean? |
||
|
|
||
| void renormalize( TheoreticalIsotopePattern& isotopes, IsotopeDistribution& isotope_dist); | ||
|
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. docs here as well please |
||
|
|
||
| /// Returns the isotope distribution for a certain mass window | ||
| const TheoreticalIsotopePattern & getIsotopeDistribution(double mass) const; | ||
| const TheoreticalIsotopePattern& getIsotopeDistribution(double mass) ; | ||
|
|
||
| const IsotopeDistribution& getIntensity(double mass); | ||
|
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this is not really an intensity which is returned here, right? |
||
|
|
||
| private: | ||
| /// Vector of pre-calculated isotope distributions for several mass windows | ||
| std::vector<TheoreticalIsotopePattern> isotope_distributions_; | ||
|
|
||
| std::vector<IsotopeDistribution> distribution_cache_; | ||
|
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. can you document the four members? |
||
|
|
||
| double mass_window_width_; | ||
|
|
||
| double intensity_percentage_ ; | ||
|
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. what is the |
||
|
|
||
| double intensity_percentage_optional_; | ||
| }; | ||
| } | ||
| }//namespace OpenMS | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -42,6 +42,9 @@ | |
| #include <OpenMS/KERNEL/MSSpectrum.h> | ||
| #include <OpenMS/KERNEL/MSExperiment.h> | ||
|
|
||
| #include <OpenMS/FILTERING/DATAREDUCTION/IsotopeDistributionCache.h> | ||
| #include <include/OpenMS/ANALYSIS/OPENSWATH/DIAScoring.h> | ||
|
|
||
| #include <utility> | ||
| #include <boost/bind.hpp> | ||
|
|
||
|
|
@@ -252,17 +255,15 @@ namespace OpenMS | |
| } | ||
| } // end getBYSeries | ||
|
|
||
| void getAveragineIsotopeDistribution(const double product_mz, | ||
| void getAveragineIsotopeDistribution(IsotopeDistributionCache& iso, | ||
| const double product_mz, | ||
| std::vector<std::pair<double, double> >& isotopesSpec, | ||
| const double charge, | ||
| const int nr_isotopes, | ||
| const double mannmass) | ||
| { | ||
| typedef OpenMS::FeatureFinderAlgorithmPickedHelperStructs::TheoreticalIsotopePattern TheoreticalIsotopePattern; | ||
| // create the theoretical distribution | ||
| CoarseIsotopePatternGenerator solver(nr_isotopes); | ||
| TheoreticalIsotopePattern isotopes; | ||
| auto d = solver.estimateFromPeptideWeight(product_mz * charge); | ||
| auto d = iso.getIntensity(product_mz * charge); | ||
|
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. can be |
||
|
|
||
| double mass = product_mz; | ||
| for (IsotopeDistribution::Iterator it = d.begin(); it != d.end(); ++it) | ||
|
|
@@ -273,29 +274,30 @@ namespace OpenMS | |
| } //end of dia_isotope_corr_sub | ||
|
|
||
| //simulate spectrum from AASequence | ||
| void simulateSpectrumFromAASequence(const AASequence& aa, | ||
| void simulateSpectrumFromAASequence(IsotopeDistributionCache& iso, | ||
| const AASequence& aa, | ||
| std::vector<double>& firstIsotopeMasses, //[out] | ||
| std::vector<std::pair<double, double> >& isotopeMasses, //[out] | ||
| TheoreticalSpectrumGenerator const * generator, double charge) | ||
| { | ||
| getTheorMasses(aa, firstIsotopeMasses, generator, charge); | ||
| for (std::size_t i = 0; i < firstIsotopeMasses.size(); ++i) | ||
| { | ||
| getAveragineIsotopeDistribution(firstIsotopeMasses[i], isotopeMasses, | ||
| getAveragineIsotopeDistribution(iso, firstIsotopeMasses[i], isotopeMasses, | ||
| charge); | ||
| } | ||
| } | ||
|
|
||
| //given an experimental spectrum add isotope pattern. | ||
| void addIsotopes2Spec(const std::vector<std::pair<double, double> >& spec, | ||
| void addIsotopes2Spec(IsotopeDistributionCache& iso, const std::vector<std::pair<double, double> >& spec, | ||
| std::vector<std::pair<double, double> >& isotopeMasses, //[out] | ||
| double charge) | ||
| { | ||
|
|
||
| for (std::size_t i = 0; i < spec.size(); ++i) | ||
| { | ||
| std::vector<std::pair<double, double> > isotopes; | ||
|
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. just as a suggestion for speed (even though this was not part of the PR): |
||
| getAveragineIsotopeDistribution(spec[i].first, isotopes, charge); | ||
| getAveragineIsotopeDistribution(iso, spec[i].first, isotopes, charge); | ||
| for (Size j = 0; j < isotopes.size(); ++j) | ||
| { | ||
| isotopes[j].second *= spec[i].second; //multiple isotope intensity by spec intensity | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
no need to include the header here.
Just forward declare should be enough (to save on compile time).
class IsotopeDistributionCache;within the OpenMS namespace.