Loading...
Searching...
No Matches
pappso::ChemicalFormula Class Reference

`#include <chemicalformula.h>`

Inheritance diagram for pappso::ChemicalFormula:

## Public Member Functions

| ChemicalFormula ()
| ChemicalFormula (const AtomNumberInterface &atom_interface)
| ChemicalFormula (const ChemicalFormula &other)
virtual | ~ChemicalFormula ()
pappso::ChemicalFormula & | operator= (const pappso::ChemicalFormula &other)
pappso::ChemicalFormula | operator- () const
pappso::ChemicalFormula | operator+ (const pappso::ChemicalFormula &to_add) const
int | getNumberOfAtom (Enums::AtomIsotopeSurvey atom) const override
| get the number of atom C, O, N, H in the molecule
int | getNumberOfIsotope (Enums::Isotope isotope) const override
| get the number of isotopes C13, H2, O17, O18, N15, S33, S34, S36 in the molecule
double | getMass () const
void | setOboPsiModTerm (const OboPsiModTerm &term)
| get formula from an Obo term
void | addIsotopeCount (const IsotopeCount &isotope_count)
| add an atom or isotope to the forumla
const QString | toString () const
void | setFullIsotope (Enums::Isotope isotope)
| set full isotope labels
Public Member Functions inherited from pappso::AtomNumberInterface
virtual const ChemicalFormula | getChemicalFormula () const

## Private Member Functions

void | setPsimodDiffFormula (const QString &diff_formula)
void | setUnimodDiffFormula (const QString &diff_formula)
void | addIsotopeNumberCount (const QString &atom_str, const QString &atom_isotope_number, std::int8_t count)
void | simplify ()
| simplify chemical formula sort, group isotope, remove 0

## Private Attributes

std::vector< IsotopeCount > | m_isotopeVector

## Detailed Description

Definition at line 43 of file chemicalformula.h.

## Constructor & Destructor Documentation

## ChemicalFormula() [1/3]

pappso::ChemicalFormula::ChemicalFormula | ( |  | ) |

Definition at line 88 of file chemicalformula.cpp.

{
}

Referenced by operator+(), and operator-().

## ChemicalFormula() [2/3]

pappso::ChemicalFormula::ChemicalFormula | ( | const AtomNumberInterface & | atom_interface | ) |

Definition at line 102 of file chemicalformula.cpp.

{
qDebug();
std::int16_t count_iso = atom_interface.getNumberOfIsotope(Enums::Isotope::C13);
std::int16_t count = atom_interface.getNumberOfAtom(Enums::AtomIsotopeSurvey::C) - count_iso;
qDebug() << count;
if(count > 0)
{
m_isotopeVector.push_back({Enums::Isotope::C, count});
}
if(count_iso > 0)
{
m_isotopeVector.push_back({Enums::Isotope::C13, count_iso});
}
count_iso = atom_interface.getNumberOfIsotope(Enums::Isotope::H2);
count = atom_interface.getNumberOfAtom(Enums::AtomIsotopeSurvey::H) - count_iso;
if(count > 0)
{
m_isotopeVector.push_back({Enums::Isotope::H, count});
}
if(count_iso > 0)
{
m_isotopeVector.push_back({Enums::Isotope::H2, count_iso});
}
qDebug();
count_iso = atom_interface.getNumberOfIsotope(Enums::Isotope::O17);
std::int16_t count_iso2 = atom_interface.getNumberOfIsotope(Enums::Isotope::O18);
count = atom_interface.getNumberOfAtom(Enums::AtomIsotopeSurvey::O) - count_iso - count_iso2;
if(count > 0)
{
m_isotopeVector.push_back({Enums::Isotope::O, count});
}
if(count_iso > 0)
{
m_isotopeVector.push_back({Enums::Isotope::O17, count_iso});
}
if(count_iso2 > 0)
{
m_isotopeVector.push_back({Enums::Isotope::O18, count_iso2});
}
qDebug();
count_iso = atom_interface.getNumberOfIsotope(Enums::Isotope::N15);
count = atom_interface.getNumberOfAtom(Enums::AtomIsotopeSurvey::N) - count_iso;
if(count > 0)
{
m_isotopeVector.push_back({Enums::Isotope::N, count});
}
if(count_iso > 0)
{
m_isotopeVector.push_back({Enums::Isotope::N15, count_iso});
}
qDebug();
count = atom_interface.getNumberOfAtom(Enums::AtomIsotopeSurvey::S);
count_iso = atom_interface.getNumberOfIsotope(Enums::Isotope::S33);
if(count_iso > 0)
{
m_isotopeVector.push_back({Enums::Isotope::S33, count_iso});
}
count = count - count_iso;
qDebug();
count_iso = atom_interface.getNumberOfIsotope(Enums::Isotope::S34);
if(count_iso > 0)
{
m_isotopeVector.push_back({Enums::Isotope::S34, count_iso});
}
count = count - count_iso;
qDebug();
count_iso = atom_interface.getNumberOfIsotope(Enums::Isotope::S36);
if(count_iso > 0)
{
m_isotopeVector.push_back({Enums::Isotope::S36, count_iso});
}
count = count - count_iso;
if(count > 0)
{
m_isotopeVector.push_back({Enums::Isotope::S, count});
}
qDebug();
count = atom_interface.getNumberOfAtom(Enums::AtomIsotopeSurvey::P);
if(count > 0)
{
m_isotopeVector.push_back({Enums::Isotope::P, count});
}
qDebug() << m_isotopeVector.size();
}
pappso::ChemicalFormula::m_isotopeVector
std::vector< IsotopeCount > m_isotopeVector
Definition chemicalformula.h:89
pappso::Enums::AtomIsotopeSurvey::C
@ C
Definition types.h:111
pappso::Enums::AtomIsotopeSurvey::P
@ P
Definition types.h:116
pappso::Enums::AtomIsotopeSurvey::S
@ S
Definition types.h:115
pappso::Enums::AtomIsotopeSurvey::N
@ N
Definition types.h:114
pappso::Enums::AtomIsotopeSurvey::H
@ H
Definition types.h:112
pappso::Enums::AtomIsotopeSurvey::O
@ O
Definition types.h:113
pappso::Enums::Isotope::C
@ C
Definition types.h:127
pappso::Enums::Isotope::S36
@ S36
Definition types.h:139
pappso::Enums::Isotope::P
@ P
Definition types.h:140
pappso::Enums::Isotope::C13
@ C13
Definition types.h:128
pappso::Enums::Isotope::S
@ S
Definition types.h:136
pappso::Enums::Isotope::N15
@ N15
Definition types.h:135
pappso::Enums::Isotope::S33
@ S33
Definition types.h:137
pappso::Enums::Isotope::O18
@ O18
Definition types.h:133
pappso::Enums::Isotope::N
@ N
Definition types.h:134
pappso::Enums::Isotope::O17
@ O17
Definition types.h:132
pappso::Enums::Isotope::H
@ H
Definition types.h:129
pappso::Enums::Isotope::S34
@ S34
Definition types.h:138
pappso::Enums::Isotope::H2
@ H2
Definition types.h:130
pappso::Enums::Isotope::O
@ O
Definition types.h:131

References pappso::Enums::C, pappso::Enums::C13, pappso::AtomNumberInterface::getNumberOfAtom(), pappso::AtomNumberInterface::getNumberOfIsotope(), pappso::Enums::H, pappso::Enums::H2, m_isotopeVector, pappso::Enums::N, pappso::Enums::N15, pappso::Enums::O, pappso::Enums::O17, pappso::Enums::O18, pappso::Enums::P, pappso::Enums::S, pappso::Enums::S33, pappso::Enums::S34, and pappso::Enums::S36.

## ChemicalFormula() [3/3]

pappso::ChemicalFormula::ChemicalFormula | ( | const ChemicalFormula & | other | ) |

Definition at line 96 of file chemicalformula.cpp.

: m_isotopeVector(other.m_isotopeVector)
{
}

References m_isotopeVector.

## ~ChemicalFormula()

pappso::ChemicalFormula::~ChemicalFormula | ( |  | ) |

virtual

Definition at line 92 of file chemicalformula.cpp.

{
}

## Member Function Documentation

## addIsotopeCount()

void pappso::ChemicalFormula::addIsotopeCount | ( | const IsotopeCount & | isotope_count | ) |

add an atom or isotope to the forumla

Definition at line 641 of file chemicalformula.cpp.

{
bool added = false;
for(IsotopeCount &iso_count : m_isotopeVector)
{
if(iso_count.isotope == isotope_count.isotope)
{
added = true;
iso_count.count += isotope_count.count;
}
}
if(!added)
m_isotopeVector.push_back(isotope_count);
}

References pappso::IsotopeCount::count, pappso::IsotopeCount::isotope, and m_isotopeVector.

Referenced by pappso::PeptideInterface::getChemicalFormulaCharge().

## addIsotopeNumberCount()

void pappso::ChemicalFormula::addIsotopeNumberCount | ( | const QString & | atom_str,
|  | const QString & | atom_isotope_number,
|  | std::int8_t | count )

private

Definition at line 498 of file chemicalformula.cpp.

{
if(atom_str == "C")
{
if(atom_isotope_number == "12")
{
m_isotopeVector.push_back({Enums::Isotope::C, count});
}
else if(atom_isotope_number == "13")
{
m_isotopeVector.push_back({Enums::Isotope::C13, count});
}
}
else if(atom_str == "H")
{
if(atom_isotope_number == "1")
{
m_isotopeVector.push_back({Enums::Isotope::H, count});
}
else if(atom_isotope_number == "2")
{
m_isotopeVector.push_back({Enums::Isotope::H2, count});
}
}
else if(atom_str == "N")
{
if(atom_isotope_number == "14")
{
m_isotopeVector.push_back({Enums::Isotope::N, count});
}
else if(atom_isotope_number == "15")
{
m_isotopeVector.push_back({Enums::Isotope::N15, count});
}
}
else if(atom_str == "O")
{
if(atom_isotope_number == "16")
{
m_isotopeVector.push_back({Enums::Isotope::O, count});
}
else if(atom_isotope_number == "17")
{
m_isotopeVector.push_back({Enums::Isotope::O17, count});
}
else if(atom_isotope_number == "18")
{
m_isotopeVector.push_back({Enums::Isotope::O18, count});
}
}
else if(atom_str == "S")
{
if(atom_isotope_number == "32")
{
m_isotopeVector.push_back({Enums::Isotope::S, count});
}
else if(atom_isotope_number == "33")
{
m_isotopeVector.push_back({Enums::Isotope::S33, count});
}
else if(atom_isotope_number == "34")
{
m_isotopeVector.push_back({Enums::Isotope::S34, count});
}
else if(atom_isotope_number == "36")
{
m_isotopeVector.push_back({Enums::Isotope::S36, count});
}
}
else
{
// not known
throw pappso::ExceptionNotFound(QObject::tr("atom string: [%1] with atom number %2 not found")
.arg(atom_str)
.arg(atom_isotope_number));
}
}

References pappso::Enums::C, pappso::Enums::C13, pappso::Enums::H, pappso::Enums::H2, m_isotopeVector, pappso::Enums::N, pappso::Enums::N15, pappso::Enums::O, pappso::Enums::O17, pappso::Enums::O18, pappso::Enums::S, pappso::Enums::S33, pappso::Enums::S34, and pappso::Enums::S36.

Referenced by setPsimodDiffFormula(), and setUnimodDiffFormula().

## getMass()

double pappso::ChemicalFormula::getMass | ( |  | ) | const

Definition at line 296 of file chemicalformula.cpp.

{
double mass = 0;
for(auto &isotope_count : m_isotopeVector)
{
switch(isotope_count.isotope)
{
case Enums::Isotope::C13:
mass += ((DIFFC12C13 + MASSCARBON) * (double)isotope_count.count);
break;
case Enums::Isotope::C:
mass += (MASSCARBON * (double)isotope_count.count);
break;
case Enums::Isotope::H:
mass += (MPROTIUM * (double)isotope_count.count);
break;
case Enums::Isotope::H2:
mass += ((DIFFH1H2 + MPROTIUM) * (double)isotope_count.count);
break;
case Enums::Isotope::N:
mass += (MASSNITROGEN * (double)isotope_count.count);
break;
case Enums::Isotope::N15:
mass += ((MASSNITROGEN + DIFFN14N15) * (double)isotope_count.count);
break;
case Enums::Isotope::O:
mass += (MASSOXYGEN * (double)isotope_count.count);
break;
case Enums::Isotope::O17:
mass += ((DIFFO16O17 + MASSOXYGEN) * (double)isotope_count.count);
break;
case Enums::Isotope::O18:
mass += ((DIFFO16O18 + MASSOXYGEN) * (double)isotope_count.count);
break;
case Enums::Isotope::S:
mass += (MASSSULFUR * (double)isotope_count.count);
break;
case Enums::Isotope::S33:
mass += ((DIFFS32S33 + MASSSULFUR) * (double)isotope_count.count);
break;
case Enums::Isotope::S34:
mass += ((DIFFS32S34 + MASSSULFUR) * (double)isotope_count.count);
break;
case Enums::Isotope::S36:
mass += ((DIFFS32S36 + MASSSULFUR) * (double)isotope_count.count);
break;
case Enums::Isotope::P:
mass += (MASSPHOSPHORUS * (double)isotope_count.count);
break;
}
}
return mass;
}
pappso::DIFFS32S33
const pappso_double DIFFS32S33(32.9714589101 - MASSSULFUR)
pappso::DIFFS32S34
const pappso_double DIFFS32S34(33.9678670300 - MASSSULFUR)
pappso::DIFFO16O17
const pappso_double DIFFO16O17(16.99913150 - MASSOXYGEN)
pappso::MASSCARBON
const pappso_double MASSCARBON(12)
pappso::MASSPHOSPHORUS
const pappso_double MASSPHOSPHORUS(30.973761998)
pappso::MASSSULFUR
const pappso_double MASSSULFUR(31.9720711741)
pappso::DIFFS32S36
const pappso_double DIFFS32S36(35.9670812000 - MASSSULFUR)
pappso::MPROTIUM
const pappso_double MPROTIUM(1.007825032241)
pappso::MASSNITROGEN
const pappso_double MASSNITROGEN(14.0030740048)
pappso::MASSOXYGEN
const pappso_double MASSOXYGEN(15.99491461956)
pappso::DIFFO16O18
const pappso_double DIFFO16O18(17.9991610 - MASSOXYGEN)
pappso::DIFFN14N15
const pappso_double DIFFN14N15(15.0001088982 - MASSNITROGEN)
pappso::DIFFC12C13
const pappso_double DIFFC12C13(1.0033548378)
pappso::DIFFH1H2
const pappso_double DIFFH1H2(2.0141017778 - MPROTIUM)

References pappso::Enums::C, pappso::Enums::C13, pappso::DIFFC12C13(), pappso::DIFFH1H2(), pappso::DIFFN14N15(), pappso::DIFFO16O17(), pappso::DIFFO16O18(), pappso::DIFFS32S33(), pappso::DIFFS32S34(), pappso::DIFFS32S36(), pappso::Enums::H, pappso::Enums::H2, m_isotopeVector, pappso::MASSCARBON(), pappso::MASSNITROGEN(), pappso::MASSOXYGEN(), pappso::MASSPHOSPHORUS(), pappso::MASSSULFUR(), pappso::MPROTIUM(), pappso::Enums::N, pappso::Enums::N15, pappso::Enums::O, pappso::Enums::O17, pappso::Enums::O18, pappso::Enums::P, pappso::Enums::S, pappso::Enums::S33, pappso::Enums::S34, and pappso::Enums::S36.

Referenced by pappso::AaModification::createInstance(), pappso::Peptide::getMass(), and pappso::OboListModel::loadPsiMod().

## getNumberOfAtom()

int pappso::ChemicalFormula::getNumberOfAtom | ( | Enums::AtomIsotopeSurvey | atom | ) | const

override virtual

get the number of atom C, O, N, H in the molecule

Implements pappso::AtomNumberInterface.

Definition at line 240 of file chemicalformula.cpp.

{
int count = 0;
for(auto &isotope_count : m_isotopeVector)
{
switch(atom)
{
case Enums::AtomIsotopeSurvey::C:
if((isotope_count.isotope == Enums::Isotope::C) ||
(isotope_count.isotope == Enums::Isotope::C13))
count += isotope_count.count;
break;
case Enums::AtomIsotopeSurvey::H:
if((isotope_count.isotope == Enums::Isotope::H) ||
(isotope_count.isotope == Enums::Isotope::H2))
count += isotope_count.count;
break;
case Enums::AtomIsotopeSurvey::O:
if((isotope_count.isotope == Enums::Isotope::O) ||
(isotope_count.isotope == Enums::Isotope::O17) ||
(isotope_count.isotope == Enums::Isotope::O18))
count += isotope_count.count;
break;
case Enums::AtomIsotopeSurvey::N:
if((isotope_count.isotope == Enums::Isotope::N) ||
(isotope_count.isotope == Enums::Isotope::N15))
count += isotope_count.count;
break;
case Enums::AtomIsotopeSurvey::S:
if((isotope_count.isotope == Enums::Isotope::S) ||
(isotope_count.isotope == Enums::Isotope::S33) ||
(isotope_count.isotope == Enums::Isotope::S34) ||
(isotope_count.isotope == Enums::Isotope::S36))
count += isotope_count.count;
break;
default:
break;
}
}
return count;
}

References pappso::Enums::C, pappso::Enums::C13, pappso::Enums::H, pappso::Enums::H2, m_isotopeVector, pappso::Enums::N, pappso::Enums::N15, pappso::Enums::O, pappso::Enums::O17, pappso::Enums::O18, pappso::Enums::S, pappso::Enums::S33, pappso::Enums::S34, and pappso::Enums::S36.

Referenced by pappso::AaModification::setDiffFormula().

## getNumberOfIsotope()

int pappso::ChemicalFormula::getNumberOfIsotope | ( | Enums::Isotope | isotope | ) | const

override virtual

get the number of isotopes C13, H2, O17, O18, N15, S33, S34, S36 in the molecule

Implements pappso::AtomNumberInterface.

Definition at line 284 of file chemicalformula.cpp.

{
int count = 0;
for(auto &isotope_count : m_isotopeVector)
{
if(isotope_count.isotope == isotope)
count += isotope_count.count;
}
return count;
}

References m_isotopeVector.

Referenced by pappso::AaModification::setDiffFormula().

## operator+()

pappso::ChemicalFormula pappso::ChemicalFormula::operator+ | ( | const pappso::ChemicalFormula & | to_add | ) | const

Definition at line 225 of file chemicalformula.cpp.

{
ChemicalFormula new_formula(*this);
new_formula.m_isotopeVector.insert(new_formula.m_isotopeVector.end(),
to_add.m_isotopeVector.begin(),
to_add.m_isotopeVector.end());
new_formula.simplify();
return new_formula;
}
pappso::ChemicalFormula::ChemicalFormula
ChemicalFormula()
Definition chemicalformula.cpp:88

References ChemicalFormula(), m_isotopeVector, and simplify().

## operator-()

pappso::ChemicalFormula pappso::ChemicalFormula::operator- | ( |  | ) | const

Definition at line 211 of file chemicalformula.cpp.

{
ChemicalFormula new_formula;
for(const IsotopeCount &isotope_count : m_isotopeVector)
{
std::int16_t count = isotope_count.count * -1;
new_formula.m_isotopeVector.push_back({isotope_count.isotope, count});
}
return new_formula;
}

References ChemicalFormula(), and m_isotopeVector.

## operator=()

pappso::ChemicalFormula & pappso::ChemicalFormula::operator= | ( | const pappso::ChemicalFormula & | other | ) |

Definition at line 204 of file chemicalformula.cpp.

{
m_isotopeVector = other.m_isotopeVector;
return *this;
}

References m_isotopeVector.

## setFullIsotope()

void pappso::ChemicalFormula::setFullIsotope | ( | Enums::Isotope | isotope | ) |

set full isotope labels

Definition at line 672 of file chemicalformula.cpp.

{
IsotopeCount *isotope_ref_p = nullptr;
std::int16_t cumul_count = 0;
for(IsotopeCount &iso_count : m_isotopeVector)
{
if(isotope == Enums::Isotope::C13)
{
if(iso_count.isotope == Enums::Isotope::C)
{
cumul_count += iso_count.count;
iso_count.count = 0;
}
if(iso_count.isotope == Enums::Isotope::C13)
{
cumul_count += iso_count.count;
isotope_ref_p = &iso_count;
}
}
else if(isotope == Enums::Isotope::N15)
{
if(iso_count.isotope == Enums::Isotope::N)
{
cumul_count += iso_count.count;
iso_count.count = 0;
}
if(iso_count.isotope == Enums::Isotope::N15)
{
cumul_count += iso_count.count;
isotope_ref_p = &iso_count;
}
}
else if(isotope == Enums::Isotope::H2)
{
if(iso_count.isotope == Enums::Isotope::H)
{
cumul_count += iso_count.count;
iso_count.count = 0;
}
if(iso_count.isotope == Enums::Isotope::H2)
{
cumul_count += iso_count.count;
isotope_ref_p = &iso_count;
}
}
}
if(isotope_ref_p == nullptr)
{
if(isotope == Enums::Isotope::C13)
{
m_isotopeVector.push_back({Enums::Isotope::C13, cumul_count});
}
else if(isotope == Enums::Isotope::N15)
{
m_isotopeVector.push_back({Enums::Isotope::N15, cumul_count});
}
else if(isotope == Enums::Isotope::H2)
{
m_isotopeVector.push_back({Enums::Isotope::H2, cumul_count});
}
}
else
{
isotope_ref_p->count = cumul_count;
}
}

References pappso::Enums::C, pappso::Enums::C13, pappso::IsotopeCount::count, pappso::Enums::H, pappso::Enums::H2, m_isotopeVector, pappso::Enums::N, and pappso::Enums::N15.

Referenced by pappso::Peptide::getChemicalFormulaCharge().

## setOboPsiModTerm()

void pappso::ChemicalFormula::setOboPsiModTerm | ( | const OboPsiModTerm & | term | ) |

get formula from an Obo term

Definition at line 352 of file chemicalformula.cpp.

{
m_isotopeVector.clear();
if(term.isUnimod())
{
qDebug();
setUnimodDiffFormula(term.m_diffFormula);
}
else
{
qDebug() << "is_a " << term.m_isA.join(" ");
if(term.isA("MOD:01441"))
{
qDebug() << "term.isA(MOD:01441)";
if(term.m_origin.isEmpty())
{
throw pappso::ExceptionNotFound(
QObject::tr("origin not found for term : [%1]").arg(term.getAccession()));
}
setPsimodDiffFormula(term.m_formula);
qDebug();
// new_mod->m_mass = AaBase::getAaMass(term.m_origin[0].toLatin1());
}
else
{
setPsimodDiffFormula(term.m_diffFormula);
}
}
qDebug();
}
pappso::ChemicalFormula::setPsimodDiffFormula
void setPsimodDiffFormula(const QString &diff_formula)
Definition chemicalformula.cpp:583
pappso::ChemicalFormula::setUnimodDiffFormula
void setUnimodDiffFormula(const QString &diff_formula)
Definition chemicalformula.cpp:385

References pappso::OboPsiModTerm::getAccession(), pappso::OboPsiModTerm::isA(), pappso::OboPsiModTerm::isUnimod(), pappso::OboPsiModTerm::m_diffFormula, pappso::OboPsiModTerm::m_formula, pappso::OboPsiModTerm::m_isA, m_isotopeVector, pappso::OboPsiModTerm::m_origin, setPsimodDiffFormula(), and setUnimodDiffFormula().

Referenced by pappso::AaModification::createInstance(), pappso::AaModification::createInstance(), and pappso::OboListModel::loadPsiMod().

## setPsimodDiffFormula()

void pappso::ChemicalFormula::setPsimodDiffFormula | ( | const QString & | diff_formula | ) |

private

Definition at line 583 of file chemicalformula.cpp.

{
QRegularExpression rx("(^|\\s)([C,H,O,N,S,P])\\s([-]{0,1}\\d+)");
QRegularExpressionMatchIterator i = rx.globalMatch(diff_formula);
while(i.hasNext())
{
QRegularExpressionMatch match = i.next();
qDebug() << match.captured(2) << " " << match.captured(2) << " " << match.captured(3);
std::int8_t count = match.captured(3).toInt();
qDebug() << count;
if(match.captured(2) == "C")
{
m_isotopeVector.push_back({Enums::Isotope::C, count});
}
else if(match.captured(2) == "H")
{
m_isotopeVector.push_back({Enums::Isotope::H, count});
}
else if(match.captured(2) == "N")
{
m_isotopeVector.push_back({Enums::Isotope::N, count});
}
else if(match.captured(2) == "O")
{
m_isotopeVector.push_back({Enums::Isotope::O, count});
}
else if(match.captured(2) == "S")
{
m_isotopeVector.push_back({Enums::Isotope::S, count});
}
else if(match.captured(2) == "P")
{
m_isotopeVector.push_back({Enums::Isotope::P, count});
}
}
// look for isotopes :
rx.setPattern("\\((\\d+)\\)([C,H,O,N,S])\\s([-]{0,1}\\d+)");
i = rx.globalMatch(diff_formula);
while(i.hasNext())
{
QRegularExpressionMatch match = i.next();
qDebug() << match.captured(1) << " " << match.captured(2) << " " << match.captured(3);
std::int8_t number_of_isotopes = match.captured(3).toInt();
addIsotopeNumberCount(match.captured(2), match.captured(1), number_of_isotopes);
}
}
pappso::ChemicalFormula::addIsotopeNumberCount
void addIsotopeNumberCount(const QString &atom_str, const QString &atom_isotope_number, std::int8_t count)
Definition chemicalformula.cpp:498

References addIsotopeNumberCount(), pappso::Enums::C, pappso::Enums::H, m_isotopeVector, pappso::Enums::N, pappso::Enums::O, pappso::Enums::P, and pappso::Enums::S.

Referenced by setOboPsiModTerm().

## setUnimodDiffFormula()

void pappso::ChemicalFormula::setUnimodDiffFormula | ( | const QString & | diff_formula | ) |

private

Definition at line 385 of file chemicalformula.cpp.

{
// C(-6) 13C(6) N(-2) 15N(2)
// atom alone
QRegularExpression rx("(^|\\s)([C,H,O,N,S,P])($|\\s)");
QRegularExpressionMatchIterator i = rx.globalMatch(diff_formula);
while(i.hasNext())
{
QRegularExpressionMatch match = i.next();
qDebug() << match.captured(2) << " " << match.captured(2);
std::int8_t count = 1;
qDebug() << count;
if(match.captured(2) == "C")
{
m_isotopeVector.push_back({Enums::Isotope::C, count});
}
else if(match.captured(2) == "H")
{
m_isotopeVector.push_back({Enums::Isotope::H, count});
}
else if(match.captured(2) == "N")
{
m_isotopeVector.push_back({Enums::Isotope::N, count});
}
else if(match.captured(2) == "O")
{
m_isotopeVector.push_back({Enums::Isotope::O, count});
}
else if(match.captured(2) == "S")
{
m_isotopeVector.push_back({Enums::Isotope::S, count});
}
else if(match.captured(2) == "P")
{
m_isotopeVector.push_back({Enums::Isotope::P, count});
}
}
// C(-6) 13C(6) N(-2) 15N(2)
rx.setPattern("(^|\\s)([C,H,O,N,S,P])\\(([-]{0,1}\\d+)\\)");
i = rx.globalMatch(diff_formula);
while(i.hasNext())
{
QRegularExpressionMatch match = i.next();
qDebug() << match.captured(2) << " " << match.captured(3);
std::int8_t count = match.captured(3).toInt();
qDebug() << count;
if(match.captured(2) == "C")
{
m_isotopeVector.push_back({Enums::Isotope::C, count});
}
else if(match.captured(2) == "H")
{
m_isotopeVector.push_back({Enums::Isotope::H, count});
}
else if(match.captured(2) == "N")
{
m_isotopeVector.push_back({Enums::Isotope::N, count});
}
else if(match.captured(2) == "O")
{
m_isotopeVector.push_back({Enums::Isotope::O, count});
}
else if(match.captured(2) == "S")
{
m_isotopeVector.push_back({Enums::Isotope::S, count});
}
else if(match.captured(2) == "P")
{
m_isotopeVector.push_back({Enums::Isotope::P, count});
}
}
// C(-6) 13C(6) N(-2) 15N(2)
// look for isotopes :
rx.setPattern("(^|\\s)(\\d+)([C,H,O,N,S])($|\\s)");
i = rx.globalMatch(diff_formula);
while(i.hasNext())
{
QRegularExpressionMatch match = i.next();
qDebug() << match.captured(2) << " " << match.captured(3);
addIsotopeNumberCount(match.captured(3), match.captured(2), 1);
}
// C(-6) 13C(6) N(-2) 15N(2)
// look for isotopes :
rx.setPattern("(^|\\s)(\\d+)([C,H,O,N,S])\\(([-]{0,1}\\d+)\\)");
i = rx.globalMatch(diff_formula);
while(i.hasNext())
{
QRegularExpressionMatch match = i.next();
qDebug() << match.captured(2) << " " << match.captured(3) << " " << match.captured(4);
std::int8_t number_of_isotopes = match.captured(4).toInt();
addIsotopeNumberCount(match.captured(3), match.captured(2), number_of_isotopes);
}
}

References addIsotopeNumberCount(), pappso::Enums::C, pappso::Enums::H, m_isotopeVector, pappso::Enums::N, pappso::Enums::O, pappso::Enums::P, and pappso::Enums::S.

Referenced by setOboPsiModTerm().

## simplify()

void pappso::ChemicalFormula::simplify | ( |  | ) |

private

simplify chemical formula sort, group isotope, remove 0

Definition at line 741 of file chemicalformula.cpp.

{
std::vector<IsotopeCount> new_vector;
std::sort(m_isotopeVector.begin(), m_isotopeVector.end(), [](IsotopeCount &a, IsotopeCount &b) {
return a.isotope < b.isotope;
});
auto it = m_isotopeVector.begin();
while(it != m_isotopeVector.end())
{
IsotopeCount current_element = *it;
it++;
if(it != m_isotopeVector.end())
{
if(it->isotope != current_element.isotope)
{
new_vector.push_back(current_element);
}
else
{
while((it != m_isotopeVector.end()) && (it->isotope == current_element.isotope))
{
current_element.count += it->count;
it++;
}
if(current_element.count != 0)
{
new_vector.push_back(current_element);
}
}
}
}
m_isotopeVector = new_vector;
}
pappso::PeptideIonNter::a
@ a
Definition peptide.h:77
pappso::PeptideIonNter::b
@ b
Definition peptide.h:74

References pappso::a, pappso::b, pappso::IsotopeCount::count, pappso::IsotopeCount::isotope, and m_isotopeVector.

Referenced by operator+().

## toString()

const QString pappso::ChemicalFormula::toString | ( |  | ) | const

Definition at line 659 of file chemicalformula.cpp.

{
QStringList str_formula;
for(const IsotopeCount &iso_count : m_isotopeVector)
{
if(iso_count.count != 0)
str_formula << iso_count.toString();
}
str_formula.sort();
return str_formula.join(" ");
}

References m_isotopeVector.

Referenced by pappso::Peptide::getChemicalFormulaCharge().

## Member Data Documentation

## m_isotopeVector

std::vector<IsotopeCount> pappso::ChemicalFormula::m_isotopeVector

private

Definition at line 89 of file chemicalformula.h.

Referenced by ChemicalFormula(), ChemicalFormula(), addIsotopeCount(), addIsotopeNumberCount(), getMass(), getNumberOfAtom(), getNumberOfIsotope(), operator+(), operator-(), operator=(), setFullIsotope(), setOboPsiModTerm(), setPsimodDiffFormula(), setUnimodDiffFormula(), simplify(), and toString().

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

- pappsomspp/core/amino_acid/chemicalformula.h
- pappsomspp/core/amino_acid/chemicalformula.cpp