| OpenMS 2.5.0

Public Member Functions | Protected Member Functions | Protected Attributes | Private Member Functions | List of all members
DefaultParamHandler Class Reference
Datastructures

A base class for all classes handling default parameters. More...

`#include <OpenMS/DATASTRUCTURES/DefaultParamHandler.h>`

Inheritance diagram for DefaultParamHandler:

## 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 &param)
| 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...

## Detailed Description

A base class for all classes handling default parameters.

This class facilitates the handling of parameters:

- it manages default parameter (defaults_)
- it checks for valid parameters:
  - unknown/misspelled parameter names
  - correct parameter type

range restrictions of numeric parameters

- valid values for string parameters (enum)

subsections that are passed to other classes can be excluded from the check (subsections_)

- it keeps member variables in synchronicity with the parameters stored in param_
- it helps to automatically create a doxygen documentation page for the parameters

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:

- Set defaults_ and subsections_ in the derived classes' default constructor.
- Make sure to set the 'advanced' flag of the parameters right in order to hide certain parameters from inexperienced users.
- Set the range restrictions for numeric defaults and valid strings for string defaults (if possible)
- Call defaultsToParam_() at the end of derived classes' default constructor. It copies the defaults to param_ (and calls updateMembers_()).

If you have extra member variables you need to synchronize with param_, do the following:

- Implement the updateMembers_() method. It is used after each change of param_ in order to update the extra member variables. If the base class is a DefaultParamHandler as well make sure to call the updateMembers_() method of the base class in the updateMembers_() method.
- Call updateMembers_() at the end of the derived classes' copy constructor and assignment operator.
- If you need mutable access to the extra member variables, provide a set-method and make sure to set the corresponding value in param_ as well!

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'.

## Constructor & Destructor Documentation

## ◆ DefaultParamHandler() [1/3]

DefaultParamHandler | ( | const String & | name | ) |

Constructor with name that is displayed in error messages.

## ◆ DefaultParamHandler() [2/3]

DefaultParamHandler | ( | const DefaultParamHandler & | rhs | ) |

Copy constructor.

## ◆ ~DefaultParamHandler()

virtual ~DefaultParamHandler | ( |  | ) |

virtual

Destructor.

## ◆ DefaultParamHandler() [3/3]

DefaultParamHandler | ( |  | ) |

private

Hidden default C'tor (class name parameter is required!)

## Member Function Documentation

## ◆ defaultsToParam_()

void defaultsToParam_ | ( |  | ) |

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().

## ◆ getDefaults()

const Param& getDefaults | ( |  | ) | const

Non-mutable access to the default parameters.

Referenced by TOPPViewBase::annotateWithID(), NucleicAcidSearchEngine::calculateAndFilterFDR_(), EmgScoring::getDefaults(), TOPPViewBase::initializeDefaultParameters_(), TOPPOpenSwathBase::performCalibration(), PeakPickerIterative::pick(), and UTILProteomicsLFQ::registerOptionsAndFlags_().

## ◆ getName()

const String& getName | ( |  | ) | const

Non-mutable access to the name.

## ◆ getParameters()

const Param& getParameters | ( |  | ) | const

Non-mutable access to the parameters.

Referenced by TOPPViewBase::annotateMS1FromMassFingerprinting_(), UTILProteomicsLFQ::calculateSeeds_(), UTILProteomicsLFQ::estimateMedianChromatographicFWHM_(), Epifany::getSubsectionDefaults_(), Epifany::main_(), NucleicAcidSearchEngine::main_(), UTILProteomicsLFQ::main_(), EmgScoring::prepareFit_(), NucleicAcidSearchEngine::preprocessSpectra_(), and SignalToNoiseOpenMS< ContainerT >::SignalToNoiseOpenMS().

## ◆ getSubsections()

const std::vector<String>& getSubsections | ( |  | ) | const

Non-mutable access to the registered subsections.

## ◆ operator=()

virtual DefaultParamHandler& operator= | ( | const DefaultParamHandler & | rhs | ) |

virtual

Assignment operator.

Referenced by BaseModel< 2 >::operator=(), SignalToNoiseEstimator< ContainerT >::operator=(), and OptimizePeakDeconvolution::operator=().

## ◆ operator==()

virtual bool operator== | ( | const DefaultParamHandler & | rhs | ) | const

virtual

Equality operator.

## ◆ setName()

void setName | ( | const String & | name | ) |

Mutable access to the name.

Referenced by SignalToNoiseEstimatorMeanIterative< Container >::SignalToNoiseEstimatorMeanIterative(), and SignalToNoiseEstimatorMedian< ContainerT >::SignalToNoiseEstimatorMedian().

## ◆ setParameters()

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.

Exceptions

  Exception::InvalidParameter | is thrown if errors occur during the check.

Referenced by UTILProteomicsLFQ::align_(), TOPPViewBase::annotateMS1FromMassFingerprinting_(), TOPPViewBase::annotateWithID(), NucleicAcidSearchEngine::calculateAndFilterFDR_(), UTILProteomicsLFQ::calculateSeeds_(), UTILProteomicsLFQ::centroidAndCorrectPrecursors_(), ModelDescription< D >::createModel(), UTILProteomicsLFQ::link_(), TOPPASBase::loadPreferences(), TOPPViewBase::loadPreferences(), TOPPOpenSwathBase::loadTransitionList(), Epifany::main_(), NucleicAcidSearchEngine::main_(), UTILProteomicsLFQ::main_(), SpectraMerger::mergeSpectra_(), SpectraMerger::mergeSpectraPrecursors(), PeakPickerIterative::pick(), EmgScoring::prepareFit_(), NucleicAcidSearchEngine::preprocessSpectra_(), UTILProteomicsLFQ::quantifyFraction_(), EmgScoring::setFitterParam(), TOPPViewBase::showSpectrumGenerationDialog(), and SignalToNoiseOpenMS< ContainerT >::SignalToNoiseOpenMS().

## ◆ updateMembers_()

virtual void updateMembers_ | ( |  | ) |

protected virtual

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 >, LinearResamplerAlign, PeptideAndProteinQuant, MapAlignmentAlgorithmSpectrumAlignment, AbsoluteQuantitation, AccurateMassSearchEngine, MRMFeatureFinderScoring, SvmTheoreticalSpectrumGenerator, TwoDOptimization, ProductModel< 2 >, SavitzkyGolayFilter, IDMapper, TransitionTSVFile, MRMDecoy, IsobaricChannelExtractor, GaussFilter, PrecursorIonSelection, PeakPickerHiRes, AScore, FeatureFindingMetabo, OptimizePeakDeconvolution, InterpolationModel, ConsensusIDAlgorithmPEPMatrix, MetaboliteSpectralMatching, SimpleTSGXLMS, TraceFitter, FIAMSDataProcessor, SiriusAdapterAlgorithm, EmgGradientDescent, LinearResampler, RTSimulation, DIAScoring, StablePairFinder, PeakPickerCWT, FeatureDistance, TheoreticalSpectrumGeneratorXLMS, BaseModel< D >, BaseModel< 1 >, BaseModel< 2 >, ElutionPeakDetection, MSSim, PrecursorIonSelectionPreprocessing, OpenPepXLAlgorithm, FeatureFinderAlgorithmPicked, KDTreeFeatureMaps, IsotopeModel, EGHTraceFitter, PeakPickerIterative, OpenPepXLLFAlgorithm, FeatureFinderIdentificationAlgorithm, PeakPickerMRM, MaxLikeliFitter1D, Normalizer, IonizationSimulation, MapAlignmentAlgorithmTreeGuided, LevMarqFitter1D, SimplePairFinder, EmgFitter1D, ExtendedIsotopeModel, EGHFitter1D, ITRAQLabeler, GaussTraceFitter, SpectrumAnnotator, CompNovoIonScoringBase, EGHModel, Fitter1D, ConsensusIDAlgorithm, SILACLabeler, FeatureFinderAlgorithmIsotopeWavelet, MetaboliteFeatureDeconvolution, NLargest, FeatureDeconvolution, BinnedSumAgreeingIntensities, RawMSSignalSimulation, MassTraceDetection, XFDRAlgorithm, ICPLLabeler, BiGaussModel, EmgModel, FeatureFinderAlgorithmMRM, GaussModel, CompNovoIdentificationCID, MRMMapping, MSPGenericFile, TMTElevenPlexQuantitationMethod, TMTSixteenPlexQuantitationMethod, TMTTenPlexQuantitationMethod, NucleicAcidSpectrumGenerator, BinnedSpectralContrastAngle, MapAlignmentAlgorithmPoseClustering, TheoreticalSpectrumGenerator, BinnedSharedPeakCount, ItraqEightPlexQuantitationMethod, TMTSixPlexQuantitationMethod, MassDecompositionAlgorithm, ItraqFourPlexQuantitationMethod, CompNovoIdentificationBase, MascotRemoteQuery, DetectabilitySimulation, ExtendedIsotopeFitter1D, BiGaussFitter1D, SpectraMerger::SpectraDistance_, IsotopeFitter1D, BayesianProteinInferenceAlgorithm, SONARScoring, IsobaricQuantifier, MRMFeatureFilter, GaussFitter1D, DiaPrescore, LowessSmoothing, MascotGenericFile, ConsensusIDAlgorithmPEPIons, SimpleSearchEngineAlgorithm, and SwathMapMassCorrection.

## Member Data Documentation

## ◆ check_defaults_

bool check_defaults_

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_'

## ◆ defaults_

Param defaults_

protected

Container for default parameters. This member should be filled in the constructor of derived classes!

Note
  call the defaultsToParam_() method at the end of the constructor in order to copy the defaults to param_.

Referenced by BaseModel< 2 >::BaseModel(), FeatureFinderAlgorithm::getDefaultParameters(), TOPPViewBase::initializeDefaultParameters_(), SignalToNoiseEstimatorMeanIterative< Container >::SignalToNoiseEstimatorMeanIterative(), SignalToNoiseEstimatorMedian< ContainerT >::SignalToNoiseEstimatorMedian(), and TOPPASBase::TOPPASBase().

## ◆ error_name_

String error_name_

protected

Name that is displayed in error messages during the parameter checking.

## ◆ param_

Param param_

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_().

## ◆ subsections_

std::vector<String> subsections_

protected

Container for registered subsections. This member should be filled in the constructor of derived classes!

Note
  Do not add a ':' character at the end of subsections.

Referenced by TOPPViewBase::initializeDefaultParameters_().

## ◆ warn_empty_defaults_

bool warn_empty_defaults_

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!

See also
  check_defaults_