![]() |
OpenMS
|
Pairs an alphabet of double-valued masses with the scaled integer weights derived from them. More...
#include <OpenMS/CHEMISTRY/MASSDECOMPOSITION/IMS/Weights.h>
Public Types | |
| typedef long unsigned int | weight_type |
| Type of integer values to be used. | |
| typedef double | alphabet_mass_type |
| Type of double values to be used. | |
| typedef std::vector< weight_type > | weights_type |
| Type of container to store integer values. | |
| typedef std::vector< alphabet_mass_type > | alphabet_masses_type |
| Type of container to store double values. | |
| typedef weights_type::size_type | size_type |
| Type of container's size. | |
Public Member Functions | |
| Weights () | |
| Default constructor. | |
| Weights (const alphabet_masses_type &masses, alphabet_mass_type precision) | |
| Construct from a set of masses and a precision. | |
| Weights (const Weights &other) | |
| Weights & | operator= (const Weights &other) |
| size_type | size () const |
| weight_type | getWeight (size_type i) const |
| void | setPrecision (alphabet_mass_type precision) |
| Replace the precision and recompute the integer weights from the stored alphabet masses. | |
| alphabet_mass_type | getPrecision () const |
| weight_type | operator[] (size_type i) const |
| weight_type | back () const |
| alphabet_mass_type | getAlphabetMass (size_type i) const |
| alphabet_mass_type | getParentMass (const std::vector< unsigned int > &decomposition) const |
| Reconstruct a parent mass from a decomposition expressed as multiplicities of the alphabet. | |
| void | swap (size_type index1, size_type index2) |
Exchange the alphabet mass and the integer weight at index1 with those at index2. | |
| bool | divideByGCD () |
| Divide every integer weight by the greatest common divisor of all weights and scale the precision accordingly. | |
| alphabet_mass_type | getMinRoundingError () const |
| Largest negative relative rounding error introduced by the current precision. | |
| alphabet_mass_type | getMaxRoundingError () const |
| Largest positive relative rounding error introduced by the current precision. | |
Private Attributes | |
| alphabet_masses_type | alphabet_masses_ |
| alphabet_mass_type | precision_ |
| weights_type | weights_ |
Pairs an alphabet of double-valued masses with the scaled integer weights derived from them.
Many mass-decomposition algorithms only operate on integer weights; this class provides those integers alongside the original double-valued masses, derived once at construction (or on the next setPrecision call) by computing round(mass / precision) per entry. Subsequent access is plain vector lookup – no recomputation happens on read.
Typical precision values are in (0, 1] (smaller values mean a finer-grained integer grid); the cpp itself does not enforce a range.
| typedef double alphabet_mass_type |
Type of double values to be used.
| typedef std::vector<alphabet_mass_type> alphabet_masses_type |
Type of container to store double values.
| typedef weights_type::size_type size_type |
Type of container's size.
| typedef long unsigned int weight_type |
Type of integer values to be used.
| typedef std::vector<weight_type> weights_type |
Type of container to store integer values.
|
inline |
Default constructor.
Produces an empty instance; size returns 0 until masses and a precision have been supplied.
|
inline |
Construct from a set of masses and a precision.
Stores masses as the alphabet masses and computes the integer weights via round(mass / precision) for each entry (so the size of both the alphabet-mass and the weight container is masses.size() after the call).
| [in] | masses | Original double-valued alphabet masses. |
| [in] | precision | Precision used to scale the masses; smaller values yield finer-grained integer weights. |
|
inline |
Gets a last weight.
| bool divideByGCD | ( | ) |
Divide every integer weight by the greatest common divisor of all weights and scale the precision accordingly.
For example, given alphabet weights 3.0, 5.0, 8.0 with precision 0.1, the integer weights would be 30, 50, 80. After calling this method the integer weights become 3, 5, 8 and the precision becomes 1.0 (since the gcd of 30, 50, 80 is 10).
true when the integer weights and the precision were changed (gcd > 1); false when the gcd was already 1 or fewer than two weights are stored.
|
inline |
Gets an original (double) alphabet mass by index.
| [in] | i | An index to access alphabet masses. |
| alphabet_mass_type getMaxRoundingError | ( | ) | const |
Largest positive relative rounding error introduced by the current precision.
(precision * weight[i] - mass[i]) / mass[i] over all entries with a positive value, or 0 if no entry's scaled weight over-estimates its mass. | alphabet_mass_type getMinRoundingError | ( | ) | const |
Largest negative relative rounding error introduced by the current precision.
(precision * weight[i] - mass[i]) / mass[i] over all entries with a negative value, or 0 if no entry's scaled weight under-estimates its mass. | alphabet_mass_type getParentMass | ( | const std::vector< unsigned int > & | decomposition | ) | const |
Reconstruct a parent mass from a decomposition expressed as multiplicities of the alphabet.
| [in] | decomposition | Per-alphabet-entry multiplicities; must have the same length as the alphabet. |
sum(alphabet_mass[i] * decomposition[i]) using the stored original (double) masses.| Exception::InvalidParameter | when decomposition.size() does not equal size. |
|
inline |
Gets precision.
|
inline |
Gets a scaled integer weight by index.
| [in] | i | An index to access weights. |
Referenced by IntegerMassDecomposer< ValueType, DecompositionValueType >::fillExtendedResidueTable_(), and IntegerMassDecomposer< ValueType, DecompositionValueType >::IntegerMassDecomposer().
|
inline |
Operator to access weights by index.
| [in] | i | An index to access weights. |
| void setPrecision | ( | alphabet_mass_type | precision | ) |
Replace the precision and recompute the integer weights from the stored alphabet masses.
| [in] | precision | New precision; the integer weights are refreshed as round(mass / precision) for every stored alphabet mass. |
|
inline |
Gets size of a set of weights.
Referenced by IntegerMassDecomposer< ValueType, DecompositionValueType >::fillExtendedResidueTable_(), and IntegerMassDecomposer< ValueType, DecompositionValueType >::IntegerMassDecomposer().
Exchange the alphabet mass and the integer weight at index1 with those at index2.
Both the alphabet_mass entry and its corresponding integer weight at the two indices are swapped, so the mass / weight pairing is preserved.
| [in] | index1 | First index to swap. |
| [in] | index2 | Second index to swap. |
|
private |
Container to store original (double) alphabet masses.
|
private |
Precision which is used to scale double values to integer.
|
private |
Container to store scaled integer weights.