Represents a set of weights (double values and scaled with a certain precision their integer counterparts) with a quick access.
More...
#include <OpenMS/CHEMISTRY/MASSDECOMPOSITION/IMS/Weights.h>
List of all members.
Detailed Description
Represents a set of weights (double values and scaled with a certain precision their integer counterparts) with a quick access.
Many algorithms can't work with real-valued alphabets and need integer weights. Those are usually obtained by dividing all alphabet masses by a "precision" parameter (0; 1) and rounding the result to integers. Class Weights allows access to the scaled masses (the weights) and to the original masses as well. Weights are cached and will not be recalculated on access.
- Note:
- Words 'weights' and 'masses' were used deliberately for naming corresponding values to help users quickly understand how they can be used. Names were chosen due to similarity in 'weights' and 'masses' interconnection in this class with real life. In reality mass value is always the same, and weight value depends on circumstances. The same as here original double masses stay the same, and scaled integer weights depend on precision applied.
- Author:
- Anton Pervukhin <Anton.Pervukhin@CeBiTec.Uni-Bielefeld.DE>
Member Typedef Documentation
Type of double values to be used.
Type of container to store double values.
Type of container's size.
Type of integer values to be used.
Type of container to store integer values.
Constructor & Destructor Documentation
Constructor with double values and precision.
- Parameters:
-
| masses | Original double values to be scaled. |
| precision | Precision to scale double values. |
Copy constructor.
- Parameters:
-
Member Function Documentation
Gets a last weight.
- Returns:
- a last weight.
Divides the integer weights by their gcd. The precision is also adjusted.
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 new weights are 3, 5, 8 with precision 1.0 (since the gcd of 30, 50, and 80 is 10).
- Returns:
- true if anything was changed, that is, if the gcd was > 1. false if the gcd was already 1 or there are less than two weights.
Gets an original (double) alphabet mass by index.
- Parameters:
-
| i | An index to access alphabet masses. |
- Returns:
- A double alphabet mass.
| alphabet_mass_type getParentMass |
( |
const std::vector< unsigned int > & |
decomposition |
) |
const |
Returns a parent mass for a given decomposition
Gets precision.
- Returns:
- Precision to scale double values to integer.
Assignment operator.
- Parameters:
-
- Returns:
- Reference to this object.
Operator to access weights by index.
- Parameters:
-
| i | An index to access weights. |
- Returns:
- An integer weight.
- See also:
- getWeight(size_type i)
Sets a new precision to scale double values to integer.
- Parameters:
-
| precision | A new precision. |
Exchanges weight and mass at index1 with weight and mass at index2.
- Parameters:
-
| index1 | Index of weight and mass to be exchanged. |
| index2 | Index of weight and mass to be exchanged. |
Member Data Documentation
Container to store original (double) alphabet masses.
Precision which is used to scale double values to integer.
Container to store scaled integer weights.