diff --git a/src/core/identification_sources/identificationxtandemfile.cpp b/src/core/identification_sources/identificationxtandemfile.cpp index 3502835d87158b8de89bcdf77dcf0d4561bd6253..2fb6f1506674c6c233c242ca7d062f5efe5c3ba8 100644 --- a/src/core/identification_sources/identificationxtandemfile.cpp +++ b/src/core/identification_sources/identificationxtandemfile.cpp @@ -78,6 +78,7 @@ void IdentificationXtandemFile::parseTo(Project* p_project) { } } + identification_group_p->addMsRunSp(msrun_sp); XtandemSaxHandler * parser = new XtandemSaxHandler(p_project, identification_group_p, this); QXmlSimpleReader simplereader; diff --git a/src/core/identificationgroup.cpp b/src/core/identificationgroup.cpp index 23eebfb3e05a4317cb4c674aebdce26978a6e42f..6b332d4e5b0b976074462ae975f5aca0bad9435a 100644 --- a/src/core/identificationgroup.cpp +++ b/src/core/identificationgroup.cpp @@ -66,12 +66,20 @@ void IdentificationGroup::addProteinMatch(ProteinMatch * protein_match) { if (accession.isEmpty()) { throw pappso::PappsoException(QObject::tr("Error adding protein match : accession is empty")); } + bool push = true; for (ProteinMatch * p_protein_match : _protein_match_list) { - if ((p_protein_match != protein_match) && (p_protein_match->getProteinXtpSp().get()->getAccession() == accession)) { - throw pappso::PappsoException(QObject::tr("Error adding protein match : accession %1 already registered").arg(accession)); + if (p_protein_match == protein_match) { + push = false; } + else { + if(p_protein_match->getProteinXtpSp().get()->getAccession() == accession) { + throw pappso::PappsoException(QObject::tr("Error adding protein match : accession %1 already registered").arg(accession)); + } + } + } + if (push) { + _protein_match_list.push_back(protein_match); } - _protein_match_list.push_back(protein_match); } bool IdentificationGroup::contains (const MsRun * p_msrun) const { @@ -81,7 +89,10 @@ bool IdentificationGroup::contains (const MsRun * p_msrun) const { return false; } void IdentificationGroup::addMsRunSp(MsRunSp ms_run_sp) { - _ms_run_list.push_back(ms_run_sp); + auto it = std::find (_ms_run_list.begin() ,_ms_run_list.end(),ms_run_sp); + if (it == _ms_run_list.end()) { + _ms_run_list.push_back(ms_run_sp); + } } const std::vector<MsRunSp> & IdentificationGroup::getMsRunSpList() const { return _ms_run_list; diff --git a/src/gui/mainwindow.cpp b/src/gui/mainwindow.cpp index 8a03691f71654a48bdcbcca1cd7a84cbf85f2a4a..023c091235555831bfea48cd45cff6bb19741704 100644 --- a/src/gui/mainwindow.cpp +++ b/src/gui/mainwindow.cpp @@ -58,12 +58,14 @@ void XtpLoaderThread::doLoadingResults(bool is_individual, AutomaticFilterParame qDebug() << "XtpLoaderThread::doLoadingResults begin "; try { ProjectSp project_sp = Project().makeProjectSp(); - project_sp.get()->setCombineMode(!is_individual); + project_sp.get()->setCombineMode(!is_individual); for (QString filename : file_list) { + emit loadingMessage(tr("loading result file %1").arg(filename)); project_sp.get()->readResultFile(filename); } + emit loadingMessage(tr("filtering proteins")); project_sp.get()->updateAutomaticFilters(param); emit projectReady(project_sp); @@ -114,6 +116,8 @@ MainWindow::MainWindow(QWidget *parent): connect(worker, SIGNAL(projectReady(ProjectSp)), this,SLOT(doProjectReady(ProjectSp))); connect(this, SIGNAL(operateLoadingResults(bool,AutomaticFilterParameters,QStringList)), worker,SLOT(doLoadingResults(bool,AutomaticFilterParameters,QStringList))); connect(_p_load_results_dialog, SIGNAL(accepted()), this,SLOT(doAcceptedLoadResultDialog())); + connect(worker, SIGNAL(loadingMessage(QString)), this,SLOT(doDisplayLoadingMessage(QString))); + connect(worker, SIGNAL(projectNotReady(QString)), this,SLOT(doProjectNotReady(QString))); /* connect(&workerThread, SIGNAL(finished()), worker, SLOT(deleteLater())); connect(this, SIGNAL(operateMsDataFile(QString)), worker,SLOT(doMsDataFileLoad(QString))); @@ -147,6 +151,7 @@ void MainWindow::viewError(QString error) { } void MainWindow::doDisplayLoadingMessage(QString message) { + qDebug() << "MainWindow::doDisplayLoadingMessage " << message; ui->statusbar->showMessage(message); } @@ -168,13 +173,17 @@ void MainWindow::doAcceptedLoadResultDialog() { void MainWindow::doProjectReady(ProjectSp project_sp) { + qDebug() << "MainWindow::doProjectReady begin"; try { + doDisplayLoadingMessage(tr("grouping proteins")); project_sp.get()->startGrouping(); } catch (pappso::PappsoException & error) { viewError(tr("Error while grouping :\n%1").arg(error.qwhat())); } _project_window->setProjectSp(project_sp); + + qDebug() << "MainWindow::doProjectReady end"; } diff --git a/src/input/xtandemsaxhandler.cpp b/src/input/xtandemsaxhandler.cpp index 8e7b258b143004f204a6d008029b0391ba243f0f..0f63fe248c26f15e5478e558b0349c1d15547b56 100644 --- a/src/input/xtandemsaxhandler.cpp +++ b/src/input/xtandemsaxhandler.cpp @@ -96,6 +96,9 @@ bool XtandemSaxHandler::endElement(const QString & namespaceURI, const QString & if (qName == "note") { is_ok = endElement_note(); + } else if (qName == "domain") + { + is_ok = endElement_domain(); } // end of detection_moulon @@ -159,14 +162,15 @@ bool XtandemSaxHandler::startElement_protein(QXmlAttributes attributes) { _current_protein.setAccession(accession); if (_p_protein_match == nullptr) { _p_protein_match = new ProteinMatch(); - //qDebug() << "startElement_protein p_protein_match 2 " << _p_protein_match; + //qDebug() << "startElement_protein p_protein_match 2 " << _p_protein_match; _p_protein_match->setChecked(false); } //qDebug() << "startElement_protein p_protein_match 3 " << _p_protein_match; ProteinXtpSp sp_xtp_protein = _current_protein.makeProteinXtpSp(); _p_protein_match->setProteinXtpSp(_p_project->getProteinStore().getInstance(sp_xtp_protein)); - + _p_protein_match->setChecked(true); + _p_identification_group->addProteinMatch(_p_protein_match); //qDebug() << "startElement_protein end" ; return is_ok; @@ -187,7 +191,7 @@ bool XtandemSaxHandler::startElement_domain(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_domain "; + //qDebug() << "startElement_domain "; bool is_ok = true; _current_text = _current_text.simplified().replace(" ", ""); if (!_current_text.isEmpty()) { @@ -206,21 +210,19 @@ bool XtandemSaxHandler::startElement_domain(QXmlAttributes attributes) { _p_peptide_match->setRetentionTime(_retention_time); _p_peptide_match->setEvalue(attributes.value("expect").simplified().toDouble()); + //qDebug() << "XtandemSaxHandler::startElement_domain evalue " << _p_peptide_match->getEvalue() << " scan " << _p_peptide_match->getScan(); pappso::pappso_double xtandem_mhtheo = attributes.value("mh").simplified().toDouble(); pappso::pappso_double xtandem_delta = attributes.value("delta").simplified().toDouble(); - pappso::pappso_double exp_mass = xtandem_mhtheo - xtandem_delta; + pappso::pappso_double exp_mass = xtandem_mhtheo + xtandem_delta - pappso::MHPLUS; _p_peptide_match->setExperimentalMass(exp_mass); _p_peptide_match->setStart(attributes.value("start").simplified().toUInt()-1); _p_peptide_match->setCharge(_charge); _p_peptide_match->setIdentificationDataSource( _p_identification_data_source); - _p_peptide_match->setChecked(false); - if (attributes.value("validate").simplified().toLower() == "true") { - _p_peptide_match->setChecked(true); - } + _p_peptide_match->setChecked(true); _p_protein_match->addPeptideMatch(_p_peptide_match); @@ -236,14 +238,21 @@ bool XtandemSaxHandler::startElement_domain(QXmlAttributes attributes) { bool XtandemSaxHandler::startElement_aa(QXmlAttributes attributes) { //<aa type="M" at="624" modified="15.99491" /> bool is_ok = true; - qDebug() << "startElement_aa "; + //qDebug() << "startElement_aa "; pappso::AaModificationP modif = getAaModificationP(attributes.value("modified").simplified().toDouble()); unsigned int position_in_prot = attributes.value("at").simplified().toUInt()-1; _current_peptide_sp.get()->addAaModification(modif, position_in_prot-_p_peptide_match->getStart()); - qDebug() << "startElement_aa end" ; + //qDebug() << "startElement_aa end" ; return is_ok; } +bool XtandemSaxHandler::endElement_domain() { + bool is_ok = true; + _current_peptide_sp = _p_project->getPeptideStore().getInstance(_current_peptide_sp); + + _p_peptide_match->setPeptideXtpSp(_current_peptide_sp); + return is_ok; +} 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> diff --git a/src/input/xtandemsaxhandler.h b/src/input/xtandemsaxhandler.h index f129e5c30d53b0777e1de5c6ef60b95e50a1604b..85babb2ec2f4403022bb734769cbf4f16da8209f 100644 --- a/src/input/xtandemsaxhandler.h +++ b/src/input/xtandemsaxhandler.h @@ -72,6 +72,7 @@ private: bool startElement_file(QXmlAttributes attributes); bool startElement_aa(QXmlAttributes attributes); bool startElement_domain(QXmlAttributes attributes); + bool endElement_domain(); bool endElement_note(); pappso::AaModificationP getAaModificationP(pappso::mz mass) const;