Loading...
Searching...
No Matches
timsddaprecursors.h
Go to the documentation of this file.
/**
* \file pappsomspp/vendors/tims/timsddaprecursors.h
* \date 30/06/2024
* \brief handle specific data for DDA MS runs
*/
/*******************************************************************************
* Copyright (c) 2024 Olivier Langella <Olivier.Langella@u-psud.fr>.
*
* This file is part of the PAPPSOms++ library.
*
* PAPPSOms++ is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* PAPPSOms++ is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with PAPPSOms++. If not, see <http://www.gnu.org/licenses/>.
*
******************************************************************************/
#pragma once
#include "timsdata.h"
#include "pappsomspp/export-import-config.h"
namespace pappso
{
/**
* @todo TimsData helper that stores all related DDA informations
*/
class PMSPP_LIB_DECL TimsDdaPrecursors
{
friend TimsData;
public:
/**
* Default constructor
*/
TimsDdaPrecursors(QSqlQuery &query, TimsData *tims_data_origin);
/**
* Destructor
*/
~TimsDdaPrecursors();
/** @brief get the number of precursors analyzed by PASEF
*/
std::size_t getTotalPrecursorCount() const;
XicCoordTims getXicCoordTimsFromPrecursorId(std::size_t precursor_id,
PrecisionPtr precision_ptr);
struct SpectrumDescr
{
std::size_t parent_frame = 0;
std::size_t precursor_id = 0;
std::size_t scan_mobility_start = 0;
std::size_t scan_mobility_end = 0;
std::size_t ms1_index = 0;
std::size_t ms2_index = 0;
double isolationMz = 0;
double isolationWidth = 0;
float collisionEnergy = 0;
std::vector<std::size_t> tims_frame_list;
PrecursorIonData precursor_ion_data;
};
/** @brief get an intermediate structure describing a spectrum
*/
TimsDdaPrecursors::SpectrumDescr
getSpectrumDescrWithPrecursorId(std::size_t precursor_id) const;
/** @brief get a list of TimsDdaPrecursors::SpectrumDescr for a frame
* @param frame_id the frame_id
*/
std::vector<TimsDdaPrecursors::SpectrumDescr>
getSpectrumDescrListByFrameId(std::size_t frame_id) const;
// FIXME NAMING: identical to above
// Not used in i2mcq
void getQualifiedMs2MassSpectrumBySpectrumDescr(
const MsRunIdCstSPtr &msrun_id,
QualifiedMassSpectrum &mass_spectrum,
const SpectrumDescr &spectrum_descr,
bool want_binary_data);
// FIXME NAMING: identical to above
// Not used in i2mcq
void getQualifiedMs1MassSpectrumBySpectrumDescr(
const MsRunIdCstSPtr &msrun_id,
QualifiedMassSpectrum &mass_spectrum,
const SpectrumDescr &spectrum_descr,
bool want_binary_data);
/** @brief filter interface to apply just after raw MS2 specturm extraction
* the filter can be a list of filters inside a FilterSuite object
*/
void setMs2FilterCstSPtr(pappso::FilterInterfaceCstSPtr &filter);
/** @brief filter interface to apply just after raw MS1 specturm extraction
* the filter can be a list of filters inside a FilterSuite object
*/
void setMs1FilterCstSPtr(pappso::FilterInterfaceCstSPtr &filter);
/** @brief enable or disable simple centroid filter on raw tims data for MS2
*/
void setMs2BuiltinCentroid(bool centroid);
/** @brief tells if simple centroid filter on raw tims data for MS2 is enabled
* or not
*/
bool getMs2BuiltinCentroid() const;
/** @brief function to visit an MsRunReader and get each Spectrum in a
* spectrum collection handler by Ms Levels
*
* this function will retrieve processed qualified spectrum depending on each
* Bruker precursors
*/
void ms2ReaderSpectrumCollectionByMsLevel(
const MsRunIdCstSPtr &msrun_id,
SpectrumCollectionHandlerInterface &handler,
unsigned int ms_level);
/** @brief set only one is_mono_thread to true
*
* this avoid to use qtconcurrent
*/
void setMonoThread(bool is_mono_thread);
/** @brief function to visit an MsRunReader and get each raw Spectrum in a
* spectrum collection handler by Ms Levels
*
* this function will retrieve every scans as a qualified mass spectrum
*/
void rawReaderSpectrumCollectionByMsLevel(
const MsRunIdCstSPtr &msrun_id,
SpectrumCollectionHandlerInterface &handler,
unsigned int ms_level);
/** @brief guess possible precursor ids given a charge, m/z, retention time
* and k0
* @return a list of possible precursor ids
*/
std::vector<std::size_t> getPrecursorsByMzRtCharge(int charge,
double mz_val,
double rt_sec,
double k0);
// FIXME: TO THROW AWAY
[[deprecated("This function will be removed")]] std::vector<std::size_t>
getMatchPrecursorIdByKo(std::vector<std::vector<double>> ids,
double ko_value);
/** @todo documentation
*/
// FIXME: TO THROW AWAY
[[deprecated("This function will be removed")]] std::vector<std::size_t>
getClosestPrecursorIdByMz(std::vector<std::vector<double>> ids,
double mz_value);
/** @brief get cumulated raw signal for a given
* precursorCMakeLists.txt.userCMakeLists.txt.userCMakeLists.txt.user only to
* use to see the raw signal
*
* @param precursor_index precursor index to extract signal from
* @result a map of integers, x=time of flights, y= intensities
*/
// Not used in i2mcq
TimsDataFastMap &getCombinedMs2ScansByPrecursorId(std::size_t precursor_id);
protected:
// FIXME NAMING: identical to above
// Not used in i2mcq
SpectrumDescr getSpectrumDescrWithScanCoordinates(
const std::pair<std::size_t, std::size_t> &scan_coordinates);
private:
void ms2ReaderGenerateMS1MS2Spectrum(
const MsRunIdCstSPtr &msrun_id,
std::vector<QualifiedMassSpectrum> &qualified_mass_spectrum_list,
SpectrumCollectionHandlerInterface &handler,
const SpectrumDescr &spectrum_descr,
unsigned int ms_level);
void fillSpectrumDescriptionWithSqlRecord(SpectrumDescr &spectrum_descr,
QSqlQuery &qprecursor_list);
private:
TimsData *mp_timsDataOrigin;
std::size_t m_totalPrecursorCount;
std::map<std::size_t, QSqlRecord> m_mapXicCoordRecord;
pappso::FilterInterfaceCstSPtr mcsp_ms2Filter = nullptr;
pappso::FilterInterfaceCstSPtr mcsp_ms1Filter = nullptr;
/** @brief enable builtin centroid on raw tims integers by default
*/
bool m_builtinMs2Centroid = true;
bool m_isMonoThread = false;
QMutex m_mutex;
};
} // namespace pappso
pappso::QualifiedMassSpectrum
Class representing a fully specified mass spectrum.
Definition qualifiedmassspectrum.h:99
pappso::SpectrumCollectionHandlerInterface
interface to collect spectrums from the MsRunReader class
Definition spectrumcollectionhandlerinterface.h:52
pappso::TimsDataFastMap
replacement for std::map
Definition timsdatafastmap.h:46
pappso::TimsDdaPrecursors::m_isMonoThread
bool m_isMonoThread
Definition timsddaprecursors.h:222
pappso::TimsDdaPrecursors::fillSpectrumDescriptionWithSqlRecord
void fillSpectrumDescriptionWithSqlRecord(SpectrumDescr &spectrum_descr, QSqlQuery &qprecursor_list)
Definition timsddaprecursors.cpp:552
pappso::TimsDdaPrecursors::ms2ReaderGenerateMS1MS2Spectrum
void ms2ReaderGenerateMS1MS2Spectrum(const MsRunIdCstSPtr &msrun_id, std::vector< QualifiedMassSpectrum > &qualified_mass_spectrum_list, SpectrumCollectionHandlerInterface &handler, const SpectrumDescr &spectrum_descr, unsigned int ms_level)
Definition timsddaprecursors.cpp:1112
pappso::TimsDdaPrecursors::getPrecursorsByMzRtCharge
std::vector< std::size_t > getPrecursorsByMzRtCharge(int charge, double mz_val, double rt_sec, double k0)
guess possible precursor ids given a charge, m/z, retention time and k0
Definition timsddaprecursors.cpp:1374
pappso::TimsDdaPrecursors::getQualifiedMs1MassSpectrumBySpectrumDescr
void getQualifiedMs1MassSpectrumBySpectrumDescr(const MsRunIdCstSPtr &msrun_id, QualifiedMassSpectrum &mass_spectrum, const SpectrumDescr &spectrum_descr, bool want_binary_data)
Definition timsddaprecursors.cpp:579
pappso::TimsDdaPrecursors::getSpectrumDescrListByFrameId
std::vector< TimsDdaPrecursors::SpectrumDescr > getSpectrumDescrListByFrameId(std::size_t frame_id) const
get a list of TimsDdaPrecursors::SpectrumDescr for a frame
Definition timsddaprecursors.cpp:74
pappso::TimsDdaPrecursors::m_totalPrecursorCount
std::size_t m_totalPrecursorCount
Definition timsddaprecursors.h:209
pappso::TimsDdaPrecursors::mcsp_ms1Filter
pappso::FilterInterfaceCstSPtr mcsp_ms1Filter
Definition timsddaprecursors.h:216
pappso::TimsDdaPrecursors::getClosestPrecursorIdByMz
std::vector< std::size_t > getClosestPrecursorIdByMz(std::vector< std::vector< double > > ids, double mz_value)
Definition timsddaprecursors.cpp:1476
pappso::TimsDdaPrecursors::m_mapXicCoordRecord
std::map< std::size_t, QSqlRecord > m_mapXicCoordRecord
Definition timsddaprecursors.h:212
pappso::TimsDdaPrecursors::getSpectrumDescrWithScanCoordinates
SpectrumDescr getSpectrumDescrWithScanCoordinates(const std::pair< std::size_t, std::size_t > &scan_coordinates)
Definition timsddaprecursors.cpp:480
pappso::TimsDdaPrecursors::setMs2BuiltinCentroid
void setMs2BuiltinCentroid(bool centroid)
enable or disable simple centroid filter on raw tims data for MS2
Definition timsddaprecursors.cpp:878
pappso::TimsDdaPrecursors::m_mutex
QMutex m_mutex
Definition timsddaprecursors.h:224
pappso::TimsDdaPrecursors::getQualifiedMs2MassSpectrumBySpectrumDescr
void getQualifiedMs2MassSpectrumBySpectrumDescr(const MsRunIdCstSPtr &msrun_id, QualifiedMassSpectrum &mass_spectrum, const SpectrumDescr &spectrum_descr, bool want_binary_data)
Definition timsddaprecursors.cpp:686
pappso::TimsDdaPrecursors::getMs2BuiltinCentroid
bool getMs2BuiltinCentroid() const
tells if simple centroid filter on raw tims data for MS2 is enabled or not
Definition timsddaprecursors.cpp:884
pappso::TimsDdaPrecursors::getXicCoordTimsFromPrecursorId
XicCoordTims getXicCoordTimsFromPrecursorId(std::size_t precursor_id, PrecisionPtr precision_ptr)
Definition timsddaprecursors.cpp:292
pappso::TimsDdaPrecursors::rawReaderSpectrumCollectionByMsLevel
void rawReaderSpectrumCollectionByMsLevel(const MsRunIdCstSPtr &msrun_id, SpectrumCollectionHandlerInterface &handler, unsigned int ms_level)
function to visit an MsRunReader and get each raw Spectrum in a spectrum collection handler by Ms Lev...
Definition timsddaprecursors.cpp:1143
pappso::TimsDdaPrecursors::TimsDdaPrecursors
TimsDdaPrecursors(QSqlQuery &query, TimsData *tims_data_origin)
Definition timsddaprecursors.cpp:38
pappso::TimsDdaPrecursors::TimsData
friend TimsData
Definition timsddaprecursors.h:39
pappso::TimsDdaPrecursors::setMs2FilterCstSPtr
void setMs2FilterCstSPtr(pappso::FilterInterfaceCstSPtr &filter)
filter interface to apply just after raw MS2 specturm extraction the filter can be a list of filters ...
Definition timsddaprecursors.cpp:675
pappso::TimsDdaPrecursors::mp_timsDataOrigin
TimsData * mp_timsDataOrigin
Definition timsddaprecursors.h:207
pappso::TimsDdaPrecursors::mcsp_ms2Filter
pappso::FilterInterfaceCstSPtr mcsp_ms2Filter
Definition timsddaprecursors.h:215
pappso::TimsDdaPrecursors::ms2ReaderSpectrumCollectionByMsLevel
void ms2ReaderSpectrumCollectionByMsLevel(const MsRunIdCstSPtr &msrun_id, SpectrumCollectionHandlerInterface &handler, unsigned int ms_level)
function to visit an MsRunReader and get each Spectrum in a spectrum collection handler by Ms Levels
Definition timsddaprecursors.cpp:890
pappso::TimsDdaPrecursors::getMatchPrecursorIdByKo
std::vector< std::size_t > getMatchPrecursorIdByKo(std::vector< std::vector< double > > ids, double ko_value)
Definition timsddaprecursors.cpp:1451
pappso::TimsDdaPrecursors::setMs1FilterCstSPtr
void setMs1FilterCstSPtr(pappso::FilterInterfaceCstSPtr &filter)
filter interface to apply just after raw MS1 specturm extraction the filter can be a list of filters ...
Definition timsddaprecursors.cpp:680
pappso::TimsDdaPrecursors::getSpectrumDescrWithPrecursorId
TimsDdaPrecursors::SpectrumDescr getSpectrumDescrWithPrecursorId(std::size_t precursor_id) const
get an intermediate structure describing a spectrum
Definition timsddaprecursors.cpp:397
pappso::TimsDdaPrecursors::setMonoThread
void setMonoThread(bool is_mono_thread)
set only one is_mono_thread to true
Definition timsddaprecursors.cpp:1106
pappso::TimsDdaPrecursors::getTotalPrecursorCount
std::size_t getTotalPrecursorCount() const
get the number of precursors analyzed by PASEF
Definition timsddaprecursors.cpp:286
pappso::TimsDdaPrecursors::m_builtinMs2Centroid
bool m_builtinMs2Centroid
enable builtin centroid on raw tims integers by default
Definition timsddaprecursors.h:220
pappso::TimsDdaPrecursors::getCombinedMs2ScansByPrecursorId
TimsDataFastMap & getCombinedMs2ScansByPrecursorId(std::size_t precursor_id)
get cumulated raw signal for a given precursorCMakeLists.txt.userCMakeLists.txt.userCMakeLists....
Definition timsddaprecursors.cpp:164
export-import-config.h
PMSPP_LIB_DECL
#define PMSPP_LIB_DECL
Definition export-import-config.h:14
pappso
tries to keep as much as possible monoisotopes, removing any possible C13 peaks and changes multichar...
Definition aa.cpp:39
pappso::MsRunIdCstSPtr
std::shared_ptr< const MsRunId > MsRunIdCstSPtr
Definition msrunid.h:46
pappso::FilterInterfaceCstSPtr
std::shared_ptr< const FilterInterface > FilterInterfaceCstSPtr
Definition filterinterface.h:47
pappso::PrecisionPtr
const PrecisionBase * PrecisionPtr
Definition precision.h:122
pappso::PrecursorIonData
Definition qualifiedmassspectrum.h:75
pappso::TimsDdaPrecursors::SpectrumDescr
Definition timsddaprecursors.h:63
pappso::TimsDdaPrecursors::SpectrumDescr::parent_frame
std::size_t parent_frame
Definition timsddaprecursors.h:64
pappso::TimsDdaPrecursors::SpectrumDescr::collisionEnergy
float collisionEnergy
Definition timsddaprecursors.h:72
pappso::TimsDdaPrecursors::SpectrumDescr::ms2_index
std::size_t ms2_index
Definition timsddaprecursors.h:69
pappso::TimsDdaPrecursors::SpectrumDescr::scan_mobility_end
std::size_t scan_mobility_end
Definition timsddaprecursors.h:67
pappso::TimsDdaPrecursors::SpectrumDescr::precursor_ion_data
PrecursorIonData precursor_ion_data
Definition timsddaprecursors.h:74
pappso::TimsDdaPrecursors::SpectrumDescr::tims_frame_list
std::vector< std::size_t > tims_frame_list
Definition timsddaprecursors.h:73
pappso::TimsDdaPrecursors::SpectrumDescr::ms1_index
std::size_t ms1_index
Definition timsddaprecursors.h:68
pappso::TimsDdaPrecursors::SpectrumDescr::isolationMz
double isolationMz
Definition timsddaprecursors.h:70
pappso::TimsDdaPrecursors::SpectrumDescr::isolationWidth
double isolationWidth
Definition timsddaprecursors.h:71
pappso::TimsDdaPrecursors::SpectrumDescr::precursor_id
std::size_t precursor_id
Definition timsddaprecursors.h:65
pappso::TimsDdaPrecursors::SpectrumDescr::scan_mobility_start
std::size_t scan_mobility_start
Definition timsddaprecursors.h:66
pappso::XicCoordTims
coordinates of the XIC to extract and the resulting XIC after extraction
Definition xiccoordtims.h:51
timsdata.h