libpappsomspp
Library for mass spectrometry
pappso::TimsDirectXicExtractor Class Reference

#include <timsdirectxicextractor.h>

Inheritance diagram for pappso::TimsDirectXicExtractor:
pappso::TimsXicExtractorInterface pappso::MsRunXicExtractorInterface

Public Member Functions

 TimsDirectXicExtractor (MsRunReaderSPtr &msrun_reader)
 
virtual ~TimsDirectXicExtractor ()
 
void extractXicCoordSPtrList (UiMonitorInterface &monitor, std::vector< XicCoordSPtr > &xic_coord_list) override
 extract a list of XIC given a list of xic coordinates to extract More...
 
- Public Member Functions inherited from pappso::TimsXicExtractorInterface
 TimsXicExtractorInterface (MsRunReaderSPtr &msrun_reader)
 
virtual ~TimsXicExtractorInterface ()
 
- Public Member Functions inherited from pappso::MsRunXicExtractorInterface
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...
 
const MsRunIdCstSPtrgetMsRunId () const
 
const MsRunReaderSPtrgetMsRunReaderSPtr () const
 get the msrunreader currently used for XIC extraction More...
 

Additional Inherited Members

- Protected Member Functions inherited from pappso::MsRunXicExtractorInterface
 MsRunXicExtractorInterface (MsRunReaderSPtr &msrun_reader)
 constructor is private, use the MsRunXicExtractorFactory More...
 
 MsRunXicExtractorInterface (const MsRunXicExtractorInterface &other)
 
virtual ~MsRunXicExtractorInterface ()
 
- Protected Attributes inherited from pappso::TimsXicExtractorInterface
const TimsDatamp_timsData
 
- Protected Attributes inherited from pappso::MsRunXicExtractorInterface
MsRunReaderSPtr msp_msrun_reader
 
XicExtractMethod m_xicExtractMethod = XicExtractMethod::max
 
double m_retentionTimeAroundTarget = std::numeric_limits<double>::max()
 

Detailed Description

Todo:
write docs

Definition at line 37 of file timsdirectxicextractor.h.

Constructor & Destructor Documentation

◆ TimsDirectXicExtractor()

TimsDirectXicExtractor::TimsDirectXicExtractor ( MsRunReaderSPtr msrun_reader)

Default constructor

Definition at line 35 of file timsdirectxicextractor.cpp.

◆ ~TimsDirectXicExtractor()

TimsDirectXicExtractor::~TimsDirectXicExtractor ( )
virtual

Destructor

Definition at line 40 of file timsdirectxicextractor.cpp.

41 {
42 }

Member Function Documentation

◆ extractXicCoordSPtrList()

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

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.

Implements pappso::MsRunXicExtractorInterface.

Definition at line 46 of file timsdirectxicextractor.cpp.

48 {
49  qDebug();
50  if(xic_coord_list.size() == 0)
51  return;
52 
53  std::vector<XicCoordTims *> xic_coord_tims_list;
54  xic_coord_tims_list.reserve(xic_coord_list.size());
55 
56  for(XicCoordSPtr &xic_coord_sp : xic_coord_list)
57  {
58  XicCoordTims *p_xic_coord_tims =
59  dynamic_cast<XicCoordTims *>(xic_coord_sp.get());
60  if(p_xic_coord_tims == nullptr)
61  {
62  }
63  else
64  {
65  xic_coord_tims_list.push_back(p_xic_coord_tims);
66  }
67  }
68 
69  std::sort(xic_coord_tims_list.begin(),
70  xic_coord_tims_list.end(),
71  [](const XicCoordTims *pa, const XicCoordTims *pb) {
72  return pa->rtTarget < pb->rtTarget;
73  });
74 
75 
76  std::vector<std::size_t> tims_frameid_list =
78  xic_coord_tims_list[0]->rtTarget - m_retentionTimeAroundTarget,
79  xic_coord_tims_list.back()->rtTarget + m_retentionTimeAroundTarget);
80 
81  monitor.setStatus(QObject::tr("extracting %1 XICs on %2 Tims frames")
82  .arg(xic_coord_list.size())
83  .arg(tims_frameid_list.size()));
84  monitor.setTotalSteps(tims_frameid_list.size());
85 
86  qDebug() << " tims_frameid_list.size()=" << tims_frameid_list.size();
87  qDebug() << " rt begin=" << xic_coord_tims_list[0]->rtTarget;
88  qDebug() << " rt end=" << xic_coord_tims_list.back()->rtTarget;
89  for(std::size_t frame_id : tims_frameid_list)
90  {
91  std::vector<XicCoordTims *>::iterator itXicListbegin =
92  xic_coord_tims_list.begin();
93  std::vector<XicCoordTims *>::iterator itXicListend =
94  xic_coord_tims_list.end();
95  qDebug();
96  TimsFrameCstSPtr frame_sptr = mp_timsData->getTimsFrameCstSPtr(frame_id);
97  qDebug();
98  double rtframe = frame_sptr.get()->getTime();
99  qDebug();
100 
101  double rtbeginframe = rtframe - m_retentionTimeAroundTarget;
102  double rtendframe = rtframe + m_retentionTimeAroundTarget;
103 
104  if(rtbeginframe < 0)
105  rtbeginframe = 0;
106 
107  qDebug() << rtbeginframe;
108  while((itXicListbegin != itXicListend) &&
109  ((*itXicListbegin)->rtTarget < rtbeginframe))
110  {
111  itXicListbegin++;
112  }
113  qDebug();
114  itXicListend = itXicListbegin;
115  while((itXicListend != xic_coord_tims_list.end()) &&
116  ((*itXicListend)->rtTarget < rtendframe))
117  {
118  itXicListend++;
119  }
120  frame_sptr.get()->extractTimsXicListInRtRange(
121  itXicListbegin, itXicListend, m_xicExtractMethod);
122 
123  qDebug() << "" << frame_sptr.get()->getId();
124  monitor.count();
125  if(monitor.shouldIstop())
126  {
128  QObject::tr("Xic extraction process interrupted"));
129  }
130  }
131  qDebug();
132 }
TimsFrameCstSPtr getTimsFrameCstSPtr(std::size_t timsId) const
get a Tims frame with his database ID
Definition: timsdata.cpp:516
std::vector< std::size_t > getTimsMS1FrameIdRange(double rt_begin, double rt_end) const
Definition: timsdata.cpp:480
virtual void setStatus(const QString &status)=0
current status of the process
virtual void setTotalSteps(std::size_t total_number_of_steps)
use it if the number of steps is known in an algorithm the total number of steps is usefull to report...
virtual bool shouldIstop()=0
should the procces be stopped ? If true, then cancel process Use this function at strategic point of ...
virtual void count()=0
count steps report when a step is computed in an algorithm
std::shared_ptr< const TimsFrame > TimsFrameCstSPtr
Definition: timsframe.h:43
std::shared_ptr< XicCoord > XicCoordSPtr
Definition: xiccoord.h:41
coordinates of the XIC to extract and the resulting XIC after extraction
Definition: xiccoordtims.h:51

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


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