| <large>libXpertMassCore and libXpertMassGui Developer Documentation</large>

- libXpertMassCore
- Averagine

# MsXpS::libXpertMassCore::Averagine Class

class MsXpS::libXpertMassCore::Averagine

The Averagine class provides features to use the Averagine concept. More...

Header: | `#include <MsXpS/libXpertMassCore/Averagine.hpp>`
Inherits: | QObject

- List of all members, including inherited members

## Properties

- formula : Formula
- isotopicData : IsotopicDataCstSPtr

## Public Functions

| Averagine(QObject *parent = nullptr)
| Averagine(MsXpS::libXpertMassCore::IsotopicDataCstSPtr isotopic_data_csp, QObject *parent = nullptr)
| Averagine(const MsXpS::libXpertMassCore::Formula &formula, QObject *parent = nullptr)
| Averagine(const MsXpS::libXpertMassCore::Formula &formula, MsXpS::libXpertMassCore::IsotopicDataCstSPtr isotopic_data_csp, QObject *parent = nullptr)
| Averagine(const MsXpS::libXpertMassCore::Averagine &other, QObject *parent = nullptr)
virtual | ~Averagine()
MsXpS::libXpertMassCore::Averagine * | clone(QObject *parent = nullptr)
double | getAvgMass() const
const MsXpS::libXpertMassCore::Formula & | getFormula() const
const MsXpS::libXpertMassCore::Formula & | getFormulaCstRef() const
MsXpS::libXpertMassCore::Formula & | getFormulaRef()
const MsXpS::libXpertMassCore::IsotopicDataCstSPtr | getIsotopicData() const
double | getMonoMass() const
MsXpS::libXpertMassCore::Averagine & | initialize(const MsXpS::libXpertMassCore::Averagine &other)
bool | isValid() const
void | setFormula(const MsXpS::libXpertMassCore::Formula &formula)
void | setFormula(const QString &formula)
void | setIsotopicData(const MsXpS::libXpertMassCore::IsotopicDataCstSPtr isotopic_data_csp)
QString | toString() const
bool | validate(MsXpS::libXpertMassCore::ErrorList *error_list_p)
bool | operator!=(const MsXpS::libXpertMassCore::Averagine &other) const
bool | operator==(const MsXpS::libXpertMassCore::Averagine &other) const

## Signals

void | formulaChanged()
void | isotopicDataChanged()

## Static Public Members

MsXpS::libXpertMassCore::Averagine * | clone(const MsXpS::libXpertMassCore::Averagine &other, QObject *parent = nullptr)

## Protected Variables

double | m_avg
MsXpS::libXpertMassCore::Formula | m_formula
bool | m_isValid
double | m_mono
MsXpS::libXpertMassCore::IsotopicDataCstSPtr | mcsp_isotopicData

## Detailed Description

Once the Averagine formula has been set and the isotopic data has been set, it is possible to compute an elemental composition corresponding to any arbitrary mass.

First, the averagine equivalents are determined using the mass of the Averagine and the mass passed to the Averagine. Then, the atom indices of the Averagine formula are compounded by the averagine equivalents and the elemental composition formula is determined. That elemental composition formula is provided either with double indices or with integer indices, depending on the user request.

## Property Documentation

### formula : Formula

Formula of the Averagine. Note that the formula holds decimal element symbol count indices.

Access functions:

const MsXpS::libXpertMassCore::Formula & | getFormula() const | [see note below]
void | setFormula(const QString &formula) | [see note below]
void | setFormula(const MsXpS::libXpertMassCore::Formula &formula) | [see note below]

Note: This function can be invoked via the meta-object system and from QML. See Q_INVOKABLE.

Notifier signal:

void | formulaChanged()

### isotopicData : IsotopicDataCstSPtr

This property holds the isotopic data to be used for the computations.

Access functions:

const MsXpS::libXpertMassCore::IsotopicDataCstSPtr | getIsotopicData() const | [see note below]
void | setIsotopicData(const MsXpS::libXpertMassCore::IsotopicDataCstSPtr isotopic_data_csp) | [see note below]

Note: This function can be invoked via the meta-object system and from QML. See Q_INVOKABLE.

Notifier signal:

void | isotopicDataChanged()

## Member Function Documentation

### `[explicit invokable]` Averagine::Averagine(QObject *parent = nullptr)

Constructs an empty Averagine instance.

m_isValid is inherently false.

Note: This function can be invoked via the meta-object system and from QML. See Q_INVOKABLE.

### `[explicit invokable]` Averagine::Averagine(MsXpS::libXpertMassCore::IsotopicDataCstSPtr isotopic_data_csp, QObject *parent = nullptr)

Constructs a Averagine instance setting the isotopic data to isotopic_data_csp.

m_isValid is inherently false because the m_mono and m_avg masses cannot be computed without the formula.

Note: This function can be invoked via the meta-object system and from QML. See Q_INVOKABLE.

### `[explicit invokable]` Averagine::Averagine(const MsXpS::libXpertMassCore::Formula &formula, QObject *parent = nullptr)

Constructs a Averagine instance setting the formula to formula.

m_isValid is inherently false because the m_mono and m_avg masses cannot be computed without the isotopic data.

Note: This function can be invoked via the meta-object system and from QML. See Q_INVOKABLE.

### `[explicit invokable]` Averagine::Averagine(const MsXpS::libXpertMassCore::Formula &formula, MsXpS::libXpertMassCore::IsotopicDataCstSPtr isotopic_data_csp, QObject *parent = nullptr)

Construct a Averagine instance setting the formula to formula and the isotopic data to isotopic_data_csp.

m_isValid is set to the value returned by validate().

The m_mono and m_avg masses are updated by the call to validate().

Note: This function can be invoked via the meta-object system and from QML. See Q_INVOKABLE.

See also validate().

### `[explicit invokable]` Averagine::Averagine(const MsXpS::libXpertMassCore::Averagine &other, QObject *parent = nullptr)

Constructs a Averagine instance as a copy of other.

The copying is deep, that is, all the members of other are copied and validate() is not called.

Note: This function can be invoked via the meta-object system and from QML. See Q_INVOKABLE.

See also validate().

### `[virtual noexcept]` Averagine::~Averagine()

Destructs this Averagine object.

### `[invokable]` MsXpS::libXpertMassCore::Averagine *Averagine::clone(QObject *parent = nullptr)

Returns a newly allocated Averagine instance with parent set to parent.

The new instance is initialized using this instance.

The copying is deep, that is, all the members of `this` are copied and validate() is not called.

Note: This function can be invoked via the meta-object system and from QML. See Q_INVOKABLE.

See also initialize().

### `[static invokable]` MsXpS::libXpertMassCore::Averagine *Averagine::clone(const MsXpS::libXpertMassCore::Averagine &other, QObject *parent = nullptr)

b*rief Returns a newly allocated Averagine instance initialized with other and with parent set to parent.

The copying is deep, that is, all the members of other are copied and validate() is not called.

Note: This function can be invoked via the meta-object system and from QML. See Q_INVOKABLE.

See also Averagine::Averagine().

### `[invokable]` double Averagine::getAvgMass() const

Returns the average mass.

Note: This function can be invoked via the meta-object system and from QML. See Q_INVOKABLE.

### `[invokable]` const MsXpS::libXpertMassCore::Formula &Averagine::getFormula() const

Returns a const reference to the member formula.

This function alias is the getter for the Q_PROPERTY system.

Note: This function can be invoked via the meta-object system and from QML. See Q_INVOKABLE.

Note: Getter function for property formula.

### `[invokable]` const MsXpS::libXpertMassCore::Formula &Averagine::getFormulaCstRef() const

Returns a const reference to the member formula.

Note: This function can be invoked via the meta-object system and from QML. See Q_INVOKABLE.

### `[invokable]` MsXpS::libXpertMassCore::Formula &Averagine::getFormulaRef()

Returns a reference to the member formula.

Note: This function can be invoked via the meta-object system and from QML. See Q_INVOKABLE.

### `[invokable]` const MsXpS::libXpertMassCore::IsotopicDataCstSPtr Averagine::getIsotopicData() const

Returns the isotopic data.

Note: This function can be invoked via the meta-object system and from QML. See Q_INVOKABLE.

Note: Getter function for property isotopicData.

### `[invokable]` double Averagine::getMonoMass() const

Returns the monoisotopic mass.

Note: This function can be invoked via the meta-object system and from QML. See Q_INVOKABLE.

### `[invokable]` MsXpS::libXpertMassCore::Averagine &Averagine::initialize(const MsXpS::libXpertMassCore::Averagine &other)

Returns a reference to this Averagine after its initialization with other.

The copying is deep, that is, all the members of other are copied and validate() is not called.

Note: This function can be invoked via the meta-object system and from QML. See Q_INVOKABLE.

See also validate().

### `[invokable]` bool Averagine::isValid() const

Returns true if this Averagine instance is valid, false otherwise.

Note: This function can be invoked via the meta-object system and from QML. See Q_INVOKABLE.

### `[invokable]` void Averagine::setFormula(const MsXpS::libXpertMassCore::Formula &formula)

Sets the member Formula to formula.

Note: This function can be invoked via the meta-object system and from QML. See Q_INVOKABLE.

Note: Setter function for property formula.

### `[invokable]` void Averagine::setFormula(const QString &formula)

Sets the member Formula to formula.

Note: This function can be invoked via the meta-object system and from QML. See Q_INVOKABLE.

Note: Setter function for property formula.

### `[invokable]` void Averagine::setIsotopicData(const MsXpS::libXpertMassCore::IsotopicDataCstSPtr isotopic_data_csp)

Sets the isotopic data to isotopic_data_csp.

Note: This function can be invoked via the meta-object system and from QML. See Q_INVOKABLE.

Note: Setter function for property isotopicData.

### `[invokable]` QString Averagine::toString() const

Returns a string describing this Averagine instance.

Note: This function can be invoked via the meta-object system and from QML. See Q_INVOKABLE.

### `[invokable]` bool Averagine::validate(MsXpS::libXpertMassCore::ErrorList *error_list_p)

Returns true if this Averagine instance could validate successfully, false otherwise.

Validation steps include checking that the isotopic data are correctly set, that the formula can validate against them and that the masses (mono and avg) of the averagine can be computed.

The errors, if any, are appended to error_list_p, that cannot be nullptr.

m_isValid is set to the result of the validation and is returned.

Note: This function can be invoked via the meta-object system and from QML. See Q_INVOKABLE.

### `[invokable]` bool Averagine::operator!=(const MsXpS::libXpertMassCore::Averagine &other) const

Returns true if this Averagine instance is different than other, false otherwise.

Note: This function can be invoked via the meta-object system and from QML. See Q_INVOKABLE.

### `[invokable]` bool Averagine::operator==(const MsXpS::libXpertMassCore::Averagine &other) const

Returns true if this instance is identical to other, false otherwise.

Note: This function can be invoked via the meta-object system and from QML. See Q_INVOKABLE.

## Member Variable Documentation

### double Averagine::m_avg

This variable holds the average mass of this Averagine instance.

### MsXpS::libXpertMassCore::Formula Averagine::m_formula

Formula of the Averagine. Note that the formula holds decimal element symbol count indices.

### bool Averagine::m_isValid

Tells if this Averagine instance is valid.

### double Averagine::m_mono

This variable holds the monoisotopic mass of this Averagine instance.

### MsXpS::libXpertMassCore::IsotopicDataCstSPtr Averagine::mcsp_isotopicData

This variable holds the isotopic data to be used for the computations.