libpappsomspp
Library for mass spectrometry
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 239 of file peptideproformaparser.cpp.

240{
241
242 // QMutexLocker locker(&_mutex);
243 Peptide peptide("");
245
246 return (peptide.makeNoConstPeptideSp());
247}
static void parseStringToPeptide(const QString &pepstr, Peptide &peptide)

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

◆ parseString()

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

◆ parseStringToPeptide()

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

Definition at line 48 of file peptideproformaparser.cpp.

49{
50 // Peptide
51 // peptide2("C[MOD:00397][MOD:01160]C[MOD:00397]AADDKEAC[MOD:00397]FAVEGPK");
52 // CCAADDKEACFAVEGPK
53 /*
54 <psimod position="1" accession="MOD:00397"/>
55 <psimod position="2" accession="MOD:00397"/>
56 <psimod position="10" accession="MOD:00397"/>
57 <psimod position="1" accession="MOD:01160"/>
58 */
59
60
61 QString peptide_str = pepstr;
62
63 QStringList res_split = peptide_str.split("?");
64 if(res_split.size() == 2)
65 {
66 peptide_str = res_split.at(1);
67 }
68 QRegularExpressionMatch match_global_mod = m_firstGlobalMod.match(peptide_str);
69
70 QStringList global_mod_list;
71 while(match_global_mod.hasMatch())
72 {
73 QStringList pline = match_global_mod.capturedTexts();
74 qDebug() << pline[1];
75 if(pline[1] == "13C")
76 {
77 // Carbon 13: <13C>ATPEILTVNSIGQLK
78 peptide.setGlobalModification(Enums::Isotope::C13);
79 }
80 else if(pline[1] == "15N")
81 {
82 // Nitrogen 15: <15N>ATPEILTVNSIGQLK
83 peptide.setGlobalModification(Enums::Isotope::N15);
84 }
85 else if(pline[1] == "D")
86 {
87 // Deuterium: <D>ATPEILTVNSIGQLK
88 peptide.setGlobalModification(Enums::Isotope::H2);
89 }
90 else
91 {
92 //<[Oxidation]@C,M>
93 global_mod_list << pline[1];
94 }
95 peptide_str = pline[2];
96 match_global_mod = m_firstGlobalMod.match(peptide_str);
97 }
98
99
100 std::size_t i = 0;
101 std::size_t end = peptide_str.size();
103 bool in_cter = false;
104 while(i < end)
105 {
106 QChar aa_char = peptide_str[i];
107 if(aa_char == '[')
108 {
109 QString mod;
110 i++;
111 aa_char = peptide_str[i];
112 while((i < end) && (aa_char != ']'))
113 {
114 mod.append(aa_char);
115 i++;
116 if(i < end)
117 aa_char = peptide_str[i];
118 }
119
120 qDebug() << aa_char;
121 if(aa_char != ']')
122 {
123 throw pappso::ExceptionNotPossible(
124 QObject::tr("modification string is malformed %1").arg(mod));
125 }
126 // we have a mod
127 // is it a double ?
128 bool is_double = false;
129 double mass_modif = mod.toDouble(&is_double);
130 AaModificationP aamod;
131 if(is_double)
132 {
133 aamod =
134 Utils::guessAaModificationPbyMonoisotopicMassDelta(last_amino_acid, mass_modif);
135 }
136 else
137 {
138 aamod = AaModification::getInstance(mod);
139 }
140 if(peptide.m_aaVec.size() == 0)
141 {
142 if(is_double)
143 {
146 if(better_mod != nullptr)
147 {
148 aamod = better_mod;
149 }
150 }
151 peptide.setNterModification(aamod);
152 }
153 else
154 {
155 if(in_cter)
156 {
157 if(is_double)
158 {
159 AaModificationP better_mod =
161 mass_modif);
162 if(better_mod != nullptr)
163 {
164 aamod = better_mod;
165 }
166 }
167 peptide.setCterModification(aamod);
168 }
169 else
170 {
171 peptide.m_aaVec.back().addAaModification(aamod);
172 }
173 }
174 }
175 else
176 {
177 if(aa_char.isLetter())
178 {
179 qDebug() << aa_char;
180 Aa pappso_aa(aa_char.toLatin1());
181 last_amino_acid = pappso_aa.getAminoAcidChar();
182 peptide.m_aaVec.push_back(pappso_aa);
183 }
184 else if(aa_char == '-')
185 {
186 if(peptide.m_aaVec.size() > 0)
187 in_cter = true;
188 }
189 else
190 {
191 throw pappso::ExceptionNotPossible(
192 QObject::tr("%1 is not an amino acid").arg(aa_char));
193 }
194 }
195 i++;
196 }
197
198
199 for(QString &global_label_str : global_mod_list)
200 {
201 qDebug() << global_label_str;
202
203 QRegularExpression global_label_reg("^\\[(.*)\\]@(.*)$");
204
205 QRegularExpressionMatch match_global = global_label_reg.match(global_label_str);
206
207 if(match_global.hasMatch())
208 {
209 QStringList pline = match_global.capturedTexts();
210 qDebug() << pline[1];
212 qDebug() << aamod->getAccession();
213 qDebug() << pline[2];
214 for(QString &aa_str : pline[2].split(","))
215 {
216 qDebug() << aa_str;
217 peptide.addAaModificationOnAllAminoAcid(aamod, (Enums::AminoAcidChar)aa_str[0].toLatin1());
218 }
219 }
220 }
221 // qDebug() << peptide.toProForma();
222 peptide.m_proxyMass = -1;
223 peptide.getMass();
224}
static AaModificationP getInstance(const QString &accession)
static QRegularExpression m_firstGlobalMod
static AaModificationP guessAaModificationPbyMonoisotopicMassDelta(Enums::AminoAcidChar aa, pappso_double mass)
Definition utils.cpp:631
const AaModification * AaModificationP

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
staticprivate

Definition at line 52 of file peptideproformaparser.h.

◆ _rx_psimod

QRegularExpression pappso::PeptideProFormaParser::_rx_psimod
staticprivate

Definition at line 51 of file peptideproformaparser.h.

◆ m_firstGlobalMod

QRegularExpression pappso::PeptideProFormaParser::m_firstGlobalMod
staticprivate

Definition at line 53 of file peptideproformaparser.h.

Referenced by parseStringToPeptide().


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