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)
106 MapAccessionModifications ret;
121 qDebug() << new_mod->
m_mass;
128 if(accession ==
"internal:Nter_hydrolytic_cleavage_H")
134 term.
m_name =
"Nter hydrolytic cleavage H+";
137 if(accession ==
"internal:Cter_hydrolytic_cleavage_HO")
143 term.
m_name =
"Cter hydrolytic cleavage HO";
146 if(accession.startsWith(
"MUTATION:"))
148 QRegularExpression regexp_mutation(
"^MUTATION:([A-Z])=>([A-Z])$");
149 QRegularExpressionMatch match = regexp_mutation.match(accession);
152 qDebug() << match.capturedTexts()[1].at(0) <<
" "
153 << match.capturedTexts()[2].at(0);
155 Aa aa_from(match.capturedTexts()[1].toStdString().c_str()[0]);
156 Aa aa_to(match.capturedTexts()[2].toStdString().c_str()[0]);
159 return instance_mutation;
163 if(accession.startsWith(
"C13N15:"))
165 QRegularExpression regexp_label(
"^C13N15:([A-Z])$");
166 QRegularExpressionMatch match = regexp_label.match(accession);
169 char labelled_aa(match.capturedTexts()[1].toStdString().c_str()[0]);
175 return instance_labelled_aa_p;
207 QRegularExpression rx(
"(^|\\s)([C,H,O,N,H,S])\\s([-]{0,1}\\d+)");
208 QRegularExpressionMatchIterator i = rx.globalMatch(diff_formula);
212 QRegularExpressionMatch match = i.next();
214 qDebug() << match.captured(2) <<
" " << match.captured(2) <<
" "
215 << match.captured(3);
217 if(match.captured(2) ==
"C")
221 else if(match.captured(2) ==
"H")
225 else if(match.captured(2) ==
"N")
229 else if(match.captured(2) ==
"O")
233 else if(match.captured(2) ==
"S")
240 rx.setPattern(
"\\(([-]{0,1}\\d+)\\)([C,H,O,N,H,S])\\s([-]{0,1}\\d+)");
242 i = rx.globalMatch(diff_formula);
246 QRegularExpressionMatch match = i.next();
248 qDebug() << match.captured(1) <<
" " << match.captured(2) <<
" "
249 << match.captured(3);
251 int number_of_isotopes = match.captured(3).toInt();
253 if(match.captured(2) ==
"C")
255 if(match.captured(1) ==
"13")
261 else if(match.captured(2) ==
"H")
263 if(match.captured(1) ==
"2")
269 else if(match.captured(2) ==
"N")
271 if(match.captured(1) ==
"15")
277 else if(match.captured(2) ==
"O")
279 if(match.captured(1) ==
"17")
283 else if(match.captured(1) ==
"18")
289 else if(match.captured(2) ==
"S")
291 if(match.captured(1) ==
"33")
295 else if(match.captured(1) ==
"34")
299 else if(match.captured(1) ==
"36")
315 std::map<AtomIsotopeSurvey, int>::const_iterator it_atom =
319 theoreticalm_mass +=
MASSCARBON * (it_atom->second);
324 theoreticalm_mass +=
MPROTIUM * (it_atom->second);
330 theoreticalm_mass +=
MASSOXYGEN * (it_atom->second);
341 theoreticalm_mass +=
MASSSULFUR * (it_atom->second);
344 qDebug() << theoreticalm_mass;
358 m_mass = theoreticalm_mass;
365 m_mass = theoreticalm_mass;
371 <<
"ERROR in AaModification::calculateMassFromChemicalComponents "
373 << theoreticalm_mass <<
" m=" <<
m_mass <<
" diff=" << diff
382 QString accession = QString(
"%1").arg(modificationMass);
383 qDebug() << accession;
405 MapAccessionModifications::iterator it =
411 std::pair<MapAccessionModifications::iterator, bool> insert_res =
413 std::pair<QString, AaModificationP>(
415 it = insert_res.first;
426 QObject::tr(
"ERROR getting instance of : %1 NOT FOUND\n%2")
436 catch(std::exception &e)
450 std::pair<MapAccessionModifications::iterator, bool> insert_res =
452 std::pair<QString, AaModificationP>(oboterm.
m_accession,
nullptr));
454 if(!insert_res.second)
466 return insert_res.first->second;
474 unsigned int position)
543 if(peptide_sp.get()->size() == (position + 1))
547 if((position == 0) || isCter)
566 QObject::tr(
"tandem modification not found : %1 %2 %3 %4")
569 .arg(peptide_sp.get()->getSequence())
596 catch(std::exception &e)
599 QObject::tr(
"ERROR in AaModification::getNumberOfIsotope %2")
635 instance_mutation->
m_name = QString(
"mutation from %1 to %2")
638 return instance_mutation;
645 QString accession(QString(
"MUTATION:%1=>%2").arg(mut_from).arg(mut_to));
649 MapAccessionModifications::iterator it =
653 Aa aa_from(mut_from.toLatin1());
654 Aa aa_to(mut_to.toLatin1());
658 std::pair<MapAccessionModifications::iterator, bool> insert_res =
660 std::pair<QString, AaModificationP>(accession,
662 it = insert_res.first;
673 QObject::tr(
"ERROR getting instance of : %1 NOT FOUND\n%2")
683 catch(std::exception &e)
694 switch(from_aa.toLatin1())
710 QString accession(QString(
"C13N15:%1").arg(from_aa));
714 QString diff_formula;
716 switch(from_aa.toLatin1())
719 diff_formula =
"(12)C -2 (13)C 2 (14)N -1 (15)N 1";
722 diff_formula =
"(12)C -3 (13)C 3 (14)N -1 (15)N 1";
725 diff_formula =
"(12)C -5 (13)C 5 (14)N -1 (15)N 1";
728 diff_formula =
"(12)C -6 (13)C 6 (14)N -1 (15)N 1";
731 diff_formula =
"(12)C -6 (13)C 6 (14)N -1 (15)N 1";
734 diff_formula =
"(12)C -3 (13)C 3 (14)N -1 (15)N 1";
737 diff_formula =
"(12)C -4 (13)C 4 (14)N -1 (15)N 1";
740 diff_formula =
"(12)C -3 (13)C 3 (14)N -1 (15)N 1";
743 diff_formula =
"(12)C -5 (13)C 5 (14)N -1 (15)N 1";
746 diff_formula =
"(12)C -4 (13)C 4 (14)N -1 (15)N 1";
749 diff_formula =
"(12)C -5 (13)C 5 (14)N -1 (15)N 1";
752 diff_formula =
"(12)C -4 (13)C 4 (14)N -2 (15)N 2";
755 diff_formula =
"(12)C -5 (13)C 5 (14)N -2 (15)N 2";
758 diff_formula =
"(12)C -11 (13)C 11 (14)N -2 (15)N 2";
761 diff_formula =
"(12)C -9 (13)C 9 (14)N -1 (15)N 1";
764 diff_formula =
"(12)C -6 (13)C 6 (14)N -3 (15)N 3";
767 diff_formula =
"(12)C -5 (13)C 5 (14)N -1 (15)N 1";
771 QObject::tr(
"ERROR creating C13N15-labelled amino acid residue %1\n")
778 obo_psi_term.
m_name = QString(
"Fully C13N15-labelled %1").arg(from_aa);
781 qDebug() <<
"obo_psi_term.m_diffFormula: " << obo_psi_term.
m_diffFormula;
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 createInstanceC13N15LabelledAminoAcid(const QChar &aa_from)
get heavy amino acid modification C13 N15
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()
const char * what() const noexcept override
virtual const QString & qwhat() const
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)