libpappsomspp
Library for mass spectrometry
Loading...
Searching...
No Matches
peptideproformaparser.cpp
Go to the documentation of this file.
1/**
2 * \file pappsomspp/peptide/peptideproformaparser.cpp
3 * \date 27/11/2023
4 * \author Olivier Langella
5 * \brief parse peptide string in ProForma to pappso::Peptide
6 */
7
8/*******************************************************************************
9 * Copyright (c) 2023 Olivier Langella
10 *<Olivier.Langella@universite-paris-saclay.fr>.
11 *
12 * This file is part of the PAPPSOms++ library.
13 *
14 * PAPPSOms++ is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU General Public License as published by
16 * the Free Software Foundation, either version 3 of the License, or
17 * (at your option) any later version.
18 *
19 * PAPPSOms++ is distributed in the hope that it will be useful,
20 * but WITHOUT ANY WARRANTY; without even the implied warranty of
21 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 * GNU General Public License for more details.
23 *
24 * You should have received a copy of the GNU General Public License
25 * along with PAPPSOms++. If not, see <http://www.gnu.org/licenses/>.
26 *
27 ******************************************************************************/
28
30#include "../obo/filterobopsimodtermlabel.h"
31#include "../obo/filterobopsimodsink.h"
32#include "../exception/exceptionnotpossible.h"
33
34namespace pappso
35{
36
37
38// QRegularExpression PeptideProFormaParser::_mod_parser("\\[[^\\]]*\\]");
39QRegularExpression PeptideProFormaParser::_rx_psimod("MOD:[0-9]+");
40QRegularExpression PeptideProFormaParser::_rx_modmass("[-+]?[0-9]+\\.?[0-9]*");
41void
43 Peptide &peptide)
44{
45 // Peptide
46 // peptide2("C[MOD:00397][MOD:01160]C[MOD:00397]AADDKEAC[MOD:00397]FAVEGPK");
47 // CCAADDKEACFAVEGPK
48 /*
49 <psimod position="1" accession="MOD:00397"/>
50 <psimod position="2" accession="MOD:00397"/>
51 <psimod position="10" accession="MOD:00397"/>
52 <psimod position="1" accession="MOD:01160"/>
53 */
54
55 std::size_t i = 0;
56 std::size_t end = pepstr.size();
57 while(i < end)
58 {
59 QChar aa_char = pepstr[i];
60 if(aa_char == '[')
61 {
62 QString mod;
63 i++;
64 aa_char = pepstr[i];
65 while((i < end) && (aa_char != ']'))
66 {
67 mod.append(aa_char);
68 i++;
69 if(i < end)
70 aa_char = pepstr[i];
71 }
72
73 qDebug() << aa_char;
74 if(aa_char != ']')
75 {
77 QObject::tr("modification string is malformed %1").arg(mod));
78 }
79 // we have a mod
80 // is it a double ?
81 bool is_double = false;
82 double mass_modif = mod.toDouble(&is_double);
83 if(is_double)
84 {
85 peptide.m_aaVec.back().addAaModification(
87 }
88 else
89 {
90 peptide.m_aaVec.back().addAaModification(
92 }
93 }
94 else
95 {
96 if(aa_char.isLetter())
97 {
98 Aa pappso_aa(aa_char.toLatin1());
99 if(peptide.size() == 0)
100 {
102 "internal:Nter_hydrolytic_cleavage_H"));
103 }
104 peptide.m_aaVec.push_back(pappso_aa);
105 }
106 }
107 i++;
108 }
109
110 peptide.m_aaVec.back().addAaModification(
111 AaModification::getInstance("internal:Cter_hydrolytic_cleavage_HO"));
112
113 // qDebug() << peptide.toProForma();
114 peptide.m_proxyMass = -1;
115 peptide.getMass();
116}
117
120{
121
122 // QMutexLocker locker(&_mutex);
123 Peptide peptide("");
125 // qDebug() << peptide.toProForma();
126 return (peptide.makePeptideSp());
127}
128
131{
132
133 // QMutexLocker locker(&_mutex);
134 Peptide peptide("");
136
137 return (peptide.makeNoConstPeptideSp());
138}
139} // namespace pappso
static AaModificationP getInstance(const QString &accession)
static AaModificationP getInstanceCustomizedMod(pappso_double modificationMass)
void addAaModification(AaModificationP aaModification)
Definition aa.cpp:190
static NoConstPeptideSp parseNoConstString(const QString &pepstr)
static QRegularExpression _rx_psimod
static PeptideSp parseString(const QString &pepstr)
static QRegularExpression _rx_modmass
static void parseStringToPeptide(const QString &pepstr, Peptide &peptide)
PeptideSp makePeptideSp() const
Definition peptide.cpp:126
NoConstPeptideSp makeNoConstPeptideSp() const
Definition peptide.cpp:132
pappso_double m_proxyMass
Definition peptide.h:245
unsigned int size() const override
Definition peptide.cpp:183
pappso_double getMass()
Definition peptide.cpp:275
std::vector< Aa > m_aaVec
Definition peptide.h:244
tries to keep as much as possible monoisotopes, removing any possible C13 peaks and changes multichar...
Definition aa.cpp:39
std::shared_ptr< const Peptide > PeptideSp
std::shared_ptr< Peptide > NoConstPeptideSp
Definition peptide.h:97
parse peptide string in ProForma to pappso::Peptide https://github.com/HUPO-PSI/ProForma/blob/master/...