Loading...
Searching...
No Matches
msrunreadconfig.cpp
Go to the documentation of this file.
/*******************************************************************************
* Copyright (c) 2023 Filippo Rusconi
*<filippo.rusconi@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 "msrunreadconfig.h"
#include <QDebug>
namespace pappso
{
MsRunReadConfig::MsRunReadConfig()
{
// Set these two levels to true by default.
m_msLevels[1] = true;
m_msLevels[2] = true;
}
MsRunReadConfig::MsRunReadConfig(const MsRunReadConfig &other)
: m_retentionTimeStartSeconds(other.m_retentionTimeStartSeconds),
m_retentionTimeEndSeconds(other.m_retentionTimeEndSeconds),
m_paramsMap(other.m_paramsMap)
{
for(std::size_t index = 0; index < MAX_MS_LEVELS; ++index)
m_msLevels[index] = other.m_msLevels[index];
}
MsRunReadConfig::~MsRunReadConfig()
{
}
MsRunReadConfig &
MsRunReadConfig::operator=(const MsRunReadConfig &other)
{
if(&other == this)
return *this;
m_retentionTimeStartSeconds = other.m_retentionTimeStartSeconds;
m_retentionTimeEndSeconds = other.m_retentionTimeEndSeconds;
m_paramsMap = other.m_paramsMap;
for(std::size_t index = 0; index < MAX_MS_LEVELS; ++index)
m_msLevels[index] = other.m_msLevels[index];
return *this;
}
void
MsRunReadConfig::setRetentionTimeStartInSeconds(double retention_time_start_in_seconds)
{
m_retentionTimeStartSeconds = retention_time_start_in_seconds;
}
double
MsRunReadConfig::getRetentionTimeStartInSeconds() const
{
return m_retentionTimeStartSeconds;
}
void
MsRunReadConfig::setRetentionTimeEndInSeconds(double retention_time_end_in_seconds)
{
m_retentionTimeEndSeconds = retention_time_end_in_seconds;
}
double
MsRunReadConfig::getRetentionTimeEndInSeconds() const
{
return m_retentionTimeEndSeconds;
}
void
MsRunReadConfig::setMsLevels(std::vector<std::size_t> ms_levels)
{
// First reset all the levels to false, this time, since we'll fill the array
// with explicit values.
for(std::size_t index = 0; index < MAX_MS_LEVELS; ++index)
m_msLevels[index] = false;
// And now actually fill with true values the proper array cells.
for(auto ms_level : ms_levels)
{
if(ms_level >= MAX_MS_LEVELS)
{
qDebug() << "The passed vector of MS levels holds a value that is "
"not correct:"
<< ms_level << ": skipping it.";
continue;
}
m_msLevels[ms_level] = true;
}
}
const bool *
MsRunReadConfig::getMsLevels(void) const
{
return m_msLevels;
}
QString
MsRunReadConfig::getMsLevelsAsString() const
{
QString text = "";
for(std::size_t index = 0; index < MAX_MS_LEVELS; ++index)
{
if(m_msLevels[index] == true)
text += QString("%1 ").arg(index);
}
return text;
}
bool
MsRunReadConfig::acceptMsLevel(std::size_t ms_level) const
{
if(ms_level >= MAX_MS_LEVELS)
return false;
return m_msLevels[ms_level];
}
bool
MsRunReadConfig::acceptRetentionTimeInSeconds(double retention_time_in_seconds) const
{
// qDebug() << "Requested retention_time_in_seconds:"
// << retention_time_in_seconds;
// Whatever the member datum below, if it is equal to -1
// then that means that RT is not a selection criterion.
if(m_retentionTimeStartSeconds == -1 || m_retentionTimeEndSeconds == -1)
{
return true;
}
// We use inclusive RT ranges.
if(retention_time_in_seconds >= m_retentionTimeStartSeconds)
{
if(retention_time_in_seconds <= m_retentionTimeEndSeconds)
{
return true;
}
}
return false;
}
bool
MsRunReadConfig::needPeakList() const
{
return m_isPeakListNeeded;
}
void
MsRunReadConfig::setNeedPeakList(bool need_peak_list)
{
m_isPeakListNeeded = need_peak_list;
}
void
MsRunReadConfig::setParameterValue(pappso::MsRunReadConfigParameter parameter,
const QVariant &value)
{
auto ret = m_paramsMap.insert(std::pair<MsRunReadConfigParameter, QVariant>(parameter, value));
if(ret.second == false)
{
ret.first->second = value;
}
}
const QVariant
MsRunReadConfig::getParameterValue(pappso::MsRunReadConfigParameter parameter) const
{
auto it = m_paramsMap.find(parameter);
if(it == m_paramsMap.end())
{
return QVariant();
}
else
{
return it->second;
}
}
void
MsRunReadConfig::reset()
{
m_retentionTimeStartSeconds = -1;
m_retentionTimeEndSeconds = -1;
m_isPeakListNeeded = true;
for(std::size_t index = 0; index < MAX_MS_LEVELS; ++index)
{
m_msLevels[index] = false;
}
// Set these two levels to true by default.
m_msLevels[1] = true;
m_msLevels[2] = true;
m_paramsMap.clear();
}
QString
MsRunReadConfig::toString() const
{
QString text = QString("MsRunReadConfig\n: RT start: %1, RT end: %2\n")
.arg(m_retentionTimeStartSeconds)
.arg(m_retentionTimeEndSeconds);
text += "MS level(s): ";
for(std::size_t index = 0; index < MAX_MS_LEVELS; ++index)
{
if(m_msLevels[index] == true)
text += QString("%1 ").arg(index);
}
text += " \n";
if(!getParameterValue(MsRunReadConfigParameter::TimsFrameIonMobScanIndexBegin).isNull())
{
text +=
QString("Mobility index range: [%1-%2]\n")
.arg(getParameterValue(MsRunReadConfigParameter::TimsFrameIonMobScanIndexBegin).toUInt())
.arg(getParameterValue(MsRunReadConfigParameter::TimsFrameIonMobScanIndexEnd).toUInt());
}
if(!getParameterValue(MsRunReadConfigParameter::TimsFrameIonMobOneOverK0Begin).isNull())
{
text +=
QString("Mobility 1/K0 range: [%1-%2]\n")
.arg(
getParameterValue(MsRunReadConfigParameter::TimsFrameIonMobOneOverK0Begin).toDouble())
.arg(getParameterValue(MsRunReadConfigParameter::TimsFrameIonMobOneOverK0End).toDouble());
}
if(!getParameterValue(MsRunReadConfigParameter::MzRangeBegin).isNull())
{
text += QString("m/z range: [%1-%2]\n")
.arg(getParameterValue(MsRunReadConfigParameter::MzRangeBegin).toDouble())
.arg(getParameterValue(MsRunReadConfigParameter::MzRangeEnd).toDouble());
}
if(!getParameterValue(MsRunReadConfigParameter::TimsFrameMzIndexMergeWindow).isNull())
{
text +=
QString("m/z merge window %1\n")
.arg(getParameterValue(MsRunReadConfigParameter::TimsFrameMzIndexMergeWindow).toUInt());
}
return text;
}
} // namespace pappso
pappso::MsRunReadConfig
Definition msrunreadconfig.h:62
pappso::MsRunReadConfig::needPeakList
bool needPeakList() const
Definition msrunreadconfig.cpp:167
pappso::MsRunReadConfig::getRetentionTimeEndInSeconds
double getRetentionTimeEndInSeconds() const
Definition msrunreadconfig.cpp:83
pappso::MsRunReadConfig::m_retentionTimeStartSeconds
double m_retentionTimeStartSeconds
Definition msrunreadconfig.h:97
pappso::MsRunReadConfig::m_msLevels
bool m_msLevels[MAX_MS_LEVELS]
Definition msrunreadconfig.h:105
pappso::MsRunReadConfig::operator=
MsRunReadConfig & operator=(const MsRunReadConfig &other)
Definition msrunreadconfig.cpp:49
pappso::MsRunReadConfig::toString
QString toString() const
Definition msrunreadconfig.cpp:225
pappso::MsRunReadConfig::m_retentionTimeEndSeconds
double m_retentionTimeEndSeconds
Definition msrunreadconfig.h:98
pappso::MsRunReadConfig::~MsRunReadConfig
~MsRunReadConfig()
Definition msrunreadconfig.cpp:44
pappso::MsRunReadConfig::setNeedPeakList
void setNeedPeakList(bool need_peak_list)
Definition msrunreadconfig.cpp:173
pappso::MsRunReadConfig::setRetentionTimeStartInSeconds
void setRetentionTimeStartInSeconds(double retention_time_start_in_seconds)
Definition msrunreadconfig.cpp:65
pappso::MsRunReadConfig::getParameterValue
const QVariant getParameterValue(MsRunReadConfigParameter parameter) const
Definition msrunreadconfig.cpp:192
pappso::MsRunReadConfig::acceptMsLevel
bool acceptMsLevel(std::size_t ms_level) const
Definition msrunreadconfig.cpp:133
pappso::MsRunReadConfig::acceptRetentionTimeInSeconds
bool acceptRetentionTimeInSeconds(double retention_time_in_seconds) const
Definition msrunreadconfig.cpp:142
pappso::MsRunReadConfig::m_isPeakListNeeded
bool m_isPeakListNeeded
Definition msrunreadconfig.h:100
pappso::MsRunReadConfig::m_paramsMap
std::map< MsRunReadConfigParameter, QVariant > m_paramsMap
map containing any parameter value
Definition msrunreadconfig.h:110
pappso::MsRunReadConfig::reset
void reset()
Definition msrunreadconfig.cpp:207
pappso::MsRunReadConfig::getRetentionTimeStartInSeconds
double getRetentionTimeStartInSeconds() const
Definition msrunreadconfig.cpp:71
pappso::MsRunReadConfig::MsRunReadConfig
MsRunReadConfig()
Definition msrunreadconfig.cpp:28
pappso::MsRunReadConfig::setMsLevels
void setMsLevels(std::vector< std::size_t > ms_levels)
Definition msrunreadconfig.cpp:89
pappso::MsRunReadConfig::setRetentionTimeEndInSeconds
void setRetentionTimeEndInSeconds(double retention_time_end_in_seconds)
Definition msrunreadconfig.cpp:77
pappso::MsRunReadConfig::getMsLevelsAsString
QString getMsLevelsAsString() const
Definition msrunreadconfig.cpp:118
pappso::MsRunReadConfig::getMsLevels
const bool * getMsLevels() const
Definition msrunreadconfig.cpp:112
pappso::MsRunReadConfig::setParameterValue
void setParameterValue(MsRunReadConfigParameter parameter, const QVariant &value)
Definition msrunreadconfig.cpp:179
msrunreadconfig.h
pappso
tries to keep as much as possible monoisotopes, removing any possible C13 peaks and changes multichar...
Definition aa.cpp:39
pappso::MAX_MS_LEVELS
constexpr std::size_t MAX_MS_LEVELS
Definition msrunreadconfig.h:59
pappso::MsRunReadConfigParameter
MsRunReadConfigParameter
Definition msrunreadconfig.h:36
pappso::MsRunReadConfigParameter::MzRangeBegin
@ MzRangeBegin
Definition msrunreadconfig.h:49
pappso::MsRunReadConfigParameter::TimsFrameIonMobOneOverK0Begin
@ TimsFrameIonMobOneOverK0Begin
Definition msrunreadconfig.h:44
pappso::MsRunReadConfigParameter::TimsFrameIonMobOneOverK0End
@ TimsFrameIonMobOneOverK0End
Definition msrunreadconfig.h:45
pappso::MsRunReadConfigParameter::TimsFrameIonMobScanIndexBegin
@ TimsFrameIonMobScanIndexBegin
Definition msrunreadconfig.h:39
pappso::MsRunReadConfigParameter::TimsFrameMzIndexMergeWindow
@ TimsFrameMzIndexMergeWindow
Definition msrunreadconfig.h:54
pappso::MsRunReadConfigParameter::TimsFrameIonMobScanIndexEnd
@ TimsFrameIonMobScanIndexEnd
Definition msrunreadconfig.h:40
pappso::MsRunReadConfigParameter::MzRangeEnd
@ MzRangeEnd
Definition msrunreadconfig.h:50