OpenMS
2.4.0
|
A base class for all classes handling default parameters. More...
#include <OpenMS/DATASTRUCTURES/DefaultParamHandler.h>
Public Member Functions | |
DefaultParamHandler (const String &name) | |
Constructor with name that is displayed in error messages. More... | |
DefaultParamHandler (const DefaultParamHandler &rhs) | |
Copy constructor. More... | |
virtual | ~DefaultParamHandler () |
Destructor. More... | |
virtual DefaultParamHandler & | operator= (const DefaultParamHandler &rhs) |
Assignment operator. More... | |
virtual bool | operator== (const DefaultParamHandler &rhs) const |
Equality operator. More... | |
void | setParameters (const Param ¶m) |
Sets the parameters. More... | |
const Param & | getParameters () const |
Non-mutable access to the parameters. More... | |
const Param & | getDefaults () const |
Non-mutable access to the default parameters. More... | |
const String & | getName () const |
Non-mutable access to the name. More... | |
void | setName (const String &name) |
Mutable access to the name. More... | |
const std::vector< String > & | getSubsections () const |
Non-mutable access to the registered subsections. More... | |
Protected Member Functions | |
virtual void | updateMembers_ () |
This method is used to update extra member variables at the end of the setParameters() method. More... | |
void | defaultsToParam_ () |
Updates the parameters after the defaults have been set in the constructor. More... | |
Protected Attributes | |
Param | param_ |
Container for current parameters. More... | |
Param | defaults_ |
Container for default parameters. This member should be filled in the constructor of derived classes! More... | |
std::vector< String > | subsections_ |
Container for registered subsections. This member should be filled in the constructor of derived classes! More... | |
String | error_name_ |
Name that is displayed in error messages during the parameter checking. More... | |
bool | check_defaults_ |
If this member is set to false no checking if parameters in done;. More... | |
bool | warn_empty_defaults_ |
If this member is set to false no warning is emitted when defaults are empty;. More... | |
Private Member Functions | |
DefaultParamHandler () | |
Hidden default C'tor (class name parameter is required!) More... | |
A base class for all classes handling default parameters.
This class facilitates the handling of parameters:
range restrictions of numeric parameters
subsections that are passed to other classes can be excluded from the check (subsections_)
Extra member variables are needed if getting the value from param_ would be too slow e.g. when they are used in methods that are called very often.
No matter if you have extra variables or not, do the following:
If you have extra member variables you need to synchronize with param_, do the following:
Base classes:
If you create a class A that is derived from DefaultParamHandler and derive another class B for A, you should set use the setName(String) method to set the name used for error messages to B.
Parameter documentation:
Each default parameter has to be documented in a comprehensive way. This is done using the Param::setValue methods and the Param::setDescription method.
Flags:
Flags (boolean parameters) are not supported directly. It's best to implement them as a string parameter with valid strings 'true' and 'false'.
DefaultParamHandler | ( | const String & | name | ) |
Constructor with name that is displayed in error messages.
DefaultParamHandler | ( | const DefaultParamHandler & | rhs | ) |
Copy constructor.
|
virtual |
Destructor.
|
private |
Hidden default C'tor (class name parameter is required!)
|
protected |
Updates the parameters after the defaults have been set in the constructor.
Referenced by SignalToNoiseEstimatorMeanIterative< Container >::SignalToNoiseEstimatorMeanIterative(), SignalToNoiseEstimatorMedian< ContainerT >::SignalToNoiseEstimatorMedian(), TOPPASBase::TOPPASBase(), and TOPPViewBase::TOPPViewBase().
const Param& getDefaults | ( | ) | const |
Non-mutable access to the default parameters.
Referenced by TOPPViewBase::annotateWithID(), EmgScoring::getDefaults(), TOPPViewBase::initializeDefaultParameters_(), and PeakPickerIterative::pick().
const String& getName | ( | ) | const |
Non-mutable access to the name.
const Param& getParameters | ( | ) | const |
Non-mutable access to the parameters.
Referenced by TOPPViewBase::annotateMS1FromMassFingerprinting_(), RNPxlSearch::initializeSpectrumGenerators(), TOPPOpenPepXLLF::main_(), SimpleSearchEngine::main_(), TOPPOpenPepXL::main_(), RNPxlSearch::main_(), RNPxlSearch::postScoreHits_(), EmgScoring::prepareFit_(), SimpleSearchEngine::preprocessSpectra_(), RNPxlSearch::preprocessSpectra_(), and SignalToNoiseOpenMS< ContainerT >::SignalToNoiseOpenMS().
const std::vector<String>& getSubsections | ( | ) | const |
Non-mutable access to the registered subsections.
|
virtual |
Assignment operator.
Referenced by BaseModel< 2 >::operator=(), SignalToNoiseEstimator< ContainerT >::operator=(), and OptimizePeakDeconvolution::operator=().
|
virtual |
Equality operator.
void setName | ( | const String & | name | ) |
Mutable access to the name.
Referenced by SignalToNoiseEstimatorMeanIterative< Container >::SignalToNoiseEstimatorMeanIterative(), and SignalToNoiseEstimatorMedian< ContainerT >::SignalToNoiseEstimatorMedian().
void setParameters | ( | const Param & | param | ) |
Sets the parameters.
Before setting the parameters, missing parameters are filled up with default values.
Then the parameters are checked for unknown parameters (warning) and violations of restrictions (exception) with the Param::checkDefaults() method.
Exception::InvalidParameter | is thrown if errors occur during the check. |
Referenced by TOPPViewBase::annotateMS1FromMassFingerprinting_(), TOPPViewBase::annotateWithID(), ModelDescription< D >::createModel(), RNPxlSearch::initializeSpectrumGenerators(), TOPPASBase::loadPreferences(), TOPPViewBase::loadPreferences(), TOPPOpenPepXLLF::main_(), SimpleSearchEngine::main_(), TOPPOpenPepXL::main_(), RNPxlSearch::main_(), TOPPMetaProSIP::main_(), SpectraMerger::mergeSpectra_(), SpectraMerger::mergeSpectraPrecursors(), PeakPickerIterative::pick(), RNPxlSearch::postScoreHits_(), EmgScoring::prepareFit_(), SimpleSearchEngine::preprocessSpectra_(), RNPxlSearch::preprocessSpectra_(), EmgScoring::setFitterParam(), TOPPViewBase::showSpectrumGenerationDialog(), and SignalToNoiseOpenMS< ContainerT >::SignalToNoiseOpenMS().
|
protectedvirtual |
This method is used to update extra member variables at the end of the setParameters() method.
Also call it at the end of the derived classes' copy constructor and assignment operator.
The default implementation is empty.
Reimplemented in PeptideIndexing, MRMTransitionGroupPicker, PeakIntegrator, TargetedSpectraExtractor, SignalToNoiseEstimatorMedian< Container >, SignalToNoiseEstimatorMedian< OpenMS::MSChromatogram >, SignalToNoiseEstimatorMedian< ContainerT >, SignalToNoiseEstimatorMeanIterative< Container >, IDMapper, LinearResamplerAlign, MapAlignmentAlgorithmSpectrumAlignment, AbsoluteQuantitation, AccurateMassSearchEngine, MRMFeatureFinderScoring, PeptideAndProteinQuant, SvmTheoreticalSpectrumGenerator, TwoDOptimization, ProductModel< 2 >, SavitzkyGolayFilter, TransitionTSVFile, MRMDecoy, IsobaricChannelExtractor, GaussFilter, PrecursorIonSelection, AScore, OptimizePeakDeconvolution, PeakPickerHiRes, InterpolationModel, ConsensusIDAlgorithmPEPMatrix, FeatureFindingMetabo, TraceFitter, MetaboliteSpectralMatching, TheoreticalSpectrumGeneratorXLMS, LinearResampler, RTSimulation, StablePairFinder, DIAScoring, PeakPickerCWT, FeatureDistance, BaseModel< D >, BaseModel< 1 >, BaseModel< 2 >, ElutionPeakDetection, MSSim, PrecursorIonSelectionPreprocessing, FeatureFinderAlgorithmPicked, KDTreeFeatureMaps, IsotopeModel, EGHTraceFitter, PeakPickerIterative, FeatureFinderIdentificationAlgorithm, MaxLikeliFitter1D, Normalizer, IonizationSimulation, PeakPickerMRM, LevMarqFitter1D, SimplePairFinder, EmgGradientDescent, EmgFitter1D, ExtendedIsotopeModel, EGHFitter1D, ITRAQLabeler, GaussTraceFitter, SpectrumAnnotator, CompNovoIonScoringBase, EGHModel, Fitter1D, ConsensusIDAlgorithm, SILACLabeler, FeatureFinderAlgorithmIsotopeWavelet, MetaboliteFeatureDeconvolution, NLargest, FeatureDeconvolution, BinnedSumAgreeingIntensities, RawMSSignalSimulation, MassTraceDetection, ICPLLabeler, BiGaussModel, EmgModel, FeatureFinderAlgorithmMRM, GaussModel, CompNovoIdentificationCID, MRMMapping, MSPGenericFile, TMTElevenPlexQuantitationMethod, TMTTenPlexQuantitationMethod, BinnedSpectralContrastAngle, MapAlignmentAlgorithmPoseClustering, BinnedSharedPeakCount, ItraqEightPlexQuantitationMethod, TMTSixPlexQuantitationMethod, MassDecompositionAlgorithm, ItraqFourPlexQuantitationMethod, CompNovoIdentificationBase, TheoreticalSpectrumGenerator, MascotRemoteQuery, DetectabilitySimulation, ExtendedIsotopeFitter1D, SpectraMerger::SpectraDistance_, BiGaussFitter1D, IsotopeFitter1D, SONARScoring, IsobaricQuantifier, GaussFitter1D, DiaPrescore, MRMFeatureFilter, LowessSmoothing, MascotGenericFile, and ConsensusIDAlgorithmPEPIons.
|
protected |
If this member is set to false no checking if parameters in done;.
The only reason to set this member to false is that the derived class has no parameters! However, if a grand-child has defaults and you are using a base class cast, checking will not be done when casting back to grand-child. To just omit the warning, use 'warn_empty_defaults_'
|
protected |
Container for default parameters. This member should be filled in the constructor of derived classes!
Referenced by BaseModel< 2 >::BaseModel(), FeatureFinderAlgorithm::getDefaultParameters(), TOPPViewBase::initializeDefaultParameters_(), SignalToNoiseEstimatorMeanIterative< Container >::SignalToNoiseEstimatorMeanIterative(), SignalToNoiseEstimatorMedian< ContainerT >::SignalToNoiseEstimatorMedian(), and TOPPASBase::TOPPASBase().
|
protected |
Name that is displayed in error messages during the parameter checking.
|
protected |
Container for current parameters.
Referenced by TOPPViewBase::addData(), TOPPViewBase::addDataFile(), TOPPViewBase::addRecentFile_(), TOPPViewBase::fileChanged_(), TOPPViewBase::finishTOPPToolExecution(), TOPPViewBase::getSpectrumParameters(), TOPPASBase::loadPreferences(), TOPPViewBase::loadPreferences(), TwoDOptimization::optimize(), TwoDOptimization::optimizeRegionsScanwise_(), TOPPViewBase::preferencesDialog(), TOPPASBase::savePreferences(), TOPPViewBase::savePreferences(), BaseModel< 2 >::setCutOff(), TOPPViewBase::showTOPPDialog_(), TOPPASBase::TOPPASBase(), TOPPViewBase::TOPPViewBase(), TOPPASBase::updateCurrentPath(), TOPPViewBase::updateCurrentPath(), BaseModel< 2 >::updateMembers_(), SignalToNoiseEstimatorMeanIterative< Container >::updateMembers_(), SignalToNoiseEstimatorMedian< ContainerT >::updateMembers_(), and TOPPViewBase::updateRecentMenu_().
|
protected |
Container for registered subsections. This member should be filled in the constructor of derived classes!
Referenced by TOPPViewBase::initializeDefaultParameters_().
|
protected |
If this member is set to false no warning is emitted when defaults are empty;.
The only reason to set this member to false is that the derived class has no parameters!