31 #include <QRegularExpression>
37 #include "../pappsoexception.h"
38 #include "../mzrange.h"
39 #include "../peptide/peptide.h"
40 #include "../obo/filterobopsimodsink.h"
41 #include "../obo/filterobopsimodtermaccession.h"
42 #include "../exception/exceptionnotfound.h"
57 : m_accession(accession), m_mass(mass)
77 : m_accession(toCopy.m_accession),
78 m_name(toCopy.m_name),
79 m_mass(toCopy.m_mass),
80 m_atomCount(std::move(toCopy.m_atomCount)),
81 m_mapIsotope(toCopy.m_mapIsotope)
104 MapAccessionModifications ret;
125 if(accession ==
"internal:Nter_hydrolytic_cleavage_H")
131 term.
m_name =
"Nter hydrolytic cleavage H+";
134 if(accession ==
"internal:Cter_hydrolytic_cleavage_HO")
140 term.
m_name =
"Cter hydrolytic cleavage HO";
143 if(accession.startsWith(
"MUTATION:"))
145 QRegularExpression regexp_mutation(
"^MUTATION:([A-Z])=>([A-Z])$");
146 QRegularExpressionMatch match = regexp_mutation.match(accession);
149 qDebug() << match.capturedTexts()[1].at(0) <<
" "
150 << match.capturedTexts()[2].at(0);
152 Aa aa_from(match.capturedTexts()[1].toStdString().c_str()[0]);
153 Aa aa_to(match.capturedTexts()[2].toStdString().c_str()[0]);
156 return instance_mutation;
188 QRegularExpression rx(
"(^|\\s)([C,H,O,N,H,S])\\s([-]{0,1}\\d+)");
189 QRegularExpressionMatchIterator i = rx.globalMatch(diff_formula);
193 QRegularExpressionMatch match = i.next();
195 qDebug() << match.captured(2) <<
" " << match.captured(2) <<
" "
196 << match.captured(3);
198 if(match.captured(2) ==
"C")
202 else if(match.captured(2) ==
"H")
206 else if(match.captured(2) ==
"N")
210 else if(match.captured(2) ==
"O")
214 else if(match.captured(2) ==
"S")
221 rx.setPattern(
"\\(([-]{0,1}\\d+)\\)([C,H,O,N,H,S])\\s([-]{0,1}\\d+)");
223 i = rx.globalMatch(diff_formula);
227 QRegularExpressionMatch match = i.next();
229 qDebug() << match.captured(1) <<
" " << match.captured(2) <<
" "
230 << match.captured(3);
232 int number_of_isotopes = match.captured(3).toInt();
234 if(match.captured(2) ==
"C")
236 if(match.captured(1) ==
"13")
242 else if(match.captured(2) ==
"H")
244 if(match.captured(1) ==
"2")
250 else if(match.captured(2) ==
"N")
252 if(match.captured(1) ==
"15")
258 else if(match.captured(2) ==
"O")
260 if(match.captured(1) ==
"17")
264 else if(match.captured(1) ==
"18")
270 else if(match.captured(2) ==
"S")
272 if(match.captured(1) ==
"33")
276 else if(match.captured(1) ==
"34")
280 else if(match.captured(1) ==
"36")
296 std::map<AtomIsotopeSurvey, int>::const_iterator it_atom =
300 theoreticalm_mass +=
MASSCARBON * (it_atom->second);
305 theoreticalm_mass +=
MPROTIUM * (it_atom->second);
311 theoreticalm_mass +=
MASSOXYGEN * (it_atom->second);
322 theoreticalm_mass +=
MASSSULFUR * (it_atom->second);
325 qDebug() << theoreticalm_mass;
340 m_mass = theoreticalm_mass;
346 <<
"ERROR in AaModification::calculateMassFromChemicalComponents theo="
347 << theoreticalm_mass <<
" m=" <<
m_mass <<
" diff=" << diff
355 QString accession = QString(
"%1").arg(modificationMass);
356 qDebug() << accession;
378 MapAccessionModifications::iterator it =
384 std::pair<MapAccessionModifications::iterator, bool> insert_res =
386 std::pair<QString, AaModificationP>(
388 it = insert_res.first;
399 QObject::tr(
"ERROR getting instance of : %1 NOT FOUND\n%2")
409 catch(std::exception &e)
422 MapAccessionModifications::iterator it =
427 std::pair<MapAccessionModifications::iterator, bool> insert_res =
430 it = insert_res.first;
444 unsigned int position)
513 if(peptide_sp.get()->size() == (position + 1))
517 if((position == 0) || isCter)
536 QObject::tr(
"tandem modification not found : %1 %2 %3 %4")
539 .arg(peptide_sp.get()->getSequence())
566 catch(std::exception &e)
569 QObject::tr(
"ERROR in AaModification::getNumberOfIsotope %2")
605 instance_mutation->
m_name = QString(
"mutation from %1 to %2")
608 return instance_mutation;
615 QString accession(QString(
"MUTATION:%1=>%2").arg(mut_from).arg(mut_to));
619 MapAccessionModifications::iterator it =
623 Aa aa_from(mut_from.toLatin1());
624 Aa aa_to(mut_to.toLatin1());
628 std::pair<MapAccessionModifications::iterator, bool> insert_res =
630 std::pair<QString, AaModificationP>(accession,
632 it = insert_res.first;
643 QObject::tr(
"ERROR getting instance of : %1 NOT FOUND\n%2")
653 catch(std::exception &e)
amino acid modification model
virtual const char & getLetter() const
const QString & getName() const
static AaModificationP getInstanceMutation(const QChar &mut_from, const QChar &mut_to)
get a fake modification coding a mutation from an amino acid to an other
static AaModificationP createInstance(const QString &saccession)
std::map< Isotope, int > m_mapIsotope
const QString & getAccession() const
static AaModificationP getInstanceXtandemMod(const QString &type, pappso_double mass, const PeptideSp &peptide_sp, unsigned int position)
AaModification(AaModification &&toCopy)
std::map< AtomIsotopeSurvey, int > m_atomCount
int getNumberOfAtom(AtomIsotopeSurvey atom) const override final
get the number of atom C, O, N, H in the molecule
pappso_double getMass() const
void setXrefOrigin(const QString &origin)
set list of amino acid on which this modification takes place
std::map< QString, AaModificationP > MapAccessionModifications
static AaModificationP getInstance(const QString &accession)
static AaModificationP getInstanceCustomizedMod(pappso_double modificationMass)
const QString m_accession
void setDiffFormula(const QString &diff_formula)
static AaModificationP createInstanceMutation(const Aa &aa_from, const Aa &aa_to)
void calculateMassFromChemicalComponents()
static MapAccessionModifications m_mapAccessionModifications
int getNumberOfIsotope(Isotope isotope) const override final
get the number of isotopes C13, H2, O17, O18, N15, S33, S34, S36 in the molecule
int getNumberOfAtom(AtomIsotopeSurvey atom) const override final
get the number of atom C, O, N, H in the molecule
pappso_double getMass() const override
const OboPsiModTerm & getOne()
virtual const QString & qwhat() const
const char * what() const noexcept override
static PrecisionPtr getDaltonInstance(pappso_double value)
get a Dalton precision pointer
tries to keep as much as possible monoisotopes, removing any possible C13 peaks and changes multichar...
const pappso_double DIFFS32S33(32.9714589101 - MASSSULFUR)
const pappso_double DIFFS32S34(33.9678670300 - MASSSULFUR)
const pappso_double DIFFO16O17(16.99913150 - MASSOXYGEN)
const pappso_double MASSCARBON(12)
const pappso_double MASSSULFUR(31.9720711741)
std::shared_ptr< const Peptide > PeptideSp
const pappso_double DIFFS32S36(35.9670812000 - MASSSULFUR)
const AaModification * AaModificationP
double pappso_double
A type definition for doubles.
const pappso_double MPROTIUM(1.007825032241)
const pappso_double MASSNITROGEN(14.0030740048)
const pappso_double MASSOXYGEN(15.99491461956)
const pappso_double DIFFO16O18(17.9991610 - MASSOXYGEN)
const pappso_double DIFFN14N15(15.0001088982 - MASSNITROGEN)
const pappso_double DIFFC12C13(1.0033548378)
const pappso_double DIFFH1H2(2.0141017778 - MPROTIUM)