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

- libXpertMassCore
- Fragmenter

# MsXpS::libXpertMassCore::Fragmenter Class

class MsXpS::libXpertMassCore::Fragmenter

The Fragmenter class provides a model for performing gas phase fragmentation reactions involving FragmentationPathway objects and Polymer Sequences. More...

Header: | `#include <MsXpS/libXpertMassCore/Fragmenter.hpp>`

- List of all members, including inherited members
- Fragmenter is part of Aqueous chemical reactions.

## Public Functions

| Fragmenter(MsXpS::libXpertMassCore::PolymerCstQSPtr polymer_cqsp, MsXpS::libXpertMassCore::PolChemDefCstSPtr pol_chem_def_csp, const std::vector<MsXpS::libXpertMassCore::FragmentationConfig> &fragmentation_configs, const MsXpS::libXpertMassCore::CalcOptions &calc_options, const MsXpS::libXpertMassCore::Ionizer &ionizer)
| Fragmenter(const MsXpS::libXpertMassCore::Fragmenter &other)
| ~Fragmenter()
std::size_t | accountFormulas(MsXpS::libXpertMassCore::OligomerSPtr &&template_oligomer_sp, MsXpS::libXpertMassCore::OligomerCollection &oligomers, const MsXpS::libXpertMassCore::FragmentationConfig &fragmentation_config, const QString &name, int charge)
bool | accountFragmentationRule(MsXpS::libXpertMassCore::FragmentationRuleSPtr fragmentation_rule_sp, bool only_for_checking, std::size_t monomer_index, MsXpS::libXpertMassCore::Enums::FragEnd frag_end, double &mono, double &avg)
MsXpS::libXpertMassCore::OligomerCollection | accountIonizationLevels(MsXpS::libXpertMassCore::OligomerCollection &oligomers, const MsXpS::libXpertMassCore::FragmentationConfig &fragmentation_config)
void | addFragmentationConfig(const MsXpS::libXpertMassCore::FragmentationConfig &fragmentation_config)
bool | fragment()
int | fragmentEndLeft(const MsXpS::libXpertMassCore::FragmentationConfig &fragmentation_config)
int | fragmentEndNone(const MsXpS::libXpertMassCore::FragmentationConfig &fragmentation_config)
int | fragmentEndRight(const MsXpS::libXpertMassCore::FragmentationConfig &fragmentation_config)
const MsXpS::libXpertMassCore::CalcOptions & | getCalcOptionsCstRef() const
MsXpS::libXpertMassCore::CalcOptions & | getCalcOptionsRef()
const std::vector<MsXpS::libXpertMassCore::FragmentationConfig> & | getFragmentationConfigsCstRef() const
std::vector<MsXpS::libXpertMassCore::FragmentationConfig> & | getFragmentationConfigsRef()
const MsXpS::libXpertMassCore::Ionizer & | getIonizerCstRef() const
MsXpS::libXpertMassCore::Ionizer & | getIonizerRef()
const MsXpS::libXpertMassCore::OligomerCollection & | getOligomerCollectionCstRef() const
MsXpS::libXpertMassCore::OligomerCollection & | getOligomerCollectionRef()
void | transferOligomer(MsXpS::libXpertMassCore::OligomerSPtr &&source_oligomer_sp, MsXpS::libXpertMassCore::OligomerCollection &dest)
std::size_t | transferOligomers(MsXpS::libXpertMassCore::OligomerCollection &source, MsXpS::libXpertMassCore::OligomerCollection &dest)

## Protected Variables

MsXpS::libXpertMassCore::CalcOptions | m_calcOptions
std::vector<MsXpS::libXpertMassCore::CrossLinkedRegion> | m_crossLinkedRegions
std::vector<MsXpS::libXpertMassCore::FragmentationConfig> | m_fragmentationConfigs
MsXpS::libXpertMassCore::Ionizer | m_ionizer
MsXpS::libXpertMassCore::OligomerCollection | m_oligomers
MsXpS::libXpertMassCore::PolChemDefCstSPtr | mcsp_polChemDef
MsXpS::libXpertMassCore::PolymerCstQSPtr | mcsp_polymer

## Detailed Description

The fragmentation process is configured by the member vector of FragmentationConfig instances that may store, for example, all the fragmentation pathways that need to be dealt with in the inner workings of this Fragmenter class. For example, the user might want to perform a series of fragmentation involving pathways b and y for protein fragmentation.

See also FragmentationPathway, FragmentationRule, FragmentationConfig, and Ionizer.

## Member Function Documentation

### Fragmenter::Fragmenter(MsXpS::libXpertMassCore::PolymerCstQSPtr polymer_cqsp, MsXpS::libXpertMassCore::PolChemDefCstSPtr pol_chem_def_csp, const std::vector<MsXpS::libXpertMassCore::FragmentationConfig> &fragmentation_configs, const MsXpS::libXpertMassCore::CalcOptions &calc_options, const MsXpS::libXpertMassCore::Ionizer &ionizer)

Constructs a Fragmenter instance with a number of parameters.

- polymer_cqsp: initializes mcsp_polymer, the Polymer instance to be fragmented.
- pol_chem_def_csp: initializes mcsp_polChemDef, the PolChemDef (polymer chemistry definition) that is the context in which the Polymer exists.
- fragmentation_configs: initializes m_fragmentationConfigs, the container of FragmentationConfig instances that configure the fragmentation.
- calc_options: initializes m_calcOptions, the CalcOptions instance that configures the mass and formula calculations.
- ionizer: initializes m_ionizer, the Ionizer instance that drives the ionization of the Oligomer instances generated by the fragmentation.

If polymer_cqsp or pol_chem_def_csp is nullptr, that is a fatal error (qFatal() is called).

### Fragmenter::Fragmenter(const MsXpS::libXpertMassCore::Fragmenter &other)

Constructs Fragmenter instance as a copy of other.

If polymer_cqsp or pol_chem_def_csp is nullptr, that is a fatal error (qFatal() is called).

### `[noexcept]` Fragmenter::~Fragmenter()

Desstructs this Fragmenter instance

### std::size_t Fragmenter::accountFormulas(MsXpS::libXpertMassCore::OligomerSPtr &&template_oligomer_sp, MsXpS::libXpertMassCore::OligomerCollection &oligomers, const MsXpS::libXpertMassCore::FragmentationConfig &fragmentation_config, const QString &name, int charge)

Generates as many more Oligomer fragments are there are Formula instances to be accounted for.

template_oligomer_sp is the Oligomer instance that serves as a template to generate as many variants as there are Formula instances in the fragmentation_config's member container of Formula instances. For example, if the caller wants to generate, for each Oligomer fragment, a variant with "-H2O" and "-NH3" formulas applied, then each fragment Oligomer in the oligomers collection will generate two variants: one with water-producing decomposition and one with ammonia-producing decomposition. Thus, in the end, there will be as many times more fragment Oligomer instances in oligomers as there are Formula instances to be accounted for.

name and charge are the name and charge onto which to base the creation of the variant fragment Oligomer new name so that the fragment Oligomer has a name that documents the kind of fragmentation pathway is was generated from, along with both the Formula that was accounted for and finally its charge.

Returns the count of variant fragment Oligomer instances that were added into the oligomers collection.

### bool Fragmenter::accountFragmentationRule(MsXpS::libXpertMassCore::FragmentationRuleSPtr fragmentation_rule_sp, bool only_for_checking, std::size_t monomer_index, MsXpS::libXpertMassCore::Enums::FragEnd frag_end, double &mono, double &avg)

Accounts for the fragmentation_rule_sp FragmentationRule if the Monomer instance at monomer_index matches the requirement of the rule along with frag_end.

The masses are accounted for to mono and avg.

If only_for_checking is true, then the computation is only a verification that the FragmentationRule is to be accounted for. If only_for_checking is false, the fragmentation rule is actually accounted for.

Returns true if the FragmentationRule should be accounted for (if only_for_checking is true) or if it was effectively accounted for (if only_for_checking is false), false otherwise.

### MsXpS::libXpertMassCore::OligomerCollection Fragmenter::accountIonizationLevels(MsXpS::libXpertMassCore::OligomerCollection &oligomers, const MsXpS::libXpertMassCore::FragmentationConfig &fragmentation_config)

For each ionization level contained in the fragmentation_config start and stop ionization level members, create fragment Oligomer variants of all the Oligomer instances present in oligomers.

The generated fragment Oligomer instances are stored in an OligomerCollection instance that is returned.

### void Fragmenter::addFragmentationConfig(const MsXpS::libXpertMassCore::FragmentationConfig &fragmentation_config)

Adds fragmentation_config to the member m_fragmentationConfigs container of FragmentationConfig instances.

### bool Fragmenter::fragment()

Performs the actual fragmentation, thus generating Oligomer instances that are added to the m_oligomers member OligomerCollection instance.

All the FragmentationConfig instances in the member container are iterated into and the fragmentation procedure is implemented.

Returns true upon success, false otherwise.

### int Fragmenter::fragmentEndLeft(const MsXpS::libXpertMassCore::FragmentationConfig &fragmentation_config)

Performs the actual fragmentation in the specific case that fragmentation_config indicates that the fragment Oligomers to be generated contain the left Polymer end (like b ions in protein gas phase chemistry).

Returns the count of produced fragment Oligomer instances.

### int Fragmenter::fragmentEndNone(const MsXpS::libXpertMassCore::FragmentationConfig &fragmentation_config)

Performs the actual fragmentation in the specific case that fragmentation_config indicates that the fragment Oligomers to be generated contain no Polymer end (like immonium ions in protein gas phase chemistry).

Returns the count of produced fragment Oligomer instances.

### int Fragmenter::fragmentEndRight(const MsXpS::libXpertMassCore::FragmentationConfig &fragmentation_config)

Performs the actual fragmentation in the specific case that fragmentation_config indicates that the fragment Oligomers to be generated contain the right Polymer end (like y ions in protein gas phase chemistry).

Returns the count of produced fragment Oligomer instances.

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

b*rief Returns a constant reference to the CalcOptions instance.

### MsXpS::libXpertMassCore::CalcOptions &Fragmenter::getCalcOptionsRef()

b*rief Returns a reference to the CalcOptions instance.

### const std::vector<MsXpS::libXpertMassCore::FragmentationConfig> &Fragmenter::getFragmentationConfigsCstRef() const

Returns a constant reference to the container of FragmentationConfig instances.

### std::vector<MsXpS::libXpertMassCore::FragmentationConfig> &Fragmenter::getFragmentationConfigsRef()

Returns a reference to the container of FragmentationConfig instances.

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

Returns a constant reference to the Ionizer instance.

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

Returns a reference to the Ionizer instance.

### const MsXpS::libXpertMassCore::OligomerCollection &Fragmenter::getOligomerCollectionCstRef() const

Returns a const reference to the member OligomerCollection instance.

### MsXpS::libXpertMassCore::OligomerCollection &Fragmenter::getOligomerCollectionRef()

Returns a reference to the member OligomerCollection instance.

### void Fragmenter::transferOligomer(MsXpS::libXpertMassCore::OligomerSPtr &&source_oligomer_sp, MsXpS::libXpertMassCore::OligomerCollection &dest)

Transfers (using std::move()) source_oligomer_sp to dest.

### std::size_t Fragmenter::transferOligomers(MsXpS::libXpertMassCore::OligomerCollection &source, MsXpS::libXpertMassCore::OligomerCollection &dest)

Transfers (using std::move()) all the Oligomer instances from source to dest.

After the transfer, the source Oligomer container is cleared since it contains only nullptr items.

## Member Variable Documentation

### MsXpS::libXpertMassCore::CalcOptions Fragmenter::m_calcOptions

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

### std::vector<MsXpS::libXpertMassCore::CrossLinkedRegion> Fragmenter::m_crossLinkedRegions

This variable holds the container of CrossLinkedRegion instances that describe the way product ions might involve CrossLink instances.

See also CrossLinkedRegion and CrossLink.

### std::vector<MsXpS::libXpertMassCore::FragmentationConfig> Fragmenter::m_fragmentationConfigs

This variable holds the container of FragmentationConfig instances that collectively configure the fragmentation pathways to be implemented during the overall fragmentation process.

### MsXpS::libXpertMassCore::Ionizer Fragmenter::m_ionizer

This variable holds the Ionizer that directs the ionization of the Oligomer instances obtained by fragmenting the Polymer.

### MsXpS::libXpertMassCore::OligomerCollection Fragmenter::m_oligomers

This variable holds the container of Oligomer product ion instances generated as a result of the fragmentation.

### MsXpS::libXpertMassCore::PolChemDefCstSPtr Fragmenter::mcsp_polChemDef

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

### MsXpS::libXpertMassCore::PolymerCstQSPtr Fragmenter::mcsp_polymer

This variable holds the Polymer instance that is being fragmented.