Loading...
Searching...
No Matches
timsframemobilitytraces.cpp
Go to the documentation of this file.
/**
* \file pappsomspp/vendors/tims/mobilitytraces
* \date 05/07/2024
* \author Olivier Langella
* \brief extracting mobility traces
*/
/*******************************************************************************
* Copyright (c) 2024 Olivier Langella
*<Olivier.Langella@universite-paris-saclay.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/>.
*
******************************************************************************/
#include "timsframemobilitytraces.h"
#include "../../../exception/exceptionnotfound.h"
#include <QDebug>
namespace pappso
{
TimsFrameMobilityTraces::TimsFrameMobilityTraces()
{
}
TimsFrameMobilityTraces::TimsFrameMobilityTraces(
const TimsFrameMobilityTraces &other)
{
}
TimsFrameMobilityTraces::~TimsFrameMobilityTraces()
{
}
void
TimsFrameMobilityTraces::extractMobilityTraces(
pappso::TimsFrameCstSPtr timsframe_sptr,
std::size_t scan_index_begin,
std::size_t scan_index_end,
std::size_t max_traces)
{
m_tofIndexList.clear();
m_ionMobTraceList.clear();
m_scanIndexList.clear();
mcsp_timsFrameCstSPtr = timsframe_sptr;
pappso::TimsDataFastMap raw_spectrum =
pappso::TimsDataFastMap::getTimsDataFastMapInstance();
timsframe_sptr.get()->combineScansInTofIndexIntensityMap(
raw_spectrum, scan_index_begin, scan_index_end);
pappso::Trace total_spectrum;
for(auto index : raw_spectrum.getTofIndexList())
{
total_spectrum.push_back(
{(double)index, (double)raw_spectrum.readIntensity(index)});
}
total_spectrum.sortY(SortOrder::descending);
qDebug() << total_spectrum.size();
total_spectrum.sortY(pappso::SortOrder::descending);
for(std::size_t i = scan_index_begin; i < (scan_index_end + 1); i++)
{
m_scanIndexList.push_back(i);
}
for(auto &datapoint : total_spectrum)
{
pappso::Trace trace(
timsframe_sptr.get()->getIonMobilityTraceByTofIndexRange(
datapoint.x - 1,
datapoint.x + 1,
pappso::XicExtractMethod::sum,
scan_index_begin,
scan_index_end));
m_ionMobTraceList.push_back(trace.makeTraceSPtr());
m_tofIndexList.push_back(datapoint.x);
if(m_ionMobTraceList.size() >= max_traces)
break;
}
qDebug();
}
const std::vector<pappso::TraceCstSPtr> &
TimsFrameMobilityTraces::getIonMobTraceList() const
{
return m_ionMobTraceList;
}
const std::vector<std::size_t> &
TimsFrameMobilityTraces::getTofIndexList() const
{
return m_tofIndexList;
}
const std::vector<double>
TimsFrameMobilityTraces::getMzList() const
{
MzCalibrationInterface *mz_calibration_p =
mcsp_timsFrameCstSPtr.get()->getMzCalibrationInterfaceSPtr().get();
if(mz_calibration_p == nullptr)
{
throw pappso::ExceptionNotFound(
QObject::tr("mz calibration pointer not found"));
}
std::vector<double> mz_list;
for(std::size_t tof : m_tofIndexList)
{
mz_list.push_back(mz_calibration_p->getMzFromTofIndex((quint32)tof));
}
return mz_list;
}
const std::vector<std::size_t> &
TimsFrameMobilityTraces::getScanIndexList() const
{
return m_scanIndexList;
}
} // namespace pappso
pappso::ExceptionNotFound
Definition exceptionnotfound.h:32
pappso::MzCalibrationInterface
Definition mzcalibrationinterface.h:43
pappso::MzCalibrationInterface::getMzFromTofIndex
virtual double getMzFromTofIndex(quint32 tof_index)=0
get m/z from time of flight raw index
pappso::TimsDataFastMap
replacement for std::map
Definition timsdatafastmap.h:46
pappso::TimsDataFastMap::getTofIndexList
const std::vector< quint32 > & getTofIndexList() const
Definition timsdatafastmap.cpp:198
pappso::TimsDataFastMap::readIntensity
std::size_t readIntensity(quint32)
reads intensity for a tof_index
Definition timsdatafastmap.cpp:88
pappso::TimsDataFastMap::getTimsDataFastMapInstance
static TimsDataFastMap & getTimsDataFastMapInstance()
Definition timsdatafastmap.cpp:41
pappso::TimsFrameMobilityTraces
Definition timsframemobilitytraces.h:39
pappso::TimsFrameMobilityTraces::extractMobilityTraces
void extractMobilityTraces(pappso::TimsFrameCstSPtr timsframe_sptr, std::size_t ion_mob_begin, std::size_t ion_mob_end, std::size_t max_traces)
Definition timsframemobilitytraces.cpp:47
pappso::TimsFrameMobilityTraces::mcsp_timsFrameCstSPtr
pappso::TimsFrameCstSPtr mcsp_timsFrameCstSPtr
Definition timsframemobilitytraces.h:69
pappso::TimsFrameMobilityTraces::getScanIndexList
const std::vector< std::size_t > & getScanIndexList() const
Definition timsframemobilitytraces.cpp:128
pappso::TimsFrameMobilityTraces::m_tofIndexList
std::vector< std::size_t > m_tofIndexList
Definition timsframemobilitytraces.h:72
pappso::TimsFrameMobilityTraces::m_ionMobTraceList
std::vector< pappso::TraceCstSPtr > m_ionMobTraceList
Definition timsframemobilitytraces.h:71
pappso::TimsFrameMobilityTraces::TimsFrameMobilityTraces
TimsFrameMobilityTraces()
Definition timsframemobilitytraces.cpp:34
pappso::TimsFrameMobilityTraces::getMzList
const std::vector< double > getMzList() const
Definition timsframemobilitytraces.cpp:111
pappso::TimsFrameMobilityTraces::m_scanIndexList
std::vector< std::size_t > m_scanIndexList
Definition timsframemobilitytraces.h:73
pappso::TimsFrameMobilityTraces::getTofIndexList
const std::vector< std::size_t > & getTofIndexList() const
Definition timsframemobilitytraces.cpp:106
pappso::TimsFrameMobilityTraces::~TimsFrameMobilityTraces
~TimsFrameMobilityTraces()
Definition timsframemobilitytraces.cpp:43
pappso::TimsFrameMobilityTraces::getIonMobTraceList
const std::vector< pappso::TraceCstSPtr > & getIonMobTraceList() const
Definition timsframemobilitytraces.cpp:101
pappso::Trace
A simple container of DataPoint instances.
Definition trace.h:148
pappso::Trace::sortY
void sortY(SortOrder sort_order=SortOrder::ascending)
Definition trace.cpp:1100
pappso::Trace::makeTraceSPtr
TraceSPtr makeTraceSPtr() const
Definition trace.cpp:674
pappso
tries to keep as much as possible monoisotopes, removing any possible C13 peaks and changes multichar...
Definition aa.cpp:39
pappso::XicExtractMethod::sum
@ sum
sum of intensities
pappso::TimsFrameCstSPtr
std::shared_ptr< const TimsFrame > TimsFrameCstSPtr
Definition timsframe.h:43
pappso::SortOrder::descending
@ descending
timsframemobilitytraces.h