libpappsomspp
Library for mass spectrometry
msrunxicextractordisk.h
Go to the documentation of this file.
1 /**
2  * \file pappsomspp/xicextractor/private/msrunxicextractordisk.h
3  * \date 12/05/2018
4  * \author Olivier Langella
5  * \brief MsRunReader based XIC extractor featuring disk cache
6  */
7 
8 /*******************************************************************************
9  * Copyright (c) 2018 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 
29 #pragma once
30 
31 
32 #include "msrunxicextractor.h"
33 #include "msrunslice.h"
34 #include <QTemporaryDir>
35 #include <deque>
36 #include <QMutex>
37 
38 
39 class MsRunXicExtractorFactory;
40 
41 namespace pappso
42 {
43 
45 {
47 
48  public:
51  virtual ~MsRunXicExtractorDisk();
52 
53 
54  protected:
56  const QDir &temporary_dir);
57 
59  UiMonitorInterface &monitor,
60  std::vector<XicCoordSPtr>::iterator it_xic_coord_list_begin,
61  std::vector<XicCoordSPtr>::iterator it_xic_coord_list_end) override;
62 
63 
64  void prepareExtractor();
65 
66  void serializeMsRun();
67 
68 
69  /** @brief store MassSpectrum slices (by daltons) for a given retention time
70  * @param slice_vector mass spectrum chunks (by daltons)
71  * @param ipos the position in the retention time vector
72  */
73  virtual void storeSlices(std::map<unsigned int, MassSpectrum> &slice_vector,
74  std::size_t ipos);
75 
76  /** @brief append a slice on disk (in a file)
77  * @param slice_number the slice number == dalton integer
78  * @param spectrum the part of the mass spectrum (mz/intensity) in the range
79  * of the slice number
80  * @param ipos the position in the retention time vector
81  */
82  void appendSliceOnDisk(unsigned int slice_number,
83  MassSpectrum &spectrum,
84  std::size_t ipos);
85 
86  /** @brief retrieve all the slices corresponding to a given mz_range
87  * @param mz_range desired mz range
88  */
89  std::vector<MsRunSliceSPtr> acquireSlices(const MzRange &mz_range);
90 
91  /** @brief get one slice from disk by her slice number (dalton)
92  * @param slice_number the slice number == dalton integer
93  */
94  MsRunSliceSPtr unserializeSlice(unsigned int slice_number);
95 
96  virtual void endPwizRead();
97 
98  protected:
100  QTemporaryDir *mpa_temporaryDirectory = nullptr;
101  std::vector<pappso::pappso_double> m_retentionTimeList;
102 
105 
106  std::size_t m_rtSize = 0;
107 
108  std::deque<MsRunSliceSPtr> m_msRunSliceListCache;
109 
110  QMutex m_mutex;
111 
112 
113  private:
114  void extractOneXicCoord(XicCoord &xic_coord);
115 };
116 
117 
118 } // namespace pappso
Class to represent a mass spectrum.
Definition: massspectrum.h:71
std::vector< MsRunSliceSPtr > acquireSlices(const MzRange &mz_range)
retrieve all the slices corresponding to a given mz_range
std::vector< pappso::pappso_double > m_retentionTimeList
MsRunXicExtractorDisk(MsRunReaderSPtr &msrun_reader)
std::deque< MsRunSliceSPtr > m_msRunSliceListCache
virtual void storeSlices(std::map< unsigned int, MassSpectrum > &slice_vector, std::size_t ipos)
store MassSpectrum slices (by daltons) for a given retention time
void extractOneXicCoord(XicCoord &xic_coord)
void appendSliceOnDisk(unsigned int slice_number, MassSpectrum &spectrum, std::size_t ipos)
append a slice on disk (in a file)
virtual void protectedExtractXicCoordSPtrList(UiMonitorInterface &monitor, std::vector< XicCoordSPtr >::iterator it_xic_coord_list_begin, std::vector< XicCoordSPtr >::iterator it_xic_coord_list_end) override
MsRunSliceSPtr unserializeSlice(unsigned int slice_number)
get one slice from disk by her slice number (dalton)
one mz slice (1 dalton) of an MsRun
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:185
std::shared_ptr< const MsRunSlice > MsRunSliceSPtr
Definition: msrunslice.h:39
double pappso_double
A type definition for doubles.
Definition: types.h:49
coordinates of the XIC to extract and the resulting XIC after extraction
Definition: xiccoord.h:54