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

WIP: using pwiz to read identification files

parent a607b2cf
No related branches found
No related tags found
No related merge requests found
......@@ -36,6 +36,7 @@
IdentificationPwizFile::IdentificationPwizFile(const QFileInfo & ident_file) : IdentificationDataSource(ident_file.absoluteFilePath()), _ident_file(ident_file)
{
//_engine = IdentificationEngine::XTandem;
_engine = IdentificationEngine::peptider;
}
IdentificationPwizFile::IdentificationPwizFile(const IdentificationPwizFile& other) : IdentificationDataSource(other),_ident_file (other._ident_file)
......@@ -60,7 +61,7 @@ pappso::SpectrumSp IdentificationPwizFile::getSpectrumSp(unsigned int scan_numbe
void IdentificationPwizFile::parseTo(Project* p_project) {
qDebug() << "Project::readXpipFile begin";
qDebug() << "IdentificationPwizFile::parseTo begin";
IdentificationPwizReader pwiz_reader(_ident_file);
......@@ -91,6 +92,7 @@ void IdentificationPwizFile::parseTo(Project* p_project) {
pwiz_reader.read(this, p_project, identification_group_p);
qDebug() << "IdentificationPwizFile::parseTo end";
// throw pappso::PappsoException(QObject::tr("Error reading %1 XPIP file :\n %2").arg(_xtandem_file.absoluteFilePath()).arg(parser->errorString()));
......
......@@ -52,7 +52,7 @@ pappso::SpectrumSp IdentificationXtandemFile::getSpectrumSp(unsigned int scan_nu
void IdentificationXtandemFile::parseTo(Project* p_project) {
qDebug() << "Project::readXpipFile begin";
qDebug() << "IdentificationXtandemFile::parseTo begin";
qDebug() << "Read X!Tandem XML result file '" << _xtandem_file.absoluteFilePath() << "'";
......@@ -104,4 +104,5 @@ void IdentificationXtandemFile::parseTo(Project* p_project) {
throw pappso::PappsoException(QObject::tr("Error reading %1 XPIP file :\n %2").arg(_xtandem_file.absoluteFilePath()).arg(parser->errorString()));
}
qDebug() << "IdentificationXtandemFile::parseTo end";
}
......@@ -32,6 +32,21 @@ PeptideMatch::PeptideMatch(MsRun * msrunid_sp, unsigned int scan) {
_hash_sample_scan = PeptideMatch::_hash_fn (QString("%1 %2").arg(msrunid_sp->getXmlId()).arg(_scan).toStdString());
}
PeptideMatch::PeptideMatch(const PeptideMatch & other): PeptideMatch(other._msrunid_sp, other._scan) {
_hash_sample_scan = other._hash_sample_scan;
_sp_grp_peptide = other._sp_grp_peptide;
_peptide_sp = other._peptide_sp;
_rt = other._rt;
_evalue = other._evalue;
_exp_mass = other._exp_mass;
_start=other._start;
_charge= other._charge;
_p_identification_source = other._p_identification_source;
_params = other._params;
_checked = other._checked;
_proxy_valid = other._proxy_valid;
}
void PeptideMatch::updateAutomaticFilters(const AutomaticFilterParameters & automatic_filter_parameters) {
_proxy_valid = false;
......
......@@ -35,6 +35,7 @@ class PeptideMatch
{
public :
PeptideMatch(MsRun * msrunid_sp, unsigned int scan);
PeptideMatch(const PeptideMatch & other);
std::size_t getHashSampleScan() const;
std::size_t getHashPeptideMassSample() const;
......
......@@ -24,6 +24,7 @@
#include "../input/xpipsaxhandler.h"
#include "peptidematch.h"
#include "proteinmatch.h"
#include <QDebug>
Project::Project()
{
......@@ -46,6 +47,7 @@ void Project::readResultFile(QString filename) {
IdentificationDataSourceSp ident_source = _identification_data_source_store.getInstance(filename);
ident_source.get()->parseTo(this);
qDebug() << "Project::readResultFile end";
}
bool Project::isCombineMode() const {
......@@ -92,11 +94,14 @@ const AutomaticFilterParameters & Project::getAutomaticFilterParameters() const
return _automatic_filter_parameters;
}
void Project::updateAutomaticFilters(const AutomaticFilterParameters & automatic_filter_parameters) {
qDebug() << "Project::updateAutomaticFilters begin";
_automatic_filter_parameters = automatic_filter_parameters;
for (auto & p_id_group : _identification_goup_list) {
p_id_group->updateAutomaticFilters(_automatic_filter_parameters);
}
qDebug() << "Project::updateAutomaticFilters end";
}
ProjectSp Project::makeProjectSp() const {
return std::make_shared<Project>(*this);
......
......@@ -41,7 +41,7 @@
WorkerThread::WorkerThread(MainWindow * p_main_window)
{
qDebug() << "WorkerThread::WorkerThread begin MainWindow";
_p_work_monitor = new WorkMonitor();
#if QT_VERSION >= 0x050000
......@@ -53,7 +53,7 @@ WorkerThread::WorkerThread(MainWindow * p_main_window)
*/
#else
// Qt4 code
//worker message
//worker message
connect(_p_work_monitor, SIGNAL(workerMessage(QString)), p_main_window,SLOT(doDisplayLoadingMessage(QString)));
connect(_p_work_monitor, SIGNAL(workerMessage(QString, int)), p_main_window,SLOT(doDisplayLoadingMessage(QString, int)));
......@@ -87,7 +87,7 @@ WorkerThread::WorkerThread(MainWindow * p_main_window)
WorkerThread::WorkerThread(ProjectWindow * p_project_window)
{
qDebug() << "WorkerThread::WorkerThread begin ProjectWindow";
_p_work_monitor = new WorkMonitor();
#if QT_VERSION >= 0x050000
......@@ -95,8 +95,8 @@ WorkerThread::WorkerThread(ProjectWindow * p_project_window)
#else
// Qt4 code
qDebug() << "WorkerThread::WorkerThread Qt4 code";
//worker message
//worker message
connect(_p_work_monitor, SIGNAL(workerMessage(QString)), p_project_window,SLOT(doDisplayLoadingMessage(QString)));
connect(_p_work_monitor, SIGNAL(workerMessage(QString, int)), p_project_window,SLOT(doDisplayLoadingMessage(QString, int)));
......@@ -104,16 +104,16 @@ WorkerThread::WorkerThread(ProjectWindow * p_project_window)
//grouping
connect(p_project_window, SIGNAL(operateGrouping(ProjectSp)), this,SLOT(doGrouping(ProjectSp)));
connect(this, SIGNAL(groupingFinished()), p_project_window,SLOT(doGroupingFinished()));
//PTM grouping on IdentificationGroup
//PTM grouping on IdentificationGroup
connect(p_project_window, SIGNAL(operatePtmGroupingOnIdentification(IdentificationGroup *)), this,SLOT(doPtmGroupingOnIdentification(IdentificationGroup *)));
connect(this, SIGNAL(ptmGroupingOnIdentificationFinished(IdentificationGroup *)), p_project_window,SLOT(refreshPtmGroup(IdentificationGroup *)));
//grouping on IdentificationGroup
connect(p_project_window, SIGNAL(operateGroupingOnIdentification(IdentificationGroup *, GroupingType)), this,SLOT(doGroupingOnIdentification(IdentificationGroup *, GroupingType)));
connect(this, SIGNAL(groupingOnIdentificationFinished(IdentificationGroup *)), p_project_window,SLOT(refreshGroup(IdentificationGroup *)));
connect(this, SIGNAL(operationFailed(QString)), p_project_window,SLOT(doOperationFailed(QString)));
connect(this, SIGNAL(operationFinished()), p_project_window,SLOT(doOperationFinished()));
......@@ -277,6 +277,7 @@ void WorkerThread::doLoadingResults(bool is_individual, AutomaticFilterParameter
emit loadingMessage(tr("filtering proteins"));
project_sp.get()->updateAutomaticFilters(param);
qDebug() << "WorkerThread::doLoadingResults emit projectReady(project_sp) ";
emit projectReady(project_sp);
}
......
......@@ -35,6 +35,7 @@
#include <QDir>
#include <QString>
#include <pappsomspp/pappsoexception.h>
#include <pappsomspp/exception/exceptionoutofrange.h>
#include <pwiz/data/identdata/IdentData.hpp>
#include <pwiz/data/identdata/IdentDataFile.hpp>
......@@ -98,7 +99,7 @@ void IdentificationPwizReader::read(
try {
ProteinStore & protein_store = _p_project->getProteinStore();
PeptideStore & peptide_store = _p_project->getPeptideStore();
std::map<QString, ProteinXtpSp> map_id2protein;
std::map<QString, ProteinMatch *> map_id2protein;
std::map<QString, PeptideXtpSp> map_id2peptide;
for (pwiz::identdata::DBSequencePtr seq_ptr :_pwiz_ident_data_file->sequenceCollection.dbSequences) {
......@@ -109,7 +110,15 @@ void IdentificationPwizReader::read(
protein.setSequence(QString::fromStdString( sequence_pwiz->seq));
ProteinXtpSp protein_sp(protein.makeProteinXtpSp());
protein_sp = protein_store.getInstance(protein_sp);
map_id2protein.insert(std::pair<QString, ProteinXtpSp>(QString::fromStdString( sequence_pwiz->id), protein_sp));
ProteinMatch * protein_match_p = _p_identification_group->getProteinMatchInstance(protein_sp.get()->getAccession());
protein_match_p->setProteinXtpSp(protein_sp);
protein_match_p->setChecked(true);
map_id2protein.insert(std::pair<QString, ProteinMatch *>(QString::fromStdString( sequence_pwiz->id), protein_match_p));
}
for (pwiz::identdata::PeptidePtr seq_ptr :_pwiz_ident_data_file->sequenceCollection.peptides) {
......@@ -136,7 +145,6 @@ void IdentificationPwizReader::read(
throw pappso::PappsoException(QObject::tr("Scan number not found"));
}
//<cvParam accession="MS:1001115" cvRef="PSI-MS" value="4925" name="scan number(s)"/>
PeptideMatch * p_peptide_match = new PeptideMatch(_sp_msrun.get(), scan);
double rt=0;
......@@ -144,30 +152,61 @@ void IdentificationPwizReader::read(
{
rt =
std::stod(spectrum_ptr.get()->cvParam(pwiz::cv::MS_retention_time).value);
p_peptide_match->setRetentionTime(rt);
}
else {
//throw pappso::PappsoException(QObject::tr("Scan number not found"));
}
/*
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::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->setParam(PeptideMatchParam::tandem_hyperscore, QVariant( attributes.value("hyperscore").toDouble()));
p_peptide_match->setIdentificationDataSource( _p_identification_data_source);
p_peptide_match->setChecked(true);
_p_protein_match->addPeptideMatch(p_peptide_match);
*/
//<SpectrumIdentificationItem passThreshold="true" rank="1"
//experimentalMassToCharge="388.2189331" id="sii2" chargeState="2" calculatedMassToCharge="388.2161235">
// <PeptideEvidenceRef peptideEvidence_ref="dbseq821_pep947_414"/>
// <PeptideEvidenceRef peptideEvidence_ref="dbseq821_pep947_414"/>
// <cvParam accession="MS:1001330" cvRef="PSI-MS" value="0.000452757388" name="X!Tandem:expect"/>
//<cvParam accession="MS:1001331" cvRef="PSI-MS" value="24.275219" name="X!Tandem:hyperscore"/>
// </SpectrumIdentificationItem>
for ( pwiz::identdata::SpectrumIdentificationItemPtr spid_item : spectrum_ptr.get()->spectrumIdentificationItem) {
PeptideMatch * p_peptide_match = new PeptideMatch(_sp_msrun.get(), scan);
p_peptide_match->setRetentionTime(rt);
p_peptide_match->setCharge(spid_item->chargeState);
pappso::pappso_double exp_mass = spid_item->experimentalMassToCharge * ((double) spid_item->chargeState) - (((double) spid_item->chargeState) * pappso::MHPLUS);
p_peptide_match->setExperimentalMass(exp_mass);
p_peptide_match->setIdentificationDataSource( p_identification_data_source);
p_peptide_match->setChecked(true);
if (spectrum_ptr.get()->hasCVParam(pwiz::cv::MS_X_Tandem_expect))
{
p_peptide_match->setEvalue(std::stod(spectrum_ptr.get()->cvParam(pwiz::cv::MS_X_Tandem_expect).value));
}
if (spectrum_ptr.get()->hasCVParam(pwiz::cv::MS_X_Tandem_hyperscore))
{
p_peptide_match->setParam(PeptideMatchParam::tandem_hyperscore, QVariant(std::stod(spectrum_ptr.get()->cvParam(pwiz::cv::MS_X_Tandem_hyperscore).value)));
}
for ( pwiz::identdata::PeptideEvidencePtr peptide_evidence_sp : spid_item.get()->peptideEvidencePtr) {
PeptideMatch * p_peptide_match_from_evidence = new PeptideMatch(*p_peptide_match);
p_peptide_match_from_evidence->setStart(peptide_evidence_sp.get()->start);
auto it_pep = map_id2peptide.find(QString::fromStdString(peptide_evidence_sp.get()->peptidePtr.get()->id));
if (it_pep == map_id2peptide.end()) {
throw pappso::ExceptionOutOfRange(QObject::tr("key %1 not found in map_id2peptide, reading SpectrumIdentificationItem %2")
.arg(QString::fromStdString(peptide_evidence_sp.get()->peptidePtr.get()->id))
.arg(QString::fromStdString(spid_item.get()->id))
);
}
p_peptide_match->setPeptideXtpSp(it_pep->second);
auto it = map_id2protein.find(QString::fromStdString(peptide_evidence_sp.get()->dbSequencePtr.get()->id));
if (it == map_id2protein.end()) {
throw pappso::ExceptionOutOfRange(QObject::tr("key %1 not found in map_id2protein").arg(QString::fromStdString(peptide_evidence_sp.get()->dbSequencePtr.get()->id)));
}
ProteinMatch * protein_match_p = it->second;
protein_match_p->addPeptideMatch(p_peptide_match_from_evidence);
}
delete p_peptide_match;
}
}
}
......
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