|
The IsotopicData class provides a collection of Isotopes and associated methods to access them in various ways. More...
Header: | #include <IsotopicData.hpp> |
IsotopicData() | |
IsotopicData(const IsotopicData &other) | |
virtual | ~IsotopicData() |
void | appendNewIsotope(IsotopeSPtr isotope_sp, bool update_maps = true) |
void | appendNewIsotopes(const std::vector<IsotopeSPtr> &isotopes, bool update_maps = true) |
void | clear() |
double | computeAvgMass(IsotopeCstIteratorPair iter_pair, std::vector<QString> &errors) const |
bool | containsName(const QString &name, int *count = nullptr) const |
bool | containsSymbol(const QString &symbol, int *count = nullptr) const |
std::vector<IsotopeSPtr>::const_iterator | eraseIsotopes(std::size_t begin_index, std::size_t end_index, bool update_maps) |
double | getAvgMassBySymbol(const QString &symbol, bool *ok = nullptr) const |
double | getCumulatedProbabilities(IsotopeCstIteratorPair iter_pair, std::vector<QString> &errors) const |
double | getCumulatedProbabilitiesBySymbol(const QString &symbol, std::vector<QString> &errors) const |
std::size_t | getIsotopeCountBySymbol(const QString &symbol) const |
const std::vector<IsotopeSPtr> & | getIsotopes() const |
IsotopeCstIteratorPair | getIsotopesByName(const QString &name) const |
IsotopeCstIteratorPair | getIsotopesBySymbol(const QString &symbol) const |
double | getMonoMass(IsotopeCstIteratorPair iter_pair, std::vector<QString> &errors) const |
double | getMonoMassBySymbol(const QString &symbol, bool *ok = nullptr) const |
std::size_t | getUniqueSymbolsCount() const |
std::vector<QString> | getUniqueSymbolsInOriginalOrder() const |
bool | insertNewIsotope(IsotopeSPtr isotope_sp, std::size_t index, bool update_maps = true) |
bool | isMonoMassIsotope(IsotopeCstSPtr isotope_csp) |
QString | isotopesAsStringBySymbol(const QString &symbol) const |
void | replace(IsotopeSPtr old_isotope_sp, IsotopeSPtr new_isotope_sp) |
std::size_t | size() const |
bool | updateAvgMassMap(const QString &symbol) |
std::size_t | updateAvgMassMap() |
void | updateMassMaps(const QString &symbol) |
std::size_t | updateMassMaps() |
bool | updateMonoMassMap(const QString &symbol) |
std::size_t | updateMonoMassMap() |
int | validate(std::vector<QString> &errors) const |
bool | validateAllBySymbol(std::vector<QString> &errors) const |
bool | validateBySymbol(const QString &symbol, std::vector<QString> &errors) const |
IsotopicData & | operator=(const IsotopicData &other) |
std::vector<IsotopeSPtr> | m_isotopes |
std::map<QString, double> | m_symbolAvgMassMap |
std::map<QString, double> | m_symbolMonoMassMap |
The IsotopicData class provides a collection of Isotopes and provides methods to access them in various ways. Methods are available to return the monoisotopic mass of an isotope or the average mass calculated from the data of all the isotopes listed for a given chemical element.
[alias]
IsotopicData::IsotopeVectorCstIteratorConstructs the IsotopicData.
The instance will have empty member data.
Constructs the IsotopicData as a copy of other.
This is a deep copy with all the data in the containers copied from other to this IsotopicData.
[virtual noexcept]
IsotopicData::~IsotopicData()Destructs the IsotopicData.
Nothing is explicitely deleted in the destructor.
Appends a new IsotopeSPtr to this IsotopicData.
isotope_sp The new isotope to be added to this collection. The isotope is added to the end of the collection using
m_isotopes.push_back(isotope_sp);
Each time a new isotope is added to this collection, the chemical signification of the corresponding chemical element changes at heart. It might thus be required that the data in the two m_symbolMonoMassMap and m_symbolAvgMassMap maps be recalculated.
update_maps Tells if the m_symbolMonoMassMap and m_symbolAvgMassMap need to be updated with the new collection of isotopes.
See also updateMassMaps() and appendNewIsotopes().
Appends a collection of new IsotopeSPtr to this IsotopicData.
isotopes The collection (<vector>) of new isotopes to be added to this collection. The isotope is added to the end of the collection using
m_isotopes.insert(m_isotopes.end(), isotopes.begin(), isotopes.end());
Each time new isotopes are added to this collection, the chemical signification of all the corresponding chemical elements changes at heart. It might thus be required that the data in the two m_symbolMonoMassMap and m_symbolAvgMassMap maps be recalculated.
Internally, this function calls <vector>.insert() to append all the isotopes in isotopes to the end of m_isotopes.
update_maps Tells if the m_symbolMonoMassMap and m_symbolAvgMassMap need to be updated with the new collection of isotopes.
See also updateMassMaps() and appendNewIsotope().
*
Clear (empties) all the containers in this collection, essentially resetting it completely.
The three containers are cleared:
Compute the average mass for isotopes contained in the iter_pair iterator range.
iter_pair pair of [begin – end[ iterators to the isotopes in this collection
errors vector of strings in which to store error messages
There are no sanity checks performed. The iterator pair should hold two iterator values that frame isotopes of the same chemical element.
The average mass is computed on the basis of the isotopes contained in the [iter_pair .first – iter_pair .second[ range.
Returns 0 if the first member of iter_pair is the collection's end iterator, the average mass otherwise.
Returns true if the collection contains at least one isotope of element name, false otherwise.
If count is not nullptr, its value is set to the count of isotopes of name element.
Returns true if the collection contains at least one isotope of symbol, false otherwise.
If count is not nullptr, its value is set to the count of isotopes of symbol.
Removes the isotopes located between begin_index and end_index.
The removed isotopes are contained inclusively between the two indices passed as parameters.
Each time isotopes are removed from this collection, the chemical signification of the corresponding chemical elements changes at heart. It might thus be required that the data in the two m_symbolMonoMassMap and m_symbolAvgMassMap maps be recalculated.
update_maps Tells if the m_symbolMonoMassMap and m_symbolAvgMassMap need to be updated with the new collection of isotopes.
Returns an iterator to the end of this collection if either begin_index is out of bounds or this collection is empty. Otherwise, returns an iterator to the collection at the position below the last removed item.
Returns the average mass of symbol.
The returned mass is found as the value for key symbol in m_symbolAvgMassMap. If ok is not nullptr, it is set to true.
If the symbol is not found, 0 is returned and ok is set to false if ok is not nullptr.
Returns the sum of the probabilities of all the isotopes in the iter_pair range of iterators.
The range of isotopes is defined by iter_pair, that is [ iter_pair .first – iter_pair .second [.
If errors are encountered, these are appended to errors.
Returns the sum of the probabilities of all the isotopes of symbol.
If errors occur, they will be described as strings appended in errors.
Returns the count of isotopes of symbol.
Returns a constant reference to the container of MsXpS::libXpertMass::Isotopes.
Returns a range of iterators framing the isotopes of element name.
Note: The order of the isotopes in the collection is not alphabetical (it is the order of the atomic number. This function works on the assumption that all the isotopes of a given symbol are clustered together in the isotopes vector with *no* gap in between.
If name is empty, the iterators are set to be end() of the Isotopes collection. The returned pair of iterators frame the isotopes of name as a [begin,end[ pair of iterators.
Returns a range of iterators framing the isotopes of symbol.
Note: The order of the isotopes in the collection is not alphabetical (it is the order of the atomic number. This function works on the assumption that all the isotopes of a given symbol are clustered together in the isotopes vector with *no* gap in between.
If symbol is empty, the iterators are set to be end() of the Isotopes collection. The returned pair of iterators frame the isotopes of symbol as a [begin,end[ pair of iterators.
Returns the mass of the most abundant isotope in a range of isotopes.
The range of isotopes is defined by iter_pair, that is [ iter_pair .first – iter_pair .second [.
If errors are encountered, these are appended to errors.
For all the common chemical elements found in organic substances, the monoisotopic mass is the mass of the most abundant isotope which happens to be also the lightest isotope. However that is not true for *all* the chemical elements. We thus need to iterate in the isotopes of each symbol in the vector of isotopes and record the mass of the isotope that is most abundant.
Returns the monoisotopic mass for element of symbol.
Returns 0 if symbol was not found in this Isotope collection and sets ok to false if ok is not nullptr; returns the monoisotopic mass for element symbol otherwise and sets ok to true if ok is not nullptr.
Returns the count of unique symbols.
Returns all the unique symbols from the collection as they are stored.
Inserts a new IsotopeSPtr to this IsotopicData at index index.
isotope_sp The new isotope to be inserted in this collection.
If index is out of bounds or this collection is empty, the isotope is appended to this collection. Otherwise, the isotope is inserted at the requested index, which means that the new isotope displaces to the bottom (aka back) the isotope currently at index.
Each time a new isotope is added to this collection, the chemical signification of the corresponding chemical element changes at heart. It might thus be required that the data in the two m_symbolMonoMassMap and m_symbolAvgMassMap maps be recalculated.
update_maps Tells if the m_symbolMonoMassMap and m_symbolAvgMassMap need to be updated with the new collection of isotopes.
Returns true if the iterator at the inserted position is not m_isotopes.end().
See also updateMassMaps(), appendNewIsotope(), and appendNewIsotopes().
Returns true if the isotope_csp is isotope of its symbol having the greatest probability, false otherwise.
Returns a string containing a stanza describing each isotope of symbol.
See also Isotope::toString().
Replaces old_isotope_sp by new_isotope_sp in this collection.
Returns the count of isotopes in the collection.
Note: The count that is returned is for all isotopes, that is, the count if items in the collection.
Recalculates the average mass of the chemical element specified by symbol.
For the set of isotopes corresponding to symbol, compute the average mass and set it in m_symbolAvgMassMap as the value for key symbol.
Returns true if the map pair was actually inserted in m_symbolAvgMassMap or false if the average mass value was set to an already existing key.
See also updateMonoMassMap(const QString &symbol), updateMonoMassMap(), updateAvgMassMap(const QString &symbol), and updateMassMaps().
Recalculates the average mass of all the chemical elements in this collection of isotopes.
This function is generally called by default by all the functions that add new isotopes to this collection [via updateMassMaps()].
First, a list of all the unique element symbols in this collection is crafted. Then for each symbol in that list, updateAvgMassMap(symbol) is called.
Returns the number of updated symbols, that is, the unique symbol count in this collection.
See also updateMonoMassMap(const QString &symbol) and updateMassMaps().
Update the monoisotopic and average symbol-mass maps only for symbol.
See also updateMonoMassMap(const QString &symbol) and updateAvgMassMap(const QString &symbol).
Update the monoisotopic and average symbol-mass maps for all the symbols in the collection.
This function is typically called each time new isotopes are added to this collection.
Returns the count of updated symbols, that is, the unique symbol count in this collection.
See also updateMonoMassMap() and updateAvgMassMap().
Redefines the monoisotopic mass of the chemical element specified by symbol.
For the set of isotopes corresponding to symbol, set the most abundant isotope's mass as the value for key symbol in m_symbolMonoMassMap.
Returns true if the map pair was actually inserted in m_symbolMonoMassMap or false if the monoisotopic mass value was set to an existing key.
Redefines the monoisotopic mass of all the chemical elements in this collection of isotopes.
This function is generally called by default by all the functions that add new isotopes to this collection [via updateMassMaps()].
First, a list of all the unique element symbols in this collection is crafted. Then for each symbol in that list, updateMonoMassMap(symbol) is called.
Returns the number of updated symbols, that is, the unique symbol count in this collection.
See also updateMonoMassMap(const QString &symbol) and updateMassMaps().
Validates this Isotope collection.
The validation involves iterating in the whole collection and for each item in it invoke its Isotope::validate(). If errors occurred during these validations, they are counted returned. The errors text strings are stored in errors.
Returns the total count of errors encountered during validation of this collection's Isotopes.
Validates all the isotopes of the collection.
The validation of the Isotopes is performed by grouping them by symbol. See validateBySymbol().
Encountered errors are stored in errors.
Returns true if all the Isotopes validated successfully, false otherwise.
See also validateBySymbol(), validate(), and getCumulatedProbabilitiesBySymbol().
Validate the Isotopes of symbol in this collection.
This function is more powerful than IsotopicData::validate() because it actually verifies the integrity of the data symbol-wise. For example, a set of isotopes by the same symbol cannot have a cumulated probability different than 1. If that were the case, the error would be reported.
Encountered errors are stored in errors.
Returns true if validation succeeded, false otherwise.
See also validateAllBySymbol() and getCumulatedProbabilitiesBySymbol().
Assigns member data from other to this instance's member data.
The copying of other into this collection is deep, making *this collection essentially identical to other.
Returns a reference to this collection.
This variable holds the vector of MsXpS::libXpertMass::IsotopeSPtr.
This variable holds the map relating the Isotope::m_symbol to the average mass.
This variable holds the map relating the Isotope::m_symbol to the monoisotopic mass.