msrun.h 5.55 KB
Newer Older
1
2
3
4
5
6
7
8
9
/**
 * \filed core/msrun.h
 * \date 5/4/2017
 * \author Olivier Langella
 * \brief describes an MS run (chemical sample injected in a mass spectrometer)
 */


/*******************************************************************************
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
 * Copyright (c) 2017 Olivier Langella <Olivier.Langella@u-psud.fr>.
 *
 * This file is part of XTPcpp.
 *
 *     XTPcpp is free software: you can redistribute it and/or modify
 *     it under the terms of the GNU General Public License as published by
 *     the Free Software Foundation, either version 3 of the License, or
 *     (at your option) any later version.
 *
 *     XTPcpp is distributed in the hope that it will be useful,
 *     but WITHOUT ANY WARRANTY; without even the implied warranty of
 *     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *     GNU General Public License for more details.
 *
 *     You should have received a copy of the GNU General Public License
 *     along with XTPcpp.  If not, see <http://www.gnu.org/licenses/>.
 *
 * Contributors:
 *     Olivier Langella <Olivier.Langella@u-psud.fr> - initial API and
 *implementation
 ******************************************************************************/
31
32


33
#pragma once
34
35
36

#include <memory>
#include <QString>
Langella Olivier's avatar
Langella Olivier committed
37
#include <QVariant>
Langella Olivier's avatar
Langella Olivier committed
38
#include <pappsomspp/msrun/msrunid.h>
Langella Olivier's avatar
Langella Olivier committed
39
#include <pappsomspp/msrun/msrunreader.h>
40
#include <pappsomspp/msrun/alignment/msrunretentiontime.h>
Langella Olivier's avatar
Langella Olivier committed
41
#include <pappsomspp/xicextractor/msrunxicextractorinterface.h>
42
#include <pappsomspp/peptide/peptide.h>
Olivier Langella's avatar
Olivier Langella committed
43
#include "../utils/types.h"
44
#include "../utils/peptideevidencestore.h"
45
#include <utils/msrunstatisticshandler.h>
46

Renne Thomas's avatar
Renne Thomas committed
47
48
49
class MsRunAlignmentGroup;
typedef std::shared_ptr<MsRunAlignmentGroup> MsRunAlignmentGroupSp;

50
51
52
class MsRun;
typedef std::shared_ptr<MsRun> MsRunSp;

53
class MsRun : public pappso::MsRunId
54
{
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
  public:
  MsRun(const QString &location);
  MsRun(const MsRun &other);
  ~MsRun();


  /** \brief set MS run statistics
   * any statistics on this MS run file
   */
  virtual void setMsRunStatistics(MsRunStatistics param, const QVariant &value);


  /** \brief get MS run statistics
   */
  virtual const QVariant getMsRunStatistics(MsRunStatistics param) const;

  /** \brief get MS run statistics map
   */
  virtual const std::map<MsRunStatistics, QVariant> &
  getMsRunStatisticsMap() const;

76
77
78
  /** \brief find the msRun file and return an msrunreader shared pointer on it
   */
  pappso::MsRunReaderSPtr findMsRunFile();
79

80
  pappso::MsRunReaderSPtr &getMsRunReaderSPtr();
Langella Olivier's avatar
Langella Olivier committed
81

82
83
84
  /** @brief release shared pointer on MSrun reader
   */
  void freeMsRunReaderSp();
85
86

  void checkMsRunStatistics();
87
  void checkMsRunStatistics(MsRunStatisticsHandler *currentHandler);
88

Langella Olivier's avatar
Langella Olivier committed
89
  pappso::MsRunXicExtractorInterfaceSp getMsRunXicExtractorInterfaceSp();
90

91
92
93
94
  void
  buildMsRunRetentionTime(const PeptideEvidenceStore &peptide_evidence_store);
  void computeMsRunRetentionTime();
  void clearMsRunRetentionTime();
95
96
  pappso::MsRunRetentionTime<const pappso::Peptide *> *
  getMsRunRetentionTimePtr();
97
  void setTimstofMs2CentroidParameters(const QString &centroid_parameters);
Renne Thomas's avatar
Renne Thomas committed
98
99
  MsRunAlignmentGroupSp getAlignmentGroup();
  void setAlignmentGroup(MsRunAlignmentGroupSp new_group);
100

101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120

  /** @brief get a mass spectrum from this MSrun with the given spectrum index
   * @param spectrum_index spectrum index in this MSrun
   * @return Mass Spectrum shared pointer
   */
  pappso::MassSpectrumCstSPtr
  getMassSpectrumCstSPtrBySpectrumIndex(std::size_t spectrum_index);


  /** @brief get a mass spectrum from this MSrun with the given scan number
   * the scan number is deprecated in favor of the spectrum index.
   * Spectrum index is always available (order of spectrum in the data file)
   * scan number is a given name by the constructor and not as reliable as the
   * spectrum index
   * @param scan_number the scan number
   * @return Mass Spectrum shared pointer
   */
  pappso::MassSpectrumCstSPtr
  getMassSpectrumCstSPtrByScanNumber(std::size_t scan_number);

121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146

  /** @brief get a qualified mass spectrum from this MSrun with the given
   * spectrum index
   * @param spectrum_index spectrum index in this MSrun
   * @param data boolean if true, retrieves the peak list, if false, only give
   * mass spectrum informations
   * @return QualifiedMassSpectrum
   */
  pappso::QualifiedMassSpectrum
  getQualifiedMassSpectrumBySpectrumIndex(std::size_t spectrum_index,
                                          bool data);


  /** @brief get a qualified mass spectrum from this MSrun with the given scan
   * number the scan number is deprecated in favor of the spectrum index.
   * Spectrum index is always available (order of spectrum in the data file)
   * scan number is a given name by the constructor and not as reliable as the
   * spectrum index
   * @param scan_number the scan number
   * @param data boolean if true, retrieves the peak list, if false, only give
   * mass spectrum informations
   * @return QualifiedMassSpectrum
   */
  pappso::QualifiedMassSpectrum
  getQualifiedMassSpectrumByScanNumber(std::size_t scan_number, bool data);

147
148
149
150
151
152
153
154

  /** @brief finds the spectrum index corresponding to a scan number
   *
   * @param scan_number the scan number to convert
   * @return spectrum index or an exception
   */
  std::size_t scanNumber2SpectrumIndex(std::size_t scan_number);

Langella Olivier's avatar
Langella Olivier committed
155
156
157
  private:
  void buildMsRunReaderSp();

158
159
160
  private:
  std::map<MsRunStatistics, QVariant> _param_stats;

161
  pappso::MsRunReaderSPtr _msrun_reader_sp;
162

Langella Olivier's avatar
Langella Olivier committed
163
  pappso::MsRunXicExtractorInterfaceSp _xic_extractor_sp;
164
165
166

  pappso::MsRunRetentionTime<const pappso::Peptide *> *mpa_msrunRetentionTime =
    nullptr;
167

Renne Thomas's avatar
Renne Thomas committed
168
  MsRunAlignmentGroupSp msp_alignmentGroup;
169
};
170
171
172


Q_DECLARE_METATYPE(MsRunSp)