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  virtual XicCstSPtr getXicCstSPtr(const MzRange &mz_range,
53  pappso::pappso_double rt_begin,
54  pappso::pappso_double rt_end) override;
55  virtual std::vector<XicCstSPtr>
56  getXicCstSPtrList(const std::vector<MzRange> &mz_range_list) override;
57 
58 
59  protected:
61  const QDir &temporary_dir);
62 
63  void prepareExtractor();
64 
65  void serializeMsRun();
66 
67 
68  /** @brief store MassSpectrum slices (by daltons) for a given retention time
69  * @param slice_vector mass spectrum chunks (by daltons)
70  * @param ipos the position in the retention time vector
71  */
72  virtual void storeSlices(std::map<unsigned int, MassSpectrum> &slice_vector,
73  std::size_t ipos);
74 
75  /** @brief append a slice on disk (in a file)
76  * @param slice_number the slice number == dalton integer
77  * @param spectrum the part of the mass spectrum (mz/intensity) in the range
78  * of the slice number
79  * @param ipos the position in the retention time vector
80  */
81  void appendSliceOnDisk(unsigned int slice_number,
82  MassSpectrum &spectrum,
83  std::size_t ipos);
84 
85  /** @brief retrieve all the slices corresponding to a given mz_range
86  * @param mz_range desired mz range
87  */
88  std::vector<MsRunSliceSPtr> acquireSlices(const MzRange &mz_range);
89 
90  /** @brief get one slice from disk by her slice number (dalton)
91  * @param slice_number the slice number == dalton integer
92  */
93  MsRunSliceSPtr unserializeSlice(unsigned int slice_number);
94 
95  virtual void endPwizRead();
96 
97  protected:
99  QTemporaryDir *mpa_temporaryDirectory = nullptr;
100  std::vector<pappso::pappso_double> m_retentionTimeList;
101 
104 
105  std::size_t m_rtSize = 0;
106 
107  std::deque<MsRunSliceSPtr> m_msRunSliceListCache;
108 
109  QMutex m_mutex;
110 };
111 
112 
113 } // 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 appendSliceOnDisk(unsigned int slice_number, MassSpectrum &spectrum, std::size_t ipos)
append a slice on disk (in a file)
virtual std::vector< XicCstSPtr > getXicCstSPtrList(const std::vector< MzRange > &mz_range_list) override
extract a list of XIC given a list of mass to extract
virtual XicCstSPtr getXicCstSPtr(const MzRange &mz_range, pappso::pappso_double rt_begin, pappso::pappso_double rt_end) override
get a XIC on this MsRun at the given mass range
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:151
std::shared_ptr< const Xic > XicCstSPtr
Definition: xic.h:37
std::shared_ptr< const MsRunSlice > MsRunSliceSPtr
Definition: msrunslice.h:39
double pappso_double
A type definition for doubles.
Definition: types.h:48