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, CborStreamWriter *cbor_output_p)
40 : PsmFileScanProcessAndCopy(buffer_scan_size, cbor_output_p, "psm features")
41{
42 m_minimumMz = 150;
44 m_tandemSpectrumProcess.setNmostIntense(100);
45 m_tandemSpectrumProcess.setDynamicRange(100);
46
47
48 m_ionList.clear();
51
53
55}
56
57PsmFeatures::PsmFeatures(std::size_t buffer_scan_size,
58 pappso::cbor::CborStreamWriter *cbor_output_p,
59 const QJsonObject &parameters)
60 : PsmFileScanProcessAndCopy(buffer_scan_size, cbor_output_p, "psm features")
61{
62
63 m_ionList.clear();
66
67 if(parameters.empty())
68 {
69 m_minimumMz = 150;
70 m_tandemSpectrumProcess.setMinimumMz(m_minimumMz);
71 m_tandemSpectrumProcess.setNmostIntense(100);
72 m_tandemSpectrumProcess.setDynamicRange(100);
73 m_fragmentTolerance = pappso::PrecisionFactory::getDaltonInstance(0.02);
74 }
75 else
76 {
77
78 m_minimumMz = parameters.value("minimum_mz").toDouble();
79 m_tandemSpectrumProcess.setMinimumMz(m_minimumMz);
80 m_tandemSpectrumProcess.setNmostIntense(
81 parameters.value("hyperscore").toObject().value("n_most_intense").toInt());
82 m_tandemSpectrumProcess.setDynamicRange(
83 parameters.value("hyperscore").toObject().value("dynamic_range").toInt());
84
85
86 if(parameters.value("fragment_tolerance_unit").toString() == "dalton")
87 {
88 m_fragmentTolerance = pappso::PrecisionFactory::getDaltonInstance(
89 parameters.value("fragment_tolerance").toDouble());
90 }
91 else if(parameters.value("fragment_tolerance_unit").toString() == "ppm")
92 {
93 m_fragmentTolerance = pappso::PrecisionFactory::getPpmInstance(
94 parameters.value("fragment_tolerance").toDouble());
95 }
96 }
97
98 mpa_psmFeatures = new pappso::PsmFeatures(m_fragmentTolerance, m_minimumMz);
99}
100
101
106
107
108void
110{
111 QCborMap cbor_features_parameters;
112
113 cbor_features_parameters.insert(QString("minimum_mz"), m_minimumMz);
114 cbor_features_parameters.insert(QString("fragment_tolerance_unit"),
116 cbor_features_parameters.insert(QString("fragment_tolerance"), m_fragmentTolerance->getNominal());
117 cbor_features_parameters.insert(QString("ion_list"), "y b");
118
119 QCborMap cbor_hyperscore;
120 cbor_hyperscore.insert(QString("minimum_mz"), m_minimumMz);
121 cbor_hyperscore.insert(QString("n_most_intense"), m_tandemSpectrumProcess.getNmostIntense());
122 cbor_hyperscore.insert(QString("dynamic_range"), m_tandemSpectrumProcess.getDynamicRange());
123
124 cbor_features_parameters.insert(QString("hyperscore"), cbor_hyperscore);
125
126 m_cborParameterMap.insert(QString("features"), cbor_features_parameters);
127
128 mp_cborOutput->append("parameter_map");
129 mp_cborOutput->writeCborMap(m_cborParameterMap);
130}
131
132
139
140} // namespace psm
141} // namespace cbor
142} // 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:544
overrides QCborStreamWriter base class to provide convenient functions
CborScanMapBase * newCborScanMap() override
pappso::XtandemSpectrumProcess m_tandemSpectrumProcess
Definition psmfeatures.h:69
void parameterMapReady(pappso::UiMonitorInterface &monitor) override
pappso::PsmFeatures * mpa_psmFeatures
Definition psmfeatures.h:73
pappso::PrecisionPtr m_fragmentTolerance
Definition psmfeatures.h:72
PsmFeatures(std::size_t buffer_scan_size, CborStreamWriter *cbor_output_p)
std::list< pappso::Enums::PeptideIon > m_ionList
Definition psmfeatures.h:71
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