ProteoWizard
MZTolerance.hpp
Go to the documentation of this file.
1//
2// $Id$
3//
4//
5// Original author: Darren Kessner <darren@proteowizard.org>
6//
7// Copyright 2009 Center for Applied Molecular Medicine
8// University of Southern California, Los Angeles, CA
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 _MZTOLERANCE_HPP_
24#define _MZTOLERANCE_HPP_
25
26
28#include <iosfwd>
29
30
31namespace pwiz {
32namespace chemistry {
33
34
35///
36/// struct for expressing m/z tolerance in either amu or ppm
37///
39{
40 enum Units {MZ, PPM};
41 double value;
43
44 MZTolerance(double _value = 0, Units _units = MZ)
45 : value(_value), units(_units)
46 {}
47};
48
49
50PWIZ_API_DECL std::ostream& operator<<(std::ostream& os, const MZTolerance& mzt);
51PWIZ_API_DECL std::istream& operator>>(std::istream& is, MZTolerance& mzt);
54
55
56PWIZ_API_DECL double& operator+=(double& d, const MZTolerance& tolerance);
57PWIZ_API_DECL double& operator-=(double& d, const MZTolerance& tolerance);
58PWIZ_API_DECL double operator+(double d, const MZTolerance& tolerance);
59PWIZ_API_DECL double operator-(double d, const MZTolerance& tolerance);
60
61
62/// returns true iff a is in (b-tolerance, b+tolerance)
63PWIZ_API_DECL bool isWithinTolerance(double a, double b, const MZTolerance& tolerance);
64/// returns true iff b - a is greater than the value in tolerance (useful for matching sorted mass lists)
65PWIZ_API_DECL bool lessThanTolerance(double a, double b, const MZTolerance& tolerance);
66
67
68} // namespace chemistry
69} // namespace pwiz
70
71
72#endif // _MZTOLERANCE_HPP_
73
#define PWIZ_API_DECL
Definition Export.hpp:32
PWIZ_API_DECL Formula operator+(const Formula &a, const Formula &b)
PWIZ_API_DECL std::istream & operator>>(std::istream &is, MZTolerance &mzt)
PWIZ_API_DECL bool isWithinTolerance(double a, double b, const MZTolerance &tolerance)
returns true iff a is in (b-tolerance, b+tolerance)
PWIZ_API_DECL bool operator==(const MZTolerance &a, const MZTolerance &b)
PWIZ_API_DECL double & operator+=(double &d, const MZTolerance &tolerance)
PWIZ_API_DECL Formula operator-(const Formula &a, const Formula &b)
PWIZ_API_DECL bool operator!=(const MZTolerance &a, const MZTolerance &b)
PWIZ_API_DECL std::ostream & operator<<(std::ostream &os, const MassAbundance &ma)
PWIZ_API_DECL double & operator-=(double &d, const MZTolerance &tolerance)
PWIZ_API_DECL bool lessThanTolerance(double a, double b, const MZTolerance &tolerance)
returns true iff b - a is greater than the value in tolerance (useful for matching sorted mass lists)
struct for expressing m/z tolerance in either amu or ppm
MZTolerance(double _value=0, Units _units=MZ)