libpappsomspp
Library for mass spectrometry
pappso::MsRunXicExtractorInterface Class Referenceabstract

#include <msrunxicextractorinterface.h>

Inheritance diagram for pappso::MsRunXicExtractorInterface:
pappso::MsRunXicExtractor pappso::TimsXicExtractorInterface pappso::MsRunXicExtractorDisk pappso::TimsDirectXicExtractor pappso::MsRunXicExtractorDiskBuffer

Public Member Functions

void setXicExtractMethod (XicExtractMethod method)
 set the XIC extraction method More...
 
void setRetentionTimeAroundTarget (double range_in_seconds)
 set the retention time range in seconds around the target rt More...
 
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 More...
 
virtual void extractXicCoordSPtrListParallelized (UiMonitorInterface &monitor, std::vector< XicCoordSPtr > &xic_coord_list) final
 multithreaded XIC extraction More...
 
const MsRunIdCstSPtrgetMsRunId () const
 
const MsRunReaderSPtrgetMsRunReaderSPtr () const
 get the msrunreader currently used for XIC extraction More...
 
void setPostExtractionTraceFilterCstSPtr (pappso::FilterInterfaceCstSPtr &filter)
 filter interface to apply just after XIC extration on each trace More...
 

Protected Member Functions

 MsRunXicExtractorInterface (MsRunReaderSPtr &msrun_reader)
 constructor is private, use the MsRunXicExtractorFactory More...
 
 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 More...
 
virtual void protectedExtractXicCoordSPtrList (UiMonitorInterface &monitor, std::vector< XicCoordSPtr >::iterator it_xic_coord_list_begin, std::vector< XicCoordSPtr >::iterator it_xic_coord_list_end)=0
 

Protected Attributes

MsRunReaderSPtr msp_msrun_reader
 
XicExtractMethod m_xicExtractMethod = XicExtractMethod::max
 
double m_retentionTimeAroundTarget = std::numeric_limits<double>::max()
 
pappso::FilterInterfaceCstSPtr mcsp_postExtractionTraceFilter = nullptr
 

Detailed Description

Definition at line 48 of file msrunxicextractorinterface.h.

Constructor & Destructor Documentation

◆ MsRunXicExtractorInterface() [1/2]

pappso::MsRunXicExtractorInterface::MsRunXicExtractorInterface ( MsRunReaderSPtr msrun_reader)
protected

constructor is private, use the MsRunXicExtractorFactory

Definition at line 40 of file msrunxicextractorinterface.cpp.

42  : msp_msrun_reader(msrun_reader)
43 {
44 }

◆ MsRunXicExtractorInterface() [2/2]

pappso::MsRunXicExtractorInterface::MsRunXicExtractorInterface ( const MsRunXicExtractorInterface other)
protected

Definition at line 47 of file msrunxicextractorinterface.cpp.

49  : msp_msrun_reader(other.msp_msrun_reader)
50 {
51  m_xicExtractMethod = other.m_xicExtractMethod;
52 }

References m_xicExtractMethod.

◆ ~MsRunXicExtractorInterface()

pappso::MsRunXicExtractorInterface::~MsRunXicExtractorInterface ( )
protectedvirtual

Definition at line 54 of file msrunxicextractorinterface.cpp.

55 {
56 }

Member Function Documentation

◆ extractXicCoordSPtrList()

void pappso::MsRunXicExtractorInterface::extractXicCoordSPtrList ( UiMonitorInterface monitor,
std::vector< XicCoordSPtr > &  xic_coord_list 
)
finalvirtual

extract a list of XIC given a list of xic coordinates to extract

XicCoord is a vessel containing the xic to fill and coordinates of this XIC in the MS run

Parameters
monitorprocess monitoring
xic_coord_listlist of xic coordinates to extract. The order of xic coordinates may change.

Definition at line 181 of file msrunxicextractorinterface.cpp.

183 {
184 
185  monitor.setStatus(
186  QObject::tr("extracting %1 XICs").arg(xic_coord_list.size()));
187  monitor.setTotalSteps(xic_coord_list.size());
189  monitor, xic_coord_list.begin(), xic_coord_list.end());
190  monitor.setTotalSteps(0);
191  postExtractionProcess(monitor, xic_coord_list.begin(), xic_coord_list.end());
192 }
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
virtual void protectedExtractXicCoordSPtrList(UiMonitorInterface &monitor, std::vector< XicCoordSPtr >::iterator it_xic_coord_list_begin, std::vector< XicCoordSPtr >::iterator it_xic_coord_list_end)=0

References postExtractionProcess(), protectedExtractXicCoordSPtrList(), pappso::UiMonitorInterface::setStatus(), and pappso::UiMonitorInterface::setTotalSteps().

Referenced by extractXicCoordSPtrListParallelized().

◆ extractXicCoordSPtrListParallelized()

void pappso::MsRunXicExtractorInterface::extractXicCoordSPtrListParallelized ( UiMonitorInterface monitor,
std::vector< XicCoordSPtr > &  xic_coord_list 
)
finalvirtual

multithreaded XIC extraction

divide xic_coord_list and run extractXicCoordSPtrList separated threads

Parameters
monitorprocess monitoring
xic_coord_listlist of xic coordinates to extract. The order of xic coordinates may change.

Definition at line 92 of file msrunxicextractorinterface.cpp.

94 {
95  qDebug();
96  // get the number of available threads :
97  int number_of_threads = QThreadPool::globalInstance()->maxThreadCount();
98 
99  if(number_of_threads == 1)
100  {
101  extractXicCoordSPtrList(monitor, xic_coord_list);
102  }
103  else
104  {
105  monitor.setStatus(QObject::tr("parallelized extraction of %1 XICs")
106  .arg(xic_coord_list.size()));
107 
108  std::size_t chunck_size = xic_coord_list.size() / number_of_threads;
109  chunck_size += 1;
110  if(chunck_size < 1000)
111  chunck_size = 1000;
112 
113  struct parallelExtractChunck
114  {
115  std::vector<XicCoordSPtr>::iterator it_xic_coord_begin;
116  std::vector<XicCoordSPtr>::iterator it_xic_coord_end;
117  };
118 
119  std::vector<parallelExtractChunck> chunck_list;
120  qDebug();
121  for(auto it = xic_coord_list.begin(); it != xic_coord_list.end();)
122  {
123  qDebug() << "chunck_size=" << chunck_size;
124  parallelExtractChunck chunck;
125  chunck.it_xic_coord_begin = it;
126  for(std::size_t i = 0; i < chunck_size && it != xic_coord_list.end();
127  i++)
128  {
129  it++;
130  }
131  chunck.it_xic_coord_end = it;
132  chunck_list.push_back(chunck);
133  }
134  qDebug();
135  auto self = this;
136 
137  qDebug();
138  std::function<std::size_t(const parallelExtractChunck &)> extractChunck =
139  [self](const parallelExtractChunck &extract_chunck) {
140  qDebug();
141  UiMonitorVoid monitor;
142  self->protectedExtractXicCoordSPtrList(
143  monitor,
144  extract_chunck.it_xic_coord_begin,
145  extract_chunck.it_xic_coord_end);
146  self->postExtractionProcess(monitor,
147  extract_chunck.it_xic_coord_begin,
148  extract_chunck.it_xic_coord_end);
149  qDebug();
150  return 1;
151  };
152  qDebug();
153  monitor.setTotalSteps(chunck_list.size());
154  UiMonitorInterface *monitorRef = &monitor;
155  std::function<void(std::size_t & result, const std::size_t &value)>
156  monitorExtract2 =
157  [monitorRef](std::size_t &result [[maybe_unused]],
158  const std::size_t &value
159  [[maybe_unused]]) { monitorRef->count(); };
160  qDebug();
161 
162  QFuture<std::size_t> res =
163  QtConcurrent::mappedReduced<std::size_t>(chunck_list.begin(),
164  chunck_list.end(),
165  extractChunck,
166  monitorExtract2,
167  QtConcurrent::UnorderedReduce);
168  qDebug();
169 
170  /*
171  QFuture<std::size_t> res =
172  QtConcurrent::mapped(chunck_list.begin(), chunck_list.end(),
173  extractChunck);
174  */
175  res.waitForFinished();
176  monitor.setTotalSteps(0);
177  }
178 }
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

References pappso::UiMonitorInterface::count(), extractXicCoordSPtrList(), pappso::res, pappso::UiMonitorInterface::setStatus(), and pappso::UiMonitorInterface::setTotalSteps().

◆ getMsRunId()

const MsRunIdCstSPtr & pappso::MsRunXicExtractorInterface::getMsRunId ( ) const

Definition at line 72 of file msrunxicextractorinterface.cpp.

73 {
74  return msp_msrun_reader.get()->getMsRunId();
75 }

References msp_msrun_reader.

◆ getMsRunReaderSPtr()

const MsRunReaderSPtr & pappso::MsRunXicExtractorInterface::getMsRunReaderSPtr ( ) const

get the msrunreader currently used for XIC extraction

Definition at line 78 of file msrunxicextractorinterface.cpp.

79 {
80  return msp_msrun_reader;
81 }

References msp_msrun_reader.

◆ postExtractionProcess()

void pappso::MsRunXicExtractorInterface::postExtractionProcess ( UiMonitorInterface monitor,
std::vector< XicCoordSPtr >::iterator  it_xic_coord_list_begin,
std::vector< XicCoordSPtr >::iterator  it_xic_coord_list_end 
)
protectedvirtual

possible post extraction process, eventually trace filters

Definition at line 195 of file msrunxicextractorinterface.cpp.

199 {
200 
201  if(mcsp_postExtractionTraceFilter != nullptr)
202  {
203  monitor.setStatus(
204  QObject::tr("filtering %1 XICs")
205  .arg(std::distance(it_xic_coord_list_begin, it_xic_coord_list_end)));
206  for(auto it = it_xic_coord_list_begin; it != it_xic_coord_list_end; it++)
207  {
208  mcsp_postExtractionTraceFilter.get()->filter(
209  *(it->get()->xicSptr.get()));
210  }
211  }
212 }
pappso::FilterInterfaceCstSPtr mcsp_postExtractionTraceFilter

References mcsp_postExtractionTraceFilter, and pappso::UiMonitorInterface::setStatus().

Referenced by extractXicCoordSPtrList().

◆ protectedExtractXicCoordSPtrList()

virtual void pappso::MsRunXicExtractorInterface::protectedExtractXicCoordSPtrList ( UiMonitorInterface monitor,
std::vector< XicCoordSPtr >::iterator  it_xic_coord_list_begin,
std::vector< XicCoordSPtr >::iterator  it_xic_coord_list_end 
)
protectedpure virtual

◆ setPostExtractionTraceFilterCstSPtr()

void pappso::MsRunXicExtractorInterface::setPostExtractionTraceFilterCstSPtr ( pappso::FilterInterfaceCstSPtr filter)

filter interface to apply just after XIC extration on each trace

Definition at line 84 of file msrunxicextractorinterface.cpp.

86 {
88 }

References mcsp_postExtractionTraceFilter.

◆ setRetentionTimeAroundTarget()

void pappso::MsRunXicExtractorInterface::setRetentionTimeAroundTarget ( double  range_in_seconds)

set the retention time range in seconds around the target rt

only the interesting part of the xic will be extracted, form the rt target

  • range_in_seconds to rt target + range in seconds by default, all the LC run time is extracted
Parameters
range_in_secondsrange in seconds

Definition at line 65 of file msrunxicextractorinterface.cpp.

67 {
68  m_retentionTimeAroundTarget = range_in_seconds;
69 }

References m_retentionTimeAroundTarget.

◆ setXicExtractMethod()

void pappso::MsRunXicExtractorInterface::setXicExtractMethod ( XicExtractMethod  method)

set the XIC extraction method

Definition at line 59 of file msrunxicextractorinterface.cpp.

60 {
61  m_xicExtractMethod = method;
62 }

References m_xicExtractMethod.

Member Data Documentation

◆ m_retentionTimeAroundTarget

double pappso::MsRunXicExtractorInterface::m_retentionTimeAroundTarget = std::numeric_limits<double>::max()
protected

◆ m_xicExtractMethod

◆ mcsp_postExtractionTraceFilter

pappso::FilterInterfaceCstSPtr pappso::MsRunXicExtractorInterface::mcsp_postExtractionTraceFilter = nullptr
protected

◆ msp_msrun_reader


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