28 #include "../../../pappsomspp/pappsoexception.h"
29 #include "../../../pappsomspp/exception/exceptionoutofrange.h"
65 double digitizerTimebase,
66 double digitizerDelay,
108 QObject::tr(
"Invalid scan number : scanNum %1 > m_scanNumber %2")
121 "ERROR unable to get number of peaks in TimsFrameBase for scan number %1")
136 "ERROR unable to getMassSpectrumSPtr in TimsFrameBase for scan number %1")
141 std::size_t scanNumEnd)
const
144 QObject::tr(
"ERROR unable to cumulateScanToTrace in TimsFrameBase for scan "
145 "number begin %1 end %2")
152 std::size_t scanNumBegin,
153 std::size_t scanNumEnd)
const
157 "ERROR unable to cumulateScansInRawMap in TimsFrameBase for scan "
158 "number begin %1 end %2")
169 "ERROR unable to cumulateSingleScanIntensities in TimsFrameBase for scan "
170 "number %1.").arg(scanNum));
178 std::size_t scanNumEnd)
const
182 "ERROR unable to cumulateScansInRawMap in TimsFrameBase for scan "
183 "number begin %1 end %2")
200 qDebug() <<
" m_msMsType=" << type;
230 [[maybe_unused]]
double C5,
236 if(tims_model_type != 2)
239 "ERROR in TimsFrame::setTimsCalibration tims_model_type != 2"));
263 QObject::tr(
"ERROR in TimsFrame::getVoltageTransformation invalid tims "
264 "calibration, v < m_timsVmin"));
271 QObject::tr(
"ERROR in TimsFrame::getVoltageTransformation invalid tims "
272 "calibration, v > m_timsVmax"));
292 double temp = 1 / one_over_k0;
298 return (std::size_t)std::round(temp);
318 std::map<quint32, quint32> &accumulated_scans)
const
330 for(
auto &scan_element : accumulated_scans)
338 local_trace.push_back(element);
349 std::map<quint32, quint32> &accumulated_scans)
const
354 std::vector<quint32> keys;
355 transform(begin(accumulated_scans),
356 end(accumulated_scans),
358 [](std::map<quint32, quint32>::value_type
const &pair) {
361 std::sort(keys.begin(), keys.end());
363 data_point_cumul.
x = 0;
364 data_point_cumul.
y = 0;
372 quint32 last_key = 0;
374 for(quint32 key : keys)
376 if(key == last_key + 1)
379 if(accumulated_scans[key] > accumulated_scans[last_key])
381 if(data_point_cumul.
x == last_key)
384 data_point_cumul.
x = key;
385 data_point_cumul.
y += accumulated_scans[key];
391 if(data_point_cumul.
y > 0)
400 local_trace.push_back(data_point_cumul);
404 data_point_cumul.
x = key;
405 data_point_cumul.
y = accumulated_scans[key];
410 data_point_cumul.
y += accumulated_scans[key];
416 if(data_point_cumul.
y > 0)
427 local_trace.push_back(data_point_cumul);
431 data_point_cumul.
x = key;
432 data_point_cumul.
y = accumulated_scans[key];
438 if(data_point_cumul.
y > 0)
447 local_trace.push_back(data_point_cumul);
463 QObject::tr(
"ERROR in %1, %2, %3 msp_mzCalibration is null")
476 if(mzCalibration ==
nullptr)
480 QObject::tr(
"ERROR in %1, %2, %3 msp_mzCalibration is null")
492 quint32 max_value = 0;
495 qDebug() <<
"m_scanNumber=" <<
m_scanNumber <<
" i=" << i;
497 auto it = std::max_element(index_list.begin(), index_list.end());
498 if(it != index_list.end())
500 max_value = std::max(max_value, *it);
511 "ERROR unable to getScanIndexList in TimsFrameBase for scan number %1")
521 "ERROR unable to getScanIntensities in TimsFrameBase for scan number %1")
527 std::size_t mz_index_lower_bound,
528 std::size_t mz_index_upper_bound,
537 qDebug() <<
"m_scanNumber=" <<
m_scanNumber <<
" i=" << i;
539 auto it_lower = std::find_if(index_list.begin(),
541 [mz_index_lower_bound](quint32 to_compare) {
542 if(to_compare < mz_index_lower_bound)
550 if(it_lower == index_list.end())
558 std::find_if(index_list.begin(),
560 [mz_index_upper_bound](quint32 to_compare) {
561 if(mz_index_upper_bound >= to_compare)
568 for(
int j = std::distance(index_list.begin(), it_lower);
569 j < std::distance(index_list.begin(), it_upper);
574 data_point.
y += intensity_list[j];
579 std::max((
double)intensity_list[j], data_point.
y);
583 im_trace.push_back(data_point);
virtual double getMzFromTofIndex(quint32 tof_index)=0
get m/z from time of flight raw index
double m_accumulationTime
accumulation time in milliseconds
virtual quint64 cumulateSingleScanIntensities(std::size_t scanNum) const
double getVoltageTransformation(std::size_t scanNum) const
get voltage for a given scan number
virtual Trace cumulateScanToTrace(std::size_t scanNumBegin, std::size_t scanNumEnd) const
cumulate spectrum given a scan number range need the binary file The intensities are normalized with ...
virtual std::size_t getTotalNumberOfScans() const
get the number of scans contained in this frame each scan represents an ion mobility slice
virtual Trace getIonMobilityTraceByMzIndexRange(std::size_t mz_index_lower_bound, std::size_t mz_index_upper_bound, XicExtractMethod method) const
get a mobility trace cumulating intensities inside the given mass index range
virtual std::size_t getNbrPeaks(std::size_t scanNum) const
get the number of peaks in this spectrum need the binary file
MzCalibrationInterfaceSPtr msp_mzCalibration
virtual MassSpectrumSPtr getMassSpectrumSPtr(std::size_t scanNum) const
get Mass spectrum with peaks for this scan number need the binary file
TimsFrameBase(std::size_t timsId, quint32 scanNum)
constructor for binary independant tims frame
virtual std::vector< quint32 > getScanIndexList(std::size_t scanNum) const
get raw index list for one given scan index are not TOF nor m/z, just index on digitizer
double getDriftTime(std::size_t scanNum) const
get drift time of a scan number in milliseconds
pappso::Trace getTraceFromCumulatedScansBuiltinCentroid(std::map< quint32, quint32 > &accumulated_scans) const
transform accumulation of raw scans into a real mass spectrum with a simple centroid on raw integers
double m_time
retention time
virtual quint64 cumulateScansIntensities(std::size_t scanNumBegin, std::size_t scanNumEnd) const
void setAccumulationTime(double accumulation_time_ms)
quint32 m_scanNumber
total number of scans contained in this frame
virtual void cumulateScansInRawMap(std::map< quint32, quint32 > &rawSpectrum, std::size_t scanNumBegin, std::size_t scanNumEnd) const
cumulate scan list into a trace into a raw spectrum map The intensities are NOT normalized with respe...
void setTime(double time)
std::size_t m_timsId
Tims frame database id (the SQL identifier of this frame)
pappso::Trace getTraceFromCumulatedScans(std::map< quint32, quint32 > &accumulated_scans) const
transform accumulation of raw scans into a real mass spectrum
virtual bool hasSameCalibrationData(const TimsFrameBase &other) const
tells if 2 tims frame has the same calibration data Usefull to know if raw data can be handled betwee...
virtual quint32 getMaximumRawMassIndex() const
get the maximum raw mass index contained in this frame
unsigned int getMsLevel() const
void setTimsCalibration(int tims_model_type, double C0, double C1, double C2, double C3, double C4, double C5, double C6, double C7, double C8, double C9)
virtual const MzCalibrationInterfaceSPtr & getMzCalibrationInterfaceSPtr() const final
get the MzCalibration model to compute mz and TOF for this frame
std::size_t getScanNumFromOneOverK0(double one_over_k0) const
get the scan number from a given 1/Ko mobility value
void setMsMsType(quint8 type)
void setMzCalibration(double T1_frame, double T2_frame, double digitizerTimebase, double digitizerDelay, double C0, double C1, double C2, double C3, double C4, double T1_ref, double T2_ref, double dC1, double dC2)
double getOneOverK0Transformation(std::size_t scanNum) const
get 1/K0 value of a given scan (mobility value)
bool checkScanNum(std::size_t scanNum) const
check that this scan number exists
void setMzCalibrationInterfaceSPtr(MzCalibrationInterfaceSPtr mzCalibration)
std::size_t getId() const
virtual std::vector< quint32 > getScanIntensities(std::size_t scanNum) const
get raw intensities without transformation from one scan it needs intensity normalization
A simple container of DataPoint instances.
implement Bruker's model type 1 formula to compute m/z
tries to keep as much as possible monoisotopes, removing any possible C13 peaks and changes multichar...
std::shared_ptr< MzCalibrationInterface > MzCalibrationInterfaceSPtr
std::shared_ptr< MassSpectrum > MassSpectrumSPtr
handle a single Bruker's TimsTof frame without binary data