![]() |
OpenMS
|
Computes empirical formulas for given mass differences using a set of allowed elements. More...
#include <OpenMS/DATASTRUCTURES/MassExplainer.h>
Public Types | |
typedef Adduct::AdductsType | AdductsType |
Type definition for a vector of Adduct objects. More... | |
typedef std::vector< Compomer >::const_iterator | CompomerIterator |
Type definition for an iterator over Compomer objects. More... | |
Constructors and destructor | |
std::vector< Compomer > | explanations_ |
Vector storing all possible explanations for mass differences. More... | |
AdductsType | adduct_base_ |
Set of allowed adducts that can be combined to explain mass differences. More... | |
Int | q_min_ |
Minimum charge state to consider in explanations. More... | |
Int | q_max_ |
Maximum charge state to consider in explanations. More... | |
Int | max_span_ |
Maximum allowed charge span between related features (e.g., a cluster with q={3,6} has span=4) More... | |
double | thresh_p_ |
Minimum required probability threshold for accepting explanations. More... | |
Size | max_neutrals_ |
Maximum number of neutral (q=0) adducts allowed in an explanation. More... | |
MassExplainer () | |
Default constructor. More... | |
MassExplainer (AdductsType adduct_base) | |
Constructor with custom adduct base. More... | |
MassExplainer (Int q_min, Int q_max, Int max_span, double thresh_logp) | |
Constructor with custom charge parameters. More... | |
MassExplainer (AdductsType adduct_base, Int q_min, Int q_max, Int max_span, double thresh_logp, Size max_neutrals) | |
Constructor with all custom parameters. More... | |
MassExplainer & | operator= (const MassExplainer &rhs) |
Assignment operator. More... | |
virtual | ~MassExplainer () |
Destructor. More... | |
void | compute () |
Compute all possible mass differences and their explanations. More... | |
void | setAdductBase (AdductsType adduct_base) |
Set the base set of allowed adducts. More... | |
AdductsType | getAdductBase () const |
Get the current set of allowed adducts. More... | |
const Compomer & | getCompomerById (Size id) const |
Get a specific compomer by its ID. More... | |
SignedSize | query (const Int net_charge, const float mass_to_explain, const float mass_delta, const float thresh_log_p, std::vector< Compomer >::const_iterator &firstExplanation, std::vector< Compomer >::const_iterator &lastExplanation) const |
Search for explanations of a given mass difference. More... | |
void | init_ (bool init_thresh_p) |
Check consistency of input parameters and initialize internal data structures. More... | |
bool | compomerValid_ (const Compomer &cmp) const |
Check if a generated compomer is valid based on its probability, charges, etc. More... | |
Adduct | createAdduct_ (const String &formula, const Int charge, const double p) const |
Create a proper adduct from formula, charge, and probability. More... | |
Computes empirical formulas for given mass differences using a set of allowed elements.
MassExplainer is used to explain observed mass differences between features by determining the most likely combination of adducts that could cause such differences.
The class works by:
This is particularly useful in mass spectrometry data analysis for identifying related features that represent the same analyte but with different adducts or charge states.
typedef Adduct::AdductsType AdductsType |
Type definition for a vector of Adduct objects.
typedef std::vector<Compomer>::const_iterator CompomerIterator |
Type definition for an iterator over Compomer objects.
MassExplainer | ( | ) |
Default constructor.
Initializes with default parameters:
MassExplainer | ( | AdductsType | adduct_base | ) |
Constructor with custom adduct base.
adduct_base | Set of allowed adducts to use for mass difference explanations |
MassExplainer | ( | Int | q_min, |
Int | q_max, | ||
Int | max_span, | ||
double | thresh_logp | ||
) |
Constructor with custom charge parameters.
q_min | Minimum charge state to consider |
q_max | Maximum charge state to consider |
max_span | Maximum allowed charge span between related features |
thresh_logp | Minimum log probability threshold for accepting explanations |
MassExplainer | ( | AdductsType | adduct_base, |
Int | q_min, | ||
Int | q_max, | ||
Int | max_span, | ||
double | thresh_logp, | ||
Size | max_neutrals | ||
) |
Constructor with all custom parameters.
adduct_base | Set of allowed adducts to use for mass difference explanations |
q_min | Minimum charge state to consider |
q_max | Maximum charge state to consider |
max_span | Maximum allowed charge span between related features |
thresh_logp | Minimum log probability threshold for accepting explanations |
max_neutrals | Maximum number of neutral adducts allowed in an explanation |
|
virtual |
Destructor.
|
protected |
Check if a generated compomer is valid based on its probability, charges, etc.
cmp | The compomer to validate |
void compute | ( | ) |
Compute all possible mass differences and their explanations.
This method generates all possible combinations of adducts from the adduct base and stores them internally for later querying. This must be called after changing any parameters and before performing queries.
Create a proper adduct from formula, charge, and probability.
formula | Chemical formula of the adduct |
charge | Charge of the adduct |
p | Probability of the adduct |
AdductsType getAdductBase | ( | ) | const |
Get the current set of allowed adducts.
Get a specific compomer by its ID.
This is typically used after a query() to retrieve detailed information about a specific explanation.
id | ID of the compomer to retrieve |
|
private |
Check consistency of input parameters and initialize internal data structures.
This method validates the input parameters and sets default values where needed.
init_thresh_p | Whether to initialize the probability threshold with default value (set to "false" to keep current value) |
MassExplainer& operator= | ( | const MassExplainer & | rhs | ) |
Assignment operator.
rhs | Source object to assign from |
SignedSize query | ( | const Int | net_charge, |
const float | mass_to_explain, | ||
const float | mass_delta, | ||
const float | thresh_log_p, | ||
std::vector< Compomer >::const_iterator & | firstExplanation, | ||
std::vector< Compomer >::const_iterator & | lastExplanation | ||
) | const |
Search for explanations of a given mass difference.
This method searches the precomputed explanations for those that match the given mass difference within the specified tolerance and have the required net charge.
net_charge | Net charge of the compomer being sought |
mass_to_explain | Mass difference in Da that needs explanation |
mass_delta | Allowed deviation from exact mass (tolerance) |
thresh_log_p | Minimum log probability required for explanations |
firstExplanation | Output iterator to the beginning of matching explanations |
lastExplanation | Output iterator to the end of matching explanations |
void setAdductBase | ( | AdductsType | adduct_base | ) |
Set the base set of allowed adducts.
adduct_base | Vector of adducts to use for explanations |
|
protected |
Set of allowed adducts that can be combined to explain mass differences.
|
protected |
Vector storing all possible explanations for mass differences.
|
protected |
Maximum number of neutral (q=0) adducts allowed in an explanation.
|
protected |
Maximum allowed charge span between related features (e.g., a cluster with q={3,6} has span=4)
|
protected |
Maximum charge state to consider in explanations.
|
protected |
Minimum charge state to consider in explanations.
|
protected |
Minimum required probability threshold for accepting explanations.