Skip to content
Snippets Groups Projects
Commit 8341bea5 authored by Olivier Langella's avatar Olivier Langella
Browse files

WIP : xtandem sax parser

parent 2f6b15eb
No related branches found
No related tags found
No related merge requests found
Showing
with 182 additions and 186 deletions
...@@ -29,8 +29,8 @@ SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${Qt5Xml_EXECUTABLE_COMPILE_FLAGS} ${Qt5 ...@@ -29,8 +29,8 @@ SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${Qt5Xml_EXECUTABLE_COMPILE_FLAGS} ${Qt5
#sudo apt-get install libpappsomspp-dev #sudo apt-get install libpappsomspp-dev
#FIND_PACKAGE( Pappsomspp REQUIRED ) #FIND_PACKAGE( Pappsomspp REQUIRED )
# SET (PAPPSOMSPP_DIR "/home/olivier/eclipse/git/pappsomspp") SET (PAPPSOMSPP_DIR "/home/olivier/eclipse/git/pappsomspp")
SET (PAPPSOMSPP_DIR "/home/langella/developpement/git/pappsomspp") # SET (PAPPSOMSPP_DIR "/home/langella/developpement/git/pappsomspp")
SET (PAPPSOMSPP_INCLUDE_DIR "${PAPPSOMSPP_DIR}/src") SET (PAPPSOMSPP_INCLUDE_DIR "${PAPPSOMSPP_DIR}/src")
SET (PAPPSOMSPP_QT4_LIBRARY "${PAPPSOMSPP_DIR}/cbuild/src/libpappsomspp-qt4.so") SET (PAPPSOMSPP_QT4_LIBRARY "${PAPPSOMSPP_DIR}/cbuild/src/libpappsomspp-qt4.so")
......
...@@ -50,16 +50,40 @@ pappso::SpectrumSp IdentificationXtandemFile::getSpectrumSp(unsigned int scan_nu ...@@ -50,16 +50,40 @@ pappso::SpectrumSp IdentificationXtandemFile::getSpectrumSp(unsigned int scan_nu
void IdentificationXtandemFile::parseTo(Project* p_project) { void IdentificationXtandemFile::parseTo(Project* p_project) {
qDebug() << "Project::readXpipFile begin"; qDebug() << "Project::readXpipFile begin";
XtandemSaxHandler * parser = new XtandemSaxHandler(p_project); qDebug() << "Read X!Tandem XML result file '" << _xtandem_file.absoluteFilePath() << "'";
MsRunSp msrun_sp = p_project->getMsRunStore().getInstance(QFileInfo(_xtandem_file).baseName());
setMsRunSp(msrun_sp);
std::vector<IdentificationGroup *> identification_list = p_project->getIdentificationGroupList();
IdentificationGroup * identification_group_p = nullptr;
if (p_project->isCombineMode()) {
if (identification_list.size() == 0) {
identification_group_p = p_project->newIdentificationGroup();
}
else {
identification_group_p = identification_list[0];
}
}
else {
for (IdentificationGroup * identification_p_flist : identification_list) {
if (identification_p_flist->contains(msrun_sp.get())) {
identification_group_p = identification_p_flist;
break;
}
}
if (identification_group_p == nullptr) {
identification_group_p = p_project->newIdentificationGroup();
}
}
XtandemSaxHandler * parser = new XtandemSaxHandler(p_project, identification_group_p);
QXmlSimpleReader simplereader; QXmlSimpleReader simplereader;
simplereader.setContentHandler(parser); simplereader.setContentHandler(parser);
simplereader.setErrorHandler(parser); simplereader.setErrorHandler(parser);
qDebug() << "Read X!Tandem XML result file '" << _xtandem_file.absoluteFilePath() << "'";
QFile qfile(_xtandem_file.absoluteFilePath()); QFile qfile(_xtandem_file.absoluteFilePath());
QXmlInputSource xmlInputSource(&qfile); QXmlInputSource xmlInputSource(&qfile);
......
...@@ -24,6 +24,7 @@ ...@@ -24,6 +24,7 @@
#include "identificationgroup.h" #include "identificationgroup.h"
#include "project.h" #include "project.h"
#include "../utils/groupstore.h" #include "../utils/groupstore.h"
#include <pappsomspp/pappsoexception.h>
IdentificationGroup::IdentificationGroup(Project * project) IdentificationGroup::IdentificationGroup(Project * project)
...@@ -49,9 +50,36 @@ void IdentificationGroup::updateAutomaticFilters(const AutomaticFilterParameters ...@@ -49,9 +50,36 @@ void IdentificationGroup::updateAutomaticFilters(const AutomaticFilterParameters
} }
} }
ProteinMatch * IdentificationGroup::getProteinMatch(const QString accession) {
if (accession.isEmpty()) {
throw pappso::PappsoException(QObject::tr("Error protein match not found : accession is empty"));
}
for (ProteinMatch * p_protein_match : _protein_match_list) {
if (p_protein_match->getProteinXtpSp().get()->getAccession() == accession) {
return p_protein_match;
}
}
return nullptr;
}
void IdentificationGroup::addProteinMatch(ProteinMatch * protein_match) { void IdentificationGroup::addProteinMatch(ProteinMatch * protein_match) {
QString accession = protein_match->getProteinXtpSp().get()->getAccession();
if (accession.isEmpty()) {
throw pappso::PappsoException(QObject::tr("Error adding protein match : accession is empty"));
}
for (ProteinMatch * p_protein_match : _protein_match_list) {
if (p_protein_match->getProteinXtpSp().get()->getAccession() == accession) {
throw pappso::PappsoException(QObject::tr("Error adding protein match : accession %1 already registered").arg(accession));
}
}
_protein_match_list.push_back(protein_match); _protein_match_list.push_back(protein_match);
} }
bool IdentificationGroup::contains (const MsRun * p_msrun) const {
for (const MsRunSp & msrun: _ms_run_list) {
if (msrun.get() == p_msrun) return true;
}
return false;
}
void IdentificationGroup::addMsRunSp(MsRunSp ms_run_sp) { void IdentificationGroup::addMsRunSp(MsRunSp ms_run_sp) {
_ms_run_list.push_back(ms_run_sp); _ms_run_list.push_back(ms_run_sp);
} }
......
...@@ -43,6 +43,7 @@ public: ...@@ -43,6 +43,7 @@ public:
IdentificationGroup(Project * project); IdentificationGroup(Project * project);
~IdentificationGroup(); ~IdentificationGroup();
ProteinMatch * getProteinMatch(const QString accession);
void addProteinMatch(ProteinMatch * protein_match); void addProteinMatch(ProteinMatch * protein_match);
std::vector<ProteinMatch *> & getProteinMatchList(); std::vector<ProteinMatch *> & getProteinMatchList();
void addMsRunSp(MsRunSp ms_run_sp); void addMsRunSp(MsRunSp ms_run_sp);
...@@ -79,6 +80,8 @@ public: ...@@ -79,6 +80,8 @@ public:
/** @brief get tab name for qtabwidget /** @brief get tab name for qtabwidget
* */ * */
const QString getTabName() const; const QString getTabName() const;
bool contains (const MsRun * p_msrun) const;
private : private :
GroupingExperiment * _p_grp_experiment= nullptr; GroupingExperiment * _p_grp_experiment= nullptr;
......
...@@ -46,7 +46,10 @@ void Project::readResultFile(QString filename) { ...@@ -46,7 +46,10 @@ void Project::readResultFile(QString filename) {
ident_source.get()->parseTo(this); ident_source.get()->parseTo(this);
} }
void Project::setCombine(bool is_combine_mode) { bool Project::isCombineMode() const {
return _is_combine_mode;
}
void Project::setCombineMode(bool is_combine_mode) {
_is_combine_mode = is_combine_mode; _is_combine_mode = is_combine_mode;
} }
std::vector<IdentificationGroup *> Project::getIdentificationGroupList() { std::vector<IdentificationGroup *> Project::getIdentificationGroupList() {
......
...@@ -62,7 +62,8 @@ public: ...@@ -62,7 +62,8 @@ public:
const GroupingType getGroupingType() const; const GroupingType getGroupingType() const;
std::vector<IdentificationGroup *> getIdentificationGroupList(); std::vector<IdentificationGroup *> getIdentificationGroupList();
void setCombine(bool is_combine_mode); void setCombineMode(bool is_combine_mode);
bool isCombineMode() const;
void readResultFile(QString filename); void readResultFile(QString filename);
private : private :
......
...@@ -99,9 +99,6 @@ void ProteinMatch::updateAutomaticFilters(const AutomaticFilterParameters & auto ...@@ -99,9 +99,6 @@ void ProteinMatch::updateAutomaticFilters(const AutomaticFilterParameters & auto
const ProteinXtpSp & ProteinMatch::getProteinXtpSp() const { const ProteinXtpSp & ProteinMatch::getProteinXtpSp() const {
return _protein_sp; return _protein_sp;
} }
void ProteinMatch::setEvalue(pappso::pappso_double evalue) {
_evalue = evalue;
}
void ProteinMatch::setProteinXtpSp(ProteinXtpSp protein_sp) { void ProteinMatch::setProteinXtpSp(ProteinXtpSp protein_sp) {
_protein_sp = protein_sp; _protein_sp = protein_sp;
......
...@@ -44,7 +44,6 @@ public: ...@@ -44,7 +44,6 @@ public:
~ProteinMatch(); ~ProteinMatch();
const ProteinXtpSp & getProteinXtpSp() const; const ProteinXtpSp & getProteinXtpSp() const;
void setEvalue(pappso::pappso_double evalue);
/** @brief compute protein Evalue within samples /** @brief compute protein Evalue within samples
* */ * */
...@@ -109,16 +108,15 @@ private : ...@@ -109,16 +108,15 @@ private :
unsigned int countValidAndCheckedPeptideMassCharge(const MsRun * sp_msrun_id) const; unsigned int countValidAndCheckedPeptideMassCharge(const MsRun * sp_msrun_id) const;
private: private:
static QColor _color_peptide_background; static QColor _color_peptide_background;
static QColor _color_highlighted_peptide_background; static QColor _color_highlighted_peptide_background;
pappso::GrpProteinSp _sp_grp_protein; pappso::GrpProteinSp _sp_grp_protein;
GroupingGroupSp _sp_group; GroupingGroupSp _sp_group;
std::vector<PeptideMatch *> _peptide_match_list; std::vector<PeptideMatch *> _peptide_match_list;
ProteinXtpSp _protein_sp = nullptr; ProteinXtpSp _protein_sp = nullptr;
pappso::pappso_double _evalue=0;
/** @brief manually checked by user (true by default) /** @brief manually checked by user (true by default)
*/ */
bool _checked = true; bool _checked = true;
......
...@@ -50,7 +50,13 @@ ProteinXtpSp ProteinXtp::makeProteinXtpSp() const { ...@@ -50,7 +50,13 @@ ProteinXtpSp ProteinXtp::makeProteinXtpSp() const {
return std::make_shared<ProteinXtp>(*this); return std::make_shared<ProteinXtp>(*this);
} }
void ProteinXtp::setCompleteDescription(const QString & full_description) {
setAccession (full_description.simplified().section(" ", 0,0));
setDescription (full_description.simplified().section(" ", 1));
}
void ProteinXtp::setIsContaminant(bool conta) { void ProteinXtp::setIsContaminant(bool conta) {
_is_contaminant = conta; _is_contaminant = conta;
} }
......
...@@ -44,6 +44,8 @@ public: ...@@ -44,6 +44,8 @@ public:
ProteinXtpSp makeProteinXtpSp() const; ProteinXtpSp makeProteinXtpSp() const;
void setCompleteDescription(const QString & full_description);
void setIsContaminant(bool conta); void setIsContaminant(bool conta);
void setIsDecoy(bool conta); void setIsDecoy(bool conta);
bool isContaminant() const; bool isContaminant() const;
......
...@@ -58,7 +58,7 @@ void XtpLoaderThread::doLoadingResults(bool is_individual, AutomaticFilterParame ...@@ -58,7 +58,7 @@ void XtpLoaderThread::doLoadingResults(bool is_individual, AutomaticFilterParame
qDebug() << "XtpLoaderThread::doLoadingResults begin "; qDebug() << "XtpLoaderThread::doLoadingResults begin ";
try { try {
ProjectSp project_sp = Project().makeProjectSp(); ProjectSp project_sp = Project().makeProjectSp();
project_sp.get()->setCombine(!is_individual); project_sp.get()->setCombineMode(!is_individual);
for (QString filename : file_list) { for (QString filename : file_list) {
project_sp.get()->readResultFile(filename); project_sp.get()->readResultFile(filename);
......
...@@ -16,7 +16,14 @@ ...@@ -16,7 +16,14 @@
<widget class="QWidget" name="centralwidget"> <widget class="QWidget" name="centralwidget">
<layout class="QVBoxLayout" name="verticalLayout"> <layout class="QVBoxLayout" name="verticalLayout">
<item> <item>
<widget class="QLabel" name="proteinLabel"> <widget class="QLabel" name="accession_label">
<property name="text">
<string>TextLabel</string>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="description_label">
<property name="text"> <property name="text">
<string>TextLabel</string> <string>TextLabel</string>
</property> </property>
...@@ -25,7 +32,6 @@ ...@@ -25,7 +32,6 @@
</property> </property>
</widget> </widget>
</item> </item>
<item> <item>
<layout class="QHBoxLayout" name="horizontalLayoutcb"> <layout class="QHBoxLayout" name="horizontalLayoutcb">
<item> <item>
...@@ -69,14 +75,13 @@ ...@@ -69,14 +75,13 @@
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>826</width> <width>826</width>
<height>31</height> <height>25</height>
</rect> </rect>
</property> </property>
</widget> </widget>
<widget class="QStatusBar" name="statusbar"/> <widget class="QStatusBar" name="statusbar"/>
</widget> </widget>
<resources/> <resources/>
<connections> <connections>
<connection> <connection>
<sender>hideNotValidCheckBox</sender> <sender>hideNotValidCheckBox</sender>
......
...@@ -108,7 +108,8 @@ void PeptideListWindow::setProteinMatch(IdentificationGroup * p_identification_g ...@@ -108,7 +108,8 @@ void PeptideListWindow::setProteinMatch(IdentificationGroup * p_identification_g
_p_protein_match = p_protein_match; _p_protein_match = p_protein_match;
_peptide_table_model_p->setProteinMatch( p_protein_match); _peptide_table_model_p->setProteinMatch( p_protein_match);
_p_proxy_model->setSourceModel(_peptide_table_model_p); _p_proxy_model->setSourceModel(_peptide_table_model_p);
ui->proteinLabel->setText(p_protein_match->getProteinXtpSp().get()->getDescription()); ui->description_label->setText(p_protein_match->getProteinXtpSp().get()->getDescription());
ui->accession_label->setText(p_protein_match->getProteinXtpSp().get()->getAccession());
} }
} }
......
...@@ -50,13 +50,13 @@ ...@@ -50,13 +50,13 @@
<item row="0" column="1"> <item row="0" column="1">
<widget class="QDoubleSpinBox" name="peptide_evalue_spinbox"> <widget class="QDoubleSpinBox" name="peptide_evalue_spinbox">
<property name="decimals"> <property name="decimals">
<number>3</number> <number>6</number>
</property> </property>
<property name="maximum"> <property name="maximum">
<double>1.000000000000000</double> <double>1.000000000000000</double>
</property> </property>
<property name="singleStep"> <property name="singleStep">
<double>0.010000000000000</double> <double>0.001000000000000</double>
</property> </property>
<property name="value"> <property name="value">
<double>0.050000000000000</double> <double>0.050000000000000</double>
......
...@@ -20,7 +20,7 @@ ...@@ -20,7 +20,7 @@
<item> <item>
<layout class="QHBoxLayout" name="horizontalLayout"> <layout class="QHBoxLayout" name="horizontalLayout">
<item> <item>
<widget class="QLabel" name="descriptionLabel"> <widget class="QLabel" name="accession_label">
<property name="sizePolicy"> <property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Minimum"> <sizepolicy hsizetype="Preferred" vsizetype="Minimum">
<horstretch>0</horstretch> <horstretch>0</horstretch>
...@@ -72,6 +72,16 @@ ...@@ -72,6 +72,16 @@
</item> </item>
</layout> </layout>
</item> </item>
<item>
<widget class="QLabel" name="description_label">
<property name="text">
<string>TextLabel</string>
</property>
<property name="wordWrap">
<bool>true</bool>
</property>
</widget>
</item>
<item> <item>
<widget class="QTextEdit" name="sequenceTextEdit"> <widget class="QTextEdit" name="sequenceTextEdit">
<property name="lineWrapMode"> <property name="lineWrapMode">
......
...@@ -73,8 +73,8 @@ void ProteinWindow::updateDisplay() { ...@@ -73,8 +73,8 @@ void ProteinWindow::updateDisplay() {
try { try {
ui->validCheckBox->setCheckState(Qt::Unchecked); ui->validCheckBox->setCheckState(Qt::Unchecked);
if (_p_protein_match->isValid()) ui->validCheckBox->setCheckState(Qt::Checked); if (_p_protein_match->isValid()) ui->validCheckBox->setCheckState(Qt::Checked);
ui->descriptionLabel->setText(_p_protein_match->getProteinXtpSp().get()->getAccession()); ui->accession_label->setText(_p_protein_match->getProteinXtpSp().get()->getAccession());
//ui->sequenceLabel->setText(_p_protein_match->getProteinXtpSp().get()->getSequence()); ui->description_label->setText(_p_protein_match->getProteinXtpSp().get()->getDescription());
ui->sequenceTextEdit->setText(_p_protein_match->getHtmlSequence()); ui->sequenceTextEdit->setText(_p_protein_match->getHtmlSequence());
ui->coverage_label->setText(QString("%1 %").arg(_p_protein_match->getCoverage()*100)); ui->coverage_label->setText(QString("%1 %").arg(_p_protein_match->getCoverage()*100));
pappso::Peptide peptide(_p_protein_match->getProteinXtpSp().get()->getSequence()); pappso::Peptide peptide(_p_protein_match->getProteinXtpSp().get()->getSequence());
......
...@@ -215,9 +215,7 @@ bool XpipSaxHandler::startElement_protein(QXmlAttributes attributes) { ...@@ -215,9 +215,7 @@ bool XpipSaxHandler::startElement_protein(QXmlAttributes attributes) {
<sequence>MASTKAPGPGEKHHSIDAQLRQLVPGKVSEDDKLIEYDALLVDRFLNILQDLHGPSLREFVQECYEVSADYEGKGDTTKLGELGAKLTGLAPADAILVASSILHMLNLANLAEEVQIAHRRRNSKLKKGGFADEGSATTESDIEETLKRLVSEVGKSPEEVFEALKNQTVDLVFTAHPTQSARRSLLQKNARIRNCLTQLNAKDITDDDKQELDEALQREIQAAFRTDEIRRAQPTPQDEMRYGMSYIHETVWKGVPKFLRRVDTALKNIGINERLPYNVSLIRFSSWMGGDRDGNPRVTPEVTRDVCLLARMMAANLYIDQIEELMFELSMWRCNDELRVRAEELHSSSGSKVTKYYIEFWKQIPPNEPYRVILGHVRDKLYNTRERARHLLASGVSEISAESSFTSIEEFLEPLELCYKSLCDCGDKAIADGSLLDLLRQVFTFGLSLVKLDIRQESERHTDVIDAITTHLGIGSYREWPEDKRQEWLLSELRGKRPLLPPDLPQTDEIADVIGAFHVLAELPPDSFGPYIISMATAPSDVLAVELLQRECGVRQPLPVVPLFERLADLQSAPASVERLFSVDWYMDRIKGKQQVMVGYSDSGKDAGRLSAAWQLYRAQEEMAQVAKRYGVKLTLFHGRGGTVGRGGGPTHLAILSQPPDTINGSIRVTVQGEVIEFCFGEEHLCFQTLQRFTAATLEHGMHPPVSPKPEWRKLMDEMAVVATEEYRSVVVKEARFVEYFRSATPETEYGRMNIGSRPAKRRPGGGITTLRAIPWIFSWTQTRFHLPVWLGVGAAFKFAIDKDVRNFQVLKEMYNEWPFFRVTLDLLEMVFAKGDPGIAGLYDELLVAEELKPFGKQLRDKYVETQQLLLQIAGHKDILEGDPFLKQGLVLRNPYITTLNVFQAYTLKRIRDPNFKVTPQPPLSKEFADENKPAGLVKLNPASEYPPGLEDTLILTMKGIAAGMQNTG</sequence> <sequence>MASTKAPGPGEKHHSIDAQLRQLVPGKVSEDDKLIEYDALLVDRFLNILQDLHGPSLREFVQECYEVSADYEGKGDTTKLGELGAKLTGLAPADAILVASSILHMLNLANLAEEVQIAHRRRNSKLKKGGFADEGSATTESDIEETLKRLVSEVGKSPEEVFEALKNQTVDLVFTAHPTQSARRSLLQKNARIRNCLTQLNAKDITDDDKQELDEALQREIQAAFRTDEIRRAQPTPQDEMRYGMSYIHETVWKGVPKFLRRVDTALKNIGINERLPYNVSLIRFSSWMGGDRDGNPRVTPEVTRDVCLLARMMAANLYIDQIEELMFELSMWRCNDELRVRAEELHSSSGSKVTKYYIEFWKQIPPNEPYRVILGHVRDKLYNTRERARHLLASGVSEISAESSFTSIEEFLEPLELCYKSLCDCGDKAIADGSLLDLLRQVFTFGLSLVKLDIRQESERHTDVIDAITTHLGIGSYREWPEDKRQEWLLSELRGKRPLLPPDLPQTDEIADVIGAFHVLAELPPDSFGPYIISMATAPSDVLAVELLQRECGVRQPLPVVPLFERLADLQSAPASVERLFSVDWYMDRIKGKQQVMVGYSDSGKDAGRLSAAWQLYRAQEEMAQVAKRYGVKLTLFHGRGGTVGRGGGPTHLAILSQPPDTINGSIRVTVQGEVIEFCFGEEHLCFQTLQRFTAATLEHGMHPPVSPKPEWRKLMDEMAVVATEEYRSVVVKEARFVEYFRSATPETEYGRMNIGSRPAKRRPGGGITTLRAIPWIFSWTQTRFHLPVWLGVGAAFKFAIDKDVRNFQVLKEMYNEWPFFRVTLDLLEMVFAKGDPGIAGLYDELLVAEELKPFGKQLRDKYVETQQLLLQIAGHKDILEGDPFLKQGLVLRNPYITTLNVFQAYTLKRIRDPNFKVTPQPPLSKEFADENKPAGLVKLNPASEYPPGLEDTLILTMKGIAAGMQNTG</sequence>
</protein> </protein>
*/ */
_p_protein_match->setEvalue(std::pow ((double) 10.0, attributes.value("evalue").toDouble())); _current_protein.setCompleteDescription(attributes.value("description"));
_current_protein.setDescription(attributes.value("description").simplified());
_current_protein.setAccession(_current_protein.getDescription().split(" ").at(0));
qDebug() << "startElement_protein end" ; qDebug() << "startElement_protein end" ;
return true; return true;
} }
......
...@@ -35,9 +35,9 @@ ...@@ -35,9 +35,9 @@
#include "../utils/peptidestore.h" #include "../utils/peptidestore.h"
#include "../utils/proteinstore.h" #include "../utils/proteinstore.h"
XtandemSaxHandler::XtandemSaxHandler(Project * p_project):_p_project(p_project) XtandemSaxHandler::XtandemSaxHandler(Project * p_project, IdentificationGroup * p_identification_group):_p_project(p_project)
{ {
_p_identification_group = p_identification_group;
} }
XtandemSaxHandler::~XtandemSaxHandler() XtandemSaxHandler::~XtandemSaxHandler()
...@@ -54,36 +54,31 @@ bool XtandemSaxHandler::startElement(const QString & namespaceURI, const QString ...@@ -54,36 +54,31 @@ bool XtandemSaxHandler::startElement(const QString & namespaceURI, const QString
try { try {
//startElement_group //startElement_group
if (qName == "match") { if (qName == "group") {
is_ok = startElement_match(attributes); is_ok = startElement_group(attributes);
} else if (qName == "protein") { } else if (qName == "protein") {
is_ok = startElement_protein(attributes); is_ok = startElement_protein(attributes);
} else if (qName == "identification") { } else if (qName == "note") {
is_ok = startElement_identification(attributes); is_ok = startElement_note(attributes);
} }
//<sample value="P6_08_10"/> else if (qName == "file") {
else if (qName == "sample") { is_ok = startElement_file(attributes);
is_ok = startElement_sample(attributes);
} else if (qName == "peptide") { } else if (qName == "peptide") {
is_ok = startElement_peptide(attributes); is_ok = startElement_peptide(attributes);
} else if (qName == "modifs_mass") { } else if (qName == "aa") {
is_ok = startElement_modifs_mass(attributes); is_ok = startElement_aa(attributes);
} else if (qName == "modif") { } else if (qName == "domain") {
is_ok = startElement_modif(attributes); is_ok = startElement_domain(attributes);
} else if (qName == "filter_params") {
is_ok = startElement_filter_params(attributes);
} else if (qName == "information") {
is_ok = startElement_information(attributes);
} }
_current_text.clear(); _current_text.clear();
} }
catch (pappso::PappsoException exception_pappso) { catch (pappso::PappsoException exception_pappso) {
_errorStr = QObject::tr("ERROR in XpipSaxHandler::startElement tag %1, PAPPSO exception:\n%2").arg(qName).arg(exception_pappso.qwhat()); _errorStr = QObject::tr("ERROR in XtandemSaxHandler::startElement tag %1, PAPPSO exception:\n%2").arg(qName).arg(exception_pappso.qwhat());
return false; return false;
} }
catch (std::exception exception_std) { catch (std::exception exception_std) {
_errorStr = QObject::tr("ERROR in XpipSaxHandler::startElement tag %1, std exception:\n%2").arg(qName).arg(exception_std.what()); _errorStr = QObject::tr("ERROR in XtandemSaxHandler::startElement tag %1, std exception:\n%2").arg(qName).arg(exception_std.what());
return false; return false;
} }
return is_ok; return is_ok;
...@@ -95,21 +90,9 @@ bool XtandemSaxHandler::endElement(const QString & namespaceURI, const QString & ...@@ -95,21 +90,9 @@ bool XtandemSaxHandler::endElement(const QString & namespaceURI, const QString &
bool is_ok = true; bool is_ok = true;
// endElement_peptide_list // endElement_peptide_list
try { try {
if (qName == "protein") if (qName == "note")
{ {
is_ok = endElement_protein(); is_ok = endElement_note();
}
else if (qName == "identification") {
is_ok = endElement_identification();
}
else if (qName == "peptide") {
is_ok = endElement_peptide();
}
else if (qName == "sequence") {
is_ok = endElement_sequence();
}
else if (qName == "match") {
is_ok = endElement_match();
} }
// end of detection_moulon // end of detection_moulon
...@@ -117,11 +100,11 @@ bool XtandemSaxHandler::endElement(const QString & namespaceURI, const QString & ...@@ -117,11 +100,11 @@ bool XtandemSaxHandler::endElement(const QString & namespaceURI, const QString &
// (_tag_stack[_tag_stack.size() - 2] == "detection_moulon")) // (_tag_stack[_tag_stack.size() - 2] == "detection_moulon"))
} }
catch (pappso::PappsoException exception_pappso) { catch (pappso::PappsoException exception_pappso) {
_errorStr = QObject::tr("ERROR in XpipSaxHandler::endElement tag %1, PAPPSO exception:\n%2").arg(qName).arg(exception_pappso.qwhat()); _errorStr = QObject::tr("ERROR in XtandemSaxHandler::endElement tag %1, PAPPSO exception:\n%2").arg(qName).arg(exception_pappso.qwhat());
return false; return false;
} }
catch (std::exception exception_std) { catch (std::exception exception_std) {
_errorStr = QObject::tr("ERROR in XpipSaxHandler::endElement tag %1, std exception:\n%2").arg(qName).arg(exception_std.what()); _errorStr = QObject::tr("ERROR in XtandemSaxHandler::endElement tag %1, std exception:\n%2").arg(qName).arg(exception_std.what());
return false; return false;
} }
...@@ -143,91 +126,61 @@ bool XtandemSaxHandler::startElement_group(QXmlAttributes attrs) { ...@@ -143,91 +126,61 @@ bool XtandemSaxHandler::startElement_group(QXmlAttributes attrs) {
_scan = attrs.value("id").toUInt(); _scan = attrs.value("id").toUInt();
_mhplus_obser = attrs.value("mh").toDouble(); _mhplus_obser = attrs.value("mh").toDouble();
_charge = attrs.value("z").toUInt(); _charge = attrs.value("z").toUInt();
_RT = attrs.value("rt"); //_retention_time = attrs.value("rt");
} }
} }
bool XtandemSaxHandler::startElement_match(QXmlAttributes attributes) { bool XtandemSaxHandler::startElement_note(QXmlAttributes attributes) {
//<note label="description">GRMZM2G083841_P01 P04711 Phosphoenolpyruvate carboxylase 1 (PEPCase 1)(PEPC 1)(EC //4.1.1.31) seq=translation; coord=9:61296279..61301686:1; parent_transcript=GRMZM2G083841_T01;
qDebug() << "startElement_match "; ////parent_gene=GRMZM2G083841</note>
/* _is_protein_description = false;
* <match_list><match validate="true"> if (attributes.value("label") == "description") {
*/ if (_tag_stack[_tag_stack.size() - 2] == "protein") {
_p_protein_match = new ProteinMatch(); _is_protein_description = true;
_p_protein_match->setChecked(false); }
if (attributes.value("validate").simplified().toLower() == "true") {
_p_protein_match->setChecked(true);
} }
qDebug() << "startElement_match end" ;
return true;
} }
bool XtandemSaxHandler::startElement_protein(QXmlAttributes attributes) { bool XtandemSaxHandler::startElement_protein(QXmlAttributes attributes) {
//<protein expect="-704.6" id="1976.1" uid="195701" label="GRMZM2G083841_P01 P04711 Phosphoenolpyruvate carboxylase 1 (PEPCase 1)(PEPC 1)(EC..." sumI="9.36" > //<protein expect="-704.6" id="1976.1" uid="195701" label="GRMZM2G083841_P01 P04711 Phosphoenolpyruvate carboxylase 1 (PEPCase 1)(PEPC 1)(EC..." sumI="9.36" >
qDebug() << "startElement_protein "; qDebug() << "startElement_protein ";
_p_protein_match->setEvalue(std::pow ((double) 10.0, attributes.value("expect").toDouble())); QString accession = attributes.value("label").simplified().split(" ", QString::SkipEmptyParts).at(0);
_current_protein.setDescription(attributes.value("label").simplified()); ProteinMatch * p_protein_match = _p_identification_group->getProteinMatch(accession);
_current_protein.setAccession(_current_protein.getDescription().split(" ").at(0));
qDebug() << "startElement_protein end" ;
return true;
}
bool XtandemSaxHandler::startElement_file(QXmlAttributes attributes) { _current_protein.setAccession(accession);
if (attrs.getValue("type").equals("peptide")) if (p_protein_match == nullptr) {
prot_.setDatabase(identification_.getDatabaseSet().getInstance( _p_protein_match = new ProteinMatch();
attrs.getValue("URL"))); _p_protein_match->setChecked(false);
}
bool XtandemSaxHandler::startElement_identification(QXmlAttributes attributes) { }
ProteinXtpSp sp_xtp_protein = _current_protein.makeProteinXtpSp();
qDebug() << "startElement_identification "; p_protein_match->setProteinXtpSp(_p_project->getProteinStore().getInstance(sp_xtp_protein));
_map_massstr_aamod.clear(); qDebug() << "startElement_protein end" ;
_current_identification_group_p = _p_project->newIdentificationGroup();
qDebug() << "startElement_identification end" ;
return true; return true;
} }
bool XtandemSaxHandler::startElement_information(QXmlAttributes attributes) {
//<information Data_Type="indiv" match_number="223"/>
qDebug() << "startElement_information ";
qDebug() << "startElement_information end" ;
return true;
}
bool XtandemSaxHandler::startElement_modifs_mass(QXmlAttributes attributes) { bool XtandemSaxHandler::startElement_file(QXmlAttributes attributes) {
//<file type="peptide" URL="/gorgone/pappso/formation/TD/Database/Genome_Z_mays_5a.fasta"/>
/* if (attributes.value("type") == "peptide") {
<modifs_list_mass><modifs_mass modvalue="-18.01056"/> //prot_.setDatabase(identification_.getDatabaseSet().getInstance(
<modifs_mass modvalue="-17.02655"/> // attrs.getValue("URL")));
<modifs_mass modvalue="15.99491"/> }
<modifs_mass modvalue="42.01057"/>
<modifs_mass modvalue="42.01056"/>
<modifs_mass modvalue="57.02146"/>
</modifs_list_mass>
*/
qDebug() << "startElement_modifs_mass ";
QString mass_str(attributes.value("modvalue").simplified());
pappso::mz mass = mass_str.toDouble();
pappso::AaModificationP mod = getAaModificationP(mass);
_map_massstr_aamod[mass_str] = mod;
qDebug() << "startElement_modifs_mass end" ;
return true;
} }
//<sample value="P6_21_23"/> bool XtandemSaxHandler::startElement_domain(QXmlAttributes attributes) {
bool XtandemSaxHandler::startElement_sample(QXmlAttributes attributes) { //<domain id="1976.1.1" start="620" end="629" expect="9.7e-04" mh="1120.5307" delta="-0.0012" hyperscore="29.9"
//nextscore="10.2" y_score="10.4" y_ions="7" b_score="11.2" b_ions="3" pre="QLYR" post="RYGV"
//seq="AQEEMAQVAK" missed_cleavages="0">
qDebug() << "startElement_sample "; qDebug() << "startElement_domain ";
MsRunSp ms_run = _p_project->getMsRunStore().getInstance(attributes.value("value").simplified()); MsRunSp ms_run = _p_project->getMsRunStore().getInstance(attributes.value("value").simplified());
ms_run.get()->setXmlId(attributes.value("value").simplified()); ms_run.get()->setXmlId(attributes.value("value").simplified());
ms_run.get()->setFilename(attributes.value("value").simplified()); ms_run.get()->setFilename(attributes.value("value").simplified());
_current_identification_group_p->addMsRunSp(ms_run); _p_identification_group->addMsRunSp(ms_run);
qDebug() << "startElement_sample end" ; qDebug() << "startElement_domain end" ;
return true; return true;
} }
bool XtandemSaxHandler::startElement_peptide(QXmlAttributes attributes) { bool XtandemSaxHandler::startElement_peptide(QXmlAttributes attributes) {
...@@ -270,52 +223,25 @@ bool XtandemSaxHandler::startElement_peptide(QXmlAttributes attributes) { ...@@ -270,52 +223,25 @@ bool XtandemSaxHandler::startElement_peptide(QXmlAttributes attributes) {
return true; return true;
} }
bool XtandemSaxHandler::startElement_modif(QXmlAttributes attributes) { bool XtandemSaxHandler::startElement_aa(QXmlAttributes attributes) {
//<aa type="M" at="624" modified="15.99491" />
//<modifs><modif aa="M" modvalue="15.99491" posi="17" posi_in_prot="49"/> qDebug() << "startElement_aa ";
qDebug() << "startElement_modif ";
pappso::AaModificationP modif = _map_massstr_aamod[attributes.value("modvalue").simplified()]; pappso::AaModificationP modif = _map_massstr_aamod[attributes.value("modvalue").simplified()];
unsigned int position = attributes.value("posi").simplified().toUInt(); unsigned int position = attributes.value("posi").simplified().toUInt();
_current_peptide_sp.get()->addAaModification(modif, position-1); _current_peptide_sp.get()->addAaModification(modif, position-1);
qDebug() << "startElement_modif end" ; qDebug() << "startElement_aa end" ;
return true;
}
bool XtandemSaxHandler::endElement_peptide() {
qDebug() << "endElement_peptide ";
PeptideXtpSp peptide_const = PeptideXtp(*(_current_peptide_sp.get())).makePeptideXtpSp();
peptide_const = _p_project->getPeptideStore().getInstance(peptide_const);
_p_peptide_match->setPeptideXtpSp(peptide_const);
return true;
}
bool XtandemSaxHandler::endElement_sequence() {
//if ((_tag_stack.size() > 1) && (_tag_stack[_tag_stack.size() - 1] == "protein")) {
_current_protein.setSequence(_current_text);
//}
//else {
// XtandemHyperscore hyperscore(_curent_spectrum, _current_peptide_sp, _precision, _ion_list, _max_charge,_refine_spectrum_synthesis);
//}
return true;
}
bool XtandemSaxHandler::endElement_protein() {
ProteinXtpSp sp_xtp_protein = _current_protein.makeProteinXtpSp();
_p_protein_match->setProteinXtpSp(_p_project->getProteinStore().getInstance(sp_xtp_protein));
return true; return true;
} }
bool XtandemSaxHandler::endElement_identification() { bool XtandemSaxHandler::endElement_note() {
//<note label="description">GRMZM2G083841_P01 P04711 Phosphoenolpyruvate carboxylase 1 (PEPCase 1)(PEPC 1)(EC //4.1.1.31) seq=translation; coord=9:61296279..61301686:1; parent_transcript=GRMZM2G083841_T01;
////parent_gene=GRMZM2G083841</note>
if (_is_protein_description) {
_p_protein_match->getProteinXtpSp().get()->setDescription(_current_text.section(" ",1));
}
return true; return true;
} }
bool XtandemSaxHandler::endElement_match() {
_current_identification_group_p->addProteinMatch(_p_protein_match);
_p_protein_match = nullptr;
return true;
}
bool XtandemSaxHandler::error(const QXmlParseException &exception) { bool XtandemSaxHandler::error(const QXmlParseException &exception) {
...@@ -340,7 +266,6 @@ QString XtandemSaxHandler::errorString() const { ...@@ -340,7 +266,6 @@ QString XtandemSaxHandler::errorString() const {
bool XtandemSaxHandler::endDocument() { bool XtandemSaxHandler::endDocument() {
_p_project->updateAutomaticFilters(_automatic_filter_parameters);
return true; return true;
} }
......
...@@ -43,7 +43,7 @@ ...@@ -43,7 +43,7 @@
class XtandemSaxHandler: public QXmlDefaultHandler class XtandemSaxHandler: public QXmlDefaultHandler
{ {
public: public:
XtandemSaxHandler(Project * p_project); XtandemSaxHandler(Project * p_project, IdentificationGroup * p_identification_group);
~XtandemSaxHandler(); ~XtandemSaxHandler();
bool startElement(const QString & namespaceURI, const QString & localName, bool startElement(const QString & namespaceURI, const QString & localName,
...@@ -66,21 +66,13 @@ public: ...@@ -66,21 +66,13 @@ public:
private: private:
bool startElement_group(QXmlAttributes attrs); bool startElement_group(QXmlAttributes attrs);
bool startElement_filter_params(QXmlAttributes attributes);
bool startElement_information(QXmlAttributes attributes);
bool startElement_identification(QXmlAttributes attributes);
bool startElement_match(QXmlAttributes attributes);
bool startElement_peptide(QXmlAttributes attributes); bool startElement_peptide(QXmlAttributes attributes);
bool startElement_protein(QXmlAttributes attributes); bool startElement_protein(QXmlAttributes attributes);
bool startElement_sample(QXmlAttributes attributes); bool startElement_note(QXmlAttributes attributes);
bool startElement_modifs_mass(QXmlAttributes attributes); bool startElement_file(QXmlAttributes attributes);
bool startElement_modif(QXmlAttributes attributes); bool startElement_aa(QXmlAttributes attributes);
bool endElement_identification(); bool startElement_domain(QXmlAttributes attributes);
bool endElement_sequence(); bool endElement_note();
bool endElement_protein();
bool endElement_peptide();
bool endElement_match();
pappso::AaModificationP getAaModificationP(pappso::mz mass) const; pappso::AaModificationP getAaModificationP(pappso::mz mass) const;
...@@ -90,19 +82,22 @@ private: ...@@ -90,19 +82,22 @@ private:
QString _current_text; QString _current_text;
Project * _p_project; Project * _p_project;
IdentificationGroup * _p_identification_group;
ProteinMatch * _p_protein_match; ProteinMatch * _p_protein_match;
PeptideMatch * _p_peptide_match; PeptideMatch * _p_peptide_match;
ProteinXtp _current_protein; ProteinXtp _current_protein;
PeptideXtpSp _current_peptide_sp; PeptideXtpSp _current_peptide_sp;
IdentificationGroup * _current_identification_group_p;
QMap<QString, pappso::AaModificationP> _map_massstr_aamod; QMap<QString, pappso::AaModificationP> _map_massstr_aamod;
QString _current_group_label; QString _current_group_label;
QString _current_group_type; QString _current_group_type;
uint _scan; unsigned int _scan;
double _mhplus_obser; pappso::pappso_double _mhplus_obser;
uint _charge; unsigned int _charge;
getValue _RT; pappso::pappso_double _retention_time;
bool _is_protein_description = false;
}; };
#endif // XTANDEMSAXHANDLER_H #endif // XTANDEMSAXHANDLER_H
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment