libpappsomspp
Library for mass spectrometry
msrunxicextractorinterface.h
Go to the documentation of this file.
1 /**
2  * \file pappsomspp/xicextractor/msrunxicextractor.h
3  * \date 07/05/2018
4  * \author Olivier Langella
5  * \brief base interface to build XICs on an MsRun file
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 #pragma once
29 
30 
31 #include "../msrun/msrunreader.h"
32 #include <memory>
33 #include <vector>
34 #include "../mzrange.h"
35 #include "../xic/xic.h"
36 
37 
38 namespace pappso
39 {
40 
41 class MsRunXicExtractorInterface;
42 typedef std::shared_ptr<MsRunXicExtractorInterface>
44 
45 class PMSPP_LIB_DECL MsRunXicExtractorInterface
46 {
47  protected:
48  struct MsRunXicExtractorPoints
49  {
50  std::size_t spectrum_index;
51  double rt;
52  };
53 
54  /** @brief class to read retention time points of MsRun
55  */
56  class MsRunXicExtractorReadPoints : public SpectrumCollectionHandlerInterface
57  {
58  private:
59  std::vector<MsRunXicExtractorPoints> &m_msrun_points;
60 
61  public:
62  MsRunXicExtractorReadPoints(
63  std::vector<MsRunXicExtractorPoints> &msrun_points)
64  : m_msrun_points(msrun_points){};
65 
66  virtual void
67  setQualifiedMassSpectrum(const QualifiedMassSpectrum &spectrum) override
68  {
69  if(spectrum.getMsLevel() == 1)
70  {
71  m_msrun_points.push_back(
72  {spectrum.getMassSpectrumId().getSpectrumIndex(),
73  spectrum.getRtInSeconds()});
74  }
75  }
76  virtual bool
77  needPeakList() const override
78  {
79  return false;
80  }
81  virtual void
82  loadingEnded() override
83  {
84  }
85  };
86 
87  MsRunReaderSPtr msp_msrun_reader;
88  XicExtractMethod m_xicExtractMethod = XicExtractMethod::max;
89 
90  /** @brief constructor is private, use the MsRunXicExtractorFactory
91  */
94  virtual ~MsRunXicExtractorInterface();
95 
96  public:
97  /** @brief set the XIC extraction method
98  */
99  void setXicExtractMethod(XicExtractMethod method); // sum or max
100 
101  /** @brief get a XIC on this MsRun at the given mass range
102  * @param mz_range mz range to extract
103  */
104  virtual XicCstSPtr getXicCstSPtr(const MzRange &mz_range) final;
105 
106  /** @brief get a XIC on this MsRun at the given mass range
107  * @param mz_range mz range to extract
108  * @param rt_begin begining of the XIC in seconds
109  * @param rt_end end of the XIC in seconds
110  */
111  virtual XicCstSPtr getXicCstSPtr(const MzRange &mz_range,
112  pappso::pappso_double rt_begin,
113  pappso::pappso_double rt_end) = 0;
114 
115  /** @brief extract a list of XIC given a list of mass to extract
116  */
117  virtual std::vector<XicCstSPtr>
118  getXicCstSPtrList(const std::vector<MzRange> &mz_range_list) = 0;
119 
120  const MsRunIdCstSPtr &getMsRunId() const;
121 };
122 
123 
124 } // namespace pappso
pappso::QualifiedMassSpectrum::getMsLevel
uint getMsLevel() const
Get the mass spectrum level.
Definition: qualifiedmassspectrum.cpp:232
pappso::pappso_double
double pappso_double
A type definition for doubles.
Definition: types.h:69
PMSPP_LIB_DECL
#define PMSPP_LIB_DECL
Definition: exportinmportconfig.h:14
pappso
tries to keep as much as possible monoisotopes, removing any possible C13 peaks
Definition: aa.cpp:39
pappso::MsRunReaderSPtr
std::shared_ptr< MsRunReader > MsRunReaderSPtr
Definition: msrunreader.h:172
pappso::MsRunIdCstSPtr
std::shared_ptr< const MsRunId > MsRunIdCstSPtr
Definition: msrunid.h:65
pappso::DataKind::rt
@ rt
Retention time.
pappso::MsRunXicExtractorInterface
Definition: msrunxicextractorinterface.h:64
pappso::MzRange
Definition: mzrange.h:67
pappso::XicExtractMethod
XicExtractMethod
Definition: types.h:204
pappso::QualifiedMassSpectrum
Class representing a fully specified mass spectrum.
Definition: qualifiedmassspectrum.h:86
pappso::XicCstSPtr
std::shared_ptr< const Xic > XicCstSPtr
Definition: xic.h:58
pappso::XicExtractMethod::max
@ max
maximum of intensities
pappso::QualifiedMassSpectrum::getMassSpectrumId
const MassSpectrumId & getMassSpectrumId() const
Get the MassSpectrumId.
Definition: qualifiedmassspectrum.cpp:146
pappso::MsRunXicExtractorInterfaceSp
std::shared_ptr< MsRunXicExtractorInterface > MsRunXicExtractorInterfaceSp
Definition: msrunxicextractorinterface.h:59
pappso::QualifiedMassSpectrum::getRtInSeconds
pappso_double getRtInSeconds() const
Get the retention time in seconds.
Definition: qualifiedmassspectrum.cpp:248