ProteoWizard
Modification.hpp
Go to the documentation of this file.
1 //
2 // $Id$
3 //
4 //
5 // Original author: Matt Chambers <matt.chambers .@. vanderbilt.edu>
6 //
7 // Copyright 2006 Louis Warschaw Prostate Cancer Center
8 // Cedars Sinai Medical Center, Los Angeles, California 90048
9 // Copyright 2008 Vanderbilt University - Nashville, TN 37232
10 //
11 // Licensed under the Apache License, Version 2.0 (the "License");
12 // you may not use this file except in compliance with the License.
13 // You may obtain a copy of the License at
14 //
15 // http://www.apache.org/licenses/LICENSE-2.0
16 //
17 // Unless required by applicable law or agreed to in writing, software
18 // distributed under the License is distributed on an "AS IS" BASIS,
19 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
20 // See the License for the specific language governing permissions and
21 // limitations under the License.
22 //
23 
24 
25 #ifndef _MODIFICATION_HPP_
26 #define _MODIFICATION_HPP_
27 
28 
30 #include "Peptide.hpp"
31 #include <string>
33 #include <boost/shared_ptr.hpp>
34 
35 
36 namespace pwiz {
37 namespace proteome {
38 
39 /// represents a post-translational modification (PTM)
40 /// modification formula or masses must be provided at instantiation
42 {
43  public:
44 
45  /// constructs a zero-mass modification (provided for MSVC compatibility)
47 
49  Modification(double monoisotopicDeltaMass,
50  double averageDeltaMass);
54 
55  /// returns true iff the mod was constructed with formula
56  bool hasFormula() const;
57 
58  /// returns the difference formula;
59  /// throws runtime_error if hasFormula() = false
60  const chemistry::Formula& formula() const;
61 
62  double monoisotopicDeltaMass() const;
63  double averageDeltaMass() const;
64 
65  /// returns true iff delta masses are equal
66  bool operator==(const Modification& rhs) const;
67 
68  /// returns true iff this mod has smaller delta masses
69  bool operator<(const Modification& rhs) const;
70 
71  private:
72  class Impl;
73  boost::shared_ptr<Impl> impl_;
74 };
75 
76 
77 /// represents a list of modifications on a single amino acid
79  : public std::vector<Modification> // TODO: make virtual wrapper
80 {
81  public:
82 
85  ModificationList(const std::vector<Modification>& mods);
86 
87  /// returns the sum of the monoisotopic delta masses of all modifications in the list
88  double monoisotopicDeltaMass() const;
89 
90  /// returns the sum of the average delta masses of all modifications in the list
91  double averageDeltaMass() const;
92 
93  /// returns true iff the list has equal modifications
94  bool operator==(const ModificationList& rhs) const;
95 
96  /// returns true iff the list has fewer modifications or one that's lesser than in the rhs list
97  bool operator<(const ModificationList& rhs) const;
98 };
99 
100 
101 /// maps peptide/protein sequence indexes (0-based) to a modification list
102 /// * ModificationMap::NTerminus() returns the index for specifying N terminal mods
103 /// * ModificationMap::CTerminus() returns the index for specifying C terminal mods
105  : public pwiz::util::virtual_map<int, ModificationList>
106 {
107  public:
108 
110 
111  // bring the const overloads into scope
121 
122  static int NTerminus();
123  static int CTerminus();
124 
125  /// returns the sum of the monoisotopic delta masses of all modifications in the map
126  double monoisotopicDeltaMass() const;
127 
128  /// returns the sum of the average delta masses of all modifications in the map
129  double averageDeltaMass() const;
130 
131  /// Returns an iterator pointing to the first element stored in the map. First is defined by the map's comparison operator, Compare.
132  virtual iterator begin();
133 
134  /// Returns an iterator pointing to the last element stored in the map; in other words, to the off-the-end value.
135  virtual iterator end();
136 
137  /// Returns a reverse_iterator pointing to the first element stored in the map. First is defined by the map's comparison operator, Compare.
139 
140  /// Returns a reverse_iterator pointing to the last element stored in the map; in other words, to the off-the-end value).
142 
143  /// If an element with the key x exists in the map, then a reference to its associated value is returned. Otherwise the pair x,T() is inserted into the map and a reference to the default object T() is returned.
144  virtual mapped_type& operator[](const key_type& x);
145 
146  /// Returns the pair (lower_bound(x), upper_bound(x)).
147  virtual std::pair<iterator, iterator> equal_range(const key_type& x);
148 
149  /// Searches the map for a pair with the key value x and returns an iterator to that pair if it is found. If such a pair is not found the value end() is returned.
150  virtual iterator find(const key_type& x);
151 
152  /// Returns a reference to the first entry with a key greater than or equal to x.
153  virtual iterator lower_bound(const key_type& x);
154 
155  /// Returns an iterator for the first entry with a key greater than x.
156  virtual iterator upper_bound(const key_type& x);
157 
158  /// Erases all elements from the self.
159  virtual void clear();
160 
161  /// Deletes the map element pointed to by the iterator position.
162  virtual void erase(iterator position);
163 
164  /// If the iterators start and finish point to the same map and last is reachable from first, all elements in the range [start, finish) are deleted from the map.
165  virtual void erase(iterator start, iterator finish);
166 
167  /// Deletes the element with the key value x from the map, if one exists. Returns 1 if x existed in the map, 0 otherwise.
168  virtual size_type erase(const key_type& x);
169 
170  /// If a value_type with the same key as x is not present in the map, then x is inserted into the map. Otherwise, the pair is not inserted.
171  virtual std::pair<iterator, bool> insert(const value_type& x);
172 
173  /// If a value_type with the same key as x is not present in the map, then x is inserted into the map. Otherwise, the pair is not inserted. A position may be supplied as a hint regarding where to do the insertion. If the insertion is done right after position, then it takes amortized constant time. Otherwise it takes O(log N) time.
175 
176  /// returns true iff the map has the same modifications
177  virtual bool operator==(const ModificationMap& rhs) const;
178 
179  /// returns true iff the map has fewer modified positions or one of the positions is less than in the rhs map
180  virtual bool operator<(const ModificationMap& rhs) const;
181 
182  private:
183 
187  class Impl;
188  boost::shared_ptr<Impl> impl_;
189  virtual void swap(ModificationMap&);
190  friend class Peptide::Impl; // allow only Peptide::Impl to construct a ModificationMap
191 };
192 
193 
194 } // namespace proteome
195 } // namespace pwiz
196 
197 
198 #endif // _MODIFICATION_HPP_
pwiz::proteome::ModificationMap
maps peptide/protein sequence indexes (0-based) to a modification list
Definition: Modification.hpp:106
pwiz::proteome::ModificationMap::ModificationMap
ModificationMap()
virtual_map.hpp
pwiz::proteome::ModificationMap::operator<
virtual bool operator<(const ModificationMap &rhs) const
returns true iff the map has fewer modified positions or one of the positions is less than in the rhs...
pwiz::proteome::Modification::Modification
Modification(const chemistry::Formula &formula)
pwiz
Definition: ChromatogramList_Filter.hpp:36
pwiz::proteome::Modification::operator<
bool operator<(const Modification &rhs) const
returns true iff this mod has smaller delta masses
pwiz::proteome::ModificationMap::upper_bound
virtual iterator upper_bound(const key_type &x)
Returns an iterator for the first entry with a key greater than x.
pwiz::proteome::ModificationMap::rbegin
virtual reverse_iterator rbegin()
Returns a reverse_iterator pointing to the first element stored in the map. First is defined by the m...
pwiz::proteome::ModificationMap::erase
virtual size_type erase(const key_type &x)
Deletes the element with the key value x from the map, if one exists. Returns 1 if x existed in the m...
pwiz::proteome::ModificationMap::insert
virtual std::pair< iterator, bool > insert(const value_type &x)
If a value_type with the same key as x is not present in the map, then x is inserted into the map....
pwiz::proteome::Modification
represents a post-translational modification (PTM) modification formula or masses must be provided at...
Definition: Modification.hpp:42
pwiz::proteome::ModificationMap::averageDeltaMass
double averageDeltaMass() const
returns the sum of the average delta masses of all modifications in the map
pwiz::proteome
Definition: AminoAcid.hpp:35
pwiz::proteome::Modification::hasFormula
bool hasFormula() const
returns true iff the mod was constructed with formula
pwiz::proteome::Modification::~Modification
~Modification()
pwiz::chemistry::Formula
class to represent a chemical formula
Definition: Chemistry.hpp:134
pwiz::proteome::ModificationMap::operator==
virtual bool operator==(const ModificationMap &rhs) const
returns true iff the map has the same modifications
pwiz::util::virtual_map< int, ModificationList >::key_type
BaseType::key_type key_type
Definition: virtual_map.hpp:44
pwiz::proteome::Modification::Modification
Modification(const Modification &)
PWIZ_API_DECL
#define PWIZ_API_DECL
Definition: Export.hpp:32
pwiz::proteome::Modification::impl_
boost::shared_ptr< Impl > impl_
Definition: Modification.hpp:72
pwiz::util::virtual_map< int, ModificationList >::mapped_type
BaseType::mapped_type mapped_type
Definition: virtual_map.hpp:49
pwiz::proteome::ModificationMap::CTerminus
static int CTerminus()
Export.hpp
pwiz::proteome::ModificationMap::operator=
ModificationMap & operator=(const ModificationMap &)
pwiz::proteome::ModificationMap::~ModificationMap
~ModificationMap()
pwiz::util::virtual_map< int, ModificationList >::size_type
BaseType::size_type size_type
Definition: virtual_map.hpp:48
pwiz::proteome::ModificationMap::erase
virtual void erase(iterator start, iterator finish)
If the iterators start and finish point to the same map and last is reachable from first,...
pwiz::proteome::ModificationMap::end
virtual iterator end()
Returns an iterator pointing to the last element stored in the map; in other words,...
pwiz::proteome::Modification::formula
const chemistry::Formula & formula() const
returns the difference formula; throws runtime_error if hasFormula() = false
pwiz::proteome::ModificationList::ModificationList
ModificationList()
pwiz::proteome::ModificationList::operator<
bool operator<(const ModificationList &rhs) const
returns true iff the list has fewer modifications or one that's lesser than in the rhs list
pwiz::proteome::ModificationList::ModificationList
ModificationList(const Modification &mod)
pwiz::proteome::ModificationList::monoisotopicDeltaMass
double monoisotopicDeltaMass() const
returns the sum of the monoisotopic delta masses of all modifications in the list
pwiz::util::virtual_map< int, ModificationList >::reverse_iterator
BaseType::reverse_iterator reverse_iterator
Definition: virtual_map.hpp:57
pwiz::proteome::Modification::operator==
bool operator==(const Modification &rhs) const
returns true iff delta masses are equal
pwiz::proteome::ModificationMap::lower_bound
virtual iterator lower_bound(const key_type &x)
Returns a reference to the first entry with a key greater than or equal to x.
x
KernelTraitsBase< Kernel >::space_type::abscissa_type x
Definition: MatchedFilter.hpp:142
pwiz::proteome::ModificationMap::monoisotopicDeltaMass
double monoisotopicDeltaMass() const
returns the sum of the monoisotopic delta masses of all modifications in the map
pwiz::proteome::Modification::Modification
Modification()
constructs a zero-mass modification (provided for MSVC compatibility)
pwiz::data::unimod::position
PWIZ_API_DECL Position position(CVID cvid=CVID_Unknown)
returns a Position corresponding to one of the following CVIDs: CVID_Unknown: Position::Anywhere MS_m...
pwiz::proteome::ModificationList::operator==
bool operator==(const ModificationList &rhs) const
returns true iff the list has equal modifications
pwiz::proteome::ModificationMap::swap
virtual void swap(ModificationMap &)
pwiz::proteome::ModificationMap::insert
virtual iterator insert(iterator position, const value_type &x)
If a value_type with the same key as x is not present in the map, then x is inserted into the map....
pwiz::proteome::ModificationMap::rend
virtual reverse_iterator rend()
Returns a reverse_iterator pointing to the last element stored in the map; in other words,...
pwiz::proteome::Modification::monoisotopicDeltaMass
double monoisotopicDeltaMass() const
pwiz::proteome::Modification::Modification
Modification(double monoisotopicDeltaMass, double averageDeltaMass)
pwiz::proteome::ModificationMap::operator[]
virtual mapped_type & operator[](const key_type &x)
If an element with the key x exists in the map, then a reference to its associated value is returned....
pwiz::util::virtual_map
a wrapper for std::map that will behave properly with polymorphism
Definition: virtual_map.hpp:39
pwiz::proteome::Modification::operator=
Modification & operator=(const Modification &)
pwiz::proteome::ModificationList::ModificationList
ModificationList(const std::vector< Modification > &mods)
pwiz::proteome::ModificationMap::impl_
boost::shared_ptr< Impl > impl_
Definition: Modification.hpp:187
pwiz::proteome::ModificationMap::ModificationMap
ModificationMap(const ModificationMap &other)
pwiz::proteome::ModificationMap::clear
virtual void clear()
Erases all elements from the self.
pwiz::proteome::ModificationMap::find
virtual iterator find(const key_type &x)
Searches the map for a pair with the key value x and returns an iterator to that pair if it is found....
pwiz::proteome::Modification::averageDeltaMass
double averageDeltaMass() const
pwiz::util::virtual_map< int, ModificationList >::iterator
BaseType::iterator iterator
Definition: virtual_map.hpp:55
pwiz::proteome::ModificationList
represents a list of modifications on a single amino acid
Definition: Modification.hpp:80
pwiz::proteome::ModificationMap::erase
virtual void erase(iterator position)
Deletes the map element pointed to by the iterator position.
pwiz::proteome::ModificationList::averageDeltaMass
double averageDeltaMass() const
returns the sum of the average delta masses of all modifications in the list
pwiz::proteome::ModificationMap::equal_range
virtual std::pair< iterator, iterator > equal_range(const key_type &x)
Returns the pair (lower_bound(x), upper_bound(x)).
pwiz::proteome::ModificationMap::NTerminus
static int NTerminus()
pwiz::proteome::ModificationMap::begin
virtual iterator begin()
Returns an iterator pointing to the first element stored in the map. First is defined by the map's co...
Peptide.hpp
pwiz::util::virtual_map< int, ModificationList >::value_type
BaseType::value_type value_type
Definition: virtual_map.hpp:45