|
The Ionizable class provides abstractions to work with entities that have masses (base class Ponderable) and that can be ionized. More...
Header: | #include <Ionizable.hpp> |
Inherits: | MsXpS::libXpertMass::PolChemDefEntity and MsXpS::libXpertMass::Ponderable |
Inherited By: | MsXpS::libXpertMass::Oligomer and MsXpS::libXpertMass::Polymer |
Ionizable(PolChemDefCstSPtr pol_chem_def_csp, const QString &name = QString("NOT_SET"), const Ponderable &ponderable = Ponderable(), const IonizeRule &ionize_rule = IonizeRule(), bool is_ionized = false) | |
Ionizable(const Ionizable &other) | |
virtual | ~Ionizable() |
virtual int | charge() const |
virtual int | deionize() |
virtual int | ionize() |
virtual int | ionize(const IonizeRule &ionize_rule) |
const IonizeRule & | ionizeRule() const |
IonizeRule * | ionizeRule() |
bool | isIonized() const |
virtual double | molecularMass(MassType mass_type) |
int | setCharge(int charge) |
QString | toString() |
virtual bool | validate() |
virtual bool | operator!=(const Ionizable &other) const |
virtual Ionizable & | operator=(const Ionizable &other) |
virtual bool | operator==(const Ionizable &other) const |
virtual bool | calculateMasses() override |
int | ionize(Ionizable *ionizable, const IonizeRule &ionize_rule) |
IonizeRule | m_ionizeRule |
bool | m_isIonized |
An Ionizable is a Ponderable that might undergo ionization, using either its own member IonizeRule or an IonizeRule passed as argument to one of its functions. An Ionizable is also a PolChemDefEntity, as it has to know at each instant what polymer chemistry definition it is based upon. The ionization status of the Ionizable can be checked at each moment and a call to an ionizing function will first trigger deionization if the Ionizable is already ionized. The main members of the Ionizable class are the following:
Upon creation of an Ionizable (without use of the copy constructor), all the data required for the full qualification of the new instance should be passed to the constructor. Default parameters ensure that the Ionizable is set to a consistent status (that is its IonizeRule member is invalid and that its m_isIonized flag is false).
The caller is responsible for seeding correct and consistent values into the constructor for proper operation of the class instances.
For the ionization to be actually performed, and the masses to be effectively updated to account for that ionization, the Ionizable instance must be ionize()d.
It is possible to deionize() an Ionizable instance as it is possible to reionize the instance with another IonizeRule, which will replace the member IonizeRule if the reionization succeeds. The deionize() call effects the state of the Ionizable instance only if the m_isIonized boolean is true.
Constructs an Ionizable.
The Ionizable instance will be an ionized entity if is_ionized is true. The ponderable's mono and avg masses must thus be masses which take (is_ionized is true) or do not take (is_ionized is false) into account the data located in ionize_rule. If is_ionized is true, the ionize_rule is validated and the level of the ionization must not be 0. If one of these two tests fails, this is an error and the program aborts.
pol_chem_def_csp Polymer chemistry definition (cannot be nullptr);
name Name of this Ionizable (defaults to "NOT_SET");
ponderable Ponderable (mono and avg masses);
ionize_rule IonizeRule (defaults to IonizeRule(), that is, an invalid IonizeRule).
is_ionized Tells if the Ionizable to be constructed should be considered as an ionized chemical entity.
Constructs an Ionizable as a copy of other.
No assumption should be made as to the status of the created Ionizable. The caller should characterize the ionization status of the Ionizable with isIonized().
[virtual noexcept]
Ionizable::~Ionizable()Destructs this Ionizable.
[override virtual]
bool Ionizable::calculateMasses()Calculates the masses of this Ionizable.
If this Ionizable is ionized, the masses of the Ponderable base class are let unchanged. If this Ionizable is not ionized and the IonizeRule is valid, perform the ionization, which calculates the masses.
This function returns false if the member IonizeRule is not valid or if the ionization failed, true otherwise.
See also ionize().
[virtual]
int Ionizable::charge() constReturns the ionization charge of this Ionizable.
The charge is returned as a positive number (0 allowed) or as -1 if the IonizeRule is not valid or if m_isIonized is false.
Note: The charge is returned as the compound product of the IonizeRule's m_charge and m_level members.
See also setCharge().
[virtual]
int Ionizable::deionize()Deionizes this Ionizable.
This Ionizable is deionized using its member m_ionizeRule. The following logic is applied:
[virtual]
int Ionizable::ionize()Ionizes this Ionizable.
Ionization is performed on this Ionizable using the member IonizeRule.
The following logic is applied:
[virtual]
int Ionizable::ionize(const IonizeRule &ionize_rule)Ionizes this Ionizable using ionize_rule.
The following logic is applied:
See also ionize().
[static]
int Ionizable::ionize(Ionizable *ionizable, const IonizeRule &ionize_rule)Ionizes the ionizable using ionize_rule.
The following logic is applied:
See also ionize().
Returns a constant reference to this IonizeRule.
Returns a pointer to this IonizeRule.
Returns true if this Ionizable is ionized, false otherwise.
The ionization status is returned on the basis of the m_isIonized member boolean value.
[virtual]
double Ionizable::molecularMass(MassType mass_type)Returns the molecular mass (either monoisotopic or average, depending on mass_type)
A copy of this Ionizable is first made, then it is deionized and its mass is returned.
Sets the charge of this Ionizable to charge.
The charge of an ionizable is the compound product of m_charge and m_level in its IonizeRule member. The value passed as charge is that compound product. Thus, the member IonizeRule is updated to reflect the new charge
using the following code:
int level = charge / m_ionizeRule.charge(); m_ionizeRule.setLevel(level);
Only the level value of IonizeRule is changed to reflect the change of the charge because the chemistry of the ionization rule itself must not be changed.
The following logic is applied:
At this point all the process went fine and 1 is returned.
See also charge().
Returns a string describing this Ionizable.
[virtual]
bool Ionizable::validate()Validates this Ionizable.
The member IonizeRule needs to validate successfully.
Returns true if the validation is successfull, false otherwise.
[virtual]
bool Ionizable::operator!=(const Ionizable &other) constReturns true if this Ionizable is different than other, false otherwise.
[virtual]
Ionizable &Ionizable::operator=(const Ionizable &other)Assigns other to this Ionizable.
Return A reference to this Ionizable instance.
[virtual]
bool Ionizable::operator==(const Ionizable &other) constReturns true if this Ionizable is identical to other, false otherwise.
This variable holds the ionization rule that defines the way to ionize this Ionizable.
See also IonizeRule.
Tells if this Ionizable has undergone an ionization.