29#include <QRegularExpression>
84 return QString(
"%1 %2").arg(atom).arg(
count);
171 count = count - count_iso;
179 count = count - count_iso;
187 count = count - count_iso;
217 std::int16_t count = isotope_count.count * -1;
250 count += isotope_count.count;
256 count += isotope_count.count;
262 count += isotope_count.count;
267 count += isotope_count.count;
274 count += isotope_count.count;
289 if(isotope_count.isotope == isotope)
290 count += isotope_count.count;
302 switch(isotope_count.isotope)
308 mass += (
MASSCARBON * (double)isotope_count.count);
311 mass += (
MPROTIUM * (double)isotope_count.count);
323 mass += (
MASSOXYGEN * (double)isotope_count.count);
332 mass += (
MASSSULFUR * (double)isotope_count.count);
363 qDebug() <<
"is_a " << term.
m_isA.join(
" ");
364 if(term.
isA(
"MOD:01441"))
366 qDebug() <<
"term.isA(MOD:01441)";
370 QObject::tr(
"origin not found for term : [%1]").arg(term.
getAccession()));
390 QRegularExpression rx(
"(^|\\s)([C,H,O,N,S,P])($|\\s)");
391 QRegularExpressionMatchIterator i = rx.globalMatch(diff_formula);
395 QRegularExpressionMatch match = i.next();
397 qDebug() << match.captured(2) <<
" " << match.captured(2);
398 std::int8_t count = 1;
401 if(match.captured(2) ==
"C")
405 else if(match.captured(2) ==
"H")
409 else if(match.captured(2) ==
"N")
413 else if(match.captured(2) ==
"O")
417 else if(match.captured(2) ==
"S")
421 else if(match.captured(2) ==
"P")
428 rx.setPattern(
"(^|\\s)([C,H,O,N,S,P])\\(([-]{0,1}\\d+)\\)");
429 i = rx.globalMatch(diff_formula);
433 QRegularExpressionMatch match = i.next();
435 qDebug() << match.captured(2) <<
" " << match.captured(3);
436 std::int8_t count = match.captured(3).toInt();
439 if(match.captured(2) ==
"C")
443 else if(match.captured(2) ==
"H")
447 else if(match.captured(2) ==
"N")
451 else if(match.captured(2) ==
"O")
455 else if(match.captured(2) ==
"S")
459 else if(match.captured(2) ==
"P")
467 rx.setPattern(
"(^|\\s)(\\d+)([C,H,O,N,S])($|\\s)");
469 i = rx.globalMatch(diff_formula);
473 QRegularExpressionMatch match = i.next();
475 qDebug() << match.captured(2) <<
" " << match.captured(3);
481 rx.setPattern(
"(^|\\s)(\\d+)([C,H,O,N,S])\\(([-]{0,1}\\d+)\\)");
483 i = rx.globalMatch(diff_formula);
487 QRegularExpressionMatch match = i.next();
489 qDebug() << match.captured(2) <<
" " << match.captured(3) <<
" " << match.captured(4);
491 std::int8_t number_of_isotopes = match.captured(4).toInt();
499 const QString &atom_isotope_number,
505 if(atom_isotope_number ==
"12")
509 else if(atom_isotope_number ==
"13")
514 else if(atom_str ==
"H")
516 if(atom_isotope_number ==
"1")
520 else if(atom_isotope_number ==
"2")
525 else if(atom_str ==
"N")
528 if(atom_isotope_number ==
"14")
532 else if(atom_isotope_number ==
"15")
537 else if(atom_str ==
"O")
539 if(atom_isotope_number ==
"16")
543 else if(atom_isotope_number ==
"17")
547 else if(atom_isotope_number ==
"18")
552 else if(atom_str ==
"S")
554 if(atom_isotope_number ==
"32")
558 else if(atom_isotope_number ==
"33")
562 else if(atom_isotope_number ==
"34")
566 else if(atom_isotope_number ==
"36")
577 .arg(atom_isotope_number));
585 QRegularExpression rx(
"(^|\\s)([C,H,O,N,S,P])\\s([-]{0,1}\\d+)");
586 QRegularExpressionMatchIterator i = rx.globalMatch(diff_formula);
590 QRegularExpressionMatch match = i.next();
592 qDebug() << match.captured(2) <<
" " << match.captured(2) <<
" " << match.captured(3);
593 std::int8_t count = match.captured(3).toInt();
596 if(match.captured(2) ==
"C")
600 else if(match.captured(2) ==
"H")
604 else if(match.captured(2) ==
"N")
608 else if(match.captured(2) ==
"O")
612 else if(match.captured(2) ==
"S")
616 else if(match.captured(2) ==
"P")
623 rx.setPattern(
"\\((\\d+)\\)([C,H,O,N,S])\\s([-]{0,1}\\d+)");
625 i = rx.globalMatch(diff_formula);
629 QRegularExpressionMatch match = i.next();
631 qDebug() << match.captured(1) <<
" " << match.captured(2) <<
" " << match.captured(3);
633 std::int8_t number_of_isotopes = match.captured(3).toInt();
646 if(iso_count.isotope == isotope_count.
isotope)
649 iso_count.count += isotope_count.
count;
661 QStringList str_formula;
664 if(iso_count.count != 0)
665 str_formula << iso_count.toString();
668 return str_formula.join(
" ");
675 std::int16_t cumul_count = 0;
682 cumul_count += iso_count.count;
687 cumul_count += iso_count.count;
688 isotope_ref_p = &iso_count;
695 cumul_count += iso_count.count;
700 cumul_count += iso_count.count;
701 isotope_ref_p = &iso_count;
708 cumul_count += iso_count.count;
713 cumul_count += iso_count.count;
714 isotope_ref_p = &iso_count;
718 if(isotope_ref_p ==
nullptr)
735 isotope_ref_p->
count = cumul_count;
743 std::vector<IsotopeCount> new_vector;
745 return a.isotope < b.isotope;
755 if(it->isotope != current_element.
isotope)
757 new_vector.push_back(current_element);
763 current_element.
count += it->count;
766 if(current_element.
count != 0)
768 new_vector.push_back(current_element);
virtual int getNumberOfIsotope(Enums::Isotope isotope) const =0
get the number of isotopes C13, H2, O17, O18, N15, S33, S34, S36 in the molecule
virtual int getNumberOfAtom(Enums::AtomIsotopeSurvey atom) const =0
get the number of atom C, O, N, H in the molecule
bool isA(const QString &accession) const
tells if this term "is_a" another accession
const QString & getAccession() const
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 MASSPHOSPHORUS(30.973761998)
const pappso_double MASSSULFUR(31.9720711741)
const pappso_double DIFFS32S36(35.9670812000 - MASSSULFUR)
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)
const QString toString() const