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)
94 qDebug() << __FILE__ <<
" " << __FUNCTION__ <<
" " << __LINE__;
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 QRegExp regexp_mutation(
"^MUTATION:([A-Z])=>([A-Z])$");
146 if(regexp_mutation.exactMatch(accession))
148 qDebug() << __FILE__ <<
" " << __FUNCTION__ <<
" " << __LINE__ <<
" "
149 << regexp_mutation.capturedTexts()[1].at(0) <<
" "
150 << regexp_mutation.capturedTexts()[2].at(0);
153 regexp_mutation.capturedTexts()[1].toStdString().c_str()[0]);
154 Aa aa_to(regexp_mutation.capturedTexts()[2].toStdString().c_str()[0]);
157 return instance_mutation;
189 QRegExp rx(
"(^|\\s)([C,H,O,N,H,S])\\s([-]{0,1}\\d+)");
192 while((pos = rx.indexIn(diff_formula, pos)) != -1)
194 qDebug() << rx.cap(2) <<
" " << rx.cap(3);
199 else if(rx.cap(2) ==
"H")
203 else if(rx.cap(2) ==
"N")
207 else if(rx.cap(2) ==
"O")
211 else if(rx.cap(2) ==
"S")
215 pos += rx.matchedLength();
219 rx.setPattern(
"\\(([-]{0,1}\\d+)\\)([C,H,O,N,H,S])\\s([-]{0,1}\\d+)");
222 while((pos = rx.indexIn(diff_formula, pos)) != -1)
224 qDebug() << rx.cap(1) <<
" " << rx.cap(2) <<
" " << rx.cap(3);
225 int number_of_isotopes = rx.cap(3).toInt();
228 if(rx.cap(1) ==
"13")
234 else if(rx.cap(2) ==
"H")
242 else if(rx.cap(2) ==
"N")
244 if(rx.cap(1) ==
"15")
250 else if(rx.cap(2) ==
"O")
252 if(rx.cap(1) ==
"17")
256 else if(rx.cap(1) ==
"18")
262 else if(rx.cap(2) ==
"S")
264 if(rx.cap(1) ==
"33")
268 else if(rx.cap(1) ==
"34")
272 else if(rx.cap(1) ==
"36")
278 pos += rx.matchedLength();
290 std::map<AtomIsotopeSurvey, int>::const_iterator it_atom =
294 theoreticalm_mass +=
MASSCARBON * (it_atom->second);
299 theoreticalm_mass +=
MPROTIUM * (it_atom->second);
305 theoreticalm_mass +=
MASSOXYGEN * (it_atom->second);
316 theoreticalm_mass +=
MASSSULFUR * (it_atom->second);
319 qDebug() << theoreticalm_mass;
334 m_mass = theoreticalm_mass;
335 qDebug() <<
"AaModification::calculateMassFromChemicalComponents "
341 <<
"ERROR in AaModification::calculateMassFromChemicalComponents theo="
342 << theoreticalm_mass <<
" m=" <<
m_mass <<
" diff=" << diff
350 QString accession = QString(
"%1").arg(modificationMass);
351 qDebug() <<
"AaModification::getInstanceCustomizedMod " << accession;
373 MapAccessionModifications::iterator it =
379 std::pair<MapAccessionModifications::iterator, bool> insert_res =
381 std::pair<QString, AaModificationP>(
383 it = insert_res.first;
394 QObject::tr(
"ERROR getting instance of : %1 NOT FOUND\n%2")
404 catch(std::exception &e)
417 MapAccessionModifications::iterator it =
422 std::pair<MapAccessionModifications::iterator, bool> insert_res =
425 it = insert_res.first;
439 unsigned int position)
508 if(peptide_sp.get()->size() == (position + 1))
512 if((position == 0) || isCter)
531 QObject::tr(
"tandem modification not found : %1 %2 %3 %4")
534 .arg(peptide_sp.get()->getSequence())
561 catch(std::exception &e)
564 QObject::tr(
"ERROR in AaModification::getNumberOfIsotope %2")
600 instance_mutation->
m_name = QString(
"mutation from %1 to %2")
603 return instance_mutation;
610 QString accession(QString(
"MUTATION:%1=>%2").arg(mut_from).arg(mut_to));
614 MapAccessionModifications::iterator it =
618 Aa aa_from(mut_from.toLatin1());
619 Aa aa_to(mut_to.toLatin1());
623 std::pair<MapAccessionModifications::iterator, bool> insert_res =
625 std::pair<QString, AaModificationP>(accession,
627 it = insert_res.first;
638 QObject::tr(
"ERROR getting instance of : %1 NOT FOUND\n%2")
648 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)