libXpertMass Developer Documentation
  • libXpertMass
  • Isotope
  • Isotope Class

    class MsXpS::libXpertMass::Isotope

    The Isotope class models an isotope. More...

    Header: #include <Isotope.hpp>

    Public Functions

    Isotope(int id, QString element, QString symbol, int atomicNo, double mass, int massNo, int extraNeutrons, double probability, double lnProbability, bool radioactive)
    Isotope(const QString &text)
    Isotope(const Isotope &other)
    virtual ~Isotope()
    int getAtomicNo() const
    QString getElement() const
    int getExtraNeutrons() const
    int getId() const
    double getLnProbability() const
    double getMass() const
    int getMassNo() const
    double getProbability() const
    bool getRadioactive() const
    QString getSymbol() const
    bool initialize(const QString &text)
    void setAtomicNo(int atomic_number)
    void setElement(const QString &element)
    void setExtraNeutrons(int extra_neutrons)
    void setId(int id)
    void setLnProbability(double ln_probability)
    void setMass(double mass)
    void setMassNo(int mass_number)
    void setProbability(double probability)
    void setRadioactive(bool is_radioactive)
    void setSymbol(const QString &symbol)
    QString toString() const
    int validate(QString *errors_p = nullptr) const
    bool operator!=(const Isotope &other) const
    virtual Isotope &operator=(const Isotope &other)
    bool operator==(const Isotope &other) const

    Protected Variables

    int m_atomicNo
    QString m_element
    int m_extraNeutrons
    int m_id
    double m_lnProbability
    double m_mass
    int m_massNo
    double m_probability
    bool m_radioactive
    QString m_symbol

    Detailed Description

    The Isotope class models an Isotope by featuring all the methods and member data required to fully characterize an isotope. The member data in this class have been inspired by the element tables from the IsoSpec library. Please, see https://github.com/MatteoLacki/IsoSpec/.

    Member Function Documentation

    Isotope::Isotope(int id, QString element, QString symbol, int atomicNo, double mass, int massNo, int extraNeutrons, double probability, double lnProbability, bool radioactive)

    Constructs the Isotope with all the required arguments.

    The isotope is created as a fully documented instance if all the following parameters a correctly set:

    id MsXpS::libXpertMass::Isotope::m_id

    element MsXpS::libXpertMass::Isotope::m_element

    symbol MsXpS::libXpertMass::Isotope::m_symbol

    atomicNo MsXpS::libXpertMass::Isotope::m_atomicNo

    mass MsXpS::libXpertMass::Isotope::m_mass

    massNo MsXpS::libXpertMass::Isotope::m_massNo

    extraNeutrons MsXpS::libXpertMass::Isotope::m_extraNeutrons

    probability MsXpS::libXpertMass::Isotope::m_probability

    lnProbability MsXpS::libXpertMass::Isotope::m_lnProbability

    radioactive MsXpS::libXpertMass::Isotope::m_radioactive

    Isotope::Isotope(const QString &text)

    Constructs the Isotope using all the data in the text string.

    The strings contains all the Isotope data, separated by a comma ',' exactly with the same format as that implemented by Isotope::toString().

    See also Isotope::initialize() and Isotope::toString().

    Isotope::Isotope(const Isotope &other)

    Constructs the Isotope as a copy of other.

    [virtual noexcept] Isotope::~Isotope()

    Destructs the Isotope.

    int Isotope::getAtomicNo() const

    Returns the atomic number of the isotope.

    See also setAtomicNo().

    QString Isotope::getElement() const

    Returns the element of the isotope.

    See also setElement().

    int Isotope::getExtraNeutrons() const

    Returns the extra neutrons of the isotope.

    See also setExtraNeutrons().

    int Isotope::getId() const

    Returns the id of the isotope.

    See also setId().

    double Isotope::getLnProbability() const

    Returns the ln(probability) of the isotope.

    See also setLnProbability().

    double Isotope::getMass() const

    Returns the mass of the isotope.

    See also setMass().

    int Isotope::getMassNo() const

    Returns the mass number of the isotope.

    See also setMassNo().

    double Isotope::getProbability() const

    Returns the probability (the abundance) of the isotope.

    See also setProbability().

    bool Isotope::getRadioactive() const

    Returns true if the isotope is radioactive, false otherwise.

    See also setRadioactive().

    QString Isotope::getSymbol() const

    Returns the symbol of the isotope.

    See also setSymbol().

    bool Isotope::initialize(const QString &text)

    Initializes the Isotope using all the data in the text string.

    The string passed as argument is QString::simplified() and QString::split() with ',' as the delimiter.

    The obtained strings are converted to the corresponding numerical or textual values to initalize all the member data. The code is similar to:

    m_radioactive =
      string_list[static_cast<int>(IsotopeFields::RADIOACTIVE)].toInt(&ok);
    
    if(!ok)
      {
        qDebug() << "Failed to extract the isotope radioactive.";
        return false;
      }

    Returns true if the string contained valid substrings that successfully initialized the Isotope, false otherwise.

    See also Isotope::Isotope(const QString &text).

    void Isotope::setAtomicNo(int atomic_number)

    Sets the the atomic number of the isotope to atomic_number.

    See also getAtomicNo().

    void Isotope::setElement(const QString &element)

    Sets the element of the isotope to element.

    See also getElement().

    void Isotope::setExtraNeutrons(int extra_neutrons)

    Sets the extra neutrons of the isotope to extra_neutrons.

    See also getExtraNeutrons().

    void Isotope::setId(int id)

    Sets the id of the isotope to id.

    See also getId().

    void Isotope::setLnProbability(double ln_probability)

    Sets the ln(probability) of the isotope to ln_probability.

    See also getLnProbability().

    void Isotope::setMass(double mass)

    Sets the the mass of the isotope to mass.

    See also getMass().

    void Isotope::setMassNo(int mass_number)

    Sets the the mass number of the isotope to mass_number.

    See also getMassNo().

    void Isotope::setProbability(double probability)

    Sets the probability (the abundance) of the isotope to probability.

    See also getProbability().

    void Isotope::setRadioactive(bool is_radioactive)

    Sets if the isotope is radioactive to is_radioactive.

    See also getRadioactive().

    void Isotope::setSymbol(const QString &symbol)

    Sets the symbol of the isotope to symbol.

    See also getSymbol().

    QString Isotope::toString() const

    Returns a string containing a comma-separated textual representation of all the member data values.

    All the member data values are separated using commas ','. Only the values are stored in the string, without naming the variables:

    return QString("%1,%2,%3,%4,%5,%6,%7,%8,%9,%10")
    .arg(m_id)
    .arg(m_element)
    .arg(m_symbol)
    .arg(m_atomicNo)
    .arg(m_mass, 0, 'f', 60)
    .arg(m_massNo)
    .arg(m_extraNeutrons)
    .arg(m_probability, 0, 'f', 60)
    .arg(m_lnProbability, 0, 'f', 60)
    .arg(m_radioactive ? 1 : 0);

    Returns a string.

    int Isotope::validate(QString *errors_p = nullptr) const

    Validates the isotope.

    The symbol, mass and probability member data are scrutinized and if errors are detected an error counter is incremented.

    errors_p Pointer to a string where the detected errors (if any) are stored as meaningful strings. If errors_p is nullptr, the errors are not stored.

    if(m_symbol.isEmpty())
      {
        ++error_count;
        errors += "The symbol is not set.";
      }

    Returns the error count. If no error occurred, the returned value is 0.

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

    Tests the inequality between this isotope and other.

    Computes the negation of the result obtained by calling operator==().

    Returns true if at lease one difference has been encountered and false otherwise.

    See also operator==().

    [virtual] Isotope &Isotope::operator=(const Isotope &other)

    Assigns to this isotope the other isotope's member data.

    Each member datum in other is copied to this isotope.

    Returns a reference to this isotope.

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

    Tests the equality between this isotope and other.

    Each member datum in other is compared to this isotope's member datum. If a difference is detected, a counter is incremented.

    Returns true if no difference has been encountered (the counter is 0) and false otherwise.

    See also operator!=().

    Member Variable Documentation

    int Isotope::m_atomicNo

    This variable holds the atomic number (Z), like 6 for "C", number of protons.

    QString Isotope::m_element

    This variable holds the element, like "carbon" or "nitrogen" (lowercase).

    int Isotope::m_extraNeutrons

    This variable holds the extra neutrons in the isotope's nucleus.

    int Isotope::m_id

    This variable holds the unambiguous id for the chemical element (Hydrogen: 1, Helium, 2, Carbon 6, for example). The id is repeated for each isotope of each chemical element.

    double Isotope::m_lnProbability

    This variable holds the ln (natural logarithm) of the probability p (eln(p)=p).

    double Isotope::m_mass

    This variable holds the mass.

    int Isotope::m_massNo

    This variable holds the mass number, (A) like 12 for "C", number of (protons + neutrons).

    double Isotope::m_probability

    This variable holds the probability of this isotope, that is, its abundance.

    bool Isotope::m_radioactive

    This variable holds the true if the isotope is unstable (disintegrates), false otherwise.

    QString Isotope::m_symbol

    This variable holds the symbol, like "C" or "N".