Loading...
Searching...
No Matches
peptideproformaparser.cpp
Go to the documentation of this file.
/**
* \file pappsomspp/peptide/peptideproformaparser.cpp
* \date 27/11/2023
* \author Olivier Langella
* \brief parse peptide string in ProForma to pappso::Peptide
*/
/*******************************************************************************
* Copyright (c) 2023 Olivier Langella
*<Olivier.Langella@universite-paris-saclay.fr>.
*
* This file is part of the PAPPSOms++ library.
*
* PAPPSOms++ is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* PAPPSOms++ is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with PAPPSOms++. If not, see <http://www.gnu.org/licenses/>.
*
******************************************************************************/
#include "peptideproformaparser.h"
#include "../obo/filterobopsimodtermlabel.h"
#include "../obo/filterobopsimodsink.h"
#include "../exception/exceptionnotpossible.h"
namespace pappso
{
// QRegularExpression PeptideProFormaParser::_mod_parser("\\[[^\\]]*\\]");
QRegularExpression PeptideProFormaParser::_rx_psimod("MOD:[0-9]+");
QRegularExpression PeptideProFormaParser::_rx_modmass("[-+]?[0-9]+\\.?[0-9]*");
void
PeptideProFormaParser::parseStringToPeptide(const QString &pepstr,
Peptide &peptide)
{
// 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"/>
*/
std::size_t i = 0;
std::size_t end = pepstr.size();
while(i < end)
{
QChar aa_char = pepstr[i];
if(aa_char == '[')
{
QString mod;
i++;
aa_char = pepstr[i];
while((i < end) && (aa_char != ']'))
{
mod.append(aa_char);
i++;
if(i < end)
aa_char = pepstr[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);
if(is_double)
{
peptide.m_aaVec.back().addAaModification(
AaModification::getInstanceCustomizedMod(mass_modif));
}
else
{
peptide.m_aaVec.back().addAaModification(
AaModification::getInstance(mod));
}
}
else
{
if(aa_char.isLetter())
{
Aa pappso_aa(aa_char.toLatin1());
if(peptide.size() == 0)
{
pappso_aa.addAaModification(AaModification::getInstance(
"internal:Nter_hydrolytic_cleavage_H"));
}
peptide.m_aaVec.push_back(pappso_aa);
}
}
i++;
}
peptide.m_aaVec.back().addAaModification(
AaModification::getInstance("internal:Cter_hydrolytic_cleavage_HO"));
// qDebug() << peptide.toProForma();
peptide.m_proxyMass = -1;
peptide.getMass();
}
PeptideSp
PeptideProFormaParser::parseString(const QString &pepstr)
{
// QMutexLocker locker(&_mutex);
Peptide peptide("");
PeptideProFormaParser::parseStringToPeptide(pepstr, peptide);
// qDebug() << peptide.toProForma();
return (peptide.makePeptideSp());
}
NoConstPeptideSp
PeptideProFormaParser::parseNoConstString(const QString &pepstr)
{
// QMutexLocker locker(&_mutex);
Peptide peptide("");
PeptideProFormaParser::parseStringToPeptide(pepstr, peptide);
return (peptide.makeNoConstPeptideSp());
}
} // namespace pappso
pappso::AaModification::getInstance
static AaModificationP getInstance(const QString &accession)
Definition aamodification.cpp:456
pappso::AaModification::getInstanceCustomizedMod
static AaModificationP getInstanceCustomizedMod(pappso_double modificationMass)
Definition aamodification.cpp:436
pappso::Aa
Definition aa.h:45
pappso::Aa::addAaModification
void addAaModification(AaModificationP aaModification)
Definition aa.cpp:190
pappso::ExceptionNotPossible
Definition exceptionnotpossible.h:29
pappso::PeptideProFormaParser::parseNoConstString
static NoConstPeptideSp parseNoConstString(const QString &pepstr)
Definition peptideproformaparser.cpp:130
pappso::PeptideProFormaParser::_rx_psimod
static QRegularExpression _rx_psimod
Definition peptideproformaparser.h:51
pappso::PeptideProFormaParser::parseString
static PeptideSp parseString(const QString &pepstr)
Definition peptideproformaparser.cpp:119
pappso::PeptideProFormaParser::_rx_modmass
static QRegularExpression _rx_modmass
Definition peptideproformaparser.h:52
pappso::PeptideProFormaParser::parseStringToPeptide
static void parseStringToPeptide(const QString &pepstr, Peptide &peptide)
Definition peptideproformaparser.cpp:42
pappso::Peptide
Definition peptide.h:100
pappso::Peptide::makePeptideSp
PeptideSp makePeptideSp() const
Definition peptide.cpp:126
pappso::Peptide::makeNoConstPeptideSp
NoConstPeptideSp makeNoConstPeptideSp() const
Definition peptide.cpp:132
pappso::Peptide::m_proxyMass
pappso_double m_proxyMass
Definition peptide.h:245
pappso::Peptide::size
unsigned int size() const override
Definition peptide.cpp:183
pappso::Peptide::getMass
pappso_double getMass()
Definition peptide.cpp:275
pappso::Peptide::m_aaVec
std::vector< Aa > m_aaVec
Definition peptide.h:244
pappso
tries to keep as much as possible monoisotopes, removing any possible C13 peaks and changes multichar...
Definition aa.cpp:39
pappso::PeptideSp
std::shared_ptr< const Peptide > PeptideSp
Definition aamodification.h:48
pappso::NoConstPeptideSp
std::shared_ptr< Peptide > NoConstPeptideSp
Definition peptide.h:97
peptideproformaparser.h
parse peptide string in ProForma to pappso::Peptide https://github.com/HUPO-PSI/ProForma/blob/master/...