libXpertMass Developer Documentation
  • libXpertMass
  • IonizeRule
  • IonizeRule Class

    class MsXpS::libXpertMass::IonizeRule

    The IonizeRule class provides an ionization rule. More...

    Header: #include <IonizeRule.hpp>
    Inherits: MsXpS::libXpertMass::Formula

    Public Functions

    IonizeRule()
    IonizeRule(const IonizeRule &other)
    int charge() const
    QString *formatXmlIonizeRuleElement(int offset, const QString &indent = QString(" "))
    QString formula() const
    bool isValid() const
    int level() const
    bool renderXmlIonizeRuleElement(const QDomElement &element)
    void setCharge(int value)
    void setLevel(int value)
    bool operator!=(const IonizeRule &other) const
    IonizeRule &operator=(const IonizeRule &other)
    bool operator==(const IonizeRule &other) const

    Reimplemented Public Functions

    virtual QString toString() const override
    virtual bool validate(IsotopicDataCstSPtr isotopic_data_csp) override

    Protected Variables

    int m_charge
    bool m_isValid
    int m_level

    Detailed Description

    Ionizations are chemical reactions that bring a charge (or more charges) to an analyte. The chemical reaction is described by the inherited Formula class. The electric charge that is brought by this reaction is described by a member of the class, m_charge. It might happen that for polymers, ionization reactions might occur more than once. This is described by one member of the class, m_level.

    An IonizeRule like the following, if used to ionize a molecule of Mr 1000

    would lead to an ion of mass 1001 and of m/z 1001.

    In protein chemistry, the ionization reaction is mainly a protonation reaction, which brings a single charge. Thus, the Formula would be "+H" and the charge 1. In MALDI, we would have a single protonation, thus level would be set to 1 by default. In electrospray ionization, more than one ionization reaction occurs, and we could have a protein that is 25+, thus having an ionization level of 25, for example.

    An IonizeRule like the following, if used to ionize a molecule of Mr 1000

    would lead to an ion of mass 1004 and of m/z 251 (1004 / 4).

    An IonizeRule like the following, if used to ionize a molecule of Mr 1000

    would lead to an ion of mass 1000 + (24 * 4) and of m/z 137 = (1096 / 8).

    Note: Both the charge and level should have positive values, since the real nature of the ionization is beared by the Formula (with, for example in protein chemistry, "+H" for protonation and, in nucleic acids chemistry, "-H" for deprotonation).

    Thus, an IonizeRule is valid if it generates a m/z ratio after ionization of the analyte that is different than the previous (M) and if its Formula validates. This means that the following should be true:

    Note: We do not consider compulsory that the Formula brings a mass difference whatsoever, because some ionizations might not involve heavy mass transfers, like electron gain or electron loss. However, the Formula must validate successfully and that means thit it cannot be empty. In that case, use the Nul chemical element that has not weight from the polymer chemistry definitions shipped with the software package.

    Member Function Documentation

    IonizeRule::IonizeRule()

    Constructs an IonizeRule initialized as an empty object.

    IonizeRule::IonizeRule(const IonizeRule &other)

    Constructs an IonizeRule as a copy of other.

    int IonizeRule::charge() const

    Returns the charge.

    See also setCharge().

    QString *IonizeRule::formatXmlIonizeRuleElement(int offset, const QString &indent = QString(" "))

    Formats a string suitable to use as an XML element.

    Formats a string suitable to be used as an XML element in a polymer chemistry definition file. The typical ionization rule element that is generated in this function looks like this:

    The DTD says this: <!ELEMENT ionizerule(formula,charge,level)>

    A typical ionization rule element looks like this:

    <ionizerule>
    ~~<formula>+H</formula>
    ~~<charge>1</charge>
    ~~<level>1</level>
    </ionizerule>

    offset times the indent string must be used as a lead in the formatting of elements.

    Returns a dynamically allocated string that needs to be freed after use.

    See also renderXmlIonizeRuleElement(const QDomElement &element).

    QString IonizeRule::formula() const

    Returns the formula.

    bool IonizeRule::isValid() const

    Returns true if this IonizeRule is valid, false otherwise.

    See also validate().

    int IonizeRule::level() const

    Returns the ionization level.

    See also setLevel().

    bool IonizeRule::renderXmlIonizeRuleElement(const QDomElement &element)

    Renders the ionization rule XML element.

    The XML element is parsed and the data extracted from the XML data are set to this IonizeRule instance.

    The DTD says this: <!ELEMENT ionizerule(formula,charge,level)>

    A typical ionization rule element looks like this:

    <ionizerule>
    <formula>+H</formula>
    <charge>1</charge>
    <level>1</level>
    </ionizerule>

    Note that this IonizeRule is not valid, as it has not been validated by calling validate(). The caller is reponsible for checking the validity of the IonizeRule prior use.

    Returns true if the parsing is successful, false otherwise.

    See also formatXmlIonizeRuleElement(int offset, const QString &indent).

    void IonizeRule::setCharge(int value)

    Sets the charge to value.

    An IonizeRule with a(charge <= 0) is invalid by definition. If so, the m_isValid member is set to false.

    See also charge().

    void IonizeRule::setLevel(int value)

    Sets the ionzation level to value.

    An IonizeRule might have an ionization level == 0 but not level < 0, as this means that the analyte is not ionized at all. If (level < 0), then the m_isValid member is set to false.

    See also level().

    [override virtual] QString IonizeRule::toString() const

    Reimplements: Formula::toString() const.

    Returns a string holding a textual representation of the member data.

    [override virtual] bool IonizeRule::validate(IsotopicDataCstSPtr isotopic_data_csp)

    Reimplements: Formula::validate(IsotopicDataCstSPtr isotopic_data_csp).

    Validates this IonizeRule against the isotopic_data_csp.

    An IonizeRule is valid if it generates a new m/z ratio after ionization (or deionization if (m_level == 0) of the analyte that is different than the previous one and if its Formula validates successfully. This means that the following should be true:

    If these three tests do not fail, the IonizeRule is considered valid and the m_isValid boolean value is set to true; false otherwise.

    Returns true if validation succeeds, false otherwise.

    See also Formula::validate().

    bool IonizeRule::operator!=(const IonizeRule &other) const

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

    IonizeRule &IonizeRule::operator=(const IonizeRule &other)

    Assigns other to this IonizeRule. Returns a reference to this ionization rule.

    bool IonizeRule::operator==(const IonizeRule &other) const

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

    Member Variable Documentation

    int IonizeRule::m_charge

    This variable holds the charge that is brought to the molecule when it is ionized by the IonizeRule with an ionization level (m_level) of 1.

    bool IonizeRule::m_isValid

    Tells if this IonizeRule is valid,

    See also isValid.

    int IonizeRule::m_level

    This variable holds the number of times this IonizRule is used to ionize a molecule.

    For example, applying this IonizeRule to a molecule

    would protonate it 4 times, with a charge of 4 and an increment in mass of the mass of 4 protons.