Loading...
Searching...
No Matches
psmfeatures.cpp
Go to the documentation of this file.
/**
* \file pappsomspp/processing/cbor/psm/evalscan/psmfeatures.cpp
* \date 15/07/2025
* \author Olivier Langella
* \brief compute features on scan's PSM
*/
/*******************************************************************************
* Copyright (c) 2025 Olivier Langella <Olivier.Langella@universite-paris-saclay.fr>.
*
* This file is part of PAPPSOms-tools.
*
* PAPPSOms-tools 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-tools 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-tools. If not, see <http://www.gnu.org/licenses/>.
*
******************************************************************************/
#include "psmfeatures.h"
#include "psmfeaturesscan.h"
#include "pappsomspp/core/utils.h"
namespace pappso
{
namespace cbor
{
namespace psm
{
PsmFeatures::PsmFeatures(std::size_t buffer_scan_size, CborStreamWriter *cbor_output_p)
: PsmFileScanProcessAndCopy(buffer_scan_size, cbor_output_p, "psm features")
{
m_minimumMz = 150;
m_tandemSpectrumProcess.setMinimumMz(m_minimumMz);
m_tandemSpectrumProcess.setNmostIntense(100);
m_tandemSpectrumProcess.setDynamicRange(100);
m_ionList.clear();
m_ionList.push_back(Enums::PeptideIon::y);
m_ionList.push_back(Enums::PeptideIon::b);
m_fragmentTolerance = pappso::PrecisionFactory::getDaltonInstance(0.02);
mpa_psmFeatures = new pappso::PsmFeatures(m_fragmentTolerance, m_minimumMz);
}
PsmFeatures::PsmFeatures(std::size_t buffer_scan_size,
pappso::cbor::CborStreamWriter *cbor_output_p,
const QJsonObject &parameters)
: PsmFileScanProcessAndCopy(buffer_scan_size, cbor_output_p, "psm features")
{
m_ionList.clear();
m_ionList.push_back(Enums::PeptideIon::y);
m_ionList.push_back(Enums::PeptideIon::b);
if(parameters.empty())
{
m_minimumMz = 150;
m_tandemSpectrumProcess.setMinimumMz(m_minimumMz);
m_tandemSpectrumProcess.setNmostIntense(100);
m_tandemSpectrumProcess.setDynamicRange(100);
m_fragmentTolerance = pappso::PrecisionFactory::getDaltonInstance(0.02);
}
else
{
m_minimumMz = parameters.value("minimum_mz").toDouble();
m_tandemSpectrumProcess.setMinimumMz(m_minimumMz);
m_tandemSpectrumProcess.setNmostIntense(
parameters.value("hyperscore").toObject().value("n_most_intense").toInt());
m_tandemSpectrumProcess.setDynamicRange(
parameters.value("hyperscore").toObject().value("dynamic_range").toInt());
if(parameters.value("fragment_tolerance_unit").toString() == "dalton")
{
m_fragmentTolerance = pappso::PrecisionFactory::getDaltonInstance(
parameters.value("fragment_tolerance").toDouble());
}
else if(parameters.value("fragment_tolerance_unit").toString() == "ppm")
{
m_fragmentTolerance = pappso::PrecisionFactory::getPpmInstance(
parameters.value("fragment_tolerance").toDouble());
}
}
mpa_psmFeatures = new pappso::PsmFeatures(m_fragmentTolerance, m_minimumMz);
}
PsmFeatures::~PsmFeatures()
{
delete mpa_psmFeatures;
}
void
PsmFeatures::parameterMapReady(pappso::UiMonitorInterface &monitor [[maybe_unused]])
{
QCborMap cbor_features_parameters;
cbor_features_parameters.insert(QString("minimum_mz"), m_minimumMz);
cbor_features_parameters.insert(QString("fragment_tolerance_unit"),
Utils::toString(m_fragmentTolerance->unit()));
cbor_features_parameters.insert(QString("fragment_tolerance"), m_fragmentTolerance->getNominal());
cbor_features_parameters.insert(QString("ion_list"), "y b");
QCborMap cbor_hyperscore;
cbor_hyperscore.insert(QString("minimum_mz"), m_minimumMz);
cbor_hyperscore.insert(QString("n_most_intense"), m_tandemSpectrumProcess.getNmostIntense());
cbor_hyperscore.insert(QString("dynamic_range"), m_tandemSpectrumProcess.getDynamicRange());
cbor_features_parameters.insert(QString("hyperscore"), cbor_hyperscore);
m_cborParameterMap.insert(QString("features"), cbor_features_parameters);
mp_cborOutput->append("parameter_map");
mp_cborOutput->writeCborMap(m_cborParameterMap);
}
CborScanMapBase *
PsmFeatures::newCborScanMap()
{
return new PsmFeaturesScan(
*this, m_tandemSpectrumProcess, m_ionList, *mpa_psmFeatures, m_fragmentTolerance);
}
} // namespace psm
} // namespace cbor
} // namespace pappso
pappso::PrecisionFactory::getDaltonInstance
static PrecisionPtr getDaltonInstance(pappso_double value)
get a Dalton precision pointer
Definition precision.cpp:136
pappso::PsmFeatures
Definition psmfeatures.h:46
pappso::PsmFeatures::~PsmFeatures
~PsmFeatures()
Definition psmfeatures.cpp:52
pappso::UiMonitorInterface
Definition uimonitorinterface.h:50
pappso::Utils::toString
static QString toString(specglob::SpectralAlignmentType type)
Convenience function to return a string describing the specglob alingment type.
Definition utils.cpp:544
pappso::cbor::CborStreamWriter
overrides QCborStreamWriter base class to provide convenient functions
Definition cborstreamwriter.h:45
pappso::cbor::psm::CborScanMapBase
Definition cborscanmapbase.h:48
pappso::cbor::psm::PsmFeaturesScan
Definition psmfeaturesscan.h:45
pappso::cbor::psm::PsmFeatures::newCborScanMap
CborScanMapBase * newCborScanMap() override
Definition psmfeatures.cpp:134
pappso::cbor::psm::PsmFeatures::m_tandemSpectrumProcess
pappso::XtandemSpectrumProcess m_tandemSpectrumProcess
Definition psmfeatures.h:69
pappso::cbor::psm::PsmFeatures::parameterMapReady
void parameterMapReady(pappso::UiMonitorInterface &monitor) override
Definition psmfeatures.cpp:109
pappso::cbor::psm::PsmFeatures::mpa_psmFeatures
pappso::PsmFeatures * mpa_psmFeatures
Definition psmfeatures.h:73
pappso::cbor::psm::PsmFeatures::m_fragmentTolerance
pappso::PrecisionPtr m_fragmentTolerance
Definition psmfeatures.h:72
pappso::cbor::psm::PsmFeatures::m_minimumMz
double m_minimumMz
Definition psmfeatures.h:70
pappso::cbor::psm::PsmFeatures::PsmFeatures
PsmFeatures(std::size_t buffer_scan_size, CborStreamWriter *cbor_output_p)
Definition psmfeatures.cpp:39
pappso::cbor::psm::PsmFeatures::m_ionList
std::list< pappso::Enums::PeptideIon > m_ionList
Definition psmfeatures.h:71
pappso::cbor::psm::PsmFileReaderBase::m_cborParameterMap
QCborMap m_cborParameterMap
Definition psmfilereaderbase.h:135
pappso::cbor::psm::PsmFileScanProcessAndCopy::mp_cborOutput
CborStreamWriter * mp_cborOutput
Definition psmfilescanprocessandcopy.h:87
pappso::cbor::psm::PsmFileScanProcessAndCopy::PsmFileScanProcessAndCopy
PsmFileScanProcessAndCopy(std::size_t buffer_scan_size, CborStreamWriter *cbor_output_p, const QString &operation)
Definition psmfilescanprocessandcopy.cpp:41
pappso::Enums::PeptideIon::y
@ y
Cter amino ions.
Definition types.h:295
pappso::Enums::PeptideIon::b
@ b
Nter acylium ions.
Definition types.h:287
pappso::cbor::psm
Definition cborscanmapbase.h:40
pappso::cbor
Definition cborstreamreader.cpp:35
pappso
tries to keep as much as possible monoisotopes, removing any possible C13 peaks and changes multichar...
Definition aa.cpp:39
psmfeatures.h
psmfeaturesscan.h
utils.h