peptideevidence.h 8.1 KB
Newer Older
1
2
3
4
/**
 * \file utils/peptideevidence.h
 * \date 18/11/2017
 * \author Olivier Langella
5
6
 * \brief peptide evidence : a peptide sequence + spectrum + identification
 * engine evaluation (psm)
7
8
9
10
 */


/*******************************************************************************
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
 * 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
 ******************************************************************************/
32
#pragma once
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49

#include <pappsomspp/types.h>
#include "peptidextp.h"
#include "identification_sources/identificationdatasource.h"
#include "automaticfilterparameters.h"
#include "msrun.h"

#include "../grouping/groupingexperiment.h"

class PeptideEvidence;

/** \brief shared pointer on a Peptide object
 */
typedef std::shared_ptr<PeptideEvidence> PeptideEvidenceSp;

class PeptideEvidence
{
50
  public:
51
52
53
54
  /** @brief build a peptide evidence either with a scan number (deprecated)
   * @param msrunid_sp the MSrun on which the peptide evidence was made
   * @param scan_index integer to store the scan number
   */
55
  PeptideEvidence(MsRun *msrunid_sp, std::size_t scan_index);
56
57
58
59
60
61
62
63
64
65
66

  /** @brief build a peptide evidence either with a scan number or a spectrum
   * index
   * @param msrunid_sp the MSrun on which the peptide evidence was made
   * @param scan_index integer to store either a scan number (deprecated) or a
   * spectrum index
   * @param isSpectrumIndex to tell if scan index is a spectrum index
   */
  PeptideEvidence(MsRun *msrunid_sp,
                  std::size_t scan_index,
                  bool isSpectrumIndex);
67
  PeptideEvidence(const PeptideEvidence &other);
68
  virtual ~PeptideEvidence();
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
  std::size_t getHashSampleScan() const;
  std::size_t getHashPeptideMassSample() const;

  PeptideEvidenceSp makePeptideEvidenceSp() const;

  void setRetentionTime(pappso::pappso_double rt);
  void setEvalue(pappso::pappso_double evalue);

  /** @brief get experimental mass of this peptide
   * @return the computed mass given the precursor measured mass and the deduced
   * peptide charge
   */
  pappso::pappso_double getExperimentalMass() const;

  /** @brief get experimental MH+ of this peptide
   * @return getExperimentalMass + MHPLUS
   */
  pappso::pappso_double getExperimentalMhplus() const;

  /** @brief get experimental mz of this peptide
   * @return the real mass measured (precuror mass) by the spectrometer
   */
  pappso::pappso_double getExperimentalMz() const;


  /** @brief set experimental mass of this peptide
   * @arg exp_mass the computed mass given the precursor measured mass and the
   * deduced peptide charge
   */
  void setExperimentalMass(pappso::pappso_double exp_mass);


  /** \brief set specific parameter value
   */
  virtual void setParam(PeptideEvidenceParam param, const QVariant &value);
  /** \brief get specific parameter value
   */
  virtual const QVariant getParam(PeptideEvidenceParam param) const;

  const std::map<PeptideEvidenceParam, QVariant> &getParamList() const;


  void setCharge(unsigned int charge);
  void setPeptideXtpSp(PeptideXtpSp peptide);
  void
  setIdentificationDataSource(IdentificationDataSource *identification_source);


  /** @brief sets the identification engine
   * by default, this is the identification engine of the datasource
   */
  void setIdentificationEngine(IdentificationEngine identification_engine);

  /** @brief get the identification engine
   * by default, this is the identification engine of the datasource
   */
  IdentificationEngine getIdentificationEngine() const;

  void setChecked(bool arg1);
  bool isChecked() const;
  bool isValid() const;
  bool isValidAndChecked() const;
  bool isGrouped() const;

  const MsRun *getMsRunP() const;
134
  MsRun *getMsRunPtr();
135
  IdentificationDataSource *getIdentificationDataSource() const;
136
  unsigned int getScanNumber() const;
137
138
139
140
141
142

  /** @brief get retention time of this PSM in seconds
   * the retention time must have been present when reading MS identification
   * results. If no retention time was set, this returns O
   * @return retention time in seconds or zero if data is missing
   */
143
  pappso::pappso_double getRetentionTime() const;
144
145
146
147
148
149
150
151
152

  /** @brief get retention time of this PSM in seconds by all means
   *
   * if retention time is missing, this tries to guess it by all means. It will
   * try to look at mz data file.
   * This could be time consuming.
   * @return retention time in seconds or zero if data is missing
   */
  pappso::pappso_double getHardenedRetentionTime() const;
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
  unsigned int getCharge() const;
  const PeptideXtpSp &getPeptideXtpSp() const;
  pappso::pappso_double getEvalue() const;

  void setGrpPeptideSp(const pappso::GrpPeptideSp &sp_grp_peptide);
  const pappso::GrpPeptideSp &getGrpPeptideSp() const;

  /** @brief validate or invalidate peptides and proteins based automatic
   * filters and manual checks
   * */
  void updateAutomaticFilters(
    const AutomaticFilterParameters &automatic_filter_parameters);

  /** @brief get delta between theoretical mhplus mass and mhplus experimental
   * mass mhplus experimental mass - theoretical mhplus mass
   */
169
  pappso::pappso_double getDeltaMass() const;
170
171
172
173
174

  /** @brief get delta in ppm between theoretical mhplus mass and mhplus
   * experimental mass
   * @return mhplus experimental mass - theoretical mhplus mass
   */
175
  pappso::pappso_double getPpmDeltaMass() const;
176
177
178
179
180

  /** @brief get theoretical (not observed) m/z based on peptide composition and
   * charge
   * @return theoretical mz mass
   */
181
  pappso::pappso_double getTheoreticalMz() const;
182
183

  ValidationState getValidationState() const;
184
185

  /** @brief get the mass spectrum associated to this peptide evidence
186
   * @return pappso::MassSpectrumCstSPtr or an exception
187
   */
188
  pappso::MassSpectrumCstSPtr getMassSpectrumCstSPtr() const;
189

190
191
192
193
194
195
196
197

  /** @brief get the qualified mass spectrum associated to this peptide evidence
   * @param data boolean if true, retrieves the peak list, if false, only give
   * mass spectrum informations
   * @return QualifiedMassSpectrum or an exception
   */
  pappso::QualifiedMassSpectrum getQualifiedMassSpectrum(bool data) const;

198
199
200
201
202
  /** @brief get the spectrum index of the mass spectrum associated to this
   * peptide evidence
   * @return spectrum index or not found exception
   */
  std::size_t getSpectrumIndex() const;
203
204
205
206
207
208
209
210
211
212
  
  
  /** @brief get the spectrum index from the scan number
   * 
   * finds a spectrum index using a scan number if necessary
   * 
   * @return spectrum_index or not found exception
   * 
   */ 
  std::size_t getSpectrumIndexByScanNumber() const;
213

214
215
216
217
218
219

  /** @brief get HTML sequence of the peptide
   * HTML sequence can be colorized depending on modifications
   */
  QString getHtmlSequence() const;

220
221
222
  private:
  static std::hash<std::string> _hash_fn;
  MsRun *_msrunid_sp;
223
224
  std::size_t m_scan_number = 0;
  bool m_isSpectrumIndex;
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
  size_t _hash_sample_scan;
  pappso::GrpPeptideSp _sp_grp_peptide;
  PeptideXtpSp _peptide_sp;
  pappso::pappso_double _rt;
  pappso::pappso_double _evalue = 0;
  pappso::pappso_double _exp_mass;
  unsigned int _charge;
  IdentificationDataSource *_p_identification_source = nullptr;
  std::map<PeptideEvidenceParam, QVariant> _params;

  /** @brief manually checked by user (true by default)
   */
  bool _checked = true;

  /** @brief automatic filter result (false by default)
   */
  bool _proxy_valid = false;

  /** @brief the search/identification engine that found this evidence
   */
  IdentificationEngine _identification_engine;
246
};