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 <QDebug>
30 
31 using namespace pappso;
32 
34  : pappso::TimsXicExtractorInterface(mp_tims_data)
35 {
36 }
37 
39 {
40 }
41 
42 
43 void
45  std::vector<TimsXicStructure> &timsXicList, double rtRange) const
46 {
47  qDebug();
48  if(timsXicList.size() == 0)
49  return;
50  std::sort(timsXicList.begin(),
51  timsXicList.end(),
52  [](const TimsXicStructure &a, const TimsXicStructure &b) {
53  return a.rtTarget < b.rtTarget;
54  });
55 
56  for(auto &&timsXic : timsXicList)
57  {
58  timsXic.xicSptr = std::make_shared<Xic>();
59  }
60 
61  std::vector<std::size_t> tims_frameid_list =
62  mp_timsData->getTimsMS1FrameIdRange(timsXicList[0].rtTarget - rtRange,
63  timsXicList.back().rtTarget + rtRange);
64 
65  qDebug() << " tims_frameid_list.size()=" << tims_frameid_list.size();
66  qDebug() << " rt begin=" << timsXicList[0].rtTarget;
67  qDebug() << " rt end=" << timsXicList.back().rtTarget;
68  for(std::size_t frame_id : tims_frameid_list)
69  {
70  std::vector<TimsXicStructure>::iterator itXicListbegin =
71  timsXicList.begin();
72  std::vector<TimsXicStructure>::iterator itXicListend = timsXicList.end();
73  TimsFrameCstSPtr frame_sptr = mp_timsData->getTimsFrameCstSPtr(frame_id);
74  double rtframe = frame_sptr.get()->getTime();
75 
76  double rtbeginframe = rtframe - rtRange;
77  double rtendframe = rtframe + rtRange;
78 
79  if(rtbeginframe < 0)
80  rtbeginframe = 0;
81  while((itXicListbegin != itXicListend) &&
82  (itXicListbegin->rtTarget < rtbeginframe))
83  {
84  itXicListbegin++;
85  }
86  itXicListend = itXicListbegin;
87  while((itXicListend != timsXicList.end()) &&
88  (itXicListend->rtTarget < rtendframe))
89  {
90  itXicListend++;
91  }
92  /*
93  while((itXicListbegin != timsXicList.end()) &&
94  ((itXicListbegin->rtTarget + rtRange) < rtframe))
95  {
96 
97  qDebug() << " itXicListbegin->rtTarget + rtRange="
98  << itXicListbegin->rtTarget + rtRange
99  << " rtframe=" << rtframe;
100  itXicListbegin++;
101  }
102 */
103  qDebug() << " from=" << itXicListbegin->rtTarget
104  << " to=" << itXicListend->rtTarget;
105  frame_sptr.get()->extractTimsXicListInRtRange(
106  itXicListbegin, itXicListend, m_xicExtractMethod);
107 
108  qDebug() << "" << frame_sptr.get()->getId();
109  }
110  qDebug();
111 }
TimsFrameCstSPtr getTimsFrameCstSPtr(std::size_t timsId) const
get a Tims frame with his database ID
Definition: timsdata.cpp:496
std::vector< std::size_t > getTimsMS1FrameIdRange(double rt_begin, double rt_end) const
Definition: timsdata.cpp:460
TimsDirectXicExtractor(const TimsData *mp_tims_data)
virtual void extractTimsXicList(std::vector< TimsXicStructure > &timsXicList, double rtRange) const override
extract XICs for given coordinates XICs are extracted given their coordinates : retention time target...
tries to keep as much as possible monoisotopes, removing any possible C13 peaks and changes multichar...
Definition: aa.cpp:39
std::shared_ptr< const TimsFrame > TimsFrameCstSPtr
Definition: timsframe.h:42
structure needed to extract XIC from Tims data
Definition: timsdata.h:49
minimum functions to extract XICs from Tims Data