ProteoWizard
masscomparefunctors.hpp
Go to the documentation of this file.
1//
2// $Id$
3//
4//
5// Original author: Witold Wolski <wewolski@gmail.com>
6//
7// Copyright : ETH Zurich
8//
9// Licensed under the Apache License, Version 2.0 (the "License");
10// you may not use this file except in compliance with the License.
11// You may obtain a copy of the License at
12//
13// http://www.apache.org/licenses/LICENSE-2.0
14//
15// Unless required by applicable law or agreed to in writing, software
16// distributed under the License is distributed on an "AS IS" BASIS,
17// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18// See the License for the specific language governing permissions and
19// limitations under the License.
20//
21
22
23#ifndef MASSCOMPAREFUNCTORS_H
24#define MASSCOMPAREFUNCTORS_H
25
26#include <stdlib.h>
27#include <cstdio>
28#include <complex>
29/*! \file MassCompareFunctors.h
30Defines function objects which are used by SortedMatcher and UnsortedMatcher.
31
32*/
33namespace ralab
34{
35
36 namespace base
37 {
38 namespace resample
39 {
40
41
42 inline double resolution2ppm(double resolution){
43 return 1/resolution * 1e6;
44 }
45
46
47 ///TODO Do checking on TReal thats a real
48 template<typename TReal>
50 {
51 typedef TReal value_type;
54
55 PPMCompFunctor(value_type window //!< in ppm
56 ):window_(window),ppm_(1e-6)
57 {}
58
59 /// returns window at mass
61 {
62 return((window_ * val)*ppm_);
63 }
64
65 /// if dist pval cval smaller then window returns true
66 inline bool operator()(value_type pval, value_type cval)
67 {
68 return( std::abs(pval - cval) < operator()(pval) );
69 }
70 };
71
72 /// Da Comparator - constant mass error
73 template<typename TReal>
75 {
76 typedef TReal value_type;
79 {
80 }
81
82 /// window at mass
84 {
85 return( window_ );
86 }
87
88 /** if dist pval cval smaller then window returns true */
89 inline bool operator()(value_type pval, value_type cval)
90 {
91 return( std::abs(pval - cval) < operator()(pval) );
92 }
93 };
94
95 /// FTMS Comparator
96 template<typename TReal>
98 {
99 typedef TReal value_type;
101
103 value_type invR_;//FTMS resolution
104
105 /// brief window at mass, i.e. 0.1 Da at 400Da
106 FTMSCompFunctor( value_type window , value_type mass ) : window_(window) , mass_(mass)
107 {
108 invR_ = sqrt(window_)/mass_;
109 }
110
111 /// brief returns size of windows for this mass
113 {
114 value_type pR = (val*invR_);
115 return( pR*pR );
116 }
117 /// brief compares two masses, returns true if they match false otherwise
118 inline bool operator()(value_type pval, value_type cval)
119 {
120 return( std::abs( pval - cval ) < operator()(pval) );
121 }
122 };
123
124 }//end resample
125 }//end MSALGO
126}//end ralab
127
128
129#endif // MASSCOMPAREFUNCTORS_H
double resolution2ppm(double resolution)
EQUISPACEINTERPOL Interpolation on a equidistantly spaced grid.
Definition base.hpp:40
Da Comparator - constant mass error.
bool operator()(value_type pval, value_type cval)
if dist pval cval smaller then window returns true
value_type operator()(value_type)
window at mass
FTMSCompFunctor(value_type window, value_type mass)
brief window at mass, i.e. 0.1 Da at 400Da
value_type operator()(value_type val)
brief returns size of windows for this mass
bool operator()(value_type pval, value_type cval)
brief compares two masses, returns true if they match false otherwise
TODO Do checking on TReal thats a real.
value_type operator()(value_type val)
returns window at mass
bool operator()(value_type pval, value_type cval)
if dist pval cval smaller then window returns true