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

`#include <peptideproformaparser.h>`

## Static Public Member Functions

static PeptideSp | parseString (const QString &pepstr)
static NoConstPeptideSp | parseNoConstString (const QString &pepstr)

## Static Private Member Functions

static void | parseStringToPeptide (const QString &pepstr, Peptide &peptide)

## Static Private Attributes

static QRegularExpression | _rx_psimod
static QRegularExpression | _rx_modmass
static QRegularExpression | m_firstGlobalMod

## Detailed Description

Todo
  write docs

Definition at line 38 of file peptideproformaparser.h.

## Member Function Documentation

## parseNoConstString()

NoConstPeptideSp pappso::PeptideProFormaParser::parseNoConstString | ( | const QString & | pepstr | ) |

static

Definition at line 240 of file peptideproformaparser.cpp.

{
// QMutexLocker locker(&_mutex);
Peptide peptide("");
PeptideProFormaParser::parseStringToPeptide(pepstr, peptide);
return (peptide.makeNoConstPeptideSp());
}
pappso::PeptideProFormaParser::parseStringToPeptide
static void parseStringToPeptide(const QString &pepstr, Peptide &peptide)
Definition peptideproformaparser.cpp:48

References pappso::Peptide::makeNoConstPeptideSp(), and parseStringToPeptide().

## parseString()

PeptideSp pappso::PeptideProFormaParser::parseString | ( | const QString & | pepstr | ) |

static

Definition at line 228 of file peptideproformaparser.cpp.

{
// QMutexLocker locker(&_mutex);
qDebug();
Peptide peptide("");
PeptideProFormaParser::parseStringToPeptide(pepstr, peptide);
// qDebug() << peptide.toProForma();
return (peptide.makePeptideSp());
}

References pappso::Peptide::makePeptideSp(), and parseStringToPeptide().

Referenced by pappso::cbor::psm::PsmFileReaderBase::getCurrentPsmPeptideSp(), pappso::cbor::psm::SageTsvHandler::parsePeptide(), pappso::cbor::psm::PsmFeaturesScan::process(), pappso::cbor::psm::PsmIonSeriesScan::process(), pappso::cbor::psm::PsmSpecGlobScan::process(), pappso::cbor::psm::PsmSpecPeptidOmsScan::process(), pappso::masschroq::JsonInput::read_peptide_list(), and pappso::masschroq::Peptide::setJsonLabelList().

## parseStringToPeptide()

void pappso::PeptideProFormaParser::parseStringToPeptide | ( | const QString & | pepstr,
|  | Peptide & | peptide )

static private

Definition at line 48 of file peptideproformaparser.cpp.

{
// Peptide
// peptide2("C[MOD:00397][MOD:01160]C[MOD:00397]AADDKEAC[MOD:00397]FAVEGPK");
// CCAADDKEACFAVEGPK
/*
<psimod position="1" accession="MOD:00397"/>
<psimod position="2" accession="MOD:00397"/>
<psimod position="10" accession="MOD:00397"/>
<psimod position="1" accession="MOD:01160"/>
*/
QString peptide_str = pepstr;
QStringList res_split = peptide_str.split("?");
if(res_split.size() == 2)
{
peptide_str = res_split.at(1);
}
QRegularExpressionMatch match_global_mod = m_firstGlobalMod.match(peptide_str);
QStringList global_mod_list;
while(match_global_mod.hasMatch())
{
QStringList pline = match_global_mod.capturedTexts();
qDebug() << pline[1];
if(pline[1] == "13C")
{
// Carbon 13: <13C>ATPEILTVNSIGQLK
peptide.setGlobalModification(Enums::Isotope::C13);
}
else if(pline[1] == "15N")
{
// Nitrogen 15: <15N>ATPEILTVNSIGQLK
peptide.setGlobalModification(Enums::Isotope::N15);
}
else if(pline[1] == "D")
{
// Deuterium: <D>ATPEILTVNSIGQLK
peptide.setGlobalModification(Enums::Isotope::H2);
}
else
{
//<[Oxidation]@C,M>
global_mod_list << pline[1];
}
peptide_str = pline[2];
match_global_mod = m_firstGlobalMod.match(peptide_str);
}
std::size_t i = 0;
std::size_t end = peptide_str.size();
Enums::AminoAcidChar last_amino_acid = Enums::AminoAcidChar::alanine;
bool in_cter = false;
while(i < end)
{
QChar aa_char = peptide_str[i];
if(aa_char == '[')
{
QString mod;
i++;
aa_char = peptide_str[i];
while((i < end) && (aa_char != ']'))
{
mod.append(aa_char);
i++;
if(i < end)
aa_char = peptide_str[i];
}
qDebug() << aa_char;
if(aa_char != ']')
{
throw pappso::ExceptionNotPossible(
QObject::tr("modification string is malformed %1").arg(mod));
}
// we have a mod
// is it a double ?
bool is_double = false;
double mass_modif = mod.toDouble(&is_double);
AaModificationP aamod;
if(is_double)
{
aamod =
Utils::guessAaModificationPbyMonoisotopicMassDelta(last_amino_acid, mass_modif);
}
else
{
aamod = AaModification::getInstance(mod);
}
if(peptide.m_aaVec.size() == 0)
{
if(is_double)
{
AaModificationP better_mod = Utils::guessAaModificationPbyMonoisotopicMassDelta(
Enums::AminoAcidChar::alanine, mass_modif);
if(better_mod != nullptr)
{
aamod = better_mod;
}
}
peptide.setNterModification(aamod);
}
else
{
if(in_cter)
{
if(is_double)
{
AaModificationP better_mod =
Utils::guessAaModificationPbyMonoisotopicMassDelta(
Enums::AminoAcidChar::alanine, mass_modif);
if(better_mod != nullptr)
{
aamod = better_mod;
}
}
peptide.setCterModification(aamod);
}
else
{
peptide.m_aaVec.back().addAaModification(aamod);
}
}
}
else
{
if(aa_char.isLetter())
{
qDebug() << aa_char;
Aa pappso_aa(aa_char.toLatin1());
last_amino_acid = pappso_aa.getAminoAcidChar();
peptide.m_aaVec.push_back(pappso_aa);
}
else if(aa_char == '-')
{
if(peptide.m_aaVec.size() > 0)
in_cter = true;
}
else
{
throw pappso::ExceptionNotPossible(
QObject::tr("%1 is not an amino acid").arg(aa_char));
}
}
i++;
}
for(QString &global_label_str : global_mod_list)
{
qDebug() << global_label_str;
QRegularExpression global_label_reg("^\\[(.*)\\]@(.*)$");
QRegularExpressionMatch match_global = global_label_reg.match(global_label_str);
if(match_global.hasMatch())
{
QStringList pline = match_global.capturedTexts();
qDebug() << pline[1];
AaModificationP aamod = AaModification::getInstance(pline[1]);
qDebug() << aamod->getAccession();
qDebug() << pline[2];
for(QString &aa_str : pline[2].split(","))
{
qDebug() << aa_str;
peptide.addAaModificationOnAllAminoAcid(aamod,
(Enums::AminoAcidChar)aa_str[0].toLatin1());
}
}
}
// qDebug() << peptide.toProForma();
peptide.m_proxyMass = -1;
peptide.getMass();
}
pappso::AaModification::getInstance
static AaModificationP getInstance(const QString &accession)
Definition aamodification.cpp:368
pappso::PeptideProFormaParser::m_firstGlobalMod
static QRegularExpression m_firstGlobalMod
Definition peptideproformaparser.h:53
pappso::Utils::guessAaModificationPbyMonoisotopicMassDelta
static AaModificationP guessAaModificationPbyMonoisotopicMassDelta(Enums::AminoAcidChar aa, pappso_double mass)
Definition utils.cpp:658
pappso::Enums::Isotope::C13
@ C13
Definition types.h:128
pappso::Enums::Isotope::N15
@ N15
Definition types.h:135
pappso::Enums::Isotope::H2
@ H2
Definition types.h:130
pappso::Enums::AminoAcidChar
AminoAcidChar
Definition types.h:196
pappso::Enums::AminoAcidChar::alanine
@ alanine
Definition types.h:197
pappso::AaModificationP
const AaModification * AaModificationP
Definition aamodification.h:52

References pappso::Peptide::addAaModificationOnAllAminoAcid(), pappso::Enums::alanine, pappso::Enums::C13, pappso::AaModification::getAccession(), pappso::AaBase::getAminoAcidChar(), pappso::AaModification::getInstance(), pappso::Peptide::getMass(), pappso::Utils::guessAaModificationPbyMonoisotopicMassDelta(), pappso::Enums::H2, pappso::Peptide::m_aaVec, m_firstGlobalMod, pappso::Peptide::m_proxyMass, pappso::Enums::N15, pappso::Peptide::setCterModification(), pappso::Peptide::setGlobalModification(), and pappso::Peptide::setNterModification().

Referenced by parseNoConstString(), and parseString().

## Member Data Documentation

## _rx_modmass

QRegularExpression pappso::PeptideProFormaParser::_rx_modmass

static private

Definition at line 52 of file peptideproformaparser.h.

## _rx_psimod

QRegularExpression pappso::PeptideProFormaParser::_rx_psimod

static private

Definition at line 51 of file peptideproformaparser.h.

## m_firstGlobalMod

QRegularExpression pappso::PeptideProFormaParser::m_firstGlobalMod

static private

Definition at line 53 of file peptideproformaparser.h.

Referenced by parseStringToPeptide().

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

- pappsomspp/core/peptide/peptideproformaparser.h
- pappsomspp/core/peptide/peptideproformaparser.cpp