Commit bd31a2b4 authored by Langella Olivier's avatar Langella Olivier
Browse files

using new generic xic extraction API

parent c3a5ecbd
...@@ -160,8 +160,6 @@ XicBox::XicBox(XicWindow *parent) : QWidget(parent), ui(new Ui::XicBox) ...@@ -160,8 +160,6 @@ XicBox::XicBox(XicWindow *parent) : QWidget(parent), ui(new Ui::XicBox)
#if QT_VERSION >= 0x050000 #if QT_VERSION >= 0x050000
// Qt5 code // Qt5 code
connect(this, &XicBox::loadXic, p_worker, &XicWorkerThread::doXicLoad); connect(this, &XicBox::loadXic, p_worker, &XicWorkerThread::doXicLoad);
connect(
this, &XicBox::loadTimsXic, p_worker, &XicWorkerThread::doTimsXicLoad);
connect(p_worker, &XicWorkerThread::xicLoaded, this, &XicBox::setXic); connect(p_worker, &XicWorkerThread::xicLoaded, this, &XicBox::setXic);
connect(p_worker, &XicWorkerThread::operationFailed, this, &XicBox::error); connect(p_worker, &XicWorkerThread::operationFailed, this, &XicBox::error);
...@@ -405,13 +403,13 @@ XicBox::getMsRunSp() ...@@ -405,13 +403,13 @@ XicBox::getMsRunSp()
} }
void void
XicBox::setXic(std::vector<pappso::XicCstSPtr> xic_sp_list) XicBox::setXic(std::vector<pappso::XicCoordSPtr> xic_sp_list)
{ {
qDebug() << xic_sp_list.size() << _natural_isotope_list.size(); qDebug() << xic_sp_list.size() << _natural_isotope_list.size();
ui->xic_widget->clear(); ui->xic_widget->clear();
for(std::size_t i = 0; i < xic_sp_list.size(); i++) for(std::size_t i = 0; i < xic_sp_list.size(); i++)
{ {
_natural_isotope_list[i].xic_sp = xic_sp_list[i]; //_natural_isotope_list[i].xic_sp = xic_sp_list[i];
} }
// pappso::XicWidget * xic_widget = new pappso::XicWidget(this); // pappso::XicWidget * xic_widget = new pappso::XicWidget(this);
// ui->xic_list_widget->layout()->addWidget(xic_widget); // ui->xic_list_widget->layout()->addWidget(xic_widget);
...@@ -632,28 +630,36 @@ XicBox::setIsotopeMassList( ...@@ -632,28 +630,36 @@ XicBox::setIsotopeMassList(
std::vector<pappso::PeptideNaturalIsotopeAverageSp> isotope_mass_list) std::vector<pappso::PeptideNaturalIsotopeAverageSp> isotope_mass_list)
{ {
_natural_isotope_list.clear(); _natural_isotope_list.clear();
std::vector<pappso::pappso_double> mass_list;
pappso::XicCoordSPtr xic_coord_ref =
_msrun_sp.get()
->getMsRunReaderSPtr()
.get()
->newXicCoordSPtrFromSpectrumIndex(
_p_peptide_evidence->getSpectrumIndex(),
_p_xic_window->getXicExtractPrecision());
std::vector<pappso::XicCoordSPtr> mass_list;
for(pappso::PeptideNaturalIsotopeAverageSp &natural_isotope_average : for(pappso::PeptideNaturalIsotopeAverageSp &natural_isotope_average :
isotope_mass_list) isotope_mass_list)
{ {
qDebug() << natural_isotope_average.get()->getMz(); qDebug() << natural_isotope_average.get()->getMz();
mass_list.push_back(natural_isotope_average.get()->getMz()); pappso::XicCoordSPtr xic_coord =
_natural_isotope_list.push_back( xic_coord_ref.get()->initializeAndClone();
{nullptr, natural_isotope_average, nullptr, nullptr, {}}); xic_coord.get()->mzRange =
} pappso::MzRange(natural_isotope_average.get()->getMz(),
_p_xic_window->getXicExtractPrecision());
mass_list.push_back(xic_coord);
if(_msrun_sp->getMzFormat() == pappso::MzFormat::brukerTims) _natural_isotope_list.push_back({xic_coord.get()->xicSptr,
{ natural_isotope_average,
runLoadTimsXic(); nullptr,
} nullptr,
else {}});
{
emit loadXic(_msrun_sp,
mass_list,
_p_xic_window->getXicExtractPrecision(),
pappso::XicExtractMethod::max);
} }
emit loadXic(_msrun_sp, mass_list, pappso::XicExtractMethod::max);
// histogram // histogram
if(m_theoreticalRatioBars == nullptr) if(m_theoreticalRatioBars == nullptr)
{ {
...@@ -735,45 +741,30 @@ XicBox::reExtractXic() ...@@ -735,45 +741,30 @@ XicBox::reExtractXic()
qDebug(); qDebug();
ui->xic_widget->clear(); ui->xic_widget->clear();
std::vector<pappso::pappso_double> mass_list; pappso::XicCoordSPtr xic_coord_ref =
for(const XicBoxNaturalIsotope &xic_isotope : _natural_isotope_list) _msrun_sp.get()
{ ->getMsRunReaderSPtr()
mass_list.push_back( .get()
xic_isotope.peptide_natural_isotope_sp.get()->getMz()); ->newXicCoordSPtrFromSpectrumIndex(
} _p_peptide_evidence->getSpectrumIndex(),
_p_xic_window->getXicExtractPrecision());
if(_msrun_sp->getMzFormat() == pappso::MzFormat::brukerTims) std::vector<pappso::XicCoordSPtr> mass_list;
{ for(XicBoxNaturalIsotope &xic_isotope : _natural_isotope_list)
runLoadTimsXic();
}
else
{ {
emit loadXic(_msrun_sp, pappso::XicCoordSPtr xic_coord =
mass_list, xic_coord_ref.get()->initializeAndClone();
_p_xic_window->getXicExtractPrecision(), xic_coord.get()->mzRange =
pappso::XicExtractMethod::max); pappso::MzRange(xic_isotope.peptide_natural_isotope_sp.get()->getMz(),
_p_xic_window->getXicExtractPrecision());
mass_list.push_back(xic_coord);
xic_isotope.xic_sp = xic_coord.get()->xicSptr;
} }
qDebug();
}
void emit loadXic(_msrun_sp, mass_list, pappso::XicExtractMethod::max);
XicBox::runLoadTimsXic()
{
qDebug() << "begin tims xic extraction";
std::vector<pappso::pappso_double> mass_list;
for(XicBoxNaturalIsotope isotope : _natural_isotope_list)
{
mass_list.push_back(isotope.peptide_natural_isotope_sp.get()->getMz());
}
std::size_t precursor_index = (_p_peptide_evidence->getScanNumber() / 2) + 1;
emit loadTimsXic(_msrun_sp,
precursor_index,
mass_list,
_p_xic_window->getXicExtractPrecision(),
pappso::XicExtractMethod::max);
qDebug() << "tims xic extraction sent to thread";
}
qDebug();
}
void void
XicBox::setRetentionTime(double rt) XicBox::setRetentionTime(double rt)
......
...@@ -81,14 +81,8 @@ class XicBox : public QWidget ...@@ -81,14 +81,8 @@ class XicBox : public QWidget
signals: signals:
void loadXic(MsRunSp p_msrun, void loadXic(MsRunSp p_msrun,
std::vector<pappso::pappso_double> mz_list, std::vector<pappso::XicCoordSPtr> mz_list,
pappso::PrecisionPtr precision,
pappso::XicExtractMethod method); pappso::XicExtractMethod method);
void loadTimsXic(MsRunSp p_msrun,
std::size_t precursor_index,
std::vector<pappso::pappso_double> mz_list,
pappso::PrecisionPtr precision,
pappso::XicExtractMethod method);
void computeIsotopeMassList(pappso::PeptideSp peptide_sp, void computeIsotopeMassList(pappso::PeptideSp peptide_sp,
unsigned int charge, unsigned int charge,
pappso::PrecisionPtr precision, pappso::PrecisionPtr precision,
...@@ -98,7 +92,7 @@ class XicBox : public QWidget ...@@ -98,7 +92,7 @@ class XicBox : public QWidget
private slots: private slots:
void remove(); void remove();
void reExtractXic(); void reExtractXic();
void setXic(std::vector<pappso::XicCstSPtr> xic_sp_list); void setXic(std::vector<pappso::XicCoordSPtr> xic_sp_list);
void setIsotopeMassList( void setIsotopeMassList(
std::vector<pappso::PeptideNaturalIsotopeAverageSp> isotope_mass_list); std::vector<pappso::PeptideNaturalIsotopeAverageSp> isotope_mass_list);
void error(QString error_message); void error(QString error_message);
...@@ -123,7 +117,6 @@ class XicBox : public QWidget ...@@ -123,7 +117,6 @@ class XicBox : public QWidget
void addCommonRt(std::vector<std::size_t> &common_peak_rt_measure_list, void addCommonRt(std::vector<std::size_t> &common_peak_rt_measure_list,
const pappso::TracePeak *peak, const pappso::TracePeak *peak,
const pappso::Xic *xic) const; const pappso::Xic *xic) const;
void runLoadTimsXic();
private: private:
Ui::XicBox *ui; Ui::XicBox *ui;
......
...@@ -43,24 +43,12 @@ XicWorkerThread::~XicWorkerThread() ...@@ -43,24 +43,12 @@ XicWorkerThread::~XicWorkerThread()
} }
void void
XicWorkerThread::doXicLoad(MsRunSp p_msrun, XicWorkerThread::doXicLoad(MsRunSp p_msrun,
std::vector<pappso::pappso_double> mz_list, std::vector<pappso::XicCoordSPtr> xic_coord_list,
pappso::PrecisionPtr precision,
pappso::XicExtractMethod method) pappso::XicExtractMethod method)
{ {
try try
{ {
std::vector<pappso::MzRange> mass_list;
for(pappso::pappso_double mass : mz_list)
{
mass_list.push_back(pappso::MzRange(mass, precision));
}
// std::vector<pappso::XicSp> xic_sp_list =
// SpectrumStore::getXicSpFromMsRunSp(p_msrun.get(), mass_list, method);
std::vector<pappso::XicCstSPtr> xic_sp_list;
pappso::MsRunXicExtractorInterfaceSp extractor = pappso::MsRunXicExtractorInterfaceSp extractor =
p_msrun.get()->getMsRunXicExtractorInterfaceSp(); p_msrun.get()->getMsRunXicExtractorInterfaceSp();
if(extractor != nullptr) if(extractor != nullptr)
...@@ -70,69 +58,11 @@ XicWorkerThread::doXicLoad(MsRunSp p_msrun, ...@@ -70,69 +58,11 @@ XicWorkerThread::doXicLoad(MsRunSp p_msrun,
qDebug(); qDebug();
xic_sp_list = extractor.get()->getXicCstSPtrList(mass_list); extractor.get()->extractXicCoordSPtrList(xic_coord_list);
qDebug(); qDebug();
} }
emit xicLoaded(xic_sp_list); emit xicLoaded(xic_coord_list);
}
catch(pappso::PappsoException &error)
{
emit operationFailed(tr("Error extracting XIC for MSrun %1:\n%2")
.arg(p_msrun->getFileName())
.arg(error.qwhat()));
}
}
void
XicWorkerThread::doTimsXicLoad(MsRunSp p_msrun,
std::size_t precursor_index,
std::vector<pappso::pappso_double> mz_list,
pappso::PrecisionPtr precision,
pappso::XicExtractMethod method)
{
try
{
pappso::TimsMsRunReaderMs2 *tims2_reader =
dynamic_cast<pappso::TimsMsRunReaderMs2 *>(
p_msrun->getMsRunReaderSPtr().get());
if(tims2_reader != nullptr)
{
pappso::TimsData *tims_data = tims2_reader->getTimsDataSPtr().get();
qDebug() << "tims_data ok";
pappso::TimsXicStructure xic_struct =
tims_data->getTimsXicStructureFromPrecursorId(precursor_index,
precision);
qDebug() << mz_list;
std::vector<pappso::TimsXicStructure> xic_struct_list;
std::vector<pappso::XicCstSPtr> xic_sp_list;
for(pappso::pappso_double mz : mz_list)
{
pappso::TimsXicStructure new_xic_struct =
pappso::TimsXicStructure(xic_struct);
new_xic_struct.mzRange = pappso::MzRange(mz, precision);
new_xic_struct.xicSptr = std::make_shared<pappso::Xic>();
xic_struct_list.push_back(new_xic_struct);
}
tims_data->extractXicListByTimsXicStructureList(
xic_struct_list, method, 100000);
for(pappso::TimsXicStructure xic_struct : xic_struct_list)
{
xic_sp_list.push_back(xic_struct.xicSptr);
}
qDebug() << "xic produced";
emit xicLoaded(xic_sp_list);
}
else
{
throw pappso::PappsoException(
tr("Error the msrun %1 isn't a timsTOF data")
.arg(p_msrun->getFileName()));
}
} }
catch(pappso::PappsoException &error) catch(pappso::PappsoException &error)
{ {
......
...@@ -27,8 +27,7 @@ ...@@ -27,8 +27,7 @@
*implementation *implementation
******************************************************************************/ ******************************************************************************/
#ifndef XICWORKERTHREAD_H #pragma once
#define XICWORKERTHREAD_H
#include <pappsomspp/peptide/peptidenaturalisotopelist.h> #include <pappsomspp/peptide/peptidenaturalisotopelist.h>
#include <QObject> #include <QObject>
...@@ -44,21 +43,15 @@ class XicWorkerThread : public QObject ...@@ -44,21 +43,15 @@ class XicWorkerThread : public QObject
virtual ~XicWorkerThread(); virtual ~XicWorkerThread();
public slots: public slots:
void doXicLoad(MsRunSp p_msrun, void doXicLoad(MsRunSp p_msrun,
std::vector<pappso::pappso_double> mz_list, std::vector<pappso::XicCoordSPtr> xic_coord_list,
pappso::PrecisionPtr precision,
pappso::XicExtractMethod method); pappso::XicExtractMethod method);
void doTimsXicLoad(MsRunSp p_msrun,
std::size_t precursor_index,
std::vector<pappso::pappso_double> mz_list,
pappso::PrecisionPtr precision,
pappso::XicExtractMethod method);
void doComputeIsotopeMassList(pappso::PeptideSp peptide_sp, void doComputeIsotopeMassList(pappso::PeptideSp peptide_sp,
unsigned int charge, unsigned int charge,
pappso::PrecisionPtr precision, pappso::PrecisionPtr precision,
double minimum_isotope_pattern_ratio); double minimum_isotope_pattern_ratio);
signals: signals:
void xicLoaded(std::vector<pappso::XicCstSPtr> xic_sp_list); void xicLoaded(std::vector<pappso::XicCoordSPtr> xic_sp_list);
void isotopeMassListComputed( void isotopeMassListComputed(
std::vector<pappso::PeptideNaturalIsotopeAverageSp> isotope_mass_list); std::vector<pappso::PeptideNaturalIsotopeAverageSp> isotope_mass_list);
void operationFailed(QString error); void operationFailed(QString error);
...@@ -66,4 +59,4 @@ class XicWorkerThread : public QObject ...@@ -66,4 +59,4 @@ class XicWorkerThread : public QObject
private: private:
std::vector<pappso::MsRunXicExtractorInterfaceSp> _extractor_list; std::vector<pappso::MsRunXicExtractorInterfaceSp> _extractor_list;
}; };
#endif // XICWORKERTHREAD_H
...@@ -59,6 +59,7 @@ main(int argc, char *argv[]) ...@@ -59,6 +59,7 @@ main(int argc, char *argv[])
qRegisterMetaType<PtmMode>("PtmMode"); qRegisterMetaType<PtmMode>("PtmMode");
qRegisterMetaType<std::vector<XicBox *>>("<std::vector<XicBox *>>"); qRegisterMetaType<std::vector<XicBox *>>("<std::vector<XicBox *>>");
qRegisterMetaType<MassChroQRunBatch>("MassChroQRunBatch"); qRegisterMetaType<MassChroQRunBatch>("MassChroQRunBatch");
qRegisterMetaType<std::vector<pappso::XicCoordSPtr>>("std::vector<pappso::XicCoordSPtr>");
// qRegisterMetaType<pappso::PeakIonIsotopeMatch>("pappso::PeakIonIsotopeMatch"); // qRegisterMetaType<pappso::PeakIonIsotopeMatch>("pappso::PeakIonIsotopeMatch");
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment