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

- libXpertMassCore
- CleavageRule

# MsXpS::libXpertMassCore::CleavageRule Class

class MsXpS::libXpertMassCore::CleavageRule

The CleavageRule class provides a model for specifying aqueous cleavage rules for refining cleavage agent specifications (CleavageAgent) of Polymer Sequences. More...

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

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

## Public Functions

| CleavageRule(MsXpS::libXpertMassCore::PolChemDefCstSPtr pol_chem_def_csp)
| CleavageRule(MsXpS::libXpertMassCore::PolChemDefCstSPtr pol_chem_def_csp, const QString &name, const QString &left_code, const QString &left_formula, const QString &right_code, const QString &right_formula)
| CleavageRule(const MsXpS::libXpertMassCore::CleavageRule &other)
| ~CleavageRule()
QString | formatXmlClrElement(int offset, const QString &indent = Utils::xmlIndentationToken)
const QString & | getLeftCode() const
const MsXpS::libXpertMassCore::Formula & | getLeftFormula() const
const QString & | getName() const
MsXpS::libXpertMassCore::PolChemDefCstSPtr | getPolchemDefCstSPtr() const
const QString & | getRightCode() const
const MsXpS::libXpertMassCore::Formula & | getRightFormula() const
bool | isValid() const
bool | renderXmlClrElement(const QDomElement &element, int version)
void | setLeftCode(const QString &code)
void | setLeftFormula(const MsXpS::libXpertMassCore::Formula &formula)
void | setName(const QString &name)
void | setPolchemDefCstSPtr(MsXpS::libXpertMassCore::PolChemDefCstSPtr pol_chem_def_csp)
void | setRightCode(const QString &code)
void | setRightFormula(const MsXpS::libXpertMassCore::Formula &formula)
bool | validate(MsXpS::libXpertMassCore::ErrorList *error_list_p) const
bool | operator!=(const MsXpS::libXpertMassCore::CleavageRule &other) const
MsXpS::libXpertMassCore::CleavageRule & | operator=(const MsXpS::libXpertMassCore::CleavageRule &other)
bool | operator==(const MsXpS::libXpertMassCore::CleavageRule &other) const

## Protected Variables

bool | m_isValid
QString | m_leftCode
MsXpS::libXpertMassCore::Formula | m_leftFormula
QString | m_name
QString | m_rightCode
MsXpS::libXpertMassCore::Formula | m_rightFormula
MsXpS::libXpertMassCore::PolChemDefCstSPtr | mcsp_polChemDef

## Detailed Description

Cleavage rules help refine the description of the chemical reaction that is the basis of a cleavage (either enzymatic or chemical).

While a number of cleavage agents (like a number of enzymes) do not make unexpected reactions upon the cleavage (enzymes usually hydrolyze their substrates), there are chemical agents that, during the process of cleaving the polymer sequence substrate, also chemically modify the ends of the generated oligomers.

One notorious example is the case of cyanogen bromide, that cleaves proteins right (that is, C-terminal) of methionyl residues. Upon such cleavage, the monomer at the right side of the generated oligomer (methionyl residue) gets modified according to this action-formula: "-CH2S+O". This reaction is modelled using a CleavageRule.

See also CleavageMotif and CleavageAgent.

## Member Function Documentation

### CleavageRule::CleavageRule(MsXpS::libXpertMassCore::PolChemDefCstSPtr pol_chem_def_csp)

Constructs a CleavageRule instance with pol_chem_def_csp as the polymer chemistry definition.

The validiy status (m_isValid) of this install will be set to false.

### CleavageRule::CleavageRule(MsXpS::libXpertMassCore::PolChemDefCstSPtr pol_chem_def_csp, const QString &name, const QString &left_code, const QString &left_formula, const QString &right_code, const QString &right_formula)

Constructs a CleavageRule instance with a number of parameters.

- pol_chem_def_csp: initializes mcsp_polChemDef, the Polymer chemistry definition.
- name: initializes m_name.
- left_code: initializes m_leftCode, the Monomer code at the left of the cleavage site.
- left_formula: initializes m_leftFormula, the Formula to be applied onto the left monomer code.
- right_code: initializes m_rightCode, the Monomer code at the right of the cleavage site.
- right_formula: initializes m_rightFormula, the Formula to be applied onto the right monomer code.

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

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

Constructs a CleavageRule instance as a copy of other.

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

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

Destructs this CleavageRule instance

### QString CleavageRule::formatXmlClrElement(int offset, const QString &indent = Utils::xmlIndentationToken)

Formats a string representing this CleavageRule instance suitable to use as an XML element.

A typical element reads like this:

    <clr>
    <name>Homoseryl</name>
    <re-mnm-code>M</re-mnm-code>
    <re-formula>-CH2S+O</re-formula>
    </clr>

The formatting of the XML element takes into account offset and indent by prepending the string with offset * indent character substring.

indent defaults to two spaces.

Returns the formatted string.

See also renderXmlClrElement().

### const QString &CleavageRule::getLeftCode() const

Returns the left code.

### const MsXpS::libXpertMassCore::Formula &CleavageRule::getLeftFormula() const

Returns the left formula.

### const QString &CleavageRule::getName() const

Returns the name.

### MsXpS::libXpertMassCore::PolChemDefCstSPtr CleavageRule::getPolchemDefCstSPtr() const

Returns the mcsp_polChemDef PolChemDef member.

### const QString &CleavageRule::getRightCode() const

Returns the right code.

### const MsXpS::libXpertMassCore::Formula &CleavageRule::getRightFormula() const

Returns the right formula.

### bool CleavageRule::isValid() const

Returns the validity status of this CleavageRule.

### bool CleavageRule::renderXmlClrElement(const QDomElement &element, int version)

Parses the CleavageRule XML element using a versioned function.

Upon parsing of the element, the member data are updated from the parsed element entities and validated along the process, thus essentially initializing this instance.

A typical element reads like this:

    <clr>
     <name>Homoseryl</name>
     <re-mnm-code>M</re-mnm-code>
     <re-formula>-CH2S+O</re-formula>
    </clr>

Returns true if parsing and validation were successful, false otherwise.

See also formatXmlClrElement().

### void CleavageRule::setLeftCode(const QString &code)

Sets the left code.

This is the code of the Monomer that sits left of the cleavage site. Upon the actual cleavage, this Monomer will be the right-end (Enums::PolymerEnd::RIGHT) Monomer of the left Oligomer.

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

### void CleavageRule::setLeftFormula(const MsXpS::libXpertMassCore::Formula &formula)

Sets the m_leftFormula member to formula.

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

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

Sets the name to name.

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

### void CleavageRule::setPolchemDefCstSPtr(MsXpS::libXpertMassCore::PolChemDefCstSPtr pol_chem_def_csp)

Sets the PolChemDef to pol_chem_def_csp.

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

### void CleavageRule::setRightCode(const QString &code)

Sets the right code.

This is the code of the Monomer that sits right of the cleavage site. Upon the actual cleavage, this Monomer will be the left-end (Enums::PolymerEnd::LEFT) Monomer of the right Oligomer.

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

### void CleavageRule::setRightFormula(const MsXpS::libXpertMassCore::Formula &formula)

Sets the m_rightFormula member to formula.

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

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

Returns true if validation of this CleavageRule instance was successful, false otherwise.

The validation process encompasses the following steps:

- The member mcsp_polChemDef cannot be nullptr.
- The member m_name name cannot be empty;
- If the member m_leftCode left monomer code is not empty, it must be known to the polymer chemistry definition. In that case, if the member m_leftFormula left formula is not empty, it needs to validate successfully.
- The same logic is applied to the monomer at the right hand side of the cleavage site.

If errors are encountered and error_list_p is not nullptr, these errors are stored in that ErrorList.

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

Returns true if `this` instance and other are different.

Returns the negated value of operator==().

### MsXpS::libXpertMassCore::CleavageRule &CleavageRule::operator=(const MsXpS::libXpertMassCore::CleavageRule &other)

Assigns other to this CleavageRule instance.

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

Returns a reference to this CleavageRule instance.

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

Returns true if `this` instance and other are identical.

See also operator!=().

## Member Variable Documentation

### bool CleavageRule::m_isValid

This variable holds the validity status of the CleavageRule instance.

### QString CleavageRule::m_leftCode

This variable holds the Monomer code at the left of the cleavage site.

### MsXpS::libXpertMassCore::Formula CleavageRule::m_leftFormula

This variable holds the Formula to be applied onto the left monomer code.

### QString CleavageRule::m_name

This variable holds the name of the CleavageRule.

### QString CleavageRule::m_rightCode

This variable holds the Monomer code at the right of the cleavage site.

### MsXpS::libXpertMassCore::Formula CleavageRule::m_rightFormula

This variable holds the Formula to be applied onto the right monomer code.

### MsXpS::libXpertMassCore::PolChemDefCstSPtr CleavageRule::mcsp_polChemDef

This variable holds the PolChemDef polymer chemistry definition.