libpappsomspp
Library for mass spectrometry
Loading...
Searching...
No Matches
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
31#include <QDebug>
32
33using namespace pappso;
34
39
43
44
45void
47 UiMonitorInterface &monitor,
48 std::vector<XicCoordSPtr>::iterator it_xic_coord_list_begin,
49 std::vector<XicCoordSPtr>::iterator it_xic_coord_list_end)
50{
51 qDebug();
52 std::size_t xic_total_number = std::distance(it_xic_coord_list_begin, it_xic_coord_list_end);
53 if(xic_total_number == 0)
54 return;
55
56 std::vector<XicCoordTims *> xic_coord_tims_list;
57 xic_coord_tims_list.reserve(xic_total_number);
58
59 for(auto it = it_xic_coord_list_begin; it != it_xic_coord_list_end; it++)
60 {
61 XicCoordTims *p_xic_coord_tims = dynamic_cast<XicCoordTims *>(it->get());
62 if(p_xic_coord_tims == nullptr)
63 {
64 }
65 else
66 {
67 xic_coord_tims_list.push_back(p_xic_coord_tims);
68 }
69 }
70
71 std::sort(
72 xic_coord_tims_list.begin(),
73 xic_coord_tims_list.end(),
74 [](const XicCoordTims *pa, const XicCoordTims *pb) { return pa->rtTarget < pb->rtTarget; });
75 std::vector<std::size_t> tims_frameid_list;
76 try
77 {
78 tims_frameid_list = mp_timsData->getTimsMS1FrameIdsInRtRange(
79 xic_coord_tims_list[0]->rtTarget - m_retentionTimeAroundTarget,
80 xic_coord_tims_list.back()->rtTarget + m_retentionTimeAroundTarget);
81 }
82 catch(pappso::PappsoException &error)
83 {
84 throw pappso::PappsoException(QObject::tr("ERROR in %1 %2 %3:\n%4")
85 .arg(__FUNCTION__)
86 .arg(xic_coord_tims_list[0]->rtTarget)
87 .arg(xic_coord_tims_list.back()->rtTarget)
88 .arg(error.qwhat()));
89 }
90 monitor.setStatus(QObject::tr("extracting %1 XICs on %2 Tims frames")
91 .arg(xic_total_number)
92 .arg(tims_frameid_list.size()));
93 monitor.setTotalSteps(tims_frameid_list.size());
94
95 qDebug() << " tims_frameid_list.size()=" << tims_frameid_list.size();
96 qDebug() << " rt begin=" << xic_coord_tims_list[0]->rtTarget;
97 qDebug() << " rt end=" << xic_coord_tims_list.back()->rtTarget;
98 for(std::size_t frame_id : tims_frameid_list)
99 {
100 std::vector<XicCoordTims *>::iterator itXicListbegin = xic_coord_tims_list.begin();
101 std::vector<XicCoordTims *>::iterator itXicListend = xic_coord_tims_list.end();
102 qDebug();
103 TimsFrameCstSPtr frame_sptr = mp_timsData->getTimsFrameCstSPtrCached(frame_id);
104 qDebug();
105 double rtframe = frame_sptr.get()->getRtInSeconds();
106 qDebug();
107
108 double rtbeginframe = rtframe - m_retentionTimeAroundTarget;
109 double rtendframe = rtframe + m_retentionTimeAroundTarget;
110
111 if(rtbeginframe < 0)
112 rtbeginframe = 0;
113
114 qDebug() << rtbeginframe;
115 while((itXicListbegin != itXicListend) && ((*itXicListbegin)->rtTarget < rtbeginframe))
116 {
117 itXicListbegin++;
118 }
119 qDebug();
120 itXicListend = itXicListbegin;
121 while((itXicListend != xic_coord_tims_list.end()) && ((*itXicListend)->rtTarget < rtendframe))
122 {
123 itXicListend++;
124 }
125 frame_sptr.get()->extractTimsXicListInRtRange(
126 itXicListbegin, itXicListend, m_xicExtractMethod);
127
128 qDebug() << "" << frame_sptr.get()->getId();
129 monitor.count();
130 if(monitor.shouldIstop())
131 {
132 throw pappso::ExceptionInterrupted(QObject::tr("Xic extraction process interrupted"));
133 }
134 }
135 qDebug();
136}
virtual const QString & qwhat() const
TimsDirectXicExtractor(MsRunReaderSPtr &msrun_reader)
void protectedExtractXicCoordSPtrList(UiMonitorInterface &monitor, std::vector< XicCoordSPtr >::iterator it_xic_coord_list_begin, std::vector< XicCoordSPtr >::iterator it_xic_coord_list_end) override
double getRtInSeconds() const
std::size_t getId() const
void extractTimsXicListInRtRange(std::vector< XicCoordTims * >::iterator &itXicListbegin, std::vector< XicCoordTims * >::iterator &itXicListend, Enums::XicExtractMethod method) const
TimsXicExtractorInterface(MsRunReaderSPtr &msrun_reader)
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:57
std::shared_ptr< const TimsFrame > TimsFrameCstSPtr
Definition timsframe.h:44
coordinates of the XIC to extract and the resulting XIC after extraction