libpappsomspp
Library for mass spectrometry
Loading...
Searching...
No Matches
sagetsvhandler.h
Go to the documentation of this file.
1/**
2 * \file input/sage/sagereader.h
3 * \date 21/08/2024
4 * \author Olivier Langella
5 * \brief read data files from Sage output
6 */
7
8/*******************************************************************************
9 * Copyright (c) 2024 Olivier Langella
10 *<Olivier.Langella@universite-paris-saclay.fr>.
11 *
12 * This file is part of i2MassChroQ.
13 *
14 * i2MassChroQ is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU General Public License as published by
16 * the Free Software Foundation, either version 3 of the License, or
17 * (at your option) any later version.
18 *
19 * i2MassChroQ is distributed in the hope that it will be useful,
20 * but WITHOUT ANY WARRANTY; without even the implied warranty of
21 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 * GNU General Public License for more details.
23 *
24 * You should have received a copy of the GNU General Public License
25 * along with i2MassChroQ. If not, see <http://www.gnu.org/licenses/>.
26 *
27 ******************************************************************************/
28
29#pragma once
30
31#include <odsstream/odsdochandlerinterface.h>
34#include "sagereader.h"
35#include "../psmproteinmap.h"
36#include <QCborArray>
37
38
39namespace pappso
40{
41namespace cbor
42{
43namespace psm
44{
45
46/**
47 * @todo write docs
48 */
49class SageTsvHandler : public OdsDocHandlerInterface
50{
51 public:
95
96 struct Line
97 {
98 int rank = 0;
99 int label = 0;
100 double expmass = 0.0;
101 double calcmass = 0.0;
102 int charge = 0;
103 std::size_t peptide_len;
112 double rt;
119 std::size_t matched_peaks;
120 std::size_t longest_b;
121 std::size_t longest_y;
124 std::size_t scored_candidates;
125 double poisson;
129 double peptide_q;
130 double protein_q;
132 };
133 /**
134 * Default constructor
135 */
137 const SageReader &sage_reader,
138 PsmProteinMap &psm_protein_map);
139
140 /**
141 * Destructor
142 */
143 virtual ~SageTsvHandler();
144 /**
145 * callback that indicates the begining of a data sheet. Override it in
146 * order to retrieve information about the current data sheet.
147 *
148 */
149 virtual void startSheet(const QString &sheet_name) override;
150
151 /**
152 * callback that indicates the end of the current data sheet. Override it if
153 * needed
154 */
155 virtual void endSheet() override;
156
157 /**
158 * callback that indicates a new line start. Override it if needed.
159 */
160
161 virtual void startLine() override;
162
163 /**
164 * callback that indicates a line ending. Override it if needed.
165 */
166
167 virtual void endLine() override;
168
169 /**
170 * callback that report the content of the current cell in a dedicated Cell
171 * object. Override it if you need to retrieve cell content.
172 */
173 virtual void setCell(const OdsCell &cell) override;
174 virtual void endDocument() override;
175
176 void writeSampleList();
177
178 private:
179 struct Psm
180 {
181 QString proforma;
182 QStringList protein_list;
184 QCborMap cbor_eval;
185 };
186 struct Scan
187 {
188 QCborMap cbor_id;
190 QCborMap cbor_ms2;
191 std::vector<Psm> psm_list;
192 };
193
194 struct Sample
195 {
196 QString name;
198 std::map<QString, Scan> scan_map;
199 };
200
201 private:
202 void parsePeptide(const QString &peptide_str);
203 void parseProteins(const QString &proteins_str);
204 bool parseSpectrumStringId(const QString &spectrum_string_id);
205 void parseMsRunFilename(const QString &msrun_filename);
206 void recordLine();
207
208 void writeSample(const Sample &one_sample);
209 void writeScan(const Scan &one_scan);
210 void writePsm(const Psm &one_psm);
211
212 private:
216 std::size_t m_progressIndex = 0;
217 std::size_t m_lineNumber = 0;
218 std::size_t m_columnNumber = 0;
219 std::vector<Columns> m_columnTypeList;
220
222 std::vector<SageReader::SageModification> m_staticModificationList;
223 std::vector<SageReader::SageModification> m_variableModificationList;
224 std::size_t m_spectrumIndex;
226 QString m_decoyTag;
227 QStringList m_proteinList;
229 std::map<QString, Sample> m_sampleMap;
231};
232} // namespace psm
233} // namespace cbor
234} // namespace pappso
store PsmProtein in a map with accession as key
std::vector< SageReader::SageModification > m_staticModificationList
void parseProteins(const QString &proteins_str)
virtual void endSheet() override
pappso::UiMonitorInterface * mp_monitor
virtual void startSheet(const QString &sheet_name) override
std::vector< SageReader::SageModification > m_variableModificationList
void parsePeptide(const QString &peptide_str)
bool parseSpectrumStringId(const QString &spectrum_string_id)
void writeSample(const Sample &one_sample)
virtual void setCell(const OdsCell &cell) override
void writePsm(const Psm &one_psm)
SageTsvHandler(pappso::UiMonitorInterface *p_monitor, const SageReader &sage_reader, PsmProteinMap &psm_protein_map)
void writeScan(const Scan &one_scan)
std::map< QString, Sample > m_sampleMap
virtual void endDocument() override
virtual void startLine() override
void parseMsRunFilename(const QString &msrun_filename)
virtual void endLine() override
std::vector< Columns > m_columnTypeList
tries to keep as much as possible monoisotopes, removing any possible C13 peaks and changes multichar...
Definition aa.cpp:39
std::shared_ptr< const Peptide > PeptideSp