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 bool is_fasta_pass,
139 PsmProteinMap &psm_protein_map);
140
141 /**
142 * Destructor
143 */
144 virtual ~SageTsvHandler();
145 /**
146 * callback that indicates the begining of a data sheet. Override it in
147 * order to retrieve information about the current data sheet.
148 *
149 */
150 virtual void startSheet(const QString &sheet_name) override;
151
152 /**
153 * callback that indicates the end of the current data sheet. Override it if
154 * needed
155 */
156 virtual void endSheet() override;
157
158 /**
159 * callback that indicates a new line start. Override it if needed.
160 */
161
162 virtual void startLine() override;
163
164 /**
165 * callback that indicates a line ending. Override it if needed.
166 */
167
168 virtual void endLine() override;
169
170 /**
171 * callback that report the content of the current cell in a dedicated Cell
172 * object. Override it if you need to retrieve cell content.
173 */
174 virtual void setCell(const OdsCell &cell) override;
175
176 /**
177 * callback that report the end of the ODS document. Override it if you need
178 * to know that reading is finished.
179 */
180 virtual void endDocument() override;
181
182 private:
183 struct Psm
184 {
185 QString proforma;
187 QCborMap cbor_eval;
188 };
189 struct Scan
190 {
191 QCborMap cbor_id;
193 QCborMap cbor_ms2;
194 std::vector<Psm> psm_list;
195 };
196
197 struct Sample
198 {
199 QString name;
201 std::map<QString, Scan> scan_map;
202 };
203
204 private:
205 void parsePeptide(const QString &peptide_str);
206 void parseProteins(const QString &proteins_str);
207 bool parseSpectrumStringId(const QString &spectrum_string_id);
208 void parseMsRunFilename(const QString &msrun_filename);
209 void recordLine();
210
211 void writeSample(const Sample &one_sample);
212 void writeScan(const Scan &one_scan);
213 void writePsm(const Psm &one_psm);
214
215 private:
219 std::size_t m_progressIndex = 0;
220 std::size_t m_lineNumber = 0;
221 std::size_t m_columnNumber = 0;
222 std::vector<Columns> m_columnTypeList;
223
225 std::vector<SageReader::SageModification> m_staticModificationList;
226 std::vector<SageReader::SageModification> m_variableModificationList;
227 std::size_t m_spectrumIndex;
229 QString m_decoyTag;
231 QStringList m_proteinList;
233 std::map<QString, Sample> m_sampleMap;
235};
236} // namespace psm
237} // namespace cbor
238} // namespace pappso
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)
SageTsvHandler(pappso::UiMonitorInterface *p_monitor, const SageReader &sage_reader, bool is_fasta_pass, PsmProteinMap &psm_protein_map)
void writeSample(const Sample &one_sample)
virtual void setCell(const OdsCell &cell) override
void writePsm(const Psm &one_psm)
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