libpappsomspp
Library for mass spectrometry
timsdirectxicextractor.cpp
Go to the documentation of this file.
1 /**
2  * \file pappsomspp/vendors/tims/xicextractor/timsdirectxicextractor.cpp
3  * \date 21/09/2019
4  * \author Olivier Langella
5  * \brief minimum functions to extract XICs from Tims Data
6  */
7 
8 /*******************************************************************************
9  * Copyright (c) 2019 Olivier Langella <Olivier.Langella@u-psud.fr>.
10  *
11  * This file is part of the PAPPSOms++ library.
12  *
13  * PAPPSOms++ is free software: you can redistribute it and/or modify
14  * it under the terms of the GNU General Public License as published by
15  * the Free Software Foundation, either version 3 of the License, or
16  * (at your option) any later version.
17  *
18  * PAPPSOms++ is distributed in the hope that it will be useful,
19  * but WITHOUT ANY WARRANTY; without even the implied warranty of
20  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21  * GNU General Public License for more details.
22  *
23  * You should have received a copy of the GNU General Public License
24  * along with PAPPSOms++. If not, see <http://www.gnu.org/licenses/>.
25  *
26  ******************************************************************************/
27 
28 #include "timsdirectxicextractor.h"
29 #include "../../../msrun/xiccoord/xiccoordtims.h"
30 #include "../../../exception/exceptioninterrupted.h"
31 #include <QDebug>
32 
33 using namespace pappso;
34 
36  : pappso::TimsXicExtractorInterface(msrun_reader)
37 {
38 }
39 
41 {
42 }
43 
44 
45 void
47  UiMonitorInterface &monitor, std::vector<XicCoordSPtr> &xic_coord_list)
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 =
77  mp_timsData->getTimsMS1FrameIdRange(
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 }
TimsDirectXicExtractor(MsRunReaderSPtr &msrun_reader)
void extractXicCoordSPtrList(UiMonitorInterface &monitor, std::vector< XicCoordSPtr > &xic_coord_list) override
extract a list of XIC given a list of xic coordinates to extract
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
tries to keep as much as possible monoisotopes, removing any possible C13 peaks and changes multichar...
Definition: aa.cpp:39
std::shared_ptr< MsRunReader > MsRunReaderSPtr
Definition: msrunreader.h:166
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
minimum functions to extract XICs from Tims Data