Loading...
Searching...
No Matches
pappso::MsRunXicExtractor Class Reference

`#include <msrunxicextractor.h>`

Inheritance diagram for pappso::MsRunXicExtractor:

## Classes

struct | MsRunXicExtractorPoints
class | MsRunXicExtractorReadPoints
| class to read retention time points of MsRun More...

## Public Member Functions

| MsRunXicExtractor (const MsRunXicExtractor &other)
virtual | ~MsRunXicExtractor ()
Public Member Functions inherited from pappso::MsRunXicExtractorInterface
void | setXicExtractMethod (XicExtractMethod method)
| set the XIC extraction method
void | setRetentionTimeAroundTarget (double range_in_seconds)
| set the retention time range in seconds around the target rt
virtual void | extractXicCoordSPtrList (UiMonitorInterface &monitor, std::vector< XicCoordSPtr > &xic_coord_list) final
| extract a list of XIC given a list of xic coordinates to extract
virtual void | extractXicCoordSPtrListParallelized (UiMonitorInterface &monitor, std::vector< XicCoordSPtr > &xic_coord_list) final
| multithreaded XIC extraction
const MsRunIdCstSPtr & | getMsRunId () const
const MsRunReaderSPtr & | getMsRunReaderSPtr () const
| get the msrunreader currently used for XIC extraction
void | setPostExtractionTraceFilterCstSPtr (pappso::FilterInterfaceCstSPtr &filter)
| filter interface to apply just after XIC extration on each trace

## Protected Member Functions

| MsRunXicExtractor (MsRunReaderSPtr &msrun_reader)
virtual void | getXicFromPwizMSDataFile (std::vector< Xic * > &xic_list, const std::vector< MzRange > &mass_range_list, pappso::pappso_double rt_begin, pappso::pappso_double rt_end)
virtual void | protectedExtractXicCoordSPtrList (UiMonitorInterface &monitor, std::vector< XicCoordSPtr >::iterator it_xic_coord_list_begin, std::vector< XicCoordSPtr >::iterator it_xic_coord_list_end) override
Protected Member Functions inherited from pappso::MsRunXicExtractorInterface
| MsRunXicExtractorInterface (MsRunReaderSPtr &msrun_reader)
| constructor is private, use the MsRunXicExtractorFactory
| MsRunXicExtractorInterface (const MsRunXicExtractorInterface &other)
virtual | ~MsRunXicExtractorInterface ()
virtual void | postExtractionProcess (UiMonitorInterface &monitor, std::vector< XicCoordSPtr >::iterator it_xic_coord_list_begin, std::vector< XicCoordSPtr >::iterator it_xic_coord_list_end)
| possible post extraction process, eventually trace filters

## Protected Attributes

std::vector< MsRunXicExtractorPoints > | m_msrun_points
Protected Attributes inherited from pappso::MsRunXicExtractorInterface
MsRunReaderSPtr | msp_msrun_reader
XicExtractMethod | m_xicExtractMethod = XicExtractMethod::max
double | m_retentionTimeAroundTarget = std::numeric_limits<double>::max()
pappso::FilterInterfaceCstSPtr | mcsp_postExtractionTraceFilter = nullptr

## Private Member Functions

void | extractOneXicCoord (XicCoord &xic_coord)

## Private Attributes

friend | MsRunXicExtractorFactory

## Detailed Description

Definition at line 41 of file msrunxicextractor.h.

## Constructor & Destructor Documentation

## MsRunXicExtractor() [1/2]

pappso::MsRunXicExtractor::MsRunXicExtractor | ( | const MsRunXicExtractor & | other | ) |

Definition at line 67 of file msrunxicextractor.cpp.

: MsRunXicExtractorInterface(other)
{
m_msrun_points = other.m_msrun_points;
}
pappso::MsRunXicExtractorInterface::MsRunXicExtractorInterface
MsRunXicExtractorInterface(MsRunReaderSPtr &msrun_reader)
constructor is private, use the MsRunXicExtractorFactory
Definition msrunxicextractorinterface.cpp:40
pappso::MsRunXicExtractor::m_msrun_points
std::vector< MsRunXicExtractorPoints > m_msrun_points
Definition msrunxicextractor.h:106

References m_msrun_points.

## ~MsRunXicExtractor()

pappso::MsRunXicExtractor::~MsRunXicExtractor | ( |  | ) |

virtual

Definition at line 62 of file msrunxicextractor.cpp.

{
}

## MsRunXicExtractor() [2/2]

pappso::MsRunXicExtractor::MsRunXicExtractor | ( | MsRunReaderSPtr & | msrun_reader | ) |

protected

Definition at line 43 of file msrunxicextractor.cpp.

: pappso::MsRunXicExtractorInterface(msrun_reader)
{
MsRunXicExtractorReadPoints get_msrun_points(m_msrun_points);
msp_msrun_reader.get()->readSpectrumCollection(get_msrun_points);
std::sort(m_msrun_points.begin(),
m_msrun_points.end(),
[](const MsRunXicExtractorPoints &a,
const MsRunXicExtractorPoints &b) { return a.rt < b.rt; });
if(m_msrun_points.size() == 0)
{
throw pappso::PappsoException(
QObject::tr("error extracting XIC: no MS level 1 in data file"));
}
}
pappso::MsRunXicExtractorInterface
Definition msrunxicextractorinterface.h:49
pappso::MsRunXicExtractorInterface::msp_msrun_reader
MsRunReaderSPtr msp_msrun_reader
Definition msrunxicextractorinterface.h:126
pappso::PappsoException
Definition pappsoexception.h:42
pappso::PeptideIonNter::a
@ a
pappso::PeptideIonNter::b
@ b

References pappso::a, pappso::b, m_msrun_points, and pappso::MsRunXicExtractorInterface::msp_msrun_reader.

## Member Function Documentation

## extractOneXicCoord()

void pappso::MsRunXicExtractor::extractOneXicCoord | ( | XicCoord & | xic_coord | ) |

private

Definition at line 103 of file msrunxicextractor.cpp.

{
FilterResampleKeepXRange keep_range(xic_coord.mzRange.lower(),
xic_coord.mzRange.upper());
std::shared_ptr<Xic> msrunxic_sp = xic_coord.xicSptr;
double rt_begin = xic_coord.rtTarget - m_retentionTimeAroundTarget;
double rt_end = xic_coord.rtTarget + m_retentionTimeAroundTarget;
auto itpoints = m_msrun_points.begin();
// find startint retention time :
while((itpoints != m_msrun_points.end()) && (itpoints->rt < rt_begin))
{
itpoints++;
}
MassSpectrumSPtr spectrum;
DataPoint peak;
while((itpoints != m_msrun_points.end()) && (itpoints->rt <= rt_end))
{
spectrum =
msp_msrun_reader.get()->massSpectrumSPtr(itpoints->spectrum_index);
// qDebug() << __FILE__ << " " << __FUNCTION__ << " " << __LINE__ << " "
// << spectrum->size(); spectrum->debugPrintValues();
qDebug() << " spectrum->size()=" << spectrum->size();
keep_range.filter(*(spectrum.get()));
qDebug() << " spectrum->size()=" << spectrum->size();
peak.x = itpoints->rt;
if(m_xicExtractMethod == XicExtractMethod::max)
{
peak.y = 0;
if(spectrum->size() > 0)
{
peak.y = maxYDataPoint(spectrum->begin(), spectrum->end())->y;
qDebug() << " peak.y=" << peak.y
<< " spectrum->size()=" << spectrum->size();
}
}
else
{
peak.y = sumYTrace(spectrum->begin(), spectrum->end(), 0);
}
msrunxic_sp->push_back(peak);
itpoints++;
}
}
pappso::MsRunXicExtractorInterface::m_retentionTimeAroundTarget
double m_retentionTimeAroundTarget
Definition msrunxicextractorinterface.h:128
pappso::MsRunXicExtractorInterface::m_xicExtractMethod
XicExtractMethod m_xicExtractMethod
Definition msrunxicextractorinterface.h:127
pappso::maxYDataPoint
std::vector< DataPoint >::const_iterator maxYDataPoint(std::vector< DataPoint >::const_iterator begin, std::vector< DataPoint >::const_iterator end)
Definition trace.cpp:180
pappso::sumYTrace
double sumYTrace(std::vector< DataPoint >::const_iterator begin, std::vector< DataPoint >::const_iterator end, double init)
calculate the sum of y value of a trace
Definition trace.cpp:244
pappso::MassSpectrumSPtr
std::shared_ptr< MassSpectrum > MassSpectrumSPtr
Definition massspectrum.h:56
pappso::XicExtractMethod::max
@ max
maximum of intensities

References pappso::FilterResampleKeepXRange::filter(), pappso::MzRange::lower(), m_msrun_points, pappso::MsRunXicExtractorInterface::m_retentionTimeAroundTarget, pappso::MsRunXicExtractorInterface::m_xicExtractMethod, pappso::max, pappso::maxYDataPoint(), pappso::MsRunXicExtractorInterface::msp_msrun_reader, pappso::XicCoord::mzRange, pappso::XicCoord::rtTarget, pappso::sumYTrace(), pappso::MzRange::upper(), pappso::DataPoint::x, pappso::XicCoord::xicSptr, and pappso::DataPoint::y.

Referenced by protectedExtractXicCoordSPtrList().

## getXicFromPwizMSDataFile()

void pappso::MsRunXicExtractor::getXicFromPwizMSDataFile | ( | std::vector< Xic * > & | xic_list,
|  | const std::vector< MzRange > & | mass_range_list,
|  | pappso::pappso_double | rt_begin,
|  | pappso::pappso_double | rt_end
| ) |  |

protected virtual

Definition at line 157 of file msrunxicextractor.cpp.

{
qDebug();
std::vector<DataPoint> peak_for_mass;
for(const MzRange &mass_range : mass_range_list)
{
peak_for_mass.push_back(DataPoint());
qDebug() << " mass_range=" << mass_range.getMz();
}
qDebug();
auto itpoints = m_msrun_points.begin();
while((itpoints != m_msrun_points.end()) && (itpoints->rt < rt_begin))
{
itpoints++;
}
MassSpectrumCstSPtr spectrum;
while((itpoints != m_msrun_points.end()) && (itpoints->rt <= rt_end))
{
spectrum =
msp_msrun_reader.get()->massSpectrumCstSPtr(itpoints->spectrum_index);
for(DataPoint &peak : peak_for_mass)
{
peak.x = itpoints->rt;
peak.y = 0;
}
// iterate through the m/z-intensity pairs
for(auto &&spectrum_point : *(spectrum.get()))
{
// qDebug() << "getXicFromPwizMSDataFile it->mz " << it->mz <<
// " it->intensity" << it->intensity;
for(std::size_t i = 0; i < mass_range_list.size(); i++)
{
if(mass_range_list[i].contains(spectrum_point.x))
{
if(m_xicExtractMethod == XicExtractMethod::max)
{
if(peak_for_mass[i].y < spectrum_point.y)
{
peak_for_mass[i].y = spectrum_point.y;
}
}
else
{
peak_for_mass[i].y += spectrum_point.y;
}
}
}
}
for(std::size_t i = 0; i < mass_range_list.size(); i++)
{
// qDebug() << "getXicFromPwizMSDataFile push_back " <<
// peak_for_mass[i].rt;
xic_list[i]->push_back(peak_for_mass[i]);
}
itpoints++;
}
qDebug();
} // namespace pappso
pappso::PeptideIonCter::y
@ y
pappso::MassSpectrumCstSPtr
std::shared_ptr< const MassSpectrum > MassSpectrumCstSPtr
Definition massspectrum.h:57

References m_msrun_points, pappso::MsRunXicExtractorInterface::m_xicExtractMethod, pappso::max, pappso::MsRunXicExtractorInterface::msp_msrun_reader, and pappso::y.

## protectedExtractXicCoordSPtrList()

void pappso::MsRunXicExtractor::protectedExtractXicCoordSPtrList | ( | UiMonitorInterface & | monitor,
|  | std::vector< XicCoordSPtr >::iterator | it_xic_coord_list_begin,
|  | std::vector< XicCoordSPtr >::iterator | it_xic_coord_list_end
| ) |  |

override protected virtual

Implements pappso::MsRunXicExtractorInterface.

Reimplemented in pappso::MsRunXicExtractorDisk.

Definition at line 75 of file msrunxicextractor.cpp.

{
// sort xic by mz:
std::sort(it_xic_coord_list_begin,
it_xic_coord_list_end,
[](XicCoordSPtr &a, XicCoordSPtr &b) {
return a.get()->rtTarget < b.get()->rtTarget;
});
for(auto it = it_xic_coord_list_begin; it != it_xic_coord_list_end; it++)
{
// XicCoord *p_xic_coord = sp_xic_coord.get();
extractOneXicCoord(*(it->get()));
monitor.count();
if(monitor.shouldIstop())
{
throw pappso::ExceptionInterrupted(
QObject::tr("Xic extraction process interrupted"));
}
}
}
pappso::ExceptionInterrupted
Definition exceptioninterrupted.h:36
pappso::MsRunXicExtractor::extractOneXicCoord
void extractOneXicCoord(XicCoord &xic_coord)
Definition msrunxicextractor.cpp:103
pappso::XicCoordSPtr
std::shared_ptr< XicCoord > XicCoordSPtr
Definition xiccoord.h:43

References pappso::a, pappso::b, pappso::UiMonitorInterface::count(), extractOneXicCoord(), and pappso::UiMonitorInterface::shouldIstop().

## Member Data Documentation

## m_msrun_points

std::vector<MsRunXicExtractorPoints> pappso::MsRunXicExtractor::m_msrun_points

protected

Definition at line 106 of file msrunxicextractor.h.

Referenced by MsRunXicExtractor(), MsRunXicExtractor(), extractOneXicCoord(), getXicFromPwizMSDataFile(), and pappso::MsRunXicExtractorDisk::serializeMsRun().

## MsRunXicExtractorFactory

friend pappso::MsRunXicExtractor::MsRunXicExtractorFactory

private

Definition at line 43 of file msrunxicextractor.h.

The documentation for this class was generated from the following files:

- pappsomspp/xicextractor/private/msrunxicextractor.h
- pappsomspp/xicextractor/private/msrunxicextractor.cpp