Loading...
Searching...
No Matches
pappso::Enzyme Class Reference

`#include <enzyme.h>`

## Public Member Functions

| Enzyme ()
| build the default enzyme (trypsin) with recognition_site = "([KR])([^P])"
| Enzyme (const QString &recognition_site)
| build any enzyme given a recognition_site
| ~Enzyme ()
void | eat (std::int8_t sequence_database_id, const ProteinSp &protein_sp, bool is_decoy, EnzymeProductInterface &enzyme_product) const
| digest a protein into enzyme products
void | setMiscleavage (unsigned int miscleavage)
| sets the maximum number of missed cleavage allowed in the digestion
unsigned int | getMiscleavage () const
| get the maximum number of missed cleavage allowed in the digestion
void | setTakeOnlyFirstWildcard (bool take_only_first_wildcard)
| take only first m_takeOnlyFirstWildcard
void | setMaxPeptideVariantListSize (std::size_t max_peptide_variant_list_size)
| if there are wildcards in the protein sequence : restrict the number of possible peptide sequences
const QRegularExpression & | getQRegExpRecognitionSite () const

## Private Member Functions

void | sanityCheck (EnzymeProductInterface &enzyme_product, std::int8_t sequence_database_id, const ProteinSp &protein_sp, bool is_decoy, const PeptideStr &peptide, unsigned int start, bool is_nter, unsigned int missed_cleavage_number, bool semi_enzyme) const
void | replaceWildcards (std::vector< std::string > *p_peptide_variant_list) const

## Private Attributes

QRegularExpression | m_recognitionSite
| example with a kinase == [K,R]
unsigned int | m_miscleavage = 0
bool | m_takeOnlyFirstWildcard = false
std::size_t | m_maxPeptideVariantListSize = 100
std::vector< char > | m_wildCardX
std::vector< char > | m_wildCardB
std::vector< char > | m_wildCardZ

## Detailed Description

Definition at line 31 of file enzyme.h.

## Constructor & Destructor Documentation

## Enzyme() [1/2]

pappso::Enzyme::Enzyme | ( |  | ) |

build the default enzyme (trypsin) with recognition_site = "([KR])([^P])"

Definition at line 32 of file enzyme.cpp.

{
m_recognitionSite.setPattern("([KR])([^P])");
m_miscleavage = 0;
char vv1[] = {'A', 'R', 'N', 'D', 'C', 'Q', 'E', 'G', 'H', 'I',
'L', 'K', 'M', 'F', 'P', 'S', 'T', 'W', 'Y', 'V'};
m_wildCardX.assign(std::begin(vv1), std::end(vv1));
char vv2[] = {'N', 'D'};
m_wildCardB.assign(std::begin(vv2), std::end(vv2));
char vv3[] = {'Q', 'E'};
m_wildCardZ.assign(std::begin(vv3), std::end(vv3));
}
pappso::Enzyme::m_recognitionSite
QRegularExpression m_recognitionSite
example with a kinase == [K,R]
Definition enzyme.h:89
pappso::Enzyme::m_wildCardB
std::vector< char > m_wildCardB
Definition enzyme.h:97
pappso::Enzyme::m_wildCardZ
std::vector< char > m_wildCardZ
Definition enzyme.h:98
pappso::Enzyme::m_wildCardX
std::vector< char > m_wildCardX
Definition enzyme.h:96
pappso::Enzyme::m_miscleavage
unsigned int m_miscleavage
Definition enzyme.h:90

References m_miscleavage, m_recognitionSite, m_wildCardB, m_wildCardX, and m_wildCardZ.

## Enzyme() [2/2]

pappso::Enzyme::Enzyme | ( | const QString & | recognition_site | ) |

build any enzyme given a recognition_site

Parameters

  recognition_site | is a regular expression that must identify 2 motifs : one on Nter side one on Cter side

Definition at line 49 of file enzyme.cpp.

{
m_recognitionSite.setPattern(recognition_site);
m_miscleavage = 0;
char vv1[] = {'A', 'R', 'N', 'D', 'C', 'Q', 'E', 'G', 'H', 'I',
'L', 'K', 'M', 'F', 'P', 'S', 'T', 'W', 'Y', 'V'};
m_wildCardX.assign(std::begin(vv1), std::end(vv1));
char vv2[] = {'N', 'D'};
m_wildCardB.assign(std::begin(vv2), std::end(vv2));
char vv3[] = {'Q', 'E'};
m_wildCardZ.assign(std::begin(vv3), std::end(vv3));
}

References m_miscleavage, m_recognitionSite, m_wildCardB, m_wildCardX, and m_wildCardZ.

## ~Enzyme()

pappso::Enzyme::~Enzyme | ( |  | ) |

Definition at line 66 of file enzyme.cpp.

{
}

## Member Function Documentation

## eat()

void pappso::Enzyme::eat | ( | std::int8_t | sequence_database_id,
|  | const ProteinSp & | protein_sp,
|  | bool | is_decoy,
|  | EnzymeProductInterface & | enzyme_product
| ) |  | const

digest a protein into enzyme products

Parameters

  sequence_database_id | integer that references the sequence fatabase (file, stream, url...)
  protein_sp | is the original protein to be digested
  is_decoy | tell if the current protein is a decoy (true) or normal (false) protein
  enzyme_product | is the object that will receive the digestion products

Definition at line 87 of file enzyme.cpp.

{
/*
* for aa in self.aa_to_cut:
seq = seq.replace(aa, aa + ' ')
seq_stack = []
for s in seq.strip().split(' '):
seq_stack.append(s)
if len(seq_stack) > self.misscleavage + 1:
seq_stack.pop(0)
s2 = ""
for s_miss in seq_stack[::-1]:
s2 = s_miss + s2
yield s2
*/
qDebug() << "Enzyme::eat begin ";
const QString sequence = protein_sp.get()->getSequence();
qDebug() << sequence;
QStringList peptide_list;
int pos = 0;
int peptide_start = 0;
int peptide_size = sequence.size();
QRegularExpressionMatch match_recognition_site =
m_recognitionSite.match(sequence, pos);
while(match_recognition_site.hasMatch())
{
pos = match_recognition_site.capturedStart(0);
peptide_size =
pos + match_recognition_site.captured(1).length() - peptide_start;
// qDebug() << "pos=" << pos << " peptide_start=" << peptide_start << "
// peptide_size=" << peptide_size << " " <<
// sequence.mid(peptide_start,peptide_size);
if(peptide_size > 0)
{
peptide_list.append(sequence.mid(peptide_start, peptide_size));
}
peptide_start += peptide_size;
pos = peptide_start; // all peptides MUST be consecutive
match_recognition_site = m_recognitionSite.match(sequence, pos);
}
peptide_size = sequence.size() - peptide_start;
if(peptide_size > 0)
{
peptide_list.append(sequence.mid(peptide_start, peptide_size));
}
unsigned int start = 1;
bool is_nter = true;
foreach(const QString &peptide, peptide_list)
{
// enzyme_product.setPeptide(sequence_database_id, protein_sp,is_decoy,
// peptide, start,is_nter,0, false);
sanityCheck(enzyme_product,
sequence_database_id,
protein_sp,
is_decoy,
peptide,
start,
is_nter,
0,
false);
is_nter = false;
start += peptide.size();
}
unsigned int miscleavage_i = 0;
while(miscleavage_i < m_miscleavage)
{
miscleavage_i++;
qDebug() << "miscleavage_i=" << miscleavage_i;
int chunk_number = miscleavage_i + 1;
unsigned int start = 1;
bool is_nter = true;
for(auto i = 0; i < peptide_list.size(); ++i)
{
qDebug() << "start=" << start;
QStringList peptide_mis_list;
for(auto j = 0; (j < chunk_number) && ((i + j) < peptide_list.size());
j++)
{
peptide_mis_list << peptide_list.at(i + j);
}
if(peptide_mis_list.size() == chunk_number)
{
// enzyme_product.setPeptide(sequence_database_id,
// protein_sp,is_decoy, peptide_mis_list.join(""), start,is_nter,
// miscleavage_i, false);
sanityCheck(enzyme_product,
sequence_database_id,
protein_sp,
is_decoy,
peptide_mis_list.join(""),
start,
is_nter,
miscleavage_i,
false);
}
is_nter = false;
start += peptide_list.at(i).size();
}
}
}
pappso::Enzyme::sanityCheck
void sanityCheck(EnzymeProductInterface &enzyme_product, std::int8_t sequence_database_id, const ProteinSp &protein_sp, bool is_decoy, const PeptideStr &peptide, unsigned int start, bool is_nter, unsigned int missed_cleavage_number, bool semi_enzyme) const
Definition enzyme.cpp:276

References m_miscleavage, m_recognitionSite, and sanityCheck().

## getMiscleavage()

unsigned int pappso::Enzyme::getMiscleavage | ( |  | ) | const

get the maximum number of missed cleavage allowed in the digestion

Returns
  miscleavage maximum number of missed cleavade to allow (defaults is 0)

Definition at line 76 of file enzyme.cpp.

{
return m_miscleavage;
}

References m_miscleavage.

## getQRegExpRecognitionSite()

const QRegularExpression & pappso::Enzyme::getQRegExpRecognitionSite | ( |  | ) | const

Definition at line 353 of file enzyme.cpp.

{
return m_recognitionSite;
}

References m_recognitionSite.

## replaceWildcards()

void pappso::Enzyme::replaceWildcards | ( | std::vector< std::string > * | p_peptide_variant_list | ) | const

private

Definition at line 195 of file enzyme.cpp.

{
std::string new_peptide = p_peptide_variant_list->at(0);
qDebug() << "Enzyme::replaceWildcards begin " << new_peptide.c_str();
std::vector<std::string> old_peptide_variant_list;
old_peptide_variant_list.assign(p_peptide_variant_list->begin(),
p_peptide_variant_list->end());
for(char wildcard : {'X', 'B', 'Z'})
{
std::size_t position = new_peptide.find(wildcard);
if(position == std::string::npos)
{
continue;
}
else
{
p_peptide_variant_list->clear();
/*
new_peptide[position] = 'A';
p_peptide_variant_list->push_back(new_peptide);
break;
*/
const std::vector<char> *p_x_replace_wildcard = nullptr;
if(wildcard == 'X')
{
p_x_replace_wildcard = &m_wildCardX;
}
else if(wildcard == 'B')
{
p_x_replace_wildcard = &m_wildCardB;
}
else if(wildcard == 'Z')
{
p_x_replace_wildcard = &m_wildCardZ;
}
if(p_x_replace_wildcard != nullptr)
{
for(std::string orig_peptide : old_peptide_variant_list)
{
for(char replace : *p_x_replace_wildcard)
{
orig_peptide[position] = replace;
p_peptide_variant_list->push_back(orig_peptide);
}
}
}
else
{
throw ExceptionNotPossible(
QObject::tr("x_replace_wildcard is empty"));
}
// new_peptide[position] = 'A';
// p_peptide_variant_list->push_back(new_peptide);
// p_peptide_variant_list->resize(1);
// std::cerr << "Enzyme::replaceWildcards begin
// p_peptide_variant_list.size()=" << p_peptide_variant_list->size()
// <<
// endl;
break;
}
}
std::vector<std::string>().swap(
old_peptide_variant_list); // clear old_peptide_variant_list reallocating
qDebug() << "Enzyme::replaceWildcards end " << new_peptide.c_str();
}

References m_wildCardB, m_wildCardX, and m_wildCardZ.

Referenced by sanityCheck().

## sanityCheck()

void pappso::Enzyme::sanityCheck | ( | EnzymeProductInterface & | enzyme_product,
|  | std::int8_t | sequence_database_id,
|  | const ProteinSp & | protein_sp,
|  | bool | is_decoy,
|  | const PeptideStr & | peptide,
|  | unsigned int | start,
|  | bool | is_nter,
|  | unsigned int | missed_cleavage_number,
|  | bool | semi_enzyme
| ) |  | const

private

Definition at line 276 of file enzyme.cpp.

{
if(peptide.contains('X') || peptide.contains('B') || peptide.contains('Z'))
{
std::vector<std::string> peptide_variant_list;
peptide_variant_list.push_back(peptide.toStdString());
while((peptide_variant_list.at(0).find('X') != std::string::npos) ||
(peptide_variant_list.at(0).find('B') != std::string::npos) ||
(peptide_variant_list.at(0).find('Z') != std::string::npos))
{
replaceWildcards(&peptide_variant_list);
if(peptide_variant_list.size() > m_maxPeptideVariantListSize)
{
peptide_variant_list.resize(m_maxPeptideVariantListSize);
peptide_variant_list.shrink_to_fit();
}
}
// peptide_variant_list.resize(2);
if(m_takeOnlyFirstWildcard)
{
enzyme_product.setPeptide(sequence_database_id,
protein_sp,
is_decoy,
QString(peptide_variant_list.at(0).c_str()),
start,
is_nter,
missed_cleavage_number,
semi_enzyme);
}
else
{
std::string peptide_variant = peptide_variant_list.back();
while(peptide_variant_list.size() > 0)
{
enzyme_product.setPeptide(sequence_database_id,
protein_sp,
is_decoy,
QString(peptide_variant.c_str()),
start,
is_nter,
missed_cleavage_number,
semi_enzyme);
peptide_variant_list.pop_back();
if(peptide_variant_list.size() > 0)
{
peptide_variant = peptide_variant_list.back();
}
}
}
std::vector<std::string>().swap(
peptide_variant_list); // clear peptide_variant_list reallocating
}
else
{
enzyme_product.setPeptide(sequence_database_id,
protein_sp,
is_decoy,
peptide,
start,
is_nter,
missed_cleavage_number,
semi_enzyme);
}
}
pappso::Enzyme::m_maxPeptideVariantListSize
std::size_t m_maxPeptideVariantListSize
Definition enzyme.h:93
pappso::Enzyme::replaceWildcards
void replaceWildcards(std::vector< std::string > *p_peptide_variant_list) const
Definition enzyme.cpp:195
pappso::Enzyme::m_takeOnlyFirstWildcard
bool m_takeOnlyFirstWildcard
Definition enzyme.h:91

References m_maxPeptideVariantListSize, m_takeOnlyFirstWildcard, replaceWildcards(), and pappso::EnzymeProductInterface::setPeptide().

Referenced by eat().

## setMaxPeptideVariantListSize()

void pappso::Enzyme::setMaxPeptideVariantListSize | ( | std::size_t | max_peptide_variant_list_size | ) |

if there are wildcards in the protein sequence : restrict the number of possible peptide sequences

Parameters

  max_peptide_variant_list_size | maximum number of peptide variant (default is 100)

Definition at line 81 of file enzyme.cpp.

{
m_maxPeptideVariantListSize = max_peptide_variant_list_size;
}

References m_maxPeptideVariantListSize.

## setMiscleavage()

void pappso::Enzyme::setMiscleavage | ( | unsigned int | miscleavage | ) |

sets the maximum number of missed cleavage allowed in the digestion

Parameters

  miscleavage | maximum number of missed cleavade to allow (defaults is 0)

Definition at line 71 of file enzyme.cpp.

{
m_miscleavage = miscleavage;
}

References m_miscleavage.

## setTakeOnlyFirstWildcard()

void pappso::Enzyme::setTakeOnlyFirstWildcard | ( | bool | take_only_first_wildcard | ) |

take only first m_takeOnlyFirstWildcard

Parameters

  bool | true : switch to take only the first possibility if there are X, B or Z wildcards in sequence

Definition at line 269 of file enzyme.cpp.

{
m_takeOnlyFirstWildcard = take_only_first_wildcard;
}

References m_takeOnlyFirstWildcard.

## Member Data Documentation

## m_maxPeptideVariantListSize

std::size_t pappso::Enzyme::m_maxPeptideVariantListSize = 100

private

Definition at line 93 of file enzyme.h.

Referenced by sanityCheck(), and setMaxPeptideVariantListSize().

## m_miscleavage

unsigned int pappso::Enzyme::m_miscleavage = 0

private

Definition at line 90 of file enzyme.h.

Referenced by Enzyme(), Enzyme(), eat(), getMiscleavage(), and setMiscleavage().

## m_recognitionSite

QRegularExpression pappso::Enzyme::m_recognitionSite

private

example with a kinase == [K,R]

Definition at line 89 of file enzyme.h.

Referenced by Enzyme(), Enzyme(), eat(), and getQRegExpRecognitionSite().

## m_takeOnlyFirstWildcard

bool pappso::Enzyme::m_takeOnlyFirstWildcard = false

private

Definition at line 91 of file enzyme.h.

Referenced by sanityCheck(), and setTakeOnlyFirstWildcard().

## m_wildCardB

std::vector<char> pappso::Enzyme::m_wildCardB

private

Definition at line 97 of file enzyme.h.

Referenced by Enzyme(), Enzyme(), and replaceWildcards().

## m_wildCardX

std::vector<char> pappso::Enzyme::m_wildCardX

private

Definition at line 96 of file enzyme.h.

Referenced by Enzyme(), Enzyme(), and replaceWildcards().

## m_wildCardZ

std::vector<char> pappso::Enzyme::m_wildCardZ

private

Definition at line 98 of file enzyme.h.

Referenced by Enzyme(), Enzyme(), and replaceWildcards().

The documentation for this class was generated from the following files:

- pappsomspp/protein/enzyme.h
- pappsomspp/protein/enzyme.cpp