ProteoWizard
PeakData.hpp
Go to the documentation of this file.
1//
2// $Id$
3//
4//
5// Original author: Darren Kessner <darren@proteowizard.org>
6//
7// Copyright 2007 Spielberg Family Center for Applied Proteomics
8// Cedars-Sinai Medical Center, Los Angeles, California 90048
9//
10// Licensed under the Apache License, Version 2.0 (the "License");
11// you may not use this file except in compliance with the License.
12// You may obtain a copy of the License at
13//
14// http://www.apache.org/licenses/LICENSE-2.0
15//
16// Unless required by applicable law or agreed to in writing, software
17// distributed under the License is distributed on an "AS IS" BASIS,
18// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
19// See the License for the specific language governing permissions and
20// limitations under the License.
21//
22
23#ifndef _PEAKDATA_HPP_
24#define _PEAKDATA_HPP_
25
26
33#include "boost/shared_ptr.hpp"
34#include <vector>
35#include <string>
36
37
38namespace pwiz {
39namespace data {
40namespace peakdata {
41
42
43using namespace pwiz::util;
44using namespace pwiz::minimxml;
45using namespace minimxml::SAXParser;
46
47
50
51
53{
54 int id;
55
56 double mz;
58
59 double intensity; // peak height
60 double area; // sum/total intensity
61 double error; // error in model fit
62
63 std::vector<pwiz::math::OrderedPair> data;
64
65 // optional attributes
66
68 {
71 Attribute_Decay
72 };
73
74 typedef std::map<Attribute, double> Attributes;
76
77 Peak(double _mz = 0, double _retentionTime = 0);
78
79 double getAttribute(Attribute attribute) const;
80
81 bool operator==(const Peak& that) const;
82 bool operator!=(const Peak& that) const;
83
84 void write(minimxml::XMLWriter& writer) const;
85 void read(std::istream& is);
86};
87
88
90{
92 HandlerPeak(Peak* _peak = 0) : peak(_peak)
93 {
94 parseCharacters = true;
96 }
97
98 virtual Status startElement(const std::string& name,
99 const Attributes& attributes,
100 stream_offset position);
101
103 stream_offset position);
104};
105
106
107PWIZ_API_DECL std::ostream& operator<<(std::ostream& os, const Peak& peak);
108PWIZ_API_DECL std::istream& operator>>(std::istream& is, Peak& peak);
109
110
112{
115 double score;
116 std::vector<Peak> peaks;
117
118 PeakFamily() : mzMonoisotopic(0), charge(0), score(0) {}
119 double sumAmplitude() const {return 0;}
120 double sumArea() const {return 0;}
121
122 void write(minimxml::XMLWriter& writer) const;
123 void read(std::istream& is);
124
125 bool operator==(const PeakFamily& that) const;
126 bool operator!=(const PeakFamily& that) const;
127};
128
129
130PWIZ_API_DECL std::ostream& operator<<(std::ostream& os, const PeakFamily& peakFamily);
131PWIZ_API_DECL std::istream& operator>>(std::istream& is, PeakFamily& peakFamily);
132
133
135{
136 size_t index;
137 std::string nativeID;
138 int scanNumber; // TODO: remove
142 std::vector<PeakFamily> peakFamilies;
143
144 Scan() : index(0), scanNumber(0), retentionTime(0), observationDuration(0) {}
145
146 void write(minimxml::XMLWriter& writer) const;
147 void read(std::istream& is);
148
149 bool operator==(const Scan& scan) const;
150 bool operator!=(const Scan& scan) const;
151};
152
153
154PWIZ_API_DECL std::ostream& operator<<(std::ostream& os, const Scan& scan);
155PWIZ_API_DECL std::istream& operator>>(std::istream& is, Scan& scan);
156
157
159{
160
161 std::string name;
162 std::string version;
163 std::string source;
164
166 {
167 std::string name;
168 std::string value;
169
170 Parameter() : name(""), value("") {};
171 Parameter(std::string name_, std::string value_) : name(name_), value(value_) {}
172 void write(minimxml::XMLWriter& xmlWriter) const;
173 void read(std::istream& is);
174 bool operator==(const Parameter& that) const;
175 bool operator!=(const Parameter& that) const;
176
177 };
178
179 std::vector<Parameter> parameters;
180
181 Software() : name(""), version(""), source(""), parameters(0) {}
182 void write(minimxml::XMLWriter& xmlWriter) const;
183 void read(std::istream& is);
184
185 bool operator==(const Software& that) const;
186 bool operator!=(const Software& that) const;
187};
188
189
191{
192 std::string sourceFilename;
194 std::vector<Scan> scans;
195
196 void write(pwiz::minimxml::XMLWriter& xmlWriter) const;
197 void read(std::istream& is);
198
199 bool operator==(const PeakData& that) const;
200 bool operator!=(const PeakData& that) const;
201};
202
203
204PWIZ_API_DECL std::ostream& operator<<(std::ostream& os, const PeakData& pd);
205PWIZ_API_DECL std::istream& operator>>(std::istream& is, PeakData& pd);
206
207
208///
209/// struct for an eluted peak (PEAK ELution)
210///
212{
213 // metadata
214 double mz;
219
220 // peak data
221 std::vector<Peak> peaks;
222
223 // construction
225 Peakel(const Peak& peak);
226
227 /// recalculates all metadata based on peak data
229
230 // retention times grabbed from peak data; assume peaks are ordered by retention time
231 double retentionTimeMin() const;
232 double retentionTimeMax() const;
233
234 void write(pwiz::minimxml::XMLWriter& xmlWriter) const;
235 void read(std::istream& is);
236
237 bool operator==(const Peakel& that) const;
238 bool operator!=(const Peakel& that) const;
239};
240
241
242typedef boost::shared_ptr<Peakel> PeakelPtr;
243
244
246{
248 HandlerPeakel(Peakel* _peakel = 0) : peakel(_peakel){}
249 virtual Status startElement(const std::string& name, const Attributes& attributes, stream_offset position);
250
251 private:
254};
255
256
257PWIZ_API_DECL std::ostream& operator<<(std::ostream& os, const Peakel& peakel);
258PWIZ_API_DECL std::istream& operator>>(std::istream& is, Peakel& peakel);
259
260
262{
265
266 std::string id; // assigned by feature detection, for easier lookup
267 double mz;
272 double score;
273 double error;
274 std::vector<PeakelPtr> peakels;
275
277
278 // retention time range calculation based on first two Peakels
279 double retentionTimeMin() const;
280 double retentionTimeMax() const;
281
282 void write(pwiz::minimxml::XMLWriter& xmlWriter) const;
283 void read(std::istream& is);
284
285 bool operator==(const Feature& that) const;
286 bool operator!=(const Feature& that) const;
287
288 // note: copy/assignment are shallow copy (same peakels)
289};
290
291
292typedef boost::shared_ptr<Feature> FeaturePtr;
293
294
295struct HandlerFeature : public SAXParser::Handler // included in header file for accession by MatchData
296{
298 HandlerFeature(Feature* _feature = 0) : feature(_feature){}
299
300 virtual Status startElement(const std::string& name, const Attributes& attributes, stream_offset position);
301
302 private:
305};
306
307
308PWIZ_API_DECL std::ostream& operator<<(std::ostream& os, const Feature& feature);
309PWIZ_API_DECL std::istream& operator>>(std::istream& is, Feature& feature);
310
311
313{
315 std::vector<FeaturePtr> features;
316
317 void write(pwiz::minimxml::XMLWriter& xmlWriter) const;
318 void read(std::istream& is);
319
320private:
321
324
325};
326
327
328} // namespace peakdata
329} // namespace data
330} // namespace pwiz
331
332#endif // _PEAKDATA_HPP_
333
#define PWIZ_API_DECL
Definition Export.hpp:32
SAX event handler interface.
bool parseCharacters
When false, no calls to characters() will be made.
boost::iostreams::stream_offset stream_offset
The XMLWriter class provides simple, tag-level XML syntax writing.
Definition XMLWriter.hpp:48
const int PeakDataFormatVersion_Minor
Definition PeakData.hpp:49
boost::shared_ptr< Feature > FeaturePtr
Definition PeakData.hpp:292
const int PeakDataFormatVersion_Major
Definition PeakData.hpp:48
PWIZ_API_DECL std::ostream & operator<<(std::ostream &os, const Peak &peak)
boost::shared_ptr< Peakel > PeakelPtr
Definition PeakData.hpp:242
PWIZ_API_DECL std::istream & operator>>(std::istream &is, Peak &peak)
std::vector< FeaturePtr > features
Definition PeakData.hpp:315
void write(pwiz::minimxml::XMLWriter &xmlWriter) const
void read(std::istream &is)
FeatureFile operator=(FeatureFile &)
bool operator==(const Feature &that) const
void read(std::istream &is)
std::vector< PeakelPtr > peakels
Definition PeakData.hpp:274
Feature(const MSIHandler::Record &record)
bool operator!=(const Feature &that) const
void write(pwiz::minimxml::XMLWriter &xmlWriter) const
HandlerFeature(Feature *_feature=0)
Definition PeakData.hpp:298
virtual Status startElement(const std::string &name, const Attributes &attributes, stream_offset position)
virtual Status characters(const SAXParser::saxstring &text, stream_offset position)
virtual Status startElement(const std::string &name, const Attributes &attributes, stream_offset position)
virtual Status startElement(const std::string &name, const Attributes &attributes, stream_offset position)
std::vector< Scan > scans
Definition PeakData.hpp:194
void write(pwiz::minimxml::XMLWriter &xmlWriter) const
void read(std::istream &is)
bool operator!=(const PeakData &that) const
bool operator==(const PeakData &that) const
void write(minimxml::XMLWriter &writer) const
bool operator==(const PeakFamily &that) const
bool operator!=(const PeakFamily &that) const
void read(std::istream &is)
Peak(double _mz=0, double _retentionTime=0)
std::map< Attribute, double > Attributes
Definition PeakData.hpp:74
void write(minimxml::XMLWriter &writer) const
double getAttribute(Attribute attribute) const
bool operator!=(const Peak &that) const
void read(std::istream &is)
std::vector< pwiz::math::OrderedPair > data
Definition PeakData.hpp:63
bool operator==(const Peak &that) const
struct for an eluted peak (PEAK ELution)
Definition PeakData.hpp:212
void calculateMetadata()
recalculates all metadata based on peak data
Peakel(const Peak &peak)
void read(std::istream &is)
bool operator!=(const Peakel &that) const
bool operator==(const Peakel &that) const
double retentionTimeMin() const
std::vector< Peak > peaks
Definition PeakData.hpp:221
double retentionTimeMax() const
void write(pwiz::minimxml::XMLWriter &xmlWriter) const
CalibrationParameters calibrationParameters
Definition PeakData.hpp:141
std::vector< PeakFamily > peakFamilies
Definition PeakData.hpp:142
bool operator!=(const Scan &scan) const
void write(minimxml::XMLWriter &writer) const
bool operator==(const Scan &scan) const
void read(std::istream &is)
bool operator!=(const Parameter &that) const
Parameter(std::string name_, std::string value_)
Definition PeakData.hpp:171
bool operator==(const Parameter &that) const
void write(minimxml::XMLWriter &xmlWriter) const
std::vector< Parameter > parameters
Definition PeakData.hpp:179
void write(minimxml::XMLWriter &xmlWriter) const
bool operator!=(const Software &that) const
bool operator==(const Software &that) const
void read(std::istream &is)
Handler returns the Status struct as a means of changing the parser's behavior.