 |
OpenMS
2.4.0
|
Go to the documentation of this file.
62 template <
typename ValueType = UInt,
typename BinSizeType =
double>
95 Histogram(BinSizeType min, BinSizeType max, BinSizeType bin_size) :
109 template <
typename DataIterator>
110 Histogram(DataIterator
begin, DataIterator
end, BinSizeType min, BinSizeType max, BinSizeType bin_size) :
116 for (DataIterator it =
begin; it !=
end; ++it)
118 this->
inc((BinSizeType) *it);
145 return *(std::max_element(
bins_.begin(),
bins_.end()));
151 return *(std::min_element(
bins_.begin(),
bins_.end()));
173 if (index >=
bins_.size())
187 if (bin_index >=
bins_.size())
192 return (BinSizeType)(
min_ + ((BinSizeType)bin_index + 0.5) *
bin_size_);
212 Size inc(BinSizeType val, ValueType increment = 1)
215 this->
bins_[bin_index] += increment;
220 Size incUntil(BinSizeType val,
bool inclusive, ValueType increment = 1)
223 for (
Size i = 0; i < bin_index; ++i)
225 this->
bins_[i] += increment;
229 this->
bins_[bin_index] += increment;
234 Size incFrom(BinSizeType val,
bool inclusive, ValueType increment = 1)
237 for (
Size i = bin_index + 1; i < this->
bins_.size(); ++i)
239 this->
bins_[i] += increment;
243 this->
bins_[bin_index] += increment;
248 template<
typename DataIterator >
254 for (DataIterator it =
begin; it !=
end; ++it)
262 histogram.
incFrom(*it, inclusive);
273 void reset(BinSizeType min, BinSizeType max, BinSizeType bin_size)
319 if (&histogram ==
this)
return *
this;
344 for (
typename std::vector<ValueType>::iterator it =
bins_.begin(); it !=
bins_.end(); ++it)
346 *it = (ValueType)(multiplier * log((BinSizeType)(*it + 1.0f)));
367 if (val < min_ || val >
max_)
384 if (this->bin_size_ <= 0)
391 if (this->max_ != this->min_)
397 this->bins_ = std::vector<ValueType>(1, 0);
404 template <
typename ValueType,
typename BinSizeType>
407 for (
Size i = 0; i < hist.
size(); ++i)
409 os << hist.
centerOfBin(i) <<
"\t"<< hist[i] << std::endl;
Base class for TOPP applications.
Definition: TOPPBase.h:150
Size incUntil(BinSizeType val, bool inclusive, ValueType increment=1)
Definition: Histogram.h:220
Histogram()
default constructor
Definition: Histogram.h:74
BinSizeType centerOfBin(Size bin_index) const
returns the center position of the bin with the index bin_index
Definition: Histogram.h:185
Size incFrom(BinSizeType val, bool inclusive, ValueType increment=1)
Definition: Histogram.h:234
void setMin(PositionType const &position)
Mutator for minimum position.
Definition: DIntervalBase.h:138
const std::vector< ConvexHull2D > & getConvexHulls() const
Non-mutable access to the convex hulls.
virtual ~Histogram()
destructor
Definition: Histogram.h:124
void store(const String &filename, const PeakMap &map) const
Stores a map in an MzML file.
std::ostream & operator<<(std::ostream &os, const Histogram< ValueType, BinSizeType > &hist)
Print the contents to a stream.
Definition: Histogram.h:405
void setMZ(CoordinateType mz)
Mutable access to m/z.
Definition: Peak1D.h:119
Histogram(BinSizeType min, BinSizeType max, BinSizeType bin_size)
constructor with min, max and bin size
Definition: Histogram.h:95
File adapter for MzML files.
Definition: MzMLFile.h:55
A more convenient string class.
Definition: String.h:57
Iterator begin()
Definition: MSExperiment.h:157
In-Memory representation of a mass spectrometry experiment.
Definition: MSExperiment.h:77
const std::vector< Precursor > & getPrecursors() const
returns a const reference to the precursors
#define LOG_ERROR
Macro to be used if non-fatal error are reported (processing continues)
Definition: LogStream.h:446
bool encloses(const PositionType &position) const
Checks whether this range contains a certain point.
Definition: DBoundingBox.h:159
size_t Size
Size type e.g. used as variable which can hold result of size()
Definition: Types.h:127
#define LOG_INFO
Macro if a information, e.g. a status should be reported.
Definition: LogStream.h:454
void setMax(PositionType const &position)
Mutator for maximum position.
Definition: DIntervalBase.h:153
Size size() const
Definition: MSExperiment.h:127
Size size() const
returns the number of bins
Definition: Histogram.h:161
ConstIterator end() const
Non-mutable iterator pointing after the last bin.
Definition: Histogram.h:338
ConstIterator getPrecursorSpectrum(ConstIterator iterator) const
Returns the precursor spectrum of the scan pointed to by iterator.
BinSizeType max_
Upper bound.
Definition: Histogram.h:354
static String concatenate(const std::vector< T > &container, const String &glue="")
Concatenates all elements of the container and puts the glue string between elements.
Definition: ListUtils.h:175
Out of range exception.
Definition: Exception.h:319
std::vector< ValueType > bins_
Vector of bins.
Definition: Histogram.h:358
Histogram(DataIterator begin, DataIterator end, BinSizeType min, BinSizeType max, BinSizeType bin_size)
constructor with data iterator and min, max, bin_size parameters
Definition: Histogram.h:110
Precursor meta information.
Definition: Precursor.h:57
PositionType const & maxPosition() const
Accessor to maximum position.
Definition: DIntervalBase.h:127
Histogram & operator=(const Histogram &histogram)
Assignment.
Definition: Histogram.h:317
Size inc(BinSizeType val, ValueType increment=1)
increases the bin corresponding to value val by increment
Definition: Histogram.h:212
std::vector< ValueType >::const_iterator ConstIterator
Non-mutable iterator of the bins.
Definition: Histogram.h:68
Main OpenMS namespace.
Definition: FeatureDeconvolution.h:46
void addSpectrum(const MSSpectrum &spectrum)
adds a spectrum to the list
BinSizeType min_
Lower bound.
Definition: Histogram.h:352
Representation of a histogram.
Definition: Histogram.h:63
ValueType operator[](Size index) const
returns the value of bin index
Definition: Histogram.h:171
#define LOG_WARN
Macro if a warning, a piece of information which should be read by the user, should be logged.
Definition: LogStream.h:450
void load(const String &filename, PeakMap &map)
Loads a map from a MzML file. Spectra and chromatograms are sorted by default (this can be disabled u...
Size valToBin_(BinSizeType val) const
Returns the bin a given value belongs to.
Definition: Histogram.h:364
BinSizeType minBound() const
returns the lower bound
Definition: Histogram.h:131
void load(const String &filename, FeatureMap &feature_map)
loads the file with name filename into map and calls updateRanges().
bool operator!=(const Histogram &histogram) const
Inequality operator.
Definition: Histogram.h:311
BinSizeType binSize() const
returns the bin size
Definition: Histogram.h:155
const ChargeType & getCharge() const
Non-mutable access to charge state.
bool operator==(const Histogram &histogram) const
Equality operator.
Definition: Histogram.h:302
T round(T x)
Rounds the value.
Definition: MathFunctions.h:138
Histogram(const Histogram &histogram)
copy constructor
Definition: Histogram.h:82
bool empty() const
Definition: MSExperiment.h:137
void initBins_()
initialize the bins
Definition: Histogram.h:382
CoordinateType getRT() const
Returns the RT coordinate (index 0)
Definition: Peak2D.h:208
BinSizeType maxBound() const
returns the upper bound
Definition: Histogram.h:137
unsigned int UInt
Unsigned integer type.
Definition: Types.h:94
static void getCumulativeHistogram(DataIterator begin, DataIterator end, bool complement, bool inclusive, Histogram< ValueType, BinSizeType > &histogram)
Definition: Histogram.h:249
Int overflow exception.
Definition: Exception.h:254
int main(int argc, const char **argv)
Definition: INIFileEditor.cpp:73
ValueType minValue() const
returns the lowest value of all bins
Definition: Histogram.h:149
ValueType binValue(BinSizeType val) const
returns the value of bin corresponding to the value val
Definition: Histogram.h:200
A container for features.
Definition: FeatureMap.h:93
ConvexHull2D & getConvexHull() const
Returns the overall convex hull of the feature (calculated from the convex hulls of the mass traces)
An LC-MS feature.
Definition: Feature.h:70
BinSizeType bin_size_
Bin size.
Definition: Histogram.h:356
PositionType const & minPosition() const
Accessor to minimum position.
Definition: DIntervalBase.h:121
This class provides Input/Output functionality for feature maps.
Definition: FeatureXMLFile.h:68
DBoundingBox< 2 > getBoundingBox() const
returns the bounding box of the feature hull points
std::vector< SpectrumType >::const_iterator ConstIterator
Non-mutable iterator.
Definition: MSExperiment.h:113
CoordinateType getMZ() const
Returns the m/z coordinate (index 1)
Definition: Peak2D.h:196
ConstIterator begin() const
Non-mutable iterator pointing to the first bin.
Definition: Histogram.h:335
const double C13C12_MASSDIFF_U
ContainerType::const_iterator ConstIterator
Non-mutable iterator.
Definition: MSSpectrum.h:103
The representation of a 1D spectrum.
Definition: MSSpectrum.h:66
void applyLogTransformation(BinSizeType multiplier)
Transforms the bin values with f(x)=multiplier*log(x+1)
Definition: Histogram.h:342
void reset(BinSizeType min, BinSizeType max, BinSizeType bin_size)
resets the histogram with the given range and bin size
Definition: Histogram.h:273
ConstIterator RTBegin(CoordinateType rt) const
Fast search for spectrum range begin.
ValueType maxValue() const
returns the highest value of all bins
Definition: Histogram.h:143