Loading...
Searching...
No Matches
xiccoordtims.cpp
Go to the documentation of this file.
/**
* \file pappsomspp/msrun/xiccoord/xiccoordtims.cpp
* \date 22/04/2021
* \author Olivier Langella
* \brief XIC coordinate in a Tims MSrun
*/
/*******************************************************************************
* Copyright (c) 2021 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 <QObject>
#include <QVariant>
#include "xiccoordtims.h"
#include "../../exception/exceptionnotpossible.h"
namespace pappso
{
XicCoordTims::XicCoordTims(const XicCoordTims &other) : XicCoord(other)
{
scanNumBegin = other.scanNumBegin;
scanNumEnd = other.scanNumEnd;
}
XicCoordTims::~XicCoordTims()
{
}
XicCoordSPtr
XicCoordTims::initializeAndClone() const
{
XicCoordTimsSPtr xic_coord_sp = std::make_shared<XicCoordTims>(*this);
xic_coord_sp.get()->xicSptr = std::make_shared<Xic>();
return xic_coord_sp;
}
XicCoordSPtr
XicCoordTims::addition(XicCoordSPtr &to_add) const
{
XicCoordTimsSPtr xic_coord_sp = std::make_shared<XicCoordTims>(*this);
XicCoordTims *toadd = dynamic_cast<XicCoordTims *>(to_add.get());
if(toadd == nullptr)
{
throw ExceptionNotPossible(
QObject::tr("XicCoord to add is of a different type"));
}
// xic_coord_sp.get()->xicSptr = xic_coord_sp.get()->xicSptr;
xic_coord_sp.get()->mzRange += to_add.get()->mzRange;
xic_coord_sp.get()->rtTarget += to_add.get()->rtTarget;
xic_coord_sp.get()->scanNumBegin += toadd->scanNumBegin;
xic_coord_sp.get()->scanNumEnd += toadd->scanNumEnd;
qDebug() << "xic_coord_sp.get()->scanNumBegin="
<< xic_coord_sp.get()->scanNumBegin;
qDebug() << "xic_coord_sp.get()->scanNumEnd="
<< xic_coord_sp.get()->scanNumEnd;
return xic_coord_sp;
}
XicCoordSPtr
XicCoordTims::multiplyBy(double number) const
{
XicCoordTimsSPtr xic_coord_sp = std::make_shared<XicCoordTims>(*this);
// xic_coord_sp.get()->xicSptr = nullptr;
xic_coord_sp.get()->rtTarget *= number;
xic_coord_sp.get()->mzRange *= number;
xic_coord_sp.get()->scanNumBegin *= number;
xic_coord_sp.get()->scanNumEnd *= number;
return xic_coord_sp;
}
XicCoordSPtr
XicCoordTims::divideBy(double number) const
{
XicCoordTimsSPtr xic_coord_sp = std::make_shared<XicCoordTims>(*this);
// xic_coord_sp.get()->xicSptr = nullptr;
xic_coord_sp.get()->rtTarget /= number;
xic_coord_sp.get()->mzRange *= (double)((double)1 / number);
xic_coord_sp.get()->scanNumBegin /= number;
xic_coord_sp.get()->scanNumEnd /= number;
qDebug() << "xic_coord_sp.get()->scanNumBegin="
<< xic_coord_sp.get()->scanNumBegin;
qDebug() << "xic_coord_sp.get()->scanNumEnd="
<< xic_coord_sp.get()->scanNumEnd;
return xic_coord_sp;
}
void
XicCoordTims::reset()
{
xicSptr = nullptr;
rtTarget = 0;
mzRange = MzRange(0.0, 0.0);
scanNumBegin = 0;
scanNumEnd = 0;
}
QString
XicCoordTims::toString() const
{
return QString("%1 begin=%2 end=%3")
.arg(XicCoord::toString())
.arg(scanNumBegin)
.arg(scanNumEnd);
}
const QVariant
XicCoordTims::getParam(XicCoordParam param) const
{
switch(param)
{
case XicCoordParam::TimsTofIonMobilityScanNumberStart:
return QVariant((quint64)scanNumBegin);
break;
case XicCoordParam::TimsTofIonMobilityScanNumberStop:
return QVariant((quint64)scanNumEnd);
break;
default:
return QVariant();
}
}
void
XicCoordTims::scanNumBeginRangeCorrection(long start_dev, long stop_dev)
{
long begin = scanNumBegin + start_dev;
long end = scanNumEnd + stop_dev;
if(begin < 0)
scanNumBegin = 0;
else
scanNumBegin = begin;
if(end < 0)
scanNumEnd = 0;
else
scanNumEnd = end;
}
} // namespace pappso
pappso::ExceptionNotPossible
Definition exceptionnotpossible.h:29
pappso::MzRange
Definition mzrange.h:46
pappso
tries to keep as much as possible monoisotopes, removing any possible C13 peaks and changes multichar...
Definition aa.cpp:39
pappso::XicCoordParam
XicCoordParam
Definition xiccoord.h:50
pappso::XicCoordParam::TimsTofIonMobilityScanNumberStart
@ TimsTofIonMobilityScanNumberStart
pappso::XicCoordParam::TimsTofIonMobilityScanNumberStop
@ TimsTofIonMobilityScanNumberStop
pappso::XicCoordTimsSPtr
std::shared_ptr< XicCoordTims > XicCoordTimsSPtr
Definition xiccoordtims.h:40
pappso::XicCoordSPtr
std::shared_ptr< XicCoord > XicCoordSPtr
Definition xiccoord.h:43
pappso::XicCoordTims
coordinates of the XIC to extract and the resulting XIC after extraction
Definition xiccoordtims.h:51
pappso::XicCoordTims::scanNumBeginRangeCorrection
void scanNumBeginRangeCorrection(long start_dev, long stop_dev)
apply scan num correction on xic coordinate
Definition xiccoordtims.cpp:169
pappso::XicCoordTims::initializeAndClone
virtual XicCoordSPtr initializeAndClone() const override
intialize the XIC and make a deep copy of object
Definition xiccoordtims.cpp:54
pappso::XicCoordTims::~XicCoordTims
virtual ~XicCoordTims()
Definition xiccoordtims.cpp:48
pappso::XicCoordTims::scanNumEnd
std::size_t scanNumEnd
mobility index end
Definition xiccoordtims.h:98
pappso::XicCoordTims::addition
virtual XicCoordSPtr addition(XicCoordSPtr &to_add) const override
compute a new XIC coord as the sum of the given one
Definition xiccoordtims.cpp:66
pappso::XicCoordTims::scanNumBegin
std::size_t scanNumBegin
mobility index begin
Definition xiccoordtims.h:94
pappso::XicCoordTims::toString
virtual QString toString() const override
get a description of the XIC coordinate in a string
Definition xiccoordtims.cpp:144
pappso::XicCoordTims::getParam
virtual const QVariant getParam(XicCoordParam param) const override
get a specific XIC coordinate parameter
Definition xiccoordtims.cpp:154
pappso::XicCoordTims::reset
virtual void reset() override
reset to zero
Definition xiccoordtims.cpp:132
pappso::XicCoordTims::divideBy
virtual XicCoordSPtr divideBy(double number) const override
compute a new xic coord as a division by
Definition xiccoordtims.cpp:110
pappso::XicCoordTims::XicCoordTims
XicCoordTims()
Definition xiccoordtims.h:55
pappso::XicCoordTims::multiplyBy
virtual XicCoordSPtr multiplyBy(double number) const override
compute a new xic coord as a product by
Definition xiccoordtims.cpp:94
pappso::XicCoord
coordinates of the XIC to extract and the resulting XIC after extraction
Definition xiccoord.h:67
pappso::XicCoord::xicSptr
XicSPtr xicSptr
extracted xic
Definition xiccoord.h:130
pappso::XicCoord::rtTarget
double rtTarget
the targeted retention time to extract around intended in seconds, and related to one msrun....
Definition xiccoord.h:126
pappso::XicCoord::mzRange
MzRange mzRange
the mass to extract
Definition xiccoord.h:120
pappso::XicCoord::toString
virtual QString toString() const
get a description of the XIC coordinate in a string
Definition xiccoord.cpp:116
xiccoordtims.h
XIC coordinate in a Tims MSrun.