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:
98
99 struct Line
100 {
101 int rank = 0;
102 int label = 0;
103 double expmass = 0.0;
104 double calcmass = 0.0;
105 int charge = 0;
106 std::size_t peptide_len;
115 double rt;
122 std::size_t matched_peaks;
123 std::size_t longest_b;
124 std::size_t longest_y;
127 std::size_t scored_candidates;
128 double poisson;
132 double peptide_q;
133 double protein_q;
135 };
136 /**
137 * Default constructor
138 */
140 const SageReader &sage_reader,
141 PsmProteinMap &psm_protein_map);
142
143 /**
144 * Destructor
145 */
146 virtual ~SageTsvHandler();
147 /**
148 * callback that indicates the begining of a data sheet. Override it in
149 * order to retrieve information about the current data sheet.
150 *
151 */
152 virtual void startSheet(const QString &sheet_name) override;
153
154 /**
155 * callback that indicates the end of the current data sheet. Override it if
156 * needed
157 */
158 virtual void endSheet() override;
159
160 /**
161 * callback that indicates a new line start. Override it if needed.
162 */
163
164 virtual void startLine() override;
165
166 /**
167 * callback that indicates a line ending. Override it if needed.
168 */
169
170 virtual void endLine() override;
171
172 /**
173 * callback that report the content of the current cell in a dedicated Cell
174 * object. Override it if you need to retrieve cell content.
175 */
176 virtual void setCell(const OdsCell &cell) override;
177 virtual void endDocument() override;
178
179 void writeSampleList();
180
181 private:
182 struct Psm
183 {
184 QString proforma;
185 QStringList protein_list;
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;
230 QStringList m_proteinList;
232 std::map<QString, Sample> m_sampleMap;
234};
235} // namespace psm
236} // namespace cbor
237} // 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