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
36namespace pwiz {
37namespace 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
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
112 using pwiz::util::virtual_map<int, ModificationList>::begin;
114 using pwiz::util::virtual_map<int, ModificationList>::rbegin;
116 using pwiz::util::virtual_map<int, ModificationList>::operator[];
117 using pwiz::util::virtual_map<int, ModificationList>::equal_range;
119 using pwiz::util::virtual_map<int, ModificationList>::lower_bound;
120 using pwiz::util::virtual_map<int, ModificationList>::upper_bound;
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.
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.
154
155 /// Returns an iterator for the first entry with a key greater than 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.
174 virtual iterator insert(iterator position, const value_type& x);
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_
#define PWIZ_API_DECL
Definition Export.hpp:32
KernelTraitsBase< Kernel >::space_type::abscissa_type x
class to represent a chemical formula
represents a post-translational modification (PTM) modification formula or masses must be provided at...
Modification(double monoisotopicDeltaMass, double averageDeltaMass)
Modification()
constructs a zero-mass modification (provided for MSVC compatibility)
boost::shared_ptr< Impl > impl_
Modification(const Modification &)
bool operator<(const Modification &rhs) const
returns true iff this mod has smaller delta masses
const chemistry::Formula & formula() const
returns the difference formula; throws runtime_error if hasFormula() = false
Modification(const chemistry::Formula &formula)
bool operator==(const Modification &rhs) const
returns true iff delta masses are equal
double averageDeltaMass() const
Modification & operator=(const Modification &)
double monoisotopicDeltaMass() const
bool hasFormula() const
returns true iff the mod was constructed with formula
represents a list of modifications on a single amino acid
bool operator<(const ModificationList &rhs) const
returns true iff the list has fewer modifications or one that's lesser than in the rhs list
ModificationList(const std::vector< Modification > &mods)
double monoisotopicDeltaMass() const
returns the sum of the monoisotopic delta masses of all modifications in the list
double averageDeltaMass() const
returns the sum of the average delta masses of all modifications in the list
bool operator==(const ModificationList &rhs) const
returns true iff the list has equal modifications
ModificationList(const Modification &mod)
maps peptide/protein sequence indexes (0-based) to a modification list
boost::shared_ptr< Impl > impl_
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....
ModificationMap & operator=(const ModificationMap &)
virtual iterator upper_bound(const key_type &x)
Returns an iterator for the first entry with a key greater than x.
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....
virtual void swap(ModificationMap &)
virtual iterator lower_bound(const key_type &x)
Returns a reference to the first entry with a key greater than or equal to x.
double monoisotopicDeltaMass() const
returns the sum of the monoisotopic delta masses of all modifications in the map
virtual void clear()
Erases all elements from the self.
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...
virtual bool operator==(const ModificationMap &rhs) const
returns true iff the map has the same modifications
double averageDeltaMass() const
returns the sum of the average delta masses of all modifications in the map
virtual void erase(iterator position)
Deletes the map element pointed to by the iterator position.
virtual void erase(iterator start, iterator finish)
If the iterators start and finish point to the same map and last is reachable from first,...
virtual iterator end()
Returns an iterator pointing to the last element stored in the map; in other words,...
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....
ModificationMap(const ModificationMap &other)
virtual std::pair< iterator, iterator > equal_range(const key_type &x)
Returns the pair (lower_bound(x), upper_bound(x)).
virtual reverse_iterator rbegin()
Returns a reverse_iterator pointing to the first element stored in the map. First is defined by the m...
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....
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...
virtual iterator begin()
Returns an iterator pointing to the first element stored in the map. First is defined by the map's co...
virtual reverse_iterator rend()
Returns a reverse_iterator pointing to the last element stored in the map; in other words,...
a wrapper for std::map that will behave properly with polymorphism