-
Notifications
You must be signed in to change notification settings - Fork 5
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
Optimization in OpenSwathWorkflow #92
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,27 +36,50 @@ | |
|
||
#include <OpenMS/KERNEL/StandardTypes.h> | ||
#include <OpenMS/TRANSFORMATIONS/FEATUREFINDER/FeatureFinderAlgorithmPickedHelperStructs.h> | ||
#include <OpenMS/CHEMISTRY/ISOTOPEDISTRIBUTION/IsotopeDistribution.h> | ||
|
||
namespace OpenMS | ||
{ | ||
/** | ||
* @brief Pre-calculate isotope distributions for interesting mass ranges | ||
*/ | ||
class OPENMS_DLLAPI IsotopeDistributionCache | ||
class OPENMS_DLLAPI IsotopeDistributionCache: | ||
public FeatureFinderAlgorithmPickedHelperStructs | ||
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. why inherit from 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. sorry, I forget to delete it. |
||
{ | ||
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 calculateisotopeDistribution(Size num_begin); | ||
|
||
void renormalize( TheoreticalIsotopePattern& isotopes, IsotopeDistribution& isotope_dist); | ||
|
||
/// 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); | ||
|
||
private: | ||
/// Vector of pre-calculated isotope distributions for several mass windows | ||
std::vector<TheoreticalIsotopePattern> isotope_distributions_; | ||
|
||
std::vector<IsotopeDistribution> intensity_; | ||
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.
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. We'll call the member |
||
|
||
double mass_window_width_; | ||
|
||
double intensity_percentage_ ; | ||
|
||
double intensity_percentage_optional_; | ||
}; | ||
} | ||
}//namespace OpenMS | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -71,8 +71,7 @@ namespace OpenMS | |
inline SignalToNoiseEstimator() : | ||
DefaultParamHandler("SignalToNoiseEstimator"), | ||
ProgressLogger(), | ||
first_(), | ||
last_(), | ||
c(), | ||
is_result_valid_(false) | ||
{ | ||
} | ||
|
@@ -82,8 +81,7 @@ namespace OpenMS | |
DefaultParamHandler(source), | ||
ProgressLogger(source), | ||
stn_estimates_(source.stn_estimates_), | ||
first_(source.first_), | ||
last_(source.last_), | ||
c(source.c), | ||
is_result_valid_(source.is_result_valid_) | ||
{} | ||
|
||
|
@@ -95,56 +93,30 @@ namespace OpenMS | |
DefaultParamHandler::operator=(source); | ||
ProgressLogger::operator=(source); | ||
stn_estimates_ = source.stn_estimates_; | ||
first_ = source.first_; | ||
last_ = source.last_; | ||
c = source.c; | ||
return *this; | ||
} | ||
|
||
/// Destructor | ||
~SignalToNoiseEstimator() override | ||
{} | ||
|
||
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. If we stick to the rule of six, don't we have to add move constructor and move assignment operator? 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. I have already added them (c with type Container). |
||
|
||
/// Set the start and endpoint of the raw data interval, for which signal to noise ratios will be estimated immediately | ||
virtual void init(const PeakIterator & it_begin, const PeakIterator & it_end) | ||
virtual void init(const Container& c) | ||
{ | ||
first_ = it_begin; | ||
last_ = it_end; | ||
computeSTN_(first_, last_); | ||
computeSTN_(c); | ||
is_result_valid_ = true; | ||
} | ||
|
||
/// Set the start and endpoint of the raw data interval, for which signal to noise ratios will be estimated immediately | ||
virtual void init(const Container & c) | ||
{ | ||
init(c.begin(), c.end()); | ||
} | ||
|
||
/// Return to signal/noise estimate for data point @p data_point | ||
/// @note the first query to this function will take longer, as | ||
/// all SignalToNoise values are calculated | ||
/// @note you will get a warning to stderr if more than 20% of the | ||
/// noise estimates used sparse windows | ||
virtual double getSignalToNoise(const PeakIterator & data_point) | ||
{ | ||
if (!is_result_valid_) | ||
{ | ||
// recompute ... | ||
init(first_, last_); | ||
} | ||
|
||
return stn_estimates_[*data_point]; | ||
} | ||
|
||
virtual double getSignalToNoise(const PeakType & data_point) | ||
virtual double getSignalToNoise(const Size index) | ||
{ | ||
if (!is_result_valid_) | ||
{ | ||
// recompute ... | ||
init(first_, last_); | ||
init(c); | ||
} | ||
|
||
return stn_estimates_[data_point]; | ||
return stn_estimates_[index]; | ||
} | ||
|
||
protected: | ||
|
@@ -154,7 +126,7 @@ namespace OpenMS | |
* | ||
* @exception Throws Exception::InvalidValue | ||
*/ | ||
virtual void computeSTN_(const PeakIterator & scan_first_, const PeakIterator & scan_last_) = 0; | ||
virtual void computeSTN_(const Container& c) = 0; | ||
|
||
|
||
|
||
|
@@ -204,12 +176,9 @@ namespace OpenMS | |
//MEMBERS: | ||
|
||
/// stores the noise estimate for each peak | ||
std::map<PeakType, double, typename PeakType::PositionLess> stn_estimates_; | ||
std::vector<double> stn_estimates_; | ||
|
||
/// points to the first raw data point in the interval | ||
PeakIterator first_; | ||
/// points to the right position next to the last raw data point in the interval | ||
PeakIterator last_; | ||
Container c; | ||
/// flag: set to true if SignalToNoise estimates are calculated and none of the params were changed. otherwise false. | ||
mutable bool is_result_valid_; | ||
}; | ||
|
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.
can you call this
iso_cache_
or something which reflects its purpose?