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")
153 std::size_t scanNumBegin,
154 std::size_t scanNumEnd)
const
158 "ERROR unable to cumulateScansInRawMap in TimsFrameBase for scan "
159 "number begin %1 end %2")
170 "ERROR unable to cumulateSingleScanIntensities in TimsFrameBase for scan "
171 "number %1.").arg(scanNum));
179 std::size_t scanNumEnd)
const
183 "ERROR unable to cumulateScansInRawMap in TimsFrameBase for scan "
184 "number begin %1 end %2")
201 qDebug() <<
" m_msMsType=" << type;
231 [[maybe_unused]]
double C5,
237 if(tims_model_type != 2)
240 "ERROR in TimsFrame::setTimsCalibration tims_model_type != 2"));
264 QObject::tr(
"ERROR in TimsFrame::getVoltageTransformation invalid tims "
265 "calibration, v < m_timsVmin"));
272 QObject::tr(
"ERROR in TimsFrame::getVoltageTransformation invalid tims "
273 "calibration, v > m_timsVmax"));
293 double temp = 1 / one_over_k0;
299 return (std::size_t)std::round(temp);
319 std::map<quint32, quint32> &accumulated_scans)
const
331 for(
auto &scan_element : accumulated_scans)
339 local_trace.push_back(element);
350 std::map<quint32, quint32> &accumulated_scans)
const
355 std::vector<quint32> keys;
356 transform(begin(accumulated_scans),
357 end(accumulated_scans),
359 [](std::map<quint32, quint32>::value_type
const &pair) {
362 std::sort(keys.begin(), keys.end());
364 data_point_cumul.
x = 0;
365 data_point_cumul.
y = 0;
373 quint32 last_key = 0;
375 for(quint32 key : keys)
377 if(key == last_key + 1)
380 if(accumulated_scans[key] > accumulated_scans[last_key])
382 if(data_point_cumul.
x == last_key)
385 data_point_cumul.
x = key;
386 data_point_cumul.
y += accumulated_scans[key];
392 if(data_point_cumul.
y > 0)
401 local_trace.push_back(data_point_cumul);
405 data_point_cumul.
x = key;
406 data_point_cumul.
y = accumulated_scans[key];
411 data_point_cumul.
y += accumulated_scans[key];
417 if(data_point_cumul.
y > 0)
428 local_trace.push_back(data_point_cumul);
432 data_point_cumul.
x = key;
433 data_point_cumul.
y = accumulated_scans[key];
439 if(data_point_cumul.
y > 0)
448 local_trace.push_back(data_point_cumul);
464 QObject::tr(
"ERROR in %1, %2, %3 msp_mzCalibration is null")
477 if(mzCalibration ==
nullptr)
481 QObject::tr(
"ERROR in %1, %2, %3 msp_mzCalibration is null")
493 quint32 max_value = 0;
496 qDebug() <<
"m_scanNumber=" <<
m_scanNumber <<
" i=" << i;
498 auto it = std::max_element(index_list.begin(), index_list.end());
499 if(it != index_list.end())
501 max_value = std::max(max_value, *it);
512 "ERROR unable to getScanIndexList in TimsFrameBase for scan number %1")
522 "ERROR unable to getScanIntensities in TimsFrameBase for scan number %1")
528 std::size_t mz_index_lower_bound,
529 std::size_t mz_index_upper_bound,
538 qDebug() <<
"m_scanNumber=" <<
m_scanNumber <<
" i=" << i;
540 auto it_lower = std::find_if(index_list.begin(),
542 [mz_index_lower_bound](quint32 to_compare) {
543 if(to_compare < mz_index_lower_bound)
551 if(it_lower == index_list.end())
559 std::find_if(index_list.begin(),
561 [mz_index_upper_bound](quint32 to_compare) {
562 if(mz_index_upper_bound >= to_compare)
569 for(
int j = std::distance(index_list.begin(), it_lower);
570 j < std::distance(index_list.begin(), it_upper);
575 data_point.
y += intensity_list[j];
580 std::max((
double)intensity_list[j], data_point.
y);
584 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