OpenMS
Loading...
Searching...
No Matches
RealMassDecomposer Class Reference

Decomposes a real-valued mass over a real-valued alphabet of Weights, within a configurable absolute mass error. More...

#include <OpenMS/CHEMISTRY/MASSDECOMPOSITION/IMS/RealMassDecomposer.h>

Collaboration diagram for RealMassDecomposer:
[legend]

Public Types

typedef IntegerMassDecomposer integer_decomposer_type
 Underlying integer decomposer.
 
typedef integer_decomposer_type::value_type integer_value_type
 Integer mass values consumed by the integer decomposer.
 
typedef integer_decomposer_type::decompositions_type decompositions_type
 Result type of the integer decomposer (collection of decompositions).
 
typedef unsigned long long number_of_decompositions_type
 Counter type returned by getNumberOfDecompositions.
 
typedef std::map< unsigned int, std::pair< unsigned int, unsigned int > > constraints_type
 Per-alphabet-entry count constraint: alphabet index -> (min count, max count); both bounds inclusive.
 

Public Member Functions

 RealMassDecomposer (const Weights &weights)
 Construct from an alphabet of Weights.
 
decompositions_type getDecompositions (double mass, double error)
 All decompositions of mass within absolute tolerance error.
 
decompositions_type getDecompositions (double mass, double error, const constraints_type &constraints)
 Same as getDecompositions(double,double), additionally filtered by per-alphabet count bounds.
 
number_of_decompositions_type getNumberOfDecompositions (double mass, double error)
 Count of decompositions of mass within absolute tolerance error.
 

Private Attributes

Weights weights_
 Alphabet captured at construction time.
 
std::pair< double, double > rounding_errors_
 Minimum and maximum relative rounding errors of weights_, captured at construction time.
 
double precision_
 Precision of weights_, captured at construction time.
 
std::shared_ptr< integer_decomposer_typedecomposer_
 Lazy integer decomposer reused across calls; captured at construction time.
 

Detailed Description

Decomposes a real-valued mass over a real-valued alphabet of Weights, within a configurable absolute mass error.

Translates the real-valued problem into integer mass decomposition against the Weights' scaled integer alphabet: it computes the integer-mass window that brackets the user-supplied [mass - error, mass + error] range (accounting for the precision-induced rounding errors stored on Weights), runs an IntegerMassDecomposer over each integer mass in the window, then drops every integer decomposition whose reconstructed real parent mass still differs from mass by more than error.

Member Typedef Documentation

◆ constraints_type

typedef std::map<unsigned int, std::pair<unsigned int, unsigned int> > constraints_type

Per-alphabet-entry count constraint: alphabet index -> (min count, max count); both bounds inclusive.

◆ decompositions_type

Result type of the integer decomposer (collection of decompositions).

◆ integer_decomposer_type

Underlying integer decomposer.

◆ integer_value_type

Integer mass values consumed by the integer decomposer.

◆ number_of_decompositions_type

typedef unsigned long long number_of_decompositions_type

Counter type returned by getNumberOfDecompositions.

Constructor & Destructor Documentation

◆ RealMassDecomposer()

RealMassDecomposer ( const Weights weights)
explicit

Construct from an alphabet of Weights.

The alphabet's precision and rounding-error bounds are captured at construction time and reused on every subsequent getDecompositions / getNumberOfDecompositions call.

Parameters
[in]weightsReal-valued alphabet to decompose against.

Member Function Documentation

◆ getDecompositions() [1/2]

decompositions_type getDecompositions ( double  mass,
double  error 
)

All decompositions of mass within absolute tolerance error.

Returns every alphabet-multiplicity vector whose reconstructed parent mass lies in [mass - error, mass + error].

Parameters
[in]massTarget real-valued mass.
[in]errorAbsolute mass tolerance.
Returns
Decompositions whose reconstructed real parent mass is within error of mass.

◆ getDecompositions() [2/2]

decompositions_type getDecompositions ( double  mass,
double  error,
const constraints_type constraints 
)

Same as getDecompositions(double,double), additionally filtered by per-alphabet count bounds.

For each entry (idx, (lo, hi)) in constraints, only decompositions d with lo <= d[idx] <= hi are kept. Constraints whose alphabet index does not appear in decompositions are simply skipped.

Parameters
[in]massTarget real-valued mass.
[in]errorAbsolute mass tolerance.
[in]constraintsPer-alphabet-entry count bounds.
Returns
Decompositions that satisfy both the mass tolerance and every supplied count constraint.

◆ getNumberOfDecompositions()

number_of_decompositions_type getNumberOfDecompositions ( double  mass,
double  error 
)

Count of decompositions of mass within absolute tolerance error.

Equivalent in result to getDecompositions(mass, error).size() but does not materialise the individual decompositions.

When mass - error is non-positive, the integer-mass window starts at 1 rather than at a non-positive value.

Parameters
[in]massTarget real-valued mass.
[in]errorAbsolute mass tolerance.
Returns
Number of decompositions whose reconstructed real parent mass is within error of mass.

Member Data Documentation

◆ decomposer_

std::shared_ptr<integer_decomposer_type> decomposer_
private

Lazy integer decomposer reused across calls; captured at construction time.

◆ precision_

double precision_
private

Precision of weights_, captured at construction time.

◆ rounding_errors_

std::pair<double, double> rounding_errors_
private

Minimum and maximum relative rounding errors of weights_, captured at construction time.

◆ weights_

Weights weights_
private

Alphabet captured at construction time.