ProteoWizard
FrequencyData.hpp
Go to the documentation of this file.
1//
2// $Id$
3//
4//
5// Original author: Darren Kessner <darren@proteowizard.org>
6//
7// Copyright 2006 Louis Warschaw Prostate Cancer Center
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
24#ifndef _FREQUENCYDATA_HPP_
25#define _FREQUENCYDATA_HPP_
26
27
29#include "SampleDatum.hpp"
31#include <vector>
32#include <complex>
33#include <memory>
34
35
36namespace pwiz {
37namespace data {
38
39
41
42
43/// Class for binary storage of complex frequency data.
44
45/// Stores raw frequency-domain data, as well as meta-data. Also includes
46/// basic access and analysis functions.
47
49{
50 public:
51
52 /// \name types
53 //@{
54 enum PWIZ_API_DECL IOMode {Binary, Text, Automatic};
55 typedef std::vector<FrequencyDatum> container;
56 typedef container::iterator iterator;
57 typedef container::const_iterator const_iterator;
58 //@}
59
60 /// \name instantiation
61 //@{
63 FrequencyData(const std::string& filename, IOMode mode=Automatic);
65 FrequencyData(const FrequencyData& that, const_iterator center, int radius);
67 //@}
68
69 /// \name I/O
70 //@{
71 void read(const std::string& filename, IOMode mode=Automatic);
72 void read(std::istream& is, IOMode mode=Binary);
73 void write(const std::string& filename, IOMode mode=Binary) const;
74 void write(std::ostream& os, IOMode mode=Binary) const;
75 //@}
76
77 /// \name data access
78 //@{
79 /// const access to underlying data
80 const container& data() const;
81
82 /// non-const access to underlying data -- must call analyze() to recache after any changes
84 //@}
85
86 /// \name metadata
87 //@{
88 int scanNumber() const;
89 void scanNumber(int value);
90
91 double retentionTime() const;
92 void retentionTime(double value);
93
96
97 double observationDuration() const;
98 void observationDuration(double value);
99
100 double noiseFloor() const;
101 void noiseFloor(double value);
102 //@}
103
104 /// \name data transformation
105 //@{
106 /// transform all underlying data: (x,y) -> (x+shift,y*scale)
107 void transform(double shift, std::complex<double> scale);
108
109 /// return current shift of data (compared to original)
110 double shift() const;
111
112 /// return current scale of data (compared to original)
113 std::complex<double> scale() const;
114
115 /// normalize by transform( -max.x, 1/abs(max.y) )
116 void normalize();
117
118 /// addition
119 void operator+=(const FrequencyData& that);
120 //@}
121
122 /// \name analysis
123 //@{
124 /// recache statistics calculations after any direct data changes via non-const data()
125 void analyze();
126
127 /// returns an iterator to FrequencyDatum with highest magnitude
129
130 double mean() const;
131 double meanSquare() const;
132 double sumSquares() const;
133 double variance() const;
134
135 /// special calculation of noise floor for data with zero holes,
136 /// e.g. data obtained from RAW file m/z-intensity pairs
137 double cutoffNoiseFloor() const;
138
139 /// calculation of the observation duration from the data
141 //@}
142
143 /// \name auxilliary
144 //@{
145 /// Finds the FrequencyDatum nearest the desired frequency.
146 const_iterator findNearest(double frequency) const;
147 //@}
148
149 /// \name auxilliary functions
150 //@{
151 /// Returns a <frequency,magnitude> pair.
152 static std::pair<double,double> magnitudeSample(const FrequencyDatum& datum);
153 //@}
154
155 private:
156 struct Impl;
157 std::auto_ptr<Impl> impl_;
158
159 /// Hidden to prevent unintended copying of large amounts of data.
161
162 /// Hidden to prevent unintended copying of large amounts of data.
164};
165
166
167} // namespace data
168} // namespace pwiz
169
170
171#endif // _FREQUENCYDATA_HPP_
172
#define PWIZ_API_DECL
Definition Export.hpp:32
Class for binary storage of complex frequency data.
std::auto_ptr< Impl > impl_
double observationDuration() const
void read(const std::string &filename, IOMode mode=Automatic)
const_iterator max() const
returns an iterator to FrequencyDatum with highest magnitude
double meanSquare() const
void observationDuration(double value)
void read(std::istream &is, IOMode mode=Binary)
container::const_iterator const_iterator
void transform(double shift, std::complex< double > scale)
transform all underlying data: (x,y) -> (x+shift,y*scale)
void operator+=(const FrequencyData &that)
addition
void retentionTime(double value)
double sumSquares() const
std::complex< double > scale() const
return current scale of data (compared to original)
void write(const std::string &filename, IOMode mode=Binary) const
void scanNumber(int value)
const_iterator findNearest(double frequency) const
Finds the FrequencyDatum nearest the desired frequency.
FrequencyData & operator=(FrequencyData &that)
Hidden to prevent unintended copying of large amounts of data.
void noiseFloor(double value)
double shift() const
return current shift of data (compared to original)
double observationDurationEstimatedFromData() const
calculation of the observation duration from the data
FrequencyData(const std::string &filename, IOMode mode=Automatic)
static std::pair< double, double > magnitudeSample(const FrequencyDatum &datum)
Returns a <frequency,magnitude> pair.
double cutoffNoiseFloor() const
special calculation of noise floor for data with zero holes, e.g.
container::iterator iterator
double retentionTime() const
container & data()
non-const access to underlying data – must call analyze() to recache after any changes
void calibrationParameters(const CalibrationParameters &cp)
const CalibrationParameters & calibrationParameters() const
FrequencyData(const FrequencyData &that, const_iterator center, int radius)
void analyze()
recache statistics calculations after any direct data changes via non-const data()
const container & data() const
const access to underlying data
std::vector< FrequencyDatum > container
FrequencyData(const FrequencyData &that, const_iterator begin, const_iterator end)
void write(std::ostream &os, IOMode mode=Binary) const
void normalize()
normalize by transform( -max.x, 1/abs(max.y) )
double noiseFloor() const
FrequencyData(FrequencyData &that)
Hidden to prevent unintended copying of large amounts of data.
SampleDatum< double, std::complex< double > > FrequencyDatum