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
33namespace pappso
34{
35
36
37// QRegularExpression PeptideProFormaParser::_mod_parser("\\[[^\\]]*\\]");
38QRegularExpression PeptideProFormaParser::_rx_psimod("MOD:[0-9]+");
39QRegularExpression PeptideProFormaParser::_rx_modmass("[-+]?[0-9]+\\.?[0-9]*");
40void
42 Peptide &peptide)
43{
44 // Peptide
45 // peptide2("C[MOD:00397][MOD:01160]C[MOD:00397]AADDKEAC[MOD:00397]FAVEGPK");
46 // CCAADDKEACFAVEGPK
47 /*
48 <psimod position="1" accession="MOD:00397"/>
49 <psimod position="2" accession="MOD:00397"/>
50 <psimod position="10" accession="MOD:00397"/>
51 <psimod position="1" accession="MOD:01160"/>
52 */
53
54 std::size_t i = 0;
55 std::size_t end = pepstr.size();
56 while(i < end)
57 {
58 QChar aa_char = pepstr[i];
59 if(aa_char == '[')
60 {
61 QString mod;
62 i++;
63 aa_char = pepstr[i];
64 while((i < end) && (aa_char != ']'))
65 {
66 mod.append(aa_char);
67 i++;
68 aa_char = pepstr[i];
69 }
70 // we have a mod
71 // is it a double ?
72 bool is_double = false;
73 double mass_modif = mod.toDouble(&is_double);
74 if(is_double)
75 {
76 peptide.m_aaVec.back().addAaModification(
78 }
79 else
80 {
81 peptide.m_aaVec.back().addAaModification(
83 }
84 }
85 else
86 {
87 if(aa_char.isLetter())
88 {
89 Aa pappso_aa(aa_char.toLatin1());
90 if(peptide.size() == 0)
91 {
93 "internal:Nter_hydrolytic_cleavage_H"));
94 }
95 peptide.m_aaVec.push_back(pappso_aa);
96 }
97 }
98 i++;
99 }
100
101 peptide.m_aaVec.back().addAaModification(
102 AaModification::getInstance("internal:Cter_hydrolytic_cleavage_HO"));
103
104 // qDebug() << peptide.toProForma();
105 peptide.m_proxyMass = -1;
106 peptide.getMass();
107}
108
111{
112
113 // QMutexLocker locker(&_mutex);
114 Peptide peptide("");
116 // qDebug() << peptide.toProForma();
117 return (peptide.makePeptideSp());
118}
119
122{
123
124 // QMutexLocker locker(&_mutex);
125 Peptide peptide("");
127
128 return (peptide.makeNoConstPeptideSp());
129}
130} // 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:125
NoConstPeptideSp makeNoConstPeptideSp() const
Definition peptide.cpp:131
pappso_double m_proxyMass
Definition peptide.h:245
unsigned int size() const override
Definition peptide.cpp:182
pappso_double getMass()
Definition peptide.cpp:274
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/...