24 #ifndef _MZRTFIELD_HPP_ 25 #define _MZRTFIELD_HPP_ 31 #include "boost/shared_ptr.hpp" 32 #include "boost/concept/assert.hpp" 33 #include "boost/concept/usage.hpp" 42 using chemistry::MZTolerance;
53 typedef boost::shared_ptr<T> TPtr;
55 bool operator()(
const T& a,
const T& b)
const 57 if (a.mz < b.mz)
return true;
58 if (b.mz < a.mz)
return false;
59 return (a.retentionTime < b.retentionTime);
62 bool operator()(
const TPtr& a,
const TPtr& b)
const 64 return (*
this)(*a, *b);
75 BOOST_CONCEPT_USAGE(HasMZRT)
81 a = c.retentionTimeMin();
82 a = c.retentionTimeMax();
94 struct MZRTField :
public std::set< boost::shared_ptr<T>, LessThan_MZRT<T> >
98 typedef boost::shared_ptr<T>
TPtr;
102 template <
typename RTMatches>
104 find(
double mz,
MZTolerance mzTolerance, RTMatches matches)
const;
107 void remove(
const TPtr& p);
120 template <
typename T>
129 template <
typename T>
136 return rt_>t.retentionTimeMin()-rtTolerance_ && rt_<t.retentionTimeMax()+rtTolerance_;
147 template <
typename T>
151 : reference_(reference), rtTolerance_(rtTolerance) {}
155 return t.retentionTimeMin() > reference_.retentionTimeMin() - rtTolerance_ &&
156 t.retentionTimeMax() < reference_.retentionTimeMax() + rtTolerance_;
165 template <
typename T>
166 template <
typename RTMatches>
167 std::vector< boost::shared_ptr<T> >
174 target->mz = mz - mzTolerance;
177 target->mz = mz + mzTolerance;
182 std::vector<TPtr> result;
186 result.push_back(*it);
192 template <
typename T>
196 range = this->equal_range(p);
199 found = std::find(range.first, range.second, p);
201 if (found == range.second)
throw std::runtime_error(
"[MZRTField::remove()] TPtr not found.");
211 #endif // _MZRTFIELD_HPP_
bool operator()(const T &t) const
predicate always returns true
MZRTField is a std::set of boost::shared_ptrs, stored as a binary tree ordered by LessThan_MZRT...
predicate returns true iff the object's retention time range contains the specified retention time ...
std::vector< TPtr > find(double mz, MZTolerance mzTolerance, RTMatches matches) const
find all objects with a given m/z, within a given m/z tolerance, satisfying the 'matches' predicate ...
RTMatches_Contains(double rt, double rtTolerance=0)
void remove(const TPtr &p)
remove an object via a shared reference, rather than an iterator into the set
MZRTField< pwiz::data::peakdata::Feature > FeatureField
boost::shared_ptr< T > TPtr
double mz(double neutralMass, int protonDelta, int electronDelta=0, int neutronDelta=0)
PWIZ_API_DECL std::ostream & operator<<(std::ostream &os, PepxmlRecordReader &prr)
MZRTField< pwiz::data::peakdata::Peakel > PeakelField
bool operator()(const T &t) const
RTMatches_IsContainedIn(const T &reference, double rtTolerance=0)
struct for expressing m/z tolerance in either amu or ppm
bool operator()(const T &t) const
predicate returns true iff the object's retention time range is completely contained within the range...