OpenMS  2.7.0
Public Member Functions | Protected Attributes | List of all members
IsoSpecTotalProbGeneratorWrapper Class Reference

Generate a p-set of configurations for a given p (that is, a set of configurations such that their probabilities sum up to p). The p in normal usage will usually be close to 1 (e.g. 0.99). More...

#include <OpenMS/CHEMISTRY/ISOTOPEDISTRIBUTION/IsoSpecWrapper.h>

Inheritance diagram for IsoSpecTotalProbGeneratorWrapper:
[legend]
Collaboration diagram for IsoSpecTotalProbGeneratorWrapper:
[legend]

Public Member Functions

 IsoSpecTotalProbGeneratorWrapper (const std::vector< int > &isotopeNumbers, const std::vector< int > &atomCounts, const std::vector< std::vector< double > > &isotopeMasses, const std::vector< std::vector< double > > &isotopeProbabilities, double p)
 Constructor. More...
 
 IsoSpecTotalProbGeneratorWrapper (const EmpiricalFormula &formula, double p)
 Setup the algorithm to run on an EmpiricalFormula. More...
 
virtual bool nextConf () override final
 Move the generator to a next isotopologue. More...
 
virtual Peak1D getConf () override final
 Obtain the current isotopologue. More...
 
virtual double getMass () override final
 Obtain the mass of the current isotopologue. More...
 
virtual double getIntensity () override final
 Obtain the intensity (probability, relative peak height) of the current configuration. More...
 
virtual double getLogIntensity () override final
 Obtain the natural logarithm of the intensity (probability, relative peak height) of the current configuration. More...
 
- Public Member Functions inherited from IsoSpecGeneratorWrapper
virtual ~IsoSpecGeneratorWrapper ()
 Destructor. More...
 

Protected Attributes

IsoSpec::IsoLayeredGenerator ILG
 

Detailed Description

Generate a p-set of configurations for a given p (that is, a set of configurations such that their probabilities sum up to p). The p in normal usage will usually be close to 1 (e.g. 0.99).

An optimal p-set of isotopologues is the smallest set of isotopologues that, taken together, cover at least p of the probability space (that is, their probabilities sum up to at least p). This means that the computed spectrum is accurate to at least degree p, and that the L1 distance between the computed spectrum and the true spectrum is less than 1-p. The optimality of the p-set means that it contains the most probable configurations - any isotopologues outside of the returned p-set have lower intensity than the configurations in the p-set.

This is the method most users will want: the p parameter directly controls the accuracy of results.

Advanced usage note: The algorithm works by computing an optimal p'-set for a p' slightly larger than the requested p. By default these extra isotopologues are returned too (as they have to be computed anyway). It is possible to request them to be discarded, but not in the generator class - one should use IsoSpecTotalProbWrapper instead, at a greater computational and memory cost.

The p is used as a hint for the algorithm - configurations will be returned in such an order that once the total accumulated probability crosses p, the returned set will be close to optimal. If exactly the optimal set is required, one should use (again, at an increased cost) the IsoSpecTotalProbWrapper class. The generator will still go over the entire configuration space if the user keeps requesting more configurations after crossing p.

Note
The eligible configurations are NOT guaranteed to be returned in any particular order.

Constructor & Destructor Documentation

◆ IsoSpecTotalProbGeneratorWrapper() [1/2]

IsoSpecTotalProbGeneratorWrapper ( const std::vector< int > &  isotopeNumbers,
const std::vector< int > &  atomCounts,
const std::vector< std::vector< double > > &  isotopeMasses,
const std::vector< std::vector< double > > &  isotopeProbabilities,
double  p 
)

Constructor.

Parameters
isotopeNumbersA vector of how many isotopes each element has, e.g. [2, 2, 3])
atomCountsHow many atoms of each we have [e.g. 12, 6, 6 for Glucose]
isotopeMassesArray with the individual elements isotopic masses
isotopeProbabilitiesArray with the individual elements isotopic probabilities
pTotal coverage of probability space desired, usually close to 1 (e.g. 0.99)
Note
This constructor is only useful if you need to define non-standard abundances of isotopes, for other uses the one accepting EmpiricalFormula is easier to use.

◆ IsoSpecTotalProbGeneratorWrapper() [2/2]

IsoSpecTotalProbGeneratorWrapper ( const EmpiricalFormula formula,
double  p 
)

Setup the algorithm to run on an EmpiricalFormula.

Member Function Documentation

◆ getConf()

virtual Peak1D getConf ( )
inlinefinaloverridevirtual

Obtain the current isotopologue.

Returns
The current isotopologue as a Peak1D
Note
It is invalid (undefined results) to call this method before the first call to nextConf(), or after it returns false

Implements IsoSpecGeneratorWrapper.

◆ getIntensity()

virtual double getIntensity ( )
inlinefinaloverridevirtual

Obtain the intensity (probability, relative peak height) of the current configuration.

Returns
The intensity (probability) of the current isotopologue
Note
It is invalid (undefined results) to call this method before the first call to nextConf(), or after it returns false

Implements IsoSpecGeneratorWrapper.

◆ getLogIntensity()

virtual double getLogIntensity ( )
inlinefinaloverridevirtual

Obtain the natural logarithm of the intensity (probability, relative peak height) of the current configuration.

This will be more precise (and faster) than just calling std::log(getIntensity()) - it will produce correct results even for configurations so unlikely that the double-precision floating point number returned from getIntensity() underflows to zero.

Returns
The natural logarithm of intensity (probability) of the current isotopologue
Note
It is invalid (undefined results) to call this method before the first call to nextConf(), or after it returns false

Implements IsoSpecGeneratorWrapper.

◆ getMass()

virtual double getMass ( )
inlinefinaloverridevirtual

Obtain the mass of the current isotopologue.

Returns
The mass of the current isotopologue
Note
It is invalid (undefined results) to call this method before the first call to nextConf(), or after it returns false

Implements IsoSpecGeneratorWrapper.

◆ nextConf()

virtual bool nextConf ( )
inlinefinaloverridevirtual

Move the generator to a next isotopologue.

Advance the internal generator to the next isotopologue. The value returned determines whether the generator has been exhausted (that is, all eligible configurations have already been visited). It is invalid to call any other generator methods before the first call to nextConf(), as well as after this method returns false.

Returns
A boolean value stating whether the generator has been exhausted.

Implements IsoSpecGeneratorWrapper.

Member Data Documentation

◆ ILG

IsoSpec::IsoLayeredGenerator ILG
protected