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