20#ifndef _IPRECURSORMASKCODEC_HPP
21#define _IPRECURSORMASKCODEC_HPP
24#include <boost/format.hpp>
31 auto upperOffsetParam = p.
isolationWindow.cvParam(cv::MS_isolation_window_upper_offset);
32 if (upperOffsetParam.value.empty())
33 throw std::runtime_error(
"precursor_upper_offset() No isolation window upper offset m/z specified");
34 double upperOffset = upperOffsetParam.valueAs<
double>();
35 if (upperOffset <= 0.0)
36 throw std::runtime_error(
"precursor_upper_offset() Positive values expected for isolation window m/z offsets");
42 auto lowerOffsetParam = p.
isolationWindow.cvParam(cv::MS_isolation_window_lower_offset);
43 if (lowerOffsetParam.value.empty())
44 throw std::runtime_error(
"precursor_lower_offset() No isolation window lower offset m/z specified");
45 double lowerOffset = lowerOffsetParam.valueAs<
double>();
46 if (lowerOffset <= 0.0)
47 throw std::runtime_error(
"precursor_lower_offset() Positive values expected for isolation window m/z offsets");
53 auto targetParam = p.
isolationWindow.cvParam(cv::MS_isolation_window_target_m_z);
54 if (targetParam.value.empty())
55 throw std::runtime_error(
"precursor_target() No isolation window target m/z specified");
56 return targetParam.valueAs<
double>();
74 return (mzLow + mzHigh) / 2.0;
106 auto mult = mz * 100000000.0;
107 auto rounded = llround(mult);
108 return static_cast<MZHash>(rounded);
114 return hashed / 100000000.0;
156 return center >= this->mzLow && center <= this->
mzHigh;
196 typedef boost::shared_ptr<IPrecursorMaskCodec>
ptr;
199 typedef boost::shared_ptr<const IPrecursorMaskCodec>
const_ptr;
Interface for generating and accessing precursor masks for a demultiplexing scheme.
virtual void SpectrumToIndices(msdata::Spectrum_const_ptr sPtr, std::vector< size_t > &indices) const =0
Identifies the precursor windows within a spectrum and returns the indices to the design matrix colum...
virtual ~IPrecursorMaskCodec()
virtual void GetMask(msdata::Spectrum_const_ptr sPtr, DemuxTypes::MatrixType &m, size_t rowNum, double weight=1.0) const =0
Generates a design matrix row describing which precursor isolation windows are present in the given s...
virtual msdata::ProcessingMethod GetProcessingMethod() const =0
Returns a descriptor of the processing done by this PrecursorMaskCodec.
virtual int GetOverlapsPerCycle() const =0
Returns the number of overlap repeats per cycle. So for no overlap, this returns 1....
boost::shared_ptr< const IPrecursorMaskCodec > const_ptr
Constant shared pointer definition.
virtual Eigen::VectorXd GetMask(msdata::Spectrum_const_ptr sPtr, double weight=1.0) const =0
Generates a design matrix row describing which precursor isolation windows are present in the given s...
boost::shared_ptr< IPrecursorMaskCodec > ptr
Shared pointer definition.
virtual size_t GetNumDemuxWindows() const =0
Returns the total number of demux'd precursor windows. This is the number of possible indices returne...
virtual int GetPrecursorsPerSpectrum() const =0
Returns the number of precursor isolations per spectrum. This is verified to be constant for all spec...
virtual size_t GetDemuxBlockSize() const =0
Returns the number of windows required to demultiplex.
virtual IsolationWindow GetIsolationWindow(size_t i) const =0
Returns the precursor window for a given index.
virtual int GetSpectraPerCycle() const =0
Returns the number of spectra required to cover all precursor isolation windows.
A method of hashing an isolation window to a unique long value mz is and m/z of a unique point in the...
static double UnHash(MZHash hashed)
Unhash an integer to a floating-point m/z value.
static MZHash Hash(double mz)
Hash a floating-point m/z value to an integer.
Matrix< DemuxScalar, Dynamic, Dynamic > MatrixType
bool stringToFloatCompare(std::string i, std::string j)
double precursor_upper_offset(const msdata::Precursor &p)
double precursor_target(const msdata::Precursor &p)
double precursor_iso_center(const msdata::Precursor &p)
double precursor_mz_low(const msdata::Precursor &p)
double precursor_mz_high(const msdata::Precursor &p)
double precursor_iso_width(const msdata::Precursor &p)
double precursor_lower_offset(const msdata::Precursor &p)
std::string prec_to_string(const msdata::Precursor &p)
boost::shared_ptr< const msdata::Spectrum > Spectrum_const_ptr
A container for describing the isolation windows that are dedicated to columns of the design matrix f...
bool operator<(const DemuxWindow &rhs) const
Isolation windows are sorted by their start value.
DemuxWindow(MZHash mzLow, MZHash mzHigh)
Constructs a DemuxWindow for a given mass range.
MZHash mzLow
Start m/z of the window range.
bool ContainsCenter(const DemuxWindow &inner) const
Used to find whether a window's center is contained within this window.
DemuxWindow(const msdata::Precursor &p)
Constructs a DemuxWindow from a Precursor by using its isolation window.
MZHash mzHigh
End m/z of the window range.
bool operator==(const DemuxWindow &rhs) const
Can be used to find whether two windows are identical within the error of the hash.
bool operator!=(const DemuxWindow &rhs) const
Can be used to find whether two windows are identical within the error of the hash.
bool Contains(const DemuxWindow &inner) const
Can be used to find whether the mass range of another DemuxWindow is a subset of this one.
A container that wraps DemuxWindow to preserve the full precision window boundaries.
double highMz
Full precision upper m/z bound.
DemuxWindow demuxWindow
Set of isolation window boundaries that provides useful operations for sorting and comparing differen...
IsolationWindow(double mzLow, double mzHigh)
Constructs an IsolationWindow from a given mass range.
IsolationWindow(const msdata::Precursor &p)
Constructs an IsolationWindow from a Precursor.
double lowMz
Full precision lower m/z bound.
bool operator<(const IsolationWindow &rhs) const
Isolation windows are sorted by their start value.
The method of precursor ion selection and activation.
IsolationWindow isolationWindow
this element captures the isolation (or 'selection') window configured to isolate one or more precurs...
Description of the default peak processing method. This element describes the base method used in the...