diff --git a/src/input/identificationpwizreader.cpp b/src/input/identificationpwizreader.cpp index c3afa93b421b7c5b154a79a7e122bc1c5a7f7993..0666dc90974fe1b6fcb04859719848f441a46ada 100644 --- a/src/input/identificationpwizreader.cpp +++ b/src/input/identificationpwizreader.cpp @@ -307,6 +307,8 @@ IdentificationPwizReader::read( //<Modification monoisotopicMassDelta="42.01056468" location="1"> // <cvParam accession="MOD:00394" cvRef="PSI-MOD" name="acetylated // residue"/> + //<cvParam cvRef="UNIMOD" accession="UNIMOD:28" + // name="Gln->pyro-Glu"/> //</Modification> for(pwiz::identdata::ModificationPtr mod_ptr : peptide_pwiz->modification) @@ -320,29 +322,28 @@ IdentificationPwizReader::read( location = location - 1; } - try - { - peptide.addAaModification( - Utils::guessAaModificationPbyMonoisotopicMassDelta( - mass_delta), - location); - } - catch(pappso::PappsoException &error) - { - throw pappso::PappsoException( - QObject::tr("ERROR adding modification mass delta %1 to " - "peptide %2 at " - "position %3 :\n %4") - .arg(mass_delta) - .arg(peptide.toAbsoluteString()) - .arg(location) - .arg(error.qwhat())); - } + pappso::AaModificationP modification_ptr = nullptr; + // std::vector<CVParam> cvParams; for(const pwiz::data::CVParam ¶m : mod_ptr.get()->cvParams) { qDebug() << "IdentificationPwizReader::read param " << QString::fromStdString(param.name()); + //<cvParam cvRef="UNIMOD" accession="UNIMOD:28" + // name="Gln->pyro-Glu"/> + if(pwiz::cv::cvTermInfo(param.cvid).prefix() == "UNIMOD") + { + modification_ptr = + Utils::translateAaModificationFromUnimod( + QString(pwiz::cv::cvTermInfo(param.cvid).id.c_str())); + /* + if(modification_ptr == nullptr) + { + throw pappso::PappsoException( + QObject::tr("UNIMOD %1 not found ") + .arg(pwiz::cv::cvTermInfo(param.cvid).id.c_str())); + }*/ + } /* if (pwiz::cv::cvTermInfo(param.cvid).prefix() == "PSI-MOD") { } @@ -354,6 +355,27 @@ IdentificationPwizReader::read( } */ } + if(modification_ptr == nullptr) + { + modification_ptr = + Utils::guessAaModificationPbyMonoisotopicMassDelta( + mass_delta); + } + try + { + peptide.addAaModification(modification_ptr, location); + } + catch(pappso::PappsoException &error) + { + throw pappso::PappsoException( + QObject::tr("ERROR adding modification mass delta %1 to " + "peptide %2 at " + "position %3 :\n %4") + .arg(mass_delta) + .arg(peptide.toAbsoluteString()) + .arg(location) + .arg(error.qwhat())); + } for(const pwiz::data::UserParam ¶m : mod_ptr.get()->userParams) diff --git a/src/utils/utils.cpp b/src/utils/utils.cpp index 6ead071872634638b71416170bad6d15088b1c54..737282c2cb5e26271403a6501112f3c97eb68753 100644 --- a/src/utils/utils.cpp +++ b/src/utils/utils.cpp @@ -203,3 +203,39 @@ Utils::guessAaModificationPbyMonoisotopicMassDelta(pappso::mz mass) "modification not found for mass %1") .arg(mass)); } + + +pappso::AaModificationP +Utils::translateAaModificationFromUnimod(const QString &unimod_accession) +{ + if(unimod_accession == "UNIMOD:1") + { + + return pappso::AaModification::getInstance("MOD:00394"); + } + if(unimod_accession == "UNIMOD:4") + { + + return pappso::AaModification::getInstance("MOD:00397"); + } + if(unimod_accession == "UNIMOD:27") + { + + return pappso::AaModification::getInstance("MOD:00420"); + } + // UNIMOD:28 => MOD:00040 + if(unimod_accession == "UNIMOD:28") + { + + return pappso::AaModification::getInstance("MOD:00040"); + } + + if(unimod_accession == "UNIMOD:35") + { + + return pappso::AaModification::getInstance("MOD:00425"); + } + qDebug() << __FILE__ << " " << __FUNCTION__ << " " << __LINE__ << " " + << unimod_accession << " not found"; + return nullptr; +} diff --git a/src/utils/utils.h b/src/utils/utils.h index 7fa5195edc9c31eb7a999bb729a1329f4b804c55..13de1f6169748a673452fe735defab0ec9cd733f 100644 --- a/src/utils/utils.h +++ b/src/utils/utils.h @@ -38,6 +38,8 @@ class Utils static const QString getXmlDouble(pappso::pappso_double number); static pappso::AaModificationP guessAaModificationPbyMonoisotopicMassDelta(pappso::mz mass); + static pappso::AaModificationP + translateAaModificationFromUnimod(const QString &unimod_accession); static std::vector<std::pair<pappso::pappso_double, size_t>> getHistogram(std::vector<pappso::pappso_double> data_values, unsigned int number_of_class);