libpappsomspp
Library for mass spectrometry
peptide.h
Go to the documentation of this file.
1 /**
2  * \file pappsomspp/peptide/peptide.h
3  * \date 7/3/2015
4  * \author Olivier Langella
5  * \brief peptide model
6  */
7 
8 /*******************************************************************************
9  * Copyright (c) 2015 Olivier Langella <Olivier.Langella@moulon.inra.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  * Contributors:
27  * Olivier Langella <Olivier.Langella@moulon.inra.fr> - initial API and
28  *implementation
29  ******************************************************************************/
30 
31 #pragma once
32 
33 
34 #include <vector>
35 #include <memory>
36 #include <QString>
37 #include "../amino_acid/aa.h"
38 #include "peptideinterface.h"
39 #include <cstdint>
40 #include "../exportinmportconfig.h"
41 
42 namespace pappso
43 {
44 
45 enum class PeptideDirection : std::int8_t
46 {
47  Nter = 0,
48  Cter = 1
49 };
50 
51 
52 /** \brief tells if an ion is Nter
53  * \param ion_type the ion to test
54  */
55 bool peptideIonIsNter(PeptideIon ion_type);
56 
57 
58 /** \brief get the direction of a peptide ion
59  * \param ion_type the ion to test
60  * \return the peptide direction
61  */
63 
64 enum class PeptideIonNter
65 {
66  b,
67  bstar,
68  bo,
69  a,
70  astar,
71  ao,
72  bp,
73  c
74 };
75 
76 
77 enum class PeptideIonCter
78 {
79  y,
80  ystar,
81  yo,
82  z,
83  yp,
84  x
85 };
86 
87 class Peptide;
88 
89 typedef std::shared_ptr<const Peptide> PeptideSp;
90 typedef std::shared_ptr<Peptide> NoConstPeptideSp;
91 
93 {
94  protected:
95  std::vector<Aa> m_aaVec;
96  pappso_double m_proxyMass = -1;
97 
98  public:
99  Peptide(const QString &pepstr);
100  virtual ~Peptide();
101  Peptide(const Peptide &peptide);
102  friend bool
103  operator<(const Peptide &l, const Peptide &r)
104  {
105  return (l.m_aaVec < r.m_aaVec);
106  }
107  friend bool
108  operator==(const Peptide &l, const Peptide &r)
109  {
110  return (l.m_aaVec == r.m_aaVec);
111  }
112 
113 
114  Peptide(Peptide &&toCopy);
115 
116  PeptideSp makePeptideSp() const;
117  NoConstPeptideSp makeNoConstPeptideSp() const;
118 
119  /** @brief adds a modification to amino acid sequence
120  * @param aaModification pointer on modification to add
121  * @param position position in the amino acid sequence (starts at 0)
122  * */
123  void addAaModification(AaModificationP aaModification, unsigned int position);
124 
125  std::vector<Aa>::iterator
127  {
128  return m_aaVec.begin();
129  }
130 
131  std::vector<Aa>::iterator
132  end()
133  {
134  return m_aaVec.end();
135  }
136 
137  std::vector<Aa>::const_iterator
138  begin() const
139  {
140  return m_aaVec.begin();
141  }
142 
143  std::vector<Aa>::const_iterator
144  end() const
145  {
146  return m_aaVec.end();
147  }
148 
149  std::vector<Aa>::const_reverse_iterator
150  rbegin() const
151  {
152  return m_aaVec.rbegin();
153  }
154 
155  std::vector<Aa>::const_reverse_iterator
156  rend() const
157  {
158  return m_aaVec.rend();
159  }
160 
161  Aa &getAa(unsigned int position);
162  const Aa &getConstAa(unsigned int position) const;
163 
164 
165  pappso_double getMass();
167  getMass() const override
168  {
169  return m_proxyMass;
170  };
171 
172  virtual int getNumberOfAtom(AtomIsotopeSurvey atom) const override;
173  virtual int getNumberOfIsotope(Isotope isotope) const override;
174 
175  /** \brief print amino acid sequence without modifications */
176  const QString getSequence() const override;
177  unsigned int
178  size() const override
179  {
180  return m_aaVec.size();
181  };
182 
183  /** @brief count modification occurence
184  * @param mod modification to look for
185  * @result number of occurences
186  */
187  unsigned int getNumberOfModification(AaModificationP mod) const;
188 
189  /** @brief count modification occurence
190  * @param mod modification to look for
191  * @param aa_list amino acid list targets (one letter code)
192  * @result number of occurences
193  */
194  unsigned int countModificationOnAa(AaModificationP mod,
195  const std::vector<char> &aa_list) const;
196 
197  /** @brief replaces all occurences of a modification by a new one
198  * @param oldmod modification to change
199  * @param newmod new modification
200  */
201  void replaceAaModification(AaModificationP oldmod, AaModificationP newmod);
202 
203  /** @brief removes all occurences of a modification
204  * @param mod modification to remove
205  */
206  void removeAaModification(AaModificationP mod);
207 
208  /** @brief get modification positions
209  * @param mod modification to look for
210  * @result vector containing positions (from 0 to size-1)
211  */
212  std::vector<unsigned int>
213  getModificationPositionList(AaModificationP mod) const;
214 
215  /** @brief get modification positions
216  * @param mod modification to look for
217  * @param aa_list amino acid list targets (one letter code)
218  * @result vector containing positions (from 0 to size-1)
219  */
220  std::vector<unsigned int>
221  getModificationPositionList(AaModificationP mod,
222  const std::vector<char> &aa_list) const;
223 
224  /** @brief get positions of one amino acid in peptide
225  * @param aa the one letter code of the amino acid
226  * @result vector containing positions (from 0 to size-1) */
227  std::vector<unsigned int> getAaPositionList(char aa) const;
228  std::vector<unsigned int> getAaPositionList(std::list<char> list_aa) const;
229 
230  /** \brief print modification except internal modifications */
231  const QString toString() const;
232  /** \brief print all modifications */
233  const QString toAbsoluteString() const;
234  /** \brief get all sequence string with modifications and converting Leucine
235  * to Isoleucine */
236  const QString getLiAbsoluteString() const;
237 
238  AaModificationP getInternalNterModification() const;
239  AaModificationP getInternalCterModification() const;
240  void removeInternalNterModification();
241  void removeInternalCterModification();
242 
243  void setInternalNterModification(AaModificationP mod);
244  void setInternalCterModification(AaModificationP mod);
245 
246 
247  void rotate();
248  void reverse();
249  /** @brief tells if the peptide sequence is a palindrome
250  */
251  virtual bool isPalindrome() const override;
252  void replaceLeucineIsoleucine();
253  void removeNterAminoAcid();
254  void removeCterAminoAcid();
255 };
256 
257 
258 } // namespace pappso
pappso::PeptideIonNter
PeptideIonNter
Definition: peptide.h:65
pappso::pappso_double
double pappso_double
A type definition for doubles.
Definition: types.h:48
pappso::Peptide::begin
std::vector< Aa >::iterator begin()
Definition: peptide.h:126
pappso::operator<
bool operator<(Aa const &l, Aa const &r)
Definition: aa.cpp:286
pappso::Peptide::size
unsigned int size() const override
Definition: peptide.h:178
pappso::Peptide::end
std::vector< Aa >::iterator end()
Definition: peptide.h:132
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 and changes multichar...
Definition: aa.cpp:39
pappso::Isotope
Isotope
Definition: types.h:91
pappso::Peptide::getMass
pappso_double getMass() const override
Definition: peptide.h:167
pappso::PeptideIonCter::y
@ y
pappso::PeptideIon
PeptideIon
PeptideIon enum defines all types of ions (Nter or Cter)
Definition: types.h:351
pappso::Peptide::end
std::vector< Aa >::const_iterator end() const
Definition: peptide.h:144
pappso::Peptide
Definition: peptide.h:93
pappso::PeptideIonCter::x
@ x
peptideinterface.h
pappso::Peptide::operator==
friend bool operator==(const Peptide &l, const Peptide &r)
Definition: peptide.h:108
pappso::PeptideInterface
Definition: peptideinterface.h:43
pappso::Peptide::m_aaVec
std::vector< Aa > m_aaVec
Definition: peptide.h:95
pappso::Peptide::rbegin
std::vector< Aa >::const_reverse_iterator rbegin() const
Definition: peptide.h:150
pappso::PeptideIonCter
PeptideIonCter
Definition: peptide.h:78
pappso::Peptide::rend
std::vector< Aa >::const_reverse_iterator rend() const
Definition: peptide.h:156
pappso::peptideIonIsNter
bool peptideIonIsNter(PeptideIon ion_type)
tells if an ion is Nter
Definition: peptide.cpp:44
pappso::PeptideIonNter::b
@ b
pappso::getPeptideIonDirection
PeptideDirection getPeptideIonDirection(PeptideIon ion_type)
get the direction of a peptide ion
Definition: peptide.cpp:54
pappso::PeptideDirection
PeptideDirection
Definition: peptide.h:46
pappso::PeptideDirection::Nter
@ Nter
pappso::Axis::unset
@ unset
pappso::PeptideSp
std::shared_ptr< const Peptide > PeptideSp
Definition: aamodification.h:47
pappso::Aa
Definition: aa.h:45
pappso::AaModification
Definition: aamodification.h:57
pappso::NoConstPeptideSp
std::shared_ptr< Peptide > NoConstPeptideSp
Definition: peptide.h:90
pappso::AtomIsotopeSurvey
AtomIsotopeSurvey
Definition: types.h:76
pappso::Peptide::begin
std::vector< Aa >::const_iterator begin() const
Definition: peptide.h:138