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

- libXpertMassCore
- CleavageMotif

# MsXpS::libXpertMassCore::CleavageMotif Class

class MsXpS::libXpertMassCore::CleavageMotif

The CleavageMotif class provides a model for specifying aqueous cleavage motfis of Polymer Sequences. More...

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

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

## Public Functions

| CleavageMotif(MsXpS::libXpertMassCore::PolChemDefCstSPtr pol_chem_def_csp)
| CleavageMotif(MsXpS::libXpertMassCore::PolChemDefCstSPtr pol_chem_def_csp, const QString &motif, int offset, MsXpS::libXpertMassCore::Enums::CleavageAction cleavage_action)
| CleavageMotif(const MsXpS::libXpertMassCore::CleavageMotif &other)
| ~CleavageMotif()
MsXpS::libXpertMassCore::Enums::CleavageAction | getCleavageAction() const
const std::vector<MsXpS::libXpertMassCore::MonomerSPtr> & | getMonomersCstRef() const
std::vector<MsXpS::libXpertMassCore::MonomerSPtr> & | getMonomersRef()
QString | getMotif() const
int | getOffset() const
MsXpS::libXpertMassCore::PolChemDefCstSPtr | getPolChemDefCstSPtr() const
bool | isValid() const
std::size_t | parseMotif(const QString &motif)
std::size_t | parseSite(const QString &site)
void | setCleavageAction(MsXpS::libXpertMassCore::Enums::CleavageAction cleavage_action)
void | setMotif(const QString &motif)
void | setOffset(int offset)
void | setPolChemDefCstSPtr(MsXpS::libXpertMassCore::PolChemDefCstSPtr pol_chem_def_csp)
bool | validate(MsXpS::libXpertMassCore::ErrorList *error_list_p) const
bool | operator!=(const MsXpS::libXpertMassCore::CleavageMotif &other) const
MsXpS::libXpertMassCore::CleavageMotif & | operator=(const MsXpS::libXpertMassCore::CleavageMotif &other)
bool | operator==(const MsXpS::libXpertMassCore::CleavageMotif &other) const

## Protected Variables

MsXpS::libXpertMassCore::Enums::CleavageAction | m_cleavageAction
bool | m_isValid
std::vector<MsXpS::libXpertMassCore::MonomerSPtr> | m_monomers
std::size_t | m_offset
MsXpS::libXpertMassCore::PolChemDefCstSPtr | mcsp_polChemDef

## Detailed Description

When a polymer sequence cleavage occurs, using, for example, the Trypsin cleavage agent, that cleavage agent specifies that cleavage should occur at the sites denoted '/' in the following pattern: "Lys/;Arg/;-Lys/Pro".

The "Lys/;Arg/;-Lys/Pro" string of sites is parsed and cleavage motifs (CleavageMotif) are generated from it. In this specific case, we'll have three CleavageMotif instances with the following data cleavage sites:

- The first motif has a single CleavageMotif::m_monomers container item with code "Lys", an offset of 1 ('/' specifies a cut right of "Lys"), and finally is set for cleavage (Enums::CleavageAction::CLEAVE);
- The second motif has a single CleavageMotif::m_monomers container item with code "Arg", offset of 1, and finally is set for cleavage;
- The third motif has two items: the first with code "Lys", the second with code "Pro"; the offset is set to 1 and the motif is set not-for-cleavage (Enums::CleavageAction::NO_CLEAVE, mind the '-').

Thanks to this deconstruction from "Lys/;Arg/;-Lys/Pro" to the 3 cleavage motifs above, the polymer sequence is cleaved according to the cleavage agent specification.

See also CleavageAgent and CleavageRule.

## Member Function Documentation

### `[explicit]` CleavageMotif::CleavageMotif(MsXpS::libXpertMassCore::PolChemDefCstSPtr pol_chem_def_csp)

Constructs an uninitialized cleavage motif with pol_chem_def_csp as the polymer chemistry definition.

The instance will be invalid (m_isValid set to false).

### `[explicit]` CleavageMotif::CleavageMotif(MsXpS::libXpertMassCore::PolChemDefCstSPtr pol_chem_def_csp, const QString &motif, int offset, MsXpS::libXpertMassCore::Enums::CleavageAction cleavage_action)

Constructs a cleavage motif with a number of parameters.

- pol_chem_def_csp: initializes mcsp_polChemDef, the polymer chemistry definition. Cannot be nullptr (qFatal() is called).
- motif: Literal string motif in the form of "Lys/" or "Lys/Pro" or "/Asp" that is immediately parsed to the m_monomers container of Monomer instances.
- offset: initializes m_offset, the offset position of the cleavage to the first monomer code in the motif.
- cleavage_action: initializes m_cleavageAction, telling if motif is for cleavage (for example, "Lys/") or not for cleavage (for example, "-Lys/Pro").

After setting the member data, the CleavageMotif instance is validated and m_isValid is set to the result of this validation. If the validation fails, qFatal() is called.

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

Constructs a CleavageMotif instance as a copy of other.

After setting the member data, the CleavageMotif instance is validated and m_isValid is set to the result of this validation. If the validation fails, qFatal() is called.

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

Destructs this CleavageMotif instance.

### MsXpS::libXpertMassCore::Enums::CleavageAction CleavageMotif::getCleavageAction() const

Returns the member m_cleavageAction Enums::CleavageAction value.

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

Returns a const reference to the m_monomers container of Monomers.

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

Returns a reference to the m_monomers container of Monomers.

### QString CleavageMotif::getMotif() const

Returns the motif as a concatenation of the codes of the Monomer instances found in the m_monomers container.

### int CleavageMotif::getOffset() const

Returns the m_offset member offset value.

### MsXpS::libXpertMassCore::PolChemDefCstSPtr CleavageMotif::getPolChemDefCstSPtr() const

Returns the mcsp_polChemDef PolChemDef member.

### bool CleavageMotif::isValid() const

Returns the m_isValid validity status of this CleavageMotif instance.

### std::size_t CleavageMotif::parseMotif(const QString &motif)

Parses the literal cleavage motif and returns the count of Monomer instances stored in the m_monomers member container as a result of parsing the motif.

A cleavage motif is a string in the form "LysPro" or "Asp" (in fact that is the string representation of a Sequence).

The difference between a cleavage motif ("LysPro") and a cleavage site ("Lys/Pro") is that the latter specifies the site using the '/' character.

### std::size_t CleavageMotif::parseSite(const QString &site)

Parses the literal cleavage site and returns the count of Monomer instances stored in the m_monomers member container as a result of parsing the site.

A cleavage site is a string in the form "Lys/Pro" or "/Asp" (note the presence of the '/' that represents the actual cleavage site). The m_monomers member container of Monomer pointers is filled-in with pointers to the member mcsp_polChemDef PolChemDef's Monomer instances having codes {Lys, Pro} or {Asp}.

The offset is the position of the '/' cleavage symbol (that is, the actual cleavage position in the motif). For "Lys/Pro", the offset is 1 while for "/Asp", the offset is 0.

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

### void CleavageMotif::setCleavageAction(MsXpS::libXpertMassCore::Enums::CleavageAction cleavage_action)

Sets the member Enums::CleavageAction to cleavage_action.

This instance then undergoes validation and m_isValid is set to the result of it.

### void CleavageMotif::setMotif(const QString &motif)

Parses the motif and fills-in the m_monomers container of Monomers as a result of the parsing.

This instance then undergoes validation and m_isValid is set to the result of that validation.

See also parseMotif().

### void CleavageMotif::setOffset(int offset)

Sets the m_offset member offset value to offset.

The offset is the position of the cleavage inside the motif, with reference to the first monomer code in that motif. For example, for a cleavage site "Lys/Pro", the cleavage motif becomes {"Lys", "Pro"} and the offset is 1, while for a site "/Asp", the cleavage motif becomes {"Asp"} and the offset is 0.

An offset value can thus not be greater than the number of Monomer codes in the motif.

This instance then undergoes validation and m_isValid is set to the result of that validation.

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

Sets the PolChemDef member to pol_chem_def_csp.

This instance then undergoes validation and m_isValid is set to the result of that validation.

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

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

The validation process encompasses the following steps:

- The member mcsp_polChemDef cannot be nullptr.
- The member m_monomers container of Monomer pointers cannot be empty.
- The member m_offset value cannot be greater than the size of m_monomers.
- The member m_cleavageAction value cannot be Enums::CleavageAction::NOT_SET.

Upon finishing the validation, if successful m_isValid is set to true, otherwise it is set to false.

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

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

Returns true if `this` and other are different.

Returns the negated result of operator==().

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

Assigns other to this CleavageMotif instance.

This instance then undergoes validation and m_isValid is set to the result of that validation. If the validation fails, qFatal() is called.

Returns a reference to this CleavageMotif instance.

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

Returns true if `this` and other are identical.

The comparison of the Monomer instances in the member container is deep (that is the Monomer instances are compared and not the shared pointers).

## Member Variable Documentation

### MsXpS::libXpertMassCore::Enums::CleavageAction CleavageMotif::m_cleavageAction

Tells if the motif is for cleavage or not for cleavage.

For the "Lys/" and "Arg/" motifs, that would be CleavageAction::CLEAVE; for the "-Lys/Pro" motif, that would be CleavageAction::NO_CLEAVE, because Trypsin does not cleave after a lysyl residue if it is followed by a prolyl residue (the '-' sign before the literal string).

### bool CleavageMotif::m_isValid

Tells the validity status of the CleavageMotif instance.

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

This variable holds the container of Monomer instances. The Monomer instances are in the form of const shared pointers to Monomer in the polymer chemistry definition.

A "Lys/Pro" motif will translate into pointers to two PolChemDef-defined Monomer instances having codes "Lys" and "Pro", in the right order.

### std::size_t CleavageMotif::m_offset

This variable holds the offset between the actual cleavage site and the first monomer of the motif.

In the "Lys/", "Arg/" and "-Lys/Pro" examples, the offset would be 1 for each motif, because the cleavage occurs after the first monomer code: Lys✂, or Arg✂ or Lys✂Pro. In the "/Asp" cleavage motif the offset would be 0, because the cleavage occurs before the first monomer in the motif (✂Asp). In the "ATGC/GCAT" cleavage motif, the offset would be 4: ATGC✂GCAT.

### MsXpS::libXpertMassCore::PolChemDefCstSPtr CleavageMotif::mcsp_polChemDef

This variable holds the PolChemDef (polymer chemistry definition) that is needed to get to reference chemical entities like {Monomer}s.