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

- libXpertMassCore
- PolChemDef

# MsXpS::libXpertMassCore::PolChemDef Class

class MsXpS::libXpertMassCore::PolChemDef

The PolChemDef class provides a complete set of chemical entities fully qualifying a polymer chemistry definition, like Proteins, Saccharides or Nucleic acids. More...

Header: | `#include <PolChemDef.hpp>`

- List of all members, including inherited members
- PolChemDef is part of Polymer chemistry definition.

## Public Functions

| PolChemDef()
| PolChemDef(const MsXpS::libXpertMassCore::PolChemDefSpec &pol_chem_def_spec)
virtual | ~PolChemDef()
bool | calculateDelimitedCodes()
QString | deduceIsotopicDataFilePath() const
QStringList | differenceBetweenMonomers(double threshold, MsXpS::libXpertMassCore::Enums::MassType mass_type)
QString | formatXmlDtd()
MsXpS::libXpertMassCore::CleavageAgentCstSPtr | getCleavageAgentCstSPtrByName(const QString &name) const
int | getCleavageAgentIndexByName(const QString &name) const
const std::vector<MsXpS::libXpertMassCore::CleavageAgentSPtr> & | getCleavageAgentsCstRef() const
std::vector<MsXpS::libXpertMassCore::CleavageAgentSPtr> & | getCleavageAgentsRef()
int | getCodeLength() const
MsXpS::libXpertMassCore::CrossLinkerCstSPtr | getCrossLinkerCstSPtrByName(const QString &name) const
const std::vector<MsXpS::libXpertMassCore::CrossLinkerSPtr> & | getCrossLinkersCstRef() const
std::vector<MsXpS::libXpertMassCore::CrossLinkerSPtr> & | getCrossLinkersRef()
const QString & | getDelimitedCodes()
MsXpS::libXpertMassCore::FragmentationPathwayCstSPtr | getFragmentationPathwayCstSPtrByName(const QString &name) const
int | getFragmentationPathwayIndexByName(const QString &name) const
const std::vector<MsXpS::libXpertMassCore::FragmentationPathwaySPtr> & | getFragmentationPathwaysCstRef() const
std::vector<MsXpS::libXpertMassCore::FragmentationPathwaySPtr> & | getFragmentationPathwaysRef()
const MsXpS::libXpertMassCore::Ionizer & | getIonizerCstRef() const
MsXpS::libXpertMassCore::Ionizer & | getIonizerRef()
MsXpS::libXpertMassCore::IsotopicDataCstSPtr | getIsotopicDataCstSPtr() const
QString | getIsotopicDataFilePath() const
MsXpS::libXpertMassCore::IsotopicDataSPtr | getIsotopicDataSPtr()
const MsXpS::libXpertMassCore::Formula & | getLeftCap() const
MsXpS::libXpertMassCore::ModifCstSPtr | getModifCstSPtrByName(const QString &name) const
int | getModifIndexByName(const QString &name) const
const std::vector<MsXpS::libXpertMassCore::ModifSPtr> & | getModifsCstRef() const
std::vector<MsXpS::libXpertMassCore::ModifSPtr> & | getModifsRef()
MsXpS::libXpertMassCore::MonomerSPtr | getMonomerCstSPtrByCode(const QString &code) const
MsXpS::libXpertMassCore::MonomerSPtr | getMonomerCstSPtrByName(const QString &name) const
int | getMonomerIndexByCode(const QString &code) const
int | getMonomerIndexByName(const QString &name) const
const std::vector<MsXpS::libXpertMassCore::MonomerSPtr> & | getMonomersCstRef() const
std::vector<MsXpS::libXpertMassCore::MonomerSPtr> & | getMonomersRef()
QString | getName() const
const MsXpS::libXpertMassCore::Formula & | getRightCap() const
QString | getXmlDataDirPath() const
QString | getXmlDataFilePath() const
bool | isChemicallyEquivalent(const MsXpS::libXpertMassCore::PolChemDef &other) const
bool | isValid() const
void | setCodeLength(int code_length)
void | setIonizer(const MsXpS::libXpertMassCore::Ionizer &ionizer)
void | setIsotopicDataFilePath(const QString &file_path)
void | setIsotopicDataSPtr(MsXpS::libXpertMassCore::IsotopicDataSPtr isotopic_data_sp)
void | setLeftCap(const MsXpS::libXpertMassCore::Formula &formula)
void | setName(const QString &name)
void | setRightCap(const MsXpS::libXpertMassCore::Formula &formula)
void | setXmlDataFilePath(const QString &file_path)
bool | validate(MsXpS::libXpertMassCore::ErrorList *error_list_p) const
bool | writeXmlFile()
bool | operator!=(const MsXpS::libXpertMassCore::PolChemDef &other) const
bool | operator==(const MsXpS::libXpertMassCore::PolChemDef &other) const

## Static Public Members

std::size_t | loadIsotopicData(MsXpS::libXpertMassCore::PolChemDefSPtr pol_chem_def_sp, const QString &file_path = QString())
bool | renderXmlPolChemDefFile(MsXpS::libXpertMassCore::PolChemDefSPtr pol_chem_def_sp)
bool | renderXmlPolChemDefFileVersion1(MsXpS::libXpertMassCore::PolChemDefSPtr pol_chem_def_sp)
bool | renderXmlPolChemDefFileVersion2(MsXpS::libXpertMassCore::PolChemDefSPtr pol_chem_def_sp)
std::size_t | writeIsotopicData(MsXpS::libXpertMassCore::PolChemDefSPtr pol_chem_def_sp, const QString &file_path = QString())

## Protected Variables

std::vector<MsXpS::libXpertMassCore::CleavageAgentSPtr> | m_cleavageAgents
int | m_codeLength
std::vector<MsXpS::libXpertMassCore::CrossLinkerSPtr> | m_crossLinkers
QString | m_delimitedCodes
std::vector<MsXpS::libXpertMassCore::FragmentationPathwaySPtr> | m_fragmentationPathways
MsXpS::libXpertMassCore::Ionizer | m_ionizer
QString | m_isotopicDataFilePath
MsXpS::libXpertMassCore::Formula | m_leftCap
std::vector<MsXpS::libXpertMassCore::ModifSPtr> | m_modifs
std::vector<MsXpS::libXpertMassCore::MonomerSPtr> | m_monomers
QString | m_name
std::vector<MsXpS::libXpertMassCore::PolChemDefCstSPtr> | m_polChemDefs
MsXpS::libXpertMassCore::Formula | m_rightCap
QString | m_xmlDataFilePath
MsXpS::libXpertMassCore::IsotopicDataSPtr | msp_isotopicData

## Detailed Description

The PolChemDef class provides a full set of chemical entity definitions (Isotopes, Monomers, chemical Modifications, CrossLinks), chemical reaction models (in the liquid or gas phase, like Polymer cleavage: CleavageAgent or Oligomer fragmentation: FragmentationPathway)

        ...

## Member Function Documentation

### PolChemDef::PolChemDef()

Constructs a polymer chemistry definition.

### PolChemDef::PolChemDef(const MsXpS::libXpertMassCore::PolChemDefSpec &pol_chem_def_spec)

Constructs a polymer chemistry definition on the basis of pol_chem_def_spec.

The pol_chem_def_spec polymer chemistry definition specification provides the name of the polymer chemistry definition and of the file that contains it.

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

Destroys the polymer chemistry definition

### bool PolChemDef::calculateDelimitedCodes()

Constructs a string with the codes of all the Monomers in this PolChemDef instance.

The codes are delimited by the '@' character.

Returns true.

### QString PolChemDef::deduceIsotopicDataFilePath() const

Returns the path of the isotopic data file.

The deduction is based on the fact that the file should have "isotopic-data.dat" as its name.

### QStringList PolChemDef::differenceBetweenMonomers(double threshold, MsXpS::libXpertMassCore::Enums::MassType mass_type)

Returns a string list with the mass difference between all the Monomers in this PolChemDef instace.

If the difference is below the threshold, the difference is added to the string list, otherwise it is skipped. The masses that are compared between every two monomers is of mass_type.

### QString PolChemDef::formatXmlDtd()

Returns a string with the XML DTD for a polymer chemistry definition file.

### MsXpS::libXpertMassCore::CleavageAgentCstSPtr PolChemDef::getCleavageAgentCstSPtrByName(const QString &name) const

Returns a pointer to the CleavageAgent instance known under name.

If no CleavageAgent by that name is known, nullptr is returned.

### int PolChemDef::getCleavageAgentIndexByName(const QString &name) const

Returns the index of the CleavageAgent in the member container of these instances or -1 if that was not found.

The search is performed using the name of the CleavageAgent.

### const std::vector<MsXpS::libXpertMassCore::CleavageAgentSPtr> &PolChemDef::getCleavageAgentsCstRef() const

Returns a const reference to the list of modifications.

### std::vector<MsXpS::libXpertMassCore::CleavageAgentSPtr> &PolChemDef::getCleavageAgentsRef()

Returns a pointer to the list of CleavageAgent instances.

### int PolChemDef::getCodeLength() const

Returns the code length.

### MsXpS::libXpertMassCore::CrossLinkerCstSPtr PolChemDef::getCrossLinkerCstSPtrByName(const QString &name) const

Returns a pointer to the CrossLinker instance known under name.

If no CrossLinker by that name is known, nullptr is returned.

### const std::vector<MsXpS::libXpertMassCore::CrossLinkerSPtr> &PolChemDef::getCrossLinkersCstRef() const

Returns a const reference to the list of modifications.

### std::vector<MsXpS::libXpertMassCore::CrossLinkerSPtr> &PolChemDef::getCrossLinkersRef()

Returns a pointer to the list of CrossLinker instances.

### const QString &PolChemDef::getDelimitedCodes()

Returns a string with the codes of all the Monomers in this PolChemDef instance.

The codes are delimited by the '@' character.

### MsXpS::libXpertMassCore::FragmentationPathwayCstSPtr PolChemDef::getFragmentationPathwayCstSPtrByName(const QString &name) const

Returns a pointer to the FragmentationPathway instance known under name.

If no FragmentationPathway by that name is known, nullptr is returned.

### int PolChemDef::getFragmentationPathwayIndexByName(const QString &name) const

Returns the index of the FragmentationPathway in the member container of these instances or -1 if that was not found.

The search is performed using the name of the FragmentationPathway.

### const std::vector<MsXpS::libXpertMassCore::FragmentationPathwaySPtr> &PolChemDef::getFragmentationPathwaysCstRef() const

Returns a const reference to the list of modifications.

### std::vector<MsXpS::libXpertMassCore::FragmentationPathwaySPtr> &PolChemDef::getFragmentationPathwaysRef()

Returns a pointer to the list of FragmentationPathway instances.

### const MsXpS::libXpertMassCore::Ionizer &PolChemDef::getIonizerCstRef() const

Returns a const reference to the ionizer.

### MsXpS::libXpertMassCore::Ionizer &PolChemDef::getIonizerRef()

Returns a pointer to the ionizer.

### MsXpS::libXpertMassCore::IsotopicDataCstSPtr PolChemDef::getIsotopicDataCstSPtr() const

Returns the isotopic data as const shared pointer..

### QString PolChemDef::getIsotopicDataFilePath() const

Returns the path of the isotopic data file.

### MsXpS::libXpertMassCore::IsotopicDataSPtr PolChemDef::getIsotopicDataSPtr()

Returns the isotopic data as non-const shared pointer..

### const MsXpS::libXpertMassCore::Formula &PolChemDef::getLeftCap() const

Returns the left cap formula.

### MsXpS::libXpertMassCore::ModifCstSPtr PolChemDef::getModifCstSPtrByName(const QString &name) const

Returns a pointer to the Modif instance known under name.

If no Modif by that name is known, nullptr is returned.

### int PolChemDef::getModifIndexByName(const QString &name) const

Returns the index of the Modif in the member container of these instances or -1 if that was not found.

The search is performed using the name of the Modif.

### const std::vector<MsXpS::libXpertMassCore::ModifSPtr> &PolChemDef::getModifsCstRef() const

Returns a const reference to the list of modifications.

### std::vector<MsXpS::libXpertMassCore::ModifSPtr> &PolChemDef::getModifsRef()

Returns a pointer to the list of modifications.

### MsXpS::libXpertMassCore::MonomerSPtr PolChemDef::getMonomerCstSPtrByCode(const QString &code) const

Returns a pointer to the Monomer instance known under code.

If no Monomer by that code is known, nullptr is returned.

### MsXpS::libXpertMassCore::MonomerSPtr PolChemDef::getMonomerCstSPtrByName(const QString &name) const

Returns a pointer to the Monomer instance known under name.

If no Monomer by that name is known, nullptr is returned.

### int PolChemDef::getMonomerIndexByCode(const QString &code) const

Returns the index of the Monomer in the member container of these instances or -1 if that was not found.

The search is performed using the code of the Monomer.

### int PolChemDef::getMonomerIndexByName(const QString &name) const

Returns the index of the Monomer in the member container of these instances or -1 if that was not found.

The search is performed using the name of the Monomer.

### const std::vector<MsXpS::libXpertMassCore::MonomerSPtr> &PolChemDef::getMonomersCstRef() const

Returns a const reference to the list of modifications.

### std::vector<MsXpS::libXpertMassCore::MonomerSPtr> &PolChemDef::getMonomersRef()

Returns a pointer to the list of Monomer instances.

### QString PolChemDef::getName() const

Returns the name of this PolChemDef instance.

### const MsXpS::libXpertMassCore::Formula &PolChemDef::getRightCap() const

Returns the right cap formula.

### QString PolChemDef::getXmlDataDirPath() const

Returns the absolute directory path of this PolChemDef instance.

### QString PolChemDef::getXmlDataFilePath() const

Returns the file path of this PolChemDef instance.

### bool PolChemDef::isChemicallyEquivalent(const MsXpS::libXpertMassCore::PolChemDef &other) const

Returns true if this PolChemDef is equal to other, false otherwise.

The comparison is deep, with all the various chemical entities in the various containers being compared (not their pointers, but the objects themselves).

Note: The names and the data file paths are not compared, because this comparison operator is aimed at comparing the chemistries of the PolChemDef.

### bool PolChemDef::isValid() const

Returns the validity status of thie PolChemDef instance.

### `[static]` std::size_t PolChemDef::loadIsotopicData(MsXpS::libXpertMassCore::PolChemDefSPtr pol_chem_def_sp, const QString &file_path = QString())

Loads the isotopic data stored in the file file_path.

The data loaded from file are parsed and validated. Upon parsing of the file, the data are stored in the pol_chem_def_sp instance's isotopic data member.

If file_path is empty, it is reconstructed using the directory of the polymer chemistry definition and the fact that the isotopic data file name is "isotopic-data.dat".

Returns the count of parsed isotopes.

### `[static]` bool PolChemDef::renderXmlPolChemDefFile(MsXpS::libXpertMassCore::PolChemDefSPtr pol_chem_def_sp)

Parses the polymer chemistry definition file and updates pol_chem_def_sp accordingly.

Upon parsing of the file and validation of the data, the pol_chem_def_sp is updated, essentially initializing it with the data from the file.

Note that the pol_chem_def_sp should have a working set of isotopic data.

Returns true if the parsing was successful and false otherwise.

### `[static]` bool PolChemDef::renderXmlPolChemDefFileVersion1(MsXpS::libXpertMassCore::PolChemDefSPtr pol_chem_def_sp)

Parses the polymer chemistry definition file and updates pol_chem_def_sp accordingly.

Upon parsing of the file and validation of the data, the pol_chem_def_sp is updated, essentially initializing it with the data from the file.

Note that the pol_chem_def_sp should have a working set of isotopic data.

Returns true if the parsing was successful and false otherwise.

### `[static]` bool PolChemDef::renderXmlPolChemDefFileVersion2(MsXpS::libXpertMassCore::PolChemDefSPtr pol_chem_def_sp)

Parses the polymer chemistry definition file and updates pol_chem_def_sp accordingly.

Upon parsing of the file and validation of the data, the pol_chem_def_sp is updated, essentially initializing it with the data from the file.

Note that the pol_chem_def_sp should have a working set of isotopic data.

Returns true if the parsing was successful and false otherwise.

### void PolChemDef::setCodeLength(int code_length)

Sets the code_length.

### void PolChemDef::setIonizer(const MsXpS::libXpertMassCore::Ionizer &ionizer)

Sets the ionizer to ionizer.

### void PolChemDef::setIsotopicDataFilePath(const QString &file_path)

Sets the path of the isotopic data file to file_path.

### void PolChemDef::setIsotopicDataSPtr(MsXpS::libXpertMassCore::IsotopicDataSPtr isotopic_data_sp)

Sets the isotopic data to isotopic_data_sp.

### void PolChemDef::setLeftCap(const MsXpS::libXpertMassCore::Formula &formula)

Sets the left cap formula.

### void PolChemDef::setName(const QString &name)

Sets the name of this PolChemDef instance.

### void PolChemDef::setRightCap(const MsXpS::libXpertMassCore::Formula &formula)

Sets the right cap formula.

### void PolChemDef::setXmlDataFilePath(const QString &file_path)

Sets the file_path of this PolChemDef instance.

### bool PolChemDef::validate(MsXpS::libXpertMassCore::ErrorList *error_list_p) const

Validates this PolChemDef instance by checking the validity of all its members data. Returns true if validation was successful, false otherwise. Any error is added to error_list_p if non-nullptr.

### `[static]` std::size_t PolChemDef::writeIsotopicData(MsXpS::libXpertMassCore::PolChemDefSPtr pol_chem_def_sp, const QString &file_path = QString())

Writes the isotopic data in the pol_chem_def_sp PolChemDef instance to file file_path.

Returns the count of isotopes written to file.

### bool PolChemDef::writeXmlFile()

Writes the polymer chemistry definition to file.

The file's name is from m_xmlDataFilePath.

Returns true if successful, false otherwise.

### bool PolChemDef::operator!=(const MsXpS::libXpertMassCore::PolChemDef &other) const

Returns true if `this` and other differ.

Returns the negated result of operator==().

### bool PolChemDef::operator==(const MsXpS::libXpertMassCore::PolChemDef &other) const

Returns true if this PolChemDef is equal to other, false otherwise.

The comparison is deep, with all the various chemical entities in the various containers being compared (not their pointers, but the objects themselves).

Note: The names and the data file paths are not compared, because this comparison operator is aimed at comparing the chemistries of the PolChemDef.

## Member Variable Documentation

### std::vector<MsXpS::libXpertMassCore::CleavageAgentSPtr> PolChemDef::m_cleavageAgents

This variable holds the container of CleavageAgents defining the various ways to cleave Polymer sequences of this PolChemDef instance.

### int PolChemDef::m_codeLength

This variable holds the maximum length of a Monomer code in this defintion.

The valid syntax of a Monomer code is that the first character of the code is uppercase and all the remaining ones are lowercase. The total number of characters cannot exceed m_codeLength.

### std::vector<MsXpS::libXpertMassCore::CrossLinkerSPtr> PolChemDef::m_crossLinkers

The container of CrossLinkers defined to be part of this PolChemDef instance.

### QString PolChemDef::m_delimitedCodes

This variable holds the set of Monomer codes separated by '@' characters, like "@Ala@Tyr@Phe@".

### std::vector<MsXpS::libXpertMassCore::FragmentationPathwaySPtr> PolChemDef::m_fragmentationPathways

This variable holds the container of FragmentationPathways defining the various ways to fragment Oligomer sequences of this PolChemDef instance.

### MsXpS::libXpertMassCore::Ionizer PolChemDef::m_ionizer

This variable holds the ionization agent that governs the manner the Polymer sequences of this polymer chemistry definition are ionized by default.

### QString PolChemDef::m_isotopicDataFilePath

This variable holds the path to the file that contains this polymer chemistry definition's isotopic data.

### MsXpS::libXpertMassCore::Formula PolChemDef::m_leftCap

This variable holds the Formula that defines how of the left end of a polymer sequence of this PolChemDef needs to be capped in order to finalize the polymerization state of the Polymer sequence.

See also PolChemDef::m_rightCap.

### std::vector<MsXpS::libXpertMassCore::ModifSPtr> PolChemDef::m_modifs

This variable holds the container of Modifs defined to be part of this PolChemDef instance.

### std::vector<MsXpS::libXpertMassCore::MonomerSPtr> PolChemDef::m_monomers

This variable holds the container of Monomers defined to be part of this PolChemDef instance.

### QString PolChemDef::m_name

This variable holds the name of the polymer chemistry definition, like protein-1-letter or nucac, for example.

This name is typically identical to both the name of the directory where all the data defining this `PolChemDef` is stored and the name of the XML file that contains the definition itself.

### std::vector<MsXpS::libXpertMassCore::PolChemDefCstSPtr> PolChemDef::m_polChemDefs

This variable holds the container of PolChemDef instances available in the repositories.

### MsXpS::libXpertMassCore::Formula PolChemDef::m_rightCap

This variable holds the Formula that defines how of the right end of a polymer sequence of this PolChemDef needs to be capped in order to finalize the polymerization state of the Polymer sequence.

See also PolChemDef::m_leftCap.

### QString PolChemDef::m_xmlDataFilePath

This variable holds the path to the XML data file that contains the description of this polymer chemistry definition.

### MsXpS::libXpertMassCore::IsotopicDataSPtr PolChemDef::msp_isotopicData

This variable holds the isotopic data defining the fundamentals of this PolChemDef instance.