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

- libXpertMassCore
- Polymer

# MsXpS::libXpertMassCore::Polymer Class

class MsXpS::libXpertMassCore::Polymer

The Polymer class provides abstractions to work with a polymer molecule (protein or saccharide , for example). More...

Header: | `#include <MsXpS/libXpertMassCore/Polymer.hpp>`
Inherits: | QObject and QEnableSharedFromThis

- List of all members, including inherited members
- Polymer is part of Polymer chemistry building blocks.

## Properties

- author : QString
- code : QString
- filePath : QString

- name : QString
- sequence : QString
- size : const std::size_t

## Public Functions

virtual | ~Polymer()
bool | accountCappingMasses(MsXpS::libXpertMassCore::Enums::CapType cap_type, int times = 1)
void | accountEndModifMasses(MsXpS::libXpertMassCore::Enums::ChemicalEntity polymer_chem_entities)
bool | accountMasses(const MsXpS::libXpertMassCore::CalcOptions &calc_options)
bool | calculateMasses()
bool | calculateMasses(const MsXpS::libXpertMassCore::CalcOptions &calc_options, bool reset)
bool | calculateMasses(const MsXpS::libXpertMassCore::CalcOptions &calc_options, const MsXpS::libXpertMassCore::Ionizer &ionizer)
bool | calculateMasses(const MsXpS::libXpertMassCore::CalcOptions *calc_options_p, const MsXpS::libXpertMassCore::Ionizer *ionizer_p)
void | clear()
QString | crossLink(MsXpS::libXpertMassCore::CrossLinkSPtr cross_link_sp)
std::size_t | crossLinkCount() const
std::vector<std::size_t> | crossLinkIndicesInvolvingMonomer(MsXpS::libXpertMassCore::MonomerCstRPtr monomer_crp) const
std::vector<std::size_t> | crossLinkIndicesInvolvingMonomer(MsXpS::libXpertMassCore::MonomerSPtr monomer_sp) const
bool | crossLinkedMonomersIndicesInRange(std::size_t start_index, std::size_t stop_index, std::vector<std::size_t> &indices, std::size_t &partials) const
bool | crossLinksInRange(std::size_t start_index, std::size_t stop_index, std::vector<MsXpS::libXpertMassCore::CrossLinkSPtr> &cross_links, std::size_t &partials) const
MsXpS::libXpertMassCore::Enums::IonizationOutcome | deionize()
MsXpS::libXpertMassCore::Enums::IonizationOutcome | deionize(const MsXpS::libXpertMassCore::Ionizer &ionizer)
QString | elementalComposition(const MsXpS::libXpertMassCore::IndexRangeCollection &index_range_collection, const MsXpS::libXpertMassCore::CalcOptions &calc_options) const
QString | elementalComposition(const MsXpS::libXpertMassCore::IndexRangeCollection &index_range_collection, const MsXpS::libXpertMassCore::CalcOptions &calc_options, const MsXpS::libXpertMassCore::Ionizer &ionizer) const
QString | elementalComposition(const MsXpS::libXpertMassCore::CalcOptions &calc_options) const
QString | elementalComposition(const MsXpS::libXpertMassCore::CalcOptions &calc_options, const MsXpS::libXpertMassCore::Ionizer &ionizer) const
QString | formatXmlCrossLinksElement(int offset, const QString &indent = QString(" "))
QString | formatXmlDtd()
QString | formatXmlPolSeqElement(int offset, const QString &indent = QString(" "))
QString | getAuthor() const
MsXpS::libXpertMassCore::CalcOptions * | getCalcOptions()
const MsXpS::libXpertMassCore::CalcOptions & | getCalcOptionsCstRef() const
const MsXpS::libXpertMassCore::CalcOptions & | getCalcOptionsRef()
QString | getCode() const
MsXpS::libXpertMassCore::CrossLinkSPtr | getCrossLinkFromUuid(const QString &uuid) const
MsXpS::libXpertMassCore::MonomerCstSPtr | getCrossLinkedMonomerCstSPtrFromUuid(const QString &uuid) const
const std::vector<MsXpS::libXpertMassCore::CrossLinkSPtr> & | getCrossLinksCstRef() const
std::vector<MsXpS::libXpertMassCore::CrossLinkSPtr> & | getCrossLinksRef()
MsXpS::libXpertMassCore::PolymerCstQSPtr | getCstSharedPtr()
QString | getDateTime() const
QString | getFilePath() const
MsXpS::libXpertMassCore::Ionizer * | getIonizer()
const MsXpS::libXpertMassCore::Ionizer & | getIonizerCstRef() const
MsXpS::libXpertMassCore::Ionizer & | getIonizerRef()
const MsXpS::libXpertMassCore::Modif & | getLeftEndModifCstRef() const
MsXpS::libXpertMassCore::Modif & | getLeftEndModifRef()
double | getMass(MsXpS::libXpertMassCore::Enums::MassType mass_type) const
double & | getMassRef(MsXpS::libXpertMassCore::Enums::MassType mass_type)
QString | getName() const
const MsXpS::libXpertMassCore::PolChemDefCstSPtr & | getPolChemDefCstSPtr() const
const MsXpS::libXpertMassCore::Modif & | getRightEndModifCstRef() const
MsXpS::libXpertMassCore::Modif & | getRightEndModifRef()
const MsXpS::libXpertMassCore::Sequence & | getSequenceCstRef() const
MsXpS::libXpertMassCore::Sequence & | getSequenceRef()
QString | getSequenceText() const
MsXpS::libXpertMassCore::PolymerQSPtr | getSharedPtr()
QString | getUuidForCrossLink(const MsXpS::libXpertMassCore::CrossLinkSPtr &cross_link_sp) const
bool | hasCrossLink(const MsXpS::libXpertMassCore::CrossLinkSPtr &cross_link_sp) const
bool | hasModifiedMonomer(std::size_t left_index, std::size_t right_index) const
bool | hasUuid(const MsXpS::libXpertMassCore::CrossLinkSPtr &cross_link_sp) const
MsXpS::libXpertMassCore::Enums::IonizationOutcome | ionize()
MsXpS::libXpertMassCore::Enums::IonizationOutcome | ionize(const MsXpS::libXpertMassCore::Ionizer &ionizer)
bool | isLeftEndModified() const
bool | isRightEndModified() const
bool | isValid() const
QByteArray | md5Sum(int hash_data_specifs) const
std::size_t | modifiedMonomerCount(const MsXpS::libXpertMassCore::IndexRangeCollection &index_range_collection) const
bool | modifyMonomer(std::size_t index, const QString modif_name, bool override)
MsXpS::libXpertMassCore::Enums::IonizationOutcome | molecularMasses(double &mono, double &avg) const
std::size_t | prepareMonomerRemoval(MsXpS::libXpertMassCore::MonomerSPtr monomer_csp)
bool | removeMonomerAt(std::size_t index)
bool | renderXmlCodesElement(const QDomElement &element)
bool | renderXmlCrossLinksElement(const QDomElement &element, int version)
bool | renderXmlPolymerFile(const QString &file_path = QString(""))
bool | renderXmlPolymerModifElement(const QDomElement &element, int version)
void | setAuthor(const QString &author)
void | setCalcOptions(const MsXpS::libXpertMassCore::CalcOptions &calc_options)
void | setCalcOptions(const MsXpS::libXpertMassCore::CalcOptions *calc_options)
void | setCode(const QString &code)
void | setDateTime()
void | setDateTime(const QString &date_time)
void | setFilePath(const QString &file_path)
void | setIonizer(const MsXpS::libXpertMassCore::Ionizer &ionizer)
void | setIonizer(const MsXpS::libXpertMassCore::Ionizer *ionizer_p)
bool | setLeftEndModif(const MsXpS::libXpertMassCore::Modif &modif)
bool | setLeftEndModifByName(const QString &name = QString())
void | setName(const QString &name)
void | setPolChemDefCstSPtr(MsXpS::libXpertMassCore::PolChemDefCstSPtr pol_chem_def_csp)
bool | setRightEndModif(const MsXpS::libXpertMassCore::Modif &modif)
bool | setRightEndModifByName(const QString &name = QString())
void | setSequence(const MsXpS::libXpertMassCore::Sequence &sequence)
void | setSequence(const QString &sequence_string)
std::size_t | size() const
QString | storeCrossLink(MsXpS::libXpertMassCore::CrossLinkSPtr cross_link_sp)
QString | toString() const
bool | uncrossLink(MsXpS::libXpertMassCore::CrossLinkSPtr cross_link_sp)
void | unmodify(MsXpS::libXpertMassCore::Enums::PolymerEnd polymer_end)
bool | validate(MsXpS::libXpertMassCore::ErrorList *error_list_p) const
bool | writeXmlFile()

## Static Public Members

bool | accountCappingMasses(const MsXpS::libXpertMassCore::Polymer *polymer_p, MsXpS::libXpertMassCore::Enums::CapType cap_type, double &mono, double &avg, int times = 1)
void | accountEndModifMasses(const MsXpS::libXpertMassCore::Polymer *polymer_p, MsXpS::libXpertMassCore::Enums::ChemicalEntity polymer_chem_entities, double &mono, double &avg)
bool | accountMasses(const MsXpS::libXpertMassCore::Polymer *polymer_p, const MsXpS::libXpertMassCore::CalcOptions &calc_options, double &mono, double &avg)
bool | calculateMasses(const MsXpS::libXpertMassCore::Polymer *polymer_p, const MsXpS::libXpertMassCore::CalcOptions &calc_options, double &mono, double &avg, bool reset)
bool | calculateMasses(const MsXpS::libXpertMassCore::Polymer *polymer_p, const MsXpS::libXpertMassCore::CalcOptions &calc_options, const MsXpS::libXpertMassCore::Ionizer &ionizer, double &mono, double &avg)
MsXpS::libXpertMassCore::PolymerQSPtr | createSPtr(MsXpS::libXpertMassCore::PolChemDefCstSPtr pol_chem_def_csp = nullptr, const QString &name = QString(), const QString &code = QString(), const QString &author = QString(), const QString &sequence_string = QString())
QString | xmlPolymerFileGetPolChemDefName(const QString &file_path)

## Protected Variables

QString | m_author
double | m_avg
QString | m_code
std::vector<MsXpS::libXpertMassCore::CrossLinkSPtr> | m_crossLinks
QDateTime | m_dateTime
QString | m_filePath
bool | m_isValid
MsXpS::libXpertMassCore::Modif | m_leftEndModif
double | m_mono
QString | m_name
MsXpS::libXpertMassCore::Modif | m_rightEndModif
MsXpS::libXpertMassCore::Sequence | m_sequence
MsXpS::libXpertMassCore::PolChemDefCstSPtr | mcsp_polChemDef
MsXpS::libXpertMassCore::CalcOptions * | mp_calcOptions
MsXpS::libXpertMassCore::Ionizer * | mp_ionizer

## Detailed Description

The Polymer class provides a polymer sequence. In the protein world, a polymer sequence is a protein. From a computing standpoint, that sequence is first created by chaining amino acid residues (the residue chain). In a second step, the entity is set to a finished polymer state by adding the N-terminal proton and the C-terminal hydroxyl residue. It might happen also that the ends of a polymer be chemically modified (acetylation of the N-terminal residue, for example).

The Polymer class allows modelling a polymer sequence in its finest details.

Note: As a design decision, Polymer instances can only be created as shared pointer instances. Hence, the constructor is private and is called by createSPtr().

Note: The Polymer class derives from std::enable_shared_from_this<Polymer> because in determinate situations it is necessary to access the shared pointer from the raw pointer (in the particular case of CrossLink instances that need to reference the Polymer in which they occur).

## Property Documentation

### author : QString

This property holds the author or creator of the file.

Access functions:

QString | getAuthor() const | [see note below]
void | setAuthor(const QString &author) | [see note below]

Note: This function can be invoked via the meta-object system and from QML. See Q_INVOKABLE.

### code : QString

This property holds the code of the polymer, for example, the accession number in SwissProt.

Access functions:

QString | getCode() const | [see note below]
void | setCode(const QString &code) | [see note below]

Note: This function can be invoked via the meta-object system and from QML. See Q_INVOKABLE.

### filePath : QString

This property holds the file path to the Polymer sequence file.

Access functions:

QString | getFilePath() const | [see note below]
void | setFilePath(const QString &file_path) | [see note below]

Note: This function can be invoked via the meta-object system and from QML. See Q_INVOKABLE.

### name : QString

This property holds the name of the polymer, for example, "Apomyoglobin".

Access functions:

QString | getName() const | [see note below]
void | setName(const QString &name) | [see note below]

Note: This function can be invoked via the meta-object system and from QML. See Q_INVOKABLE.

### sequence : QString

This property holds the Sequence instance that enshrines the actual Polymer sequence of Monomer instances.

Access functions:

QString | getSequenceText() const | [see note below]
void | setSequence(const QString &sequence_string) | [see note below]
void | setSequence(const MsXpS::libXpertMassCore::Sequence &sequence)

Note: This function can be invoked via the meta-object system and from QML. See Q_INVOKABLE.

### `[read-only]` size : const std::size_t

This property holds the number of residues in the polymer sequence.

Access functions:

std::size_t | size() const | [see note below]

Note: This function can be invoked via the meta-object system and from QML. See Q_INVOKABLE.

## Member Function Documentation

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

Destructs the polymer.

### bool Polymer::accountCappingMasses(MsXpS::libXpertMassCore::Enums::CapType cap_type, int times = 1)

Accounts for the mass of the end caps.

The polymer sequence is actually a chain of monomers (that is, residues). In order to compute the mass of the polymer in its finished state, it is necessary to add the masses of its end caps (typically, a proton and a hydroxyl group in protein chemistry, respectively capping the N-terminus and the C-terminus).

The mass of the the left end cap is added to the monoisotopic and average masses of this polymer if (cap_type & Enums::CapType::LEFT). The mass of the the right end cap is added to the monoisotopic and average masses of this polymer if (cap_type & Enums::CapType::RIGHT).

The masses of the caps are multiplied by times before accounting them to this polymer's masses.

Returns true.

### `[static]` bool Polymer::accountCappingMasses(const MsXpS::libXpertMassCore::Polymer *polymer_p, MsXpS::libXpertMassCore::Enums::CapType cap_type, double &mono, double &avg, int times = 1)

Accounts for the polymer_p's end caps masses to mono and avg.

polymer_p cannot be nullptr.

The polymer sequence is actually a chain of monomers (that is, residues). In order to compute the mass of the polymer in its finished state, it is necessary to add the masses of its end caps (typically, a proton and a hydroxyl group in protein chemistry, respectively capping the N-terminus and the C-terminus).

The mass of the the left end cap is added to the mono and avg masses if (cap_type & Enums::CapType::LEFT). The mass of the the right end cap is added to the mono and avg masses if (cap_type & Enums::CapType::RIGHT).

The masses of the caps are multiplied by times before accounting them to mono and avg. Returns true.

### void Polymer::accountEndModifMasses(MsXpS::libXpertMassCore::Enums::ChemicalEntity polymer_chem_entities)

Accounts for this Polymer instance's end modifications masses as defined by polymer_chem_entities.

See also accountEndModifMasses().

### `[static]` void Polymer::accountEndModifMasses(const MsXpS::libXpertMassCore::Polymer *polymer_p, MsXpS::libXpertMassCore::Enums::ChemicalEntity polymer_chem_entities, double &mono, double &avg)

Accounts for the polymer_p's masses as defined by polymer_chem_entities.

The end modifications masses are accounted for into the mono and avg masses without prior resetting of them.

If `(polymer_chem_entities & Enums::ChemicalEntity::LEFT_END_MODIF)`, the left end modification masses are accounted for; if `(polymer_chem_entities & Enums::ChemicalEntity::RIGHT_END_MODIF)` the right end modification masses are accounted for.

### bool Polymer::accountMasses(const MsXpS::libXpertMassCore::CalcOptions &calc_options)

Accounts the masses of this polymer.

Accounting masses means calculating masses and adding the results to objects. Here the masses of this polymer are calculated and added to those of this polymer.

The calculation of the masses (monoisotopic and average) is configured in calc_options.

Returns true upon success, false otherwise.

See also CalcOptions.

### `[static]` bool Polymer::accountMasses(const MsXpS::libXpertMassCore::Polymer *polymer_p, const MsXpS::libXpertMassCore::CalcOptions &calc_options, double &mono, double &avg)

Accounts the masses of polymer_p.

polymer_p cannot be nullptr.

Accounting masses means calculating masses and adding the results to objects. Here the masses of this polymer are calculated and set to mono and avg.

The calculation of the masses (monoisotopic and average) is configured in calc_options.

This function overloads Polymer::accountMasses().

See also CalcOptions.

### `[static invokable]` bool Polymer::calculateMasses(const MsXpS::libXpertMassCore::Polymer *polymer_p, const MsXpS::libXpertMassCore::CalcOptions &calc_options, double &mono, double &avg, bool reset)

Calculates the masses of polymer_p.

The calculated masses are set to mono and avg.

If reset is true, mono and avg are reset to 0.0, otherwise they are left unchanged and incremented with the masses obtained from the calculation.

The calculation of the masses (monoisotopic and average) is configured in calc_options.

The ionization of the polymer is not accounted for in this function.

Returns true if all the calculation steps were performed succesfully, false otherwise.

Note: This function can be invoked via the meta-object system and from QML. See Q_INVOKABLE.

See also calculateMasses().

### `[invokable]` bool Polymer::calculateMasses()

Calculates the masses of this polymer.

The calculated masses are set to this polymer's m_mono and m_avg members. These masses are first reset to 0.0.

The calculation of the masses (monoisotopic and average) is configured in the member CalcOptions object.

After the masses are computed, the ionization described in the member Ionizer object is accounted for.

Returns true if all steps could be performed successfully, false otherwise.

Note: This function can be invoked via the meta-object system and from QML. See Q_INVOKABLE.

This function overloads Polymer::calculateMasses().

See also calculateMasses(), CalcOptions, and Ionizer.

### `[invokable]` bool Polymer::calculateMasses(const MsXpS::libXpertMassCore::CalcOptions &calc_options, bool reset)

Calculates the masses of this polymer.

The calculated masses are set to this polymer's m_mono and m_avg members. If reset is true, these masses are first reset to 0.0, otherwise this polymer's masses are left unchanged and incremented with those obtained from the calculation.

The calculation of the masses (monoisotopic and average) is configured in calc_options.

No ionization is accounted for in this function.

Returns true.

Note: This function can be invoked via the meta-object system and from QML. See Q_INVOKABLE.

This function overloads Polymer::calculateMasses().

See also calculateMasses() and CalcOptions.

### `[invokable]` bool Polymer::calculateMasses(const MsXpS::libXpertMassCore::CalcOptions &calc_options, const MsXpS::libXpertMassCore::Ionizer &ionizer)

Calculates the masses of this polymer.

The calculated masses are set to this polymer's m_mono and m_avg members. These masses are first reset to 0.0.

The calculation of the masses (monoisotopic and average) is configured in calc_options.

After the masses are computed, the ionization described in ionizer is accounted for.

Returns true if all steps could be performed successfully, false otherwise.

Note: This function can be invoked via the meta-object system and from QML. See Q_INVOKABLE.

This function overloads Polymer::calculateMasses().

See also calculateMasses(), CalcOptions, and Ionizer.

### `[invokable]` bool Polymer::calculateMasses(const MsXpS::libXpertMassCore::CalcOptions *calc_options_p, const MsXpS::libXpertMassCore::Ionizer *ionizer_p)

Calculates the masses of this polymer.

The calculated masses are set to this polymer's m_mono and m_avg members. These masses are first reset to 0.0.

The calculation of the masses (monoisotopic and average) is configured in calc_options_p.

After the masses are computed, the ionization described in ionizer_p is accounted for.

Returns true if all steps could be performed successfully, false otherwise.

Note: This function can be invoked via the meta-object system and from QML. See Q_INVOKABLE.

This function overloads Polymer::calculateMasses().

See also calculateMasses(), CalcOptions, and Ionizer.

### `[static invokable]` bool Polymer::calculateMasses(const MsXpS::libXpertMassCore::Polymer *polymer_p, const MsXpS::libXpertMassCore::CalcOptions &calc_options, const MsXpS::libXpertMassCore::Ionizer &ionizer, double &mono, double &avg)

Calculates the masses of polymer_p.

The calculated masses are set to mono and avg. Prior to setting the masses to mono and avg, these masses are reset to 0.0.

The calculation of the masses (monoisotopic and average) is configured in calc_options.

After the masses are computed, the ionization described in ionizer is accounted for.

Returns true if all steps could be performed successfully, false otherwise.

Note: This function can be invoked via the meta-object system and from QML. See Q_INVOKABLE.

This function overloads Polymer::calculateMasses().

See also calculateMasses(), CalcOptions, and Ionizer.

### `[invokable]` void Polymer::clear()

Clears all the member data.

Note: This function can be invoked via the meta-object system and from QML. See Q_INVOKABLE.

### `[static]` MsXpS::libXpertMassCore::PolymerQSPtr Polymer::createSPtr(MsXpS::libXpertMassCore::PolChemDefCstSPtr pol_chem_def_csp = nullptr, const QString &name = QString(), const QString &code = QString(), const QString &author = QString(), const QString &sequence_string = QString())

Constructs a polymer with a number of arguments.

- pol_chem_def_csp The polymer chemistry definition context in which this Polymer instance exists
- name The name of the Polymer instance (could be the name of the protein from the SwissProt or the GenBank database, for example)
- code The code of Polymer sequence (could be an accession number from the SwissProt or the GenBank database, for example)
- author The author creating the Polymer sequence
- sequence_string The monomer codes that make the Polymer sequence.

This function call the actual private constructor.

### QString Polymer::crossLink(MsXpS::libXpertMassCore::CrossLinkSPtr cross_link_sp)

Performs the actual cross-linking as described in cross_link_sp.

The chemical representation of the cross-link must have been previously defined in cross_link_sp.

Upon performing the actual cross-link, a Uuid string is generated to identify that cross-link unambiguously. That string is returned. If the cross-link fails, the empty string is returned.

Returns true upon success or false if the CrossLink did not not validate successfully.

Note: Emits the `crossLinkChangedSignal(this)` signal to let interested parties know that the Polymer has seen its cross-linking state changed.

### `[invokable]` std::size_t Polymer::crossLinkCount() const

Returns the number of CrossLink instances in the member container.

Note: This function can be invoked via the meta-object system and from QML. See Q_INVOKABLE.

### std::vector<std::size_t> Polymer::crossLinkIndicesInvolvingMonomer(MsXpS::libXpertMassCore::MonomerCstRPtr monomer_crp) const

Searches for all the CrossLink instances that involve monomer_crp and returns a container with the index of each one of them in the member container of CrossLink instances.

### std::vector<std::size_t> Polymer::crossLinkIndicesInvolvingMonomer(MsXpS::libXpertMassCore::MonomerSPtr monomer_sp) const

Searches for all the CrossLink instances that involve monomer_sp and returns a container with all of them.

### bool Polymer::crossLinkedMonomersIndicesInRange(std::size_t start_index, std::size_t stop_index, std::vector<std::size_t> &indices, std::size_t &partials) const

Fills-in the indices container with indices of Monomer instances involved in cross-links found to be entirely contained in the start_index – stop_index sequence range. f This function iterates in all of this polymer's cross-links and checks, for each cross-link if:

- It is fully contained in the indices range [start_index, stop_index] (the indices of the monomer in between the two cross-linked monomers are added to indices)
- It is only partially contained in the range (the partials counter is then incremented)
- Not contained at all in the range (nothing is done).

Returns true if at least one cross-link was found to be fully encompassed by the range, false otherwise.

See also crossLinksInRange().

### bool Polymer::crossLinksInRange(std::size_t start_index, std::size_t stop_index, std::vector<MsXpS::libXpertMassCore::CrossLinkSPtr> &cross_links, std::size_t &partials) const

Fills-in the cross_links CrossLink container with cross-links found to be entirely contained in the start_index – stop_index sequence range.

This function iterates in all of this polymer's cross-links and checks, for each cross-link if:

- It is fully contained in the indices range [start_index, stop_index] (it is then added to cross_links)
- It is only partially contained in the range (the partials counter is then incremented)
- Not contained at all in the range (nothing is done).

Returns true if at least one cross-link was found to be fully encompassed by the range, false otherwise.

See also crossLinkedMonomersIndicesInRange().

### `[invokable]` MsXpS::libXpertMassCore::Enums::IonizationOutcome Polymer::deionize()

Returns the result of the deionization process.

The new masses, if a change occurred, are updated in the member monoisotopic and average masses.

Note: This function can be invoked via the meta-object system and from QML. See Q_INVOKABLE.

### `[invokable]` MsXpS::libXpertMassCore::Enums::IonizationOutcome Polymer::deionize(const MsXpS::libXpertMassCore::Ionizer &ionizer)

Returns the result of the deionization process using ionizer.

The new masses, if a change occurred, are updated in the member monoisotopic and average masses.

Note: This function can be invoked via the meta-object system and from QML. See Q_INVOKABLE.

### `[invokable]` QString Polymer::elementalComposition(const MsXpS::libXpertMassCore::IndexRangeCollection &index_range_collection, const MsXpS::libXpertMassCore::CalcOptions &calc_options) const

*brief Determines the elemental composition of this polymer.

The elemental composition is computed by looking into the core chemical entities of the polymer, like the monomers, the modifications, and the CalcOptions calc_options. The sequence elements that are accounted for are described in IndexRange instances stored in index_range_collection.

The member ionizer is checked for validity and if valid is taken into account.

Returns the elemental composition.

Note: This function can be invoked via the meta-object system and from QML. See Q_INVOKABLE.

See also elementalComposition(), IndexRange, Ionizer, and CalcOptions.

### `[invokable]` QString Polymer::elementalComposition(const MsXpS::libXpertMassCore::IndexRangeCollection &index_range_collection, const MsXpS::libXpertMassCore::CalcOptions &calc_options, const MsXpS::libXpertMassCore::Ionizer &ionizer) const

Determines the elemental composition of this polymer.

The elemental composition is computed by looking into the core chemical entities of the polymer, like the monomers, the modifications, but also by accounting for the Ionizer ionizer, and the CalcOptions calc_options. The sequence elements that are accounted for are described in IndexRange instances stored in index_range_collection.

ionizer is checked for validity and if valid, it is accounted for.

Returns the elemental composition.

Note: This function can be invoked via the meta-object system and from QML. See Q_INVOKABLE.

See also elementalComposition(), IndexRange, Ionizer, and CalcOptions.

### `[invokable]` QString Polymer::elementalComposition(const MsXpS::libXpertMassCore::CalcOptions &calc_options) const

Determines the elemental composition of this polymer.

The elemental composition is computed by looking into the core chemical entities of the polymer, like the monomers, the modifications, but also by accounting for the CalcOptions calc_options.

The IndexRange instances of the Polymer for which the elemental composition is to be computed are found in the IndexRangeCollection instance of calc_options.

If the member ionizer is valid, it is accounted for.

Returns the elemental composition.

Note: This function can be invoked via the meta-object system and from QML. See Q_INVOKABLE.

This is an overloaded function.

See also elementalComposition().

### `[invokable]` QString Polymer::elementalComposition(const MsXpS::libXpertMassCore::CalcOptions &calc_options, const MsXpS::libXpertMassCore::Ionizer &ionizer) const

Determines the elemental composition of this polymer.

The elemental composition is computed by looking into the core chemical entities of the polymer, like the monomers, the modifications, but also by accounting for the Ionizer ionizer, and the CalcOptions calc_options.

The IndexRange instances of the Polymer for which the elemental composition is to be computed are found in the IndexRangeCollection instance of calc_options.

Returns the elemental composition.

Note: This function can be invoked via the meta-object system and from QML. See Q_INVOKABLE.

This is an overloaded function.

See also elementalComposition().

### QString Polymer::formatXmlCrossLinksElement(int offset, const QString &indent = QString(" "))

Formats an XML element suitable to describe the `<crosslinks>` element.

Iterates in the cross-link list of this polymer and crafts XML elements describing them.

The XML element looks like this:

    <crosslinks>
    <crosslink>
    <name>DisulfideBond</name>
    <targets>;2;6;</targets>
    </crosslink>
    </crosslinks>

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

Returns the XML element as a dynamically allocated string.

### QString Polymer::formatXmlDtd()

Creates the XML DTD for a polymer sequence file.

Returns the DTD in string.

### QString Polymer::formatXmlPolSeqElement(int offset, const QString &indent = QString(" "))

Formats this polymer's sequence as a string suitable to use as an XML element.

This function generates a string holding all the elements pertaining to this polymer' sequence (the list of monomers, potentially modified, not all the other data). The typical element that is generated in this function looks like this:

    <polseq>
    <codes>MEFEEDWYGEEDWYGTEEDWYGTEEDWYGTEEDWYGTEEDWYGTEEDWYGT</codes>
    <monomer>
    <code>S</code>
    <mdf>
    <name>Phosphorylation</name>
    <formula></formula>
    <targets>*</targets>
    </mdf>
    </monomer>
    </polseq>

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 writeXmlFile().

### `[invokable]` QString Polymer::getAuthor() const

Returns the author.

Note: This function can be invoked via the meta-object system and from QML. See Q_INVOKABLE.

Note: Getter function for property author.

### `[invokable]` MsXpS::libXpertMassCore::CalcOptions *Polymer::getCalcOptions()

Returns a reference to the member CalcOptions.

Note: This function can be invoked via the meta-object system and from QML. See Q_INVOKABLE.

### const MsXpS::libXpertMassCore::CalcOptions &Polymer::getCalcOptionsCstRef() const

Returns a const reference to the member CalcOptions.

### const MsXpS::libXpertMassCore::CalcOptions &Polymer::getCalcOptionsRef()

Returns a reference to the member CalcOptions.

### `[invokable]` QString Polymer::getCode() const

Returns the code.

Note: This function can be invoked via the meta-object system and from QML. See Q_INVOKABLE.

Note: Getter function for property code.

### MsXpS::libXpertMassCore::CrossLinkSPtr Polymer::getCrossLinkFromUuid(const QString &uuid) const

Returns the CrossLinkSPtr that is associated with uuid, if it is found in the member container of UuidCrossLinkWPtrPair objects.

If no such pair is found to hold uuid as its first member, then nullptr is returned.

See also getCrossLinkFromUuid().

### MsXpS::libXpertMassCore::MonomerCstSPtr Polymer::getCrossLinkedMonomerCstSPtrFromUuid(const QString &uuid) const

Returns the MonomerCstSPtr that is associated with uuid, if it is found in any CrossLink belonging to this Polymer.

If no such Monomer is found, nullptr is returned.

See also getCrossLinkFromUuid().

### const std::vector<MsXpS::libXpertMassCore::CrossLinkSPtr> &Polymer::getCrossLinksCstRef() const

Returns a const reference to the container of CrossLink instances.

### std::vector<MsXpS::libXpertMassCore::CrossLinkSPtr> &Polymer::getCrossLinksRef()

Returns a reference to the container of CrossLink instances.

### MsXpS::libXpertMassCore::PolymerCstQSPtr Polymer::getCstSharedPtr()

Returns a const-cast of the PolymerSPtr (std::shared_ptr<Polymer>) that manages this Polymer *.

This function should never fail because a Polymer can only be allocated as a PolymerSPtr (private Polymer::Polymer() constructor called by a public createSPtr() function).

See also CrossLink::CrossLink() and renderXmlCrossLinksElement().

### `[invokable]` QString Polymer::getDateTime() const

Returns the date and time.

Note: This function can be invoked via the meta-object system and from QML. See Q_INVOKABLE.

### `[invokable]` QString Polymer::getFilePath() const

Returns the polymer sequence file path.

Note: This function can be invoked via the meta-object system and from QML. See Q_INVOKABLE.

Note: Getter function for property filePath.

### `[invokable]` MsXpS::libXpertMassCore::Ionizer *Polymer::getIonizer()

Returns a reference to the member Ionizer instance.

Note: This function can be invoked via the meta-object system and from QML. See Q_INVOKABLE.

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

Returns a const reference to the member Ionizer instance.

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

Returns a reference to the member Ionizer instance.

### const MsXpS::libXpertMassCore::Modif &Polymer::getLeftEndModifCstRef() const

Returns a const reference to this Polymer's left end modif.

### MsXpS::libXpertMassCore::Modif &Polymer::getLeftEndModifRef()

Returns a reference to this Polymer's left end modif.

### `[invokable]` double Polymer::getMass(MsXpS::libXpertMassCore::Enums::MassType mass_type) const

Returns the Polymer's mass of the type defined by mass_type.

Note: This function can be invoked via the meta-object system and from QML. See Q_INVOKABLE.

### `[invokable]` double &Polymer::getMassRef(MsXpS::libXpertMassCore::Enums::MassType mass_type)

Returns a reference to the Polymer's mass of the type defined by mass_type.

Note: This function can be invoked via the meta-object system and from QML. See Q_INVOKABLE.

### `[invokable]` QString Polymer::getName() const

Returns the name.

Note: This function can be invoked via the meta-object system and from QML. See Q_INVOKABLE.

Note: Getter function for property name.

### const MsXpS::libXpertMassCore::PolChemDefCstSPtr &Polymer::getPolChemDefCstSPtr() const

Returns the polymer chemistry definition.

### const MsXpS::libXpertMassCore::Modif &Polymer::getRightEndModifCstRef() const

Returns a const reference to this Polymer's right end modif.

### MsXpS::libXpertMassCore::Modif &Polymer::getRightEndModifRef()

Returns a reference to this Polymer's right end modif.

### const MsXpS::libXpertMassCore::Sequence &Polymer::getSequenceCstRef() const

Returns a const reference to the member Sequence instance.

### MsXpS::libXpertMassCore::Sequence &Polymer::getSequenceRef()

Returns a reference to the member Sequence instance.

### `[invokable]` QString Polymer::getSequenceText() const

Returns this Polymer instance's Sequence's sequence as a text string.

Note: This function can be invoked via the meta-object system and from QML. See Q_INVOKABLE.

Note: Getter function for property sequence.

### MsXpS::libXpertMassCore::PolymerQSPtr Polymer::getSharedPtr()

Returns the PolymerSPtr (std::shared_ptr<Polymer>) that manages this Polymer *.

This function should never fail because a Polymer can only be allocated as a PolymerSPtr (private Polymer::Polymer() constructor called by a public createSPtr() function).

See also CrossLink::CrossLink() and renderXmlCrossLinksElement().

### QString Polymer::getUuidForCrossLink(const MsXpS::libXpertMassCore::CrossLinkSPtr &cross_link_sp) const

Returns the UUID string identifying cross_link_sp in the member container.

If no such CrossLink is found, an empty string is returned.

### bool Polymer::hasCrossLink(const MsXpS::libXpertMassCore::CrossLinkSPtr &cross_link_sp) const

Returns true if cross_link_sp was found in the member container of Monomer instances, false otherwise.

### `[invokable]` bool Polymer::hasModifiedMonomer(std::size_t left_index, std::size_t right_index) const

Return true if this Polymer's Sequence contains at least one modified Monomer in the sequence range delimited by left_index and right_index, false otherwise.

Note: This function can be invoked via the meta-object system and from QML. See Q_INVOKABLE.

### bool Polymer::hasUuid(const MsXpS::libXpertMassCore::CrossLinkSPtr &cross_link_sp) const

Returns true if cross_link_sp was found in the member container of Uuid-CrossLink pairs, false otherwise.

### `[invokable]` MsXpS::libXpertMassCore::Enums::IonizationOutcome Polymer::ionize()

Returns the result of the ionization process.

The ionization is performed by the member mp_ionizer and the masses that are updated are the member masses of this Polymer instance.

Note: This function can be invoked via the meta-object system and from QML. See Q_INVOKABLE.

### `[invokable]` MsXpS::libXpertMassCore::Enums::IonizationOutcome Polymer::ionize(const MsXpS::libXpertMassCore::Ionizer &ionizer)

Returns the result of the ionization process using ionizer.

The ionizer instance is used to perform the ionization and the masses that are updated are the member masses of this Polymer instance.

Note: This function can be invoked via the meta-object system and from QML. See Q_INVOKABLE.

See also Ionizer::ionize().

### bool Polymer::isLeftEndModified() const

Returns true if this Polymer is modified at its left end.

### bool Polymer::isRightEndModified() const

Returns true if this Polymer is modified at its right end.

### `[invokable]` bool Polymer::isValid() const

Returns the validity status of this instance.

Note: This function can be invoked via the meta-object system and from QML. See Q_INVOKABLE.

### QByteArray Polymer::md5Sum(int hash_data_specifs) const

Computes a MD5SUM has with the data described in hash_data_specifs.

If hash_data_specifs & HASH_ACCOUNT_SEQUENCE, the sequence is included in the hash computation. If hash_data_specifs & HASH_ACCOUNT_MONOMER_MODIF, the monomer modifications are included in the hash computation. If hash_data_specifs & HASH_ACCOUNT_POLYMER_MODIF, the polymer modifications are include in the hash computation.

Returns the hash.

### std::size_t Polymer::modifiedMonomerCount(const MsXpS::libXpertMassCore::IndexRangeCollection &index_range_collection) const

Returns the count of modified Monomers occurring in the IndexRange instances contained in index_range_collection.

### `[invokable]` bool Polymer::modifyMonomer(std::size_t index, const QString modif_name, bool override)

Returns true if the modification of Monomer instance at index using modif_name was succesful, false otherwise.

If override is true, the Monomer at index is modified even if it is current modified the maximum count for modif_name.

Note: This function can be invoked via the meta-object system and from QML. See Q_INVOKABLE.

See also Modif::m_maxCount.

### `[invokable]` MsXpS::libXpertMassCore::Enums::IonizationOutcome Polymer::molecularMasses(double &mono, double &avg) const

Sets mono and avg to the masses of an unionized Polymer analyte.

If the member Ionizer instance reports that this Polymer analyte is ionized, that Ionizer instance is first used to deionize this Polymer instance into copied monoisotopic and average mass values. Then these values are returned as the molecular masses of this Polymer instance.

Note: Since no member data were touched, that this function is marked const.

Returns the process outcome.

Note: This function can be invoked via the meta-object system and from QML. See Q_INVOKABLE.

### std::size_t Polymer::prepareMonomerRemoval(MsXpS::libXpertMassCore::MonomerSPtr monomer_csp)

Prepares for the removal of monomer_csp from this polymer's sequence.

The challenge is that monomers might be involved in cross-links. In that case, removing a Monomer instance that was involved in a cross-link needs preparation: it needs first to be uncross-linked.

Returns the count of uncross-links that were performed.

See also uncrossLink().

### bool Polymer::removeMonomerAt(std::size_t index)

Removes the Monomer instance at index.

An index that is out of bounds is fatal.

The monomer is first uncross-linked (if it was).

Returns true if the removal was succesful, false otherwise.

### bool Polymer::renderXmlCodesElement(const QDomElement &element)

Parses the XML element representing a sequence of monomer codes.

We are getting this: `<codes>MEFEEGTEEDWYGTEEDWYGTEEDWYGTEEDWYGT</codes>` about which we need to create Monomers and add them to this polymer's Sequence.

Returns true if parsing and conversion of the text to a monomer list were successful, false otherwise.

See also elementalComposition() and Sequence::makeMonomers().

### bool Polymer::renderXmlCrossLinksElement(const QDomElement &element, int version)

Extracts from element, using the proper function (version), all the CrossLinks contained in it.

Each cross-link is rendered apart and applied to this polymer.

Returns true if no error was encountered, false otherwise.

See also crossLink().

### bool Polymer::renderXmlPolymerFile(const QString &file_path = QString(""))

Parses the file_path polymer sequence file.

During parsing, the encountered data are set to this polymer. This parsing is called "rendering".

Returns true if parsing succeeded, false otherwise.

### bool Polymer::renderXmlPolymerModifElement(const QDomElement &element, int version)

Extracts from element, using the proper function (version), the polymer end modification.

The element tag is found in the polymer sequence XML file.

If the element tag name is `le_modif`, the modification name is set to the left end modification of this polymer sequence; if the tag name is `re_modif`, the right end of this polymer is modifified. The modifications are then rendered in place.

Returns true if no error was encountered, false otherwise.

See also Modif::renderXmlMdfElement().

### `[invokable]` void Polymer::setAuthor(const QString &author)

Sets the author.

Note: This function can be invoked via the meta-object system and from QML. See Q_INVOKABLE.

Note: Setter function for property author.

### `[invokable]` void Polymer::setCalcOptions(const MsXpS::libXpertMassCore::CalcOptions &calc_options)

Sets calc_options to the member datum.

Note: This function can be invoked via the meta-object system and from QML. See Q_INVOKABLE.

### `[invokable]` void Polymer::setCalcOptions(const MsXpS::libXpertMassCore::CalcOptions *calc_options)

Sets calc_options to the member datum.

Note: This function can be invoked via the meta-object system and from QML. See Q_INVOKABLE.

### `[invokable]` void Polymer::setCode(const QString &code)

Sets the code.

The code might identify the polymer in a database, like the Swissprot code, for example.

Note: This function can be invoked via the meta-object system and from QML. See Q_INVOKABLE.

Note: Setter function for property code.

### `[invokable]` void Polymer::setDateTime()

Sets the date and time to now.

Note: This function can be invoked via the meta-object system and from QML. See Q_INVOKABLE.

### `[invokable]` void Polymer::setDateTime(const QString &date_time)

Sets the date and time to date_time.

Note: This function can be invoked via the meta-object system and from QML. See Q_INVOKABLE.

### `[invokable]` void Polymer::setFilePath(const QString &file_path)

Sets the polymer's Sequence file path to file_path.

Note: This function can be invoked via the meta-object system and from QML. See Q_INVOKABLE.

Note: Setter function for property filePath.

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

Sets the member Ionizer instance to ionizer.

If presently ionized, this Polymer is first deionized. Then this Polymer undergoes ionization according to the current ionization status of ionizer. This is required so that we put ourselves in line with the contents of ionizer.

### `[invokable]` void Polymer::setIonizer(const MsXpS::libXpertMassCore::Ionizer *ionizer_p)

Sets the member Ionizer instance to ionizer_p.

Calls the Polymer::setIonizer(const Ionizer &ionizer) by dereferencing the pointer.

Note: This function can be invoked via the meta-object system and from QML. See Q_INVOKABLE.

### bool Polymer::setLeftEndModif(const MsXpS::libXpertMassCore::Modif &modif)

Sets this polymer's left end modification to modif.

Returns true if modif could validate successfully and if that modification could be set and its masses could be calculated successfully, otherwise returns false.

After setting the member data, the instance is validated and the result is set to m_isValid.

### `[invokable]` bool Polymer::setLeftEndModifByName(const QString &name = QString())

Sets this polymer's left end modification to name.

If name is empty, the corresponding Modif instance of this Polymer object is removed (ie, the polymer's end is unmodifed.)

Returns true if a modification by name was found in the member polymer chemistry definition's list of modifications and if that modification could be set and its masses could be calculated successfully, otherwise returns false.

After setting the member data, the instance is validated and the result is set to m_isValid.

Note: This function can be invoked via the meta-object system and from QML. See Q_INVOKABLE.

### `[invokable]` void Polymer::setName(const QString &name)

Sets the name.

Note: This function can be invoked via the meta-object system and from QML. See Q_INVOKABLE.

Note: Setter function for property name.

### void Polymer::setPolChemDefCstSPtr(MsXpS::libXpertMassCore::PolChemDefCstSPtr pol_chem_def_csp)

Sets the polymer chemistry definition to pol_chem_def_csp.

### bool Polymer::setRightEndModif(const MsXpS::libXpertMassCore::Modif &modif)

Sets this polymer's right end modification to modif.

Returns true if modif could validate successfully and if that modification could be set and its masses could be calculated successfully, otherwise returns false.

After setting the member data, the instance is validated and the result is set to m_isValid.

### `[invokable]` bool Polymer::setRightEndModifByName(const QString &name = QString())

Sets this polymer's right end modification to name.

Returns true if a modification by name was found in the member polymer chemistry definition's list of modifications and if that modification could be set and its masses could be calculated successfully, otherwise returns false.

After setting the member data, the instance is validated and the result is set to m_isValid.

Note: This function can be invoked via the meta-object system and from QML. See Q_INVOKABLE.

### void Polymer::setSequence(const MsXpS::libXpertMassCore::Sequence &sequence)

Sets the Sequence as sequence.

Note: Setter function for property sequence.

### `[invokable]` void Polymer::setSequence(const QString &sequence_string)

Sets the Sequence as created using text sequence_string.

Note: This function can be invoked via the meta-object system and from QML. See Q_INVOKABLE.

Note: Setter function for property sequence.

### `[invokable]` std::size_t Polymer::size() const

Returns the size of this Polymer instance as the count of Monomer instances contained in the Monomer container belonging to the member Sequence instance.

Note: This function can be invoked via the meta-object system and from QML. See Q_INVOKABLE.

Note: Getter function for property size.

### QString Polymer::storeCrossLink(MsXpS::libXpertMassCore::CrossLinkSPtr cross_link_sp)

Stores cross_link_sp as a UuidCrossLinkWPtrPair in the member container.

A Uuid string is computed and associated unambiguously to cross_link_sp via a UuidCrossLinkWPtrPair object.

Returns the Uuid string (a QUuid).

### `[invokable]` QString Polymer::toString() const

Returns a string describing the polymer.

Note: This function can be invoked via the meta-object system and from QML. See Q_INVOKABLE.

### bool Polymer::uncrossLink(MsXpS::libXpertMassCore::CrossLinkSPtr cross_link_sp)

Undoes the cross-link cross_link_sp.

Returns true upon success or false if the CrossLink does not validate successfully.

Note: Emits the `crossLinkChangedSignal(this)` signal to let interested parties know that the Polymer has seen its cross-linking state changed.

### `[invokable]` void Polymer::unmodify(MsXpS::libXpertMassCore::Enums::PolymerEnd polymer_end)

Removes this Polymer instance's modification on the end specified in polymer_end.

Note: This function can be invoked via the meta-object system and from QML. See Q_INVOKABLE.

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

Validates the Sequence of this polymer, setting errors as messages in error_list_p.

Returns true if validation was successful, false, otherwise.

See also Sequence::validate().

### bool Polymer::writeXmlFile()

Writes this polymer to file.

Returns true if successful, false otherwise.

### `[static]` QString Polymer::xmlPolymerFileGetPolChemDefName(const QString &file_path)

Extracts the name of the polymer chemistry definition from the file_path polymer sequence file.

Returns the polymer chemistry definition name.

## Member Variable Documentation

### QString Polymer::m_author

This variable holds the author or creator of the file.

### double Polymer::m_avg

This variable holds the average mass computed for this Polymer instance.

### QString Polymer::m_code

This variable holds the code of the polymer, for example, the accession number in SwissProt.

### std::vector<MsXpS::libXpertMassCore::CrossLinkSPtr> Polymer::m_crossLinks

This variable holds the container of UuidCrossLinkWPtrPair instances occurring in this Polymer sequence.

### QDateTime Polymer::m_dateTime

This variable holds the date and time of last modification.

### QString Polymer::m_filePath

This variable holds the file path to the Polymer sequence file.

### bool Polymer::m_isValid

This variable holds the validity status of this Polymer instance.

### MsXpS::libXpertMassCore::Modif Polymer::m_leftEndModif

This variable holds the left end modification.

### double Polymer::m_mono

This variable holds the monoisotopic mass computed for this Polymer instance.

### QString Polymer::m_name

This variable holds the name of the polymer, for example, "Apomyoglobin".

### MsXpS::libXpertMassCore::Modif Polymer::m_rightEndModif

This variable holds the right end modification.

### MsXpS::libXpertMassCore::Sequence Polymer::m_sequence

This variable holds the Sequence instance that enshrines the actual Polymer sequence of Monomer instances.

### MsXpS::libXpertMassCore::PolChemDefCstSPtr Polymer::mcsp_polChemDef

This variable holds the PolChemDef polymer chemistry definition that is the context in which the Polymer exists.

### MsXpS::libXpertMassCore::CalcOptions *Polymer::mp_calcOptions

This variable holds the CalcOptions instance that configure the way masses and formulas are computed.

### MsXpS::libXpertMassCore::Ionizer *Polymer::mp_ionizer

This variable holds the Ionizer instance that configure the ionization of this Polymer instance.