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)
#if QT_VERSION >= 0x050000
// Qt5 code
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::operationFailed, this, &XicBox::error);
......@@ -405,13 +403,13 @@ XicBox::getMsRunSp()
}
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();
ui->xic_widget->clear();
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);
// ui->xic_list_widget->layout()->addWidget(xic_widget);
......@@ -632,28 +630,36 @@ XicBox::setIsotopeMassList(
std::vector<pappso::PeptideNaturalIsotopeAverageSp> isotope_mass_list)
{
_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 :
isotope_mass_list)
{
qDebug() << natural_isotope_average.get()->getMz();
mass_list.push_back(natural_isotope_average.get()->getMz());
_natural_isotope_list.push_back(
{nullptr, natural_isotope_average, nullptr, nullptr, {}});
}
pappso::XicCoordSPtr xic_coord =
xic_coord_ref.get()->initializeAndClone();
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)
{
runLoadTimsXic();
}
else
{
emit loadXic(_msrun_sp,
mass_list,
_p_xic_window->getXicExtractPrecision(),
pappso::XicExtractMethod::max);
_natural_isotope_list.push_back({xic_coord.get()->xicSptr,
natural_isotope_average,
nullptr,
nullptr,
{}});
}
emit loadXic(_msrun_sp, mass_list, pappso::XicExtractMethod::max);
// histogram
if(m_theoreticalRatioBars == nullptr)
{
......@@ -735,45 +741,30 @@ XicBox::reExtractXic()
qDebug();
ui->xic_widget->clear();
std::vector<pappso::pappso_double> mass_list;
for(const XicBoxNaturalIsotope &xic_isotope : _natural_isotope_list)
{
mass_list.push_back(
xic_isotope.peptide_natural_isotope_sp.get()->getMz());
}
pappso::XicCoordSPtr xic_coord_ref =
_msrun_sp.get()
->getMsRunReaderSPtr()
.get()
->newXicCoordSPtrFromSpectrumIndex(
_p_peptide_evidence->getSpectrumIndex(),
_p_xic_window->getXicExtractPrecision());
if(_msrun_sp->getMzFormat() == pappso::MzFormat::brukerTims)
{
runLoadTimsXic();
}
else
std::vector<pappso::XicCoordSPtr> mass_list;
for(XicBoxNaturalIsotope &xic_isotope : _natural_isotope_list)
{
emit loadXic(_msrun_sp,
mass_list,
_p_xic_window->getXicExtractPrecision(),
pappso::XicExtractMethod::max);
pappso::XicCoordSPtr xic_coord =
xic_coord_ref.get()->initializeAndClone();
xic_coord.get()->mzRange =
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
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";
}
emit loadXic(_msrun_sp, mass_list, pappso::XicExtractMethod::max);
qDebug();
}
void
XicBox::setRetentionTime(double rt)
......
......@@ -81,13 +81,7 @@ class XicBox : public QWidget
signals:
void loadXic(MsRunSp p_msrun,
std::vector<pappso::pappso_double> mz_list,
pappso::PrecisionPtr precision,
pappso::XicExtractMethod method);
void loadTimsXic(MsRunSp p_msrun,
std::size_t precursor_index,
std::vector<pappso::pappso_double> mz_list,
pappso::PrecisionPtr precision,
std::vector<pappso::XicCoordSPtr> mz_list,
pappso::XicExtractMethod method);
void computeIsotopeMassList(pappso::PeptideSp peptide_sp,
unsigned int charge,
......@@ -98,7 +92,7 @@ class XicBox : public QWidget
private slots:
void remove();
void reExtractXic();
void setXic(std::vector<pappso::XicCstSPtr> xic_sp_list);
void setXic(std::vector<pappso::XicCoordSPtr> xic_sp_list);
void setIsotopeMassList(
std::vector<pappso::PeptideNaturalIsotopeAverageSp> isotope_mass_list);
void error(QString error_message);
......@@ -123,7 +117,6 @@ class XicBox : public QWidget
void addCommonRt(std::vector<std::size_t> &common_peak_rt_measure_list,
const pappso::TracePeak *peak,
const pappso::Xic *xic) const;
void runLoadTimsXic();
private:
Ui::XicBox *ui;
......
......@@ -43,24 +43,12 @@ XicWorkerThread::~XicWorkerThread()
}
void
XicWorkerThread::doXicLoad(MsRunSp p_msrun,
std::vector<pappso::pappso_double> mz_list,
pappso::PrecisionPtr precision,
std::vector<pappso::XicCoordSPtr> xic_coord_list,
pappso::XicExtractMethod method)
{
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 =
p_msrun.get()->getMsRunXicExtractorInterfaceSp();
if(extractor != nullptr)
......@@ -70,69 +58,11 @@ XicWorkerThread::doXicLoad(MsRunSp p_msrun,
qDebug();
xic_sp_list = extractor.get()->getXicCstSPtrList(mass_list);
extractor.get()->extractXicCoordSPtrList(xic_coord_list);
qDebug();
}
emit xicLoaded(xic_sp_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()));
}
emit xicLoaded(xic_coord_list);
}
catch(pappso::PappsoException &error)
{
......
......@@ -27,8 +27,7 @@
*implementation
******************************************************************************/
#ifndef XICWORKERTHREAD_H
#define XICWORKERTHREAD_H
#pragma once
#include <pappsomspp/peptide/peptidenaturalisotopelist.h>
#include <QObject>
......@@ -44,13 +43,7 @@ class XicWorkerThread : public QObject
virtual ~XicWorkerThread();
public slots:
void doXicLoad(MsRunSp p_msrun,
std::vector<pappso::pappso_double> mz_list,
pappso::PrecisionPtr precision,
pappso::XicExtractMethod method);
void doTimsXicLoad(MsRunSp p_msrun,
std::size_t precursor_index,
std::vector<pappso::pappso_double> mz_list,
pappso::PrecisionPtr precision,
std::vector<pappso::XicCoordSPtr> xic_coord_list,
pappso::XicExtractMethod method);
void doComputeIsotopeMassList(pappso::PeptideSp peptide_sp,
unsigned int charge,
......@@ -58,7 +51,7 @@ class XicWorkerThread : public QObject
double minimum_isotope_pattern_ratio);
signals:
void xicLoaded(std::vector<pappso::XicCstSPtr> xic_sp_list);
void xicLoaded(std::vector<pappso::XicCoordSPtr> xic_sp_list);
void isotopeMassListComputed(
std::vector<pappso::PeptideNaturalIsotopeAverageSp> isotope_mass_list);
void operationFailed(QString error);
......@@ -66,4 +59,4 @@ class XicWorkerThread : public QObject
private:
std::vector<pappso::MsRunXicExtractorInterfaceSp> _extractor_list;
};
#endif // XICWORKERTHREAD_H
......@@ -59,6 +59,7 @@ main(int argc, char *argv[])
qRegisterMetaType<PtmMode>("PtmMode");
qRegisterMetaType<std::vector<XicBox *>>("<std::vector<XicBox *>>");
qRegisterMetaType<MassChroQRunBatch>("MassChroQRunBatch");
qRegisterMetaType<std::vector<pappso::XicCoordSPtr>>("std::vector<pappso::XicCoordSPtr>");
// 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