libpappsomspp
Library for mass spectrometry
Loading...
Searching...
No Matches
psmfeatures.cpp
Go to the documentation of this file.
1/**
2 * \file pappsomspp/processing/cbor/psm/evalscan/psmfeatures.cpp
3 * \date 15/07/2025
4 * \author Olivier Langella
5 * \brief compute features on scan's PSM
6 */
7
8/*******************************************************************************
9 * Copyright (c) 2025 Olivier Langella <Olivier.Langella@universite-paris-saclay.fr>.
10 *
11 * This file is part of PAPPSOms-tools.
12 *
13 * PAPPSOms-tools is free software: you can redistribute it and/or modify
14 * it under the terms of the GNU General Public License as published by
15 * the Free Software Foundation, either version 3 of the License, or
16 * (at your option) any later version.
17 *
18 * PAPPSOms-tools is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU General Public License for more details.
22 *
23 * You should have received a copy of the GNU General Public License
24 * along with PAPPSOms-tools. If not, see <http://www.gnu.org/licenses/>.
25 *
26 ******************************************************************************/
27
28#include "psmfeatures.h"
29#include "psmfeaturesscan.h"
31
32namespace pappso
33{
34namespace cbor
35{
36namespace psm
37{
38
39PsmFeatures::PsmFeatures(std::size_t buffer_scan_size,
40 CborStreamWriter *cbor_output_p)
41 : PsmFileScanProcessAndCopy(buffer_scan_size, cbor_output_p, "psm features")
42{
43 m_minimumMz = 150;
45 m_tandemSpectrumProcess.setNmostIntense(100);
46 m_tandemSpectrumProcess.setDynamicRange(100);
47
48
49 m_ionList.clear();
52
54
56}
57
58PsmFeatures::PsmFeatures(std::size_t buffer_scan_size,
59 pappso::cbor::CborStreamWriter *cbor_output_p,
60 const QJsonObject &parameters)
61 : PsmFileScanProcessAndCopy(buffer_scan_size, cbor_output_p, "psm features")
62{
63
64 m_ionList.clear();
67
68 if(parameters.empty())
69 {
70 m_minimumMz = 150;
71 m_tandemSpectrumProcess.setMinimumMz(m_minimumMz);
72 m_tandemSpectrumProcess.setNmostIntense(100);
73 m_tandemSpectrumProcess.setDynamicRange(100);
74 m_fragmentTolerance = pappso::PrecisionFactory::getDaltonInstance(0.02);
75 }
76 else
77 {
78
79 m_minimumMz = parameters.value("minimum_mz").toDouble();
80 m_tandemSpectrumProcess.setMinimumMz(m_minimumMz);
81 m_tandemSpectrumProcess.setNmostIntense(
82 parameters.value("hyperscore").toObject().value("n_most_intense").toInt());
83 m_tandemSpectrumProcess.setDynamicRange(
84 parameters.value("hyperscore").toObject().value("dynamic_range").toInt());
85
86
87 if(parameters.value("fragment_tolerance_unit").toString() == "dalton")
88 {
89 m_fragmentTolerance = pappso::PrecisionFactory::getDaltonInstance(
90 parameters.value("fragment_tolerance").toDouble());
91 }
92 else if(parameters.value("fragment_tolerance_unit").toString() == "ppm")
93 {
94 m_fragmentTolerance = pappso::PrecisionFactory::getPpmInstance(
95 parameters.value("fragment_tolerance").toDouble());
96 }
97 }
98
99 mpa_psmFeatures = new pappso::PsmFeatures(m_fragmentTolerance, m_minimumMz);
100}
101
102
107
108
109void
111 [[maybe_unused]])
112{
113 QCborMap cbor_features_parameters;
114
115 cbor_features_parameters.insert(QString("minimum_mz"), m_minimumMz);
116 cbor_features_parameters.insert(QString("fragment_tolerance_unit"),
118 cbor_features_parameters.insert(QString("fragment_tolerance"), m_fragmentTolerance->getNominal());
119 cbor_features_parameters.insert(QString("ion_list"), "y b");
120
121 QCborMap cbor_hyperscore;
122 cbor_hyperscore.insert(QString("minimum_mz"), m_minimumMz);
123 cbor_hyperscore.insert(QString("n_most_intense"), m_tandemSpectrumProcess.getNmostIntense());
124 cbor_hyperscore.insert(QString("dynamic_range"), m_tandemSpectrumProcess.getDynamicRange());
125
126 cbor_features_parameters.insert(QString("hyperscore"), cbor_hyperscore);
127
128 m_cborParameterMap.insert(QString("features"), cbor_features_parameters);
129
130 mp_cborOutput->append("parameter_map");
131 mp_cborOutput->writeCborMap(m_cborParameterMap);
132}
133
134
141
142} // namespace psm
143} // namespace cbor
144} // namespace pappso
static PrecisionPtr getDaltonInstance(pappso_double value)
get a Dalton precision pointer
static QString toString(specglob::SpectralAlignmentType type)
Convenience function to return a string describing the specglob alingment type.
Definition utils.cpp:517
CborScanMapBase * newCborScanMap() override
pappso::XtandemSpectrumProcess m_tandemSpectrumProcess
Definition psmfeatures.h:68
void parameterMapReady(pappso::UiMonitorInterface &monitor) override
pappso::PsmFeatures * mpa_psmFeatures
Definition psmfeatures.h:72
pappso::PrecisionPtr m_fragmentTolerance
Definition psmfeatures.h:71
PsmFeatures(std::size_t buffer_scan_size, CborStreamWriter *cbor_output_p)
std::list< pappso::Enums::PeptideIon > m_ionList
Definition psmfeatures.h:70
PsmFileScanProcessAndCopy(std::size_t buffer_scan_size, CborStreamWriter *cbor_output_p, const QString &operation)
@ y
Cter amino ions.
Definition types.h:295
@ b
Nter acylium ions.
Definition types.h:287
tries to keep as much as possible monoisotopes, removing any possible C13 peaks and changes multichar...
Definition aa.cpp:39