Loading...
Searching...
No Matches
sagetsvhandler.h
Go to the documentation of this file.
/**
* \file input/sage/sagereader.h
* \date 21/08/2024
* \author Olivier Langella
* \brief read data files from Sage output
*/
/*******************************************************************************
* Copyright (c) 2024 Olivier Langella
*<Olivier.Langella@universite-paris-saclay.fr>.
*
* This file is part of i2MassChroQ.
*
* i2MassChroQ is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* i2MassChroQ is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with i2MassChroQ. If not, see <http://www.gnu.org/licenses/>.
*
******************************************************************************/
#pragma once
#include <odsstream/odsdochandlerinterface.h>
#include "pappsomspp/core/processing/uimonitor/uimonitorinterface.h"
#include "../../../../peptide/peptide.h"
#include "sagereader.h"
#include "../psmproteinmap.h"
#include <QCborArray>
namespace pappso
{
namespace cbor
{
namespace psm
{
/**
* @todo write docs
*/
class SageTsvHandler : public OdsDocHandlerInterface
{
public:
enum class Columns : std::int8_t
{
psm_id,
peptide,
proteins,
protein_groups,
num_proteins,
num_protein_groups,
filename,
scannr,
rank,
label,
expmass,
calcmass,
charge,
peptide_len,
missed_cleavages,
semi_enzymatic,
isotope_error,
precursor_ppm,
fragment_ppm,
hyperscore,
delta_next,
delta_best,
rt,
aligned_rt,
predicted_rt,
delta_rt_model,
ion_mobility,
predicted_mobility,
delta_mobility,
matched_peaks,
longest_b,
longest_y,
longest_y_pct,
matched_intensity_pct,
scored_candidates,
poisson,
sage_discriminant_score,
posterior_error,
spectrum_q,
peptide_q,
protein_q,
protein_group_q,
ms2_intensity,
};
struct Line
{
int rank = 0;
int label = 0;
double expmass = 0.0;
double calcmass = 0.0;
int charge = 0;
std::size_t peptide_len;
int missed_cleavages;
int semi_enzymatic;
double isotope_error;
double precursor_ppm;
double fragment_ppm;
double hyperscore;
double delta_next;
double delta_best;
double rt;
double aligned_rt;
double predicted_rt;
double delta_rt_model;
double ion_mobility;
double predicted_mobility;
double delta_mobility;
std::size_t matched_peaks;
std::size_t longest_b;
std::size_t longest_y;
double longest_y_pct;
double matched_intensity_pct;
std::size_t scored_candidates;
double poisson;
double sage_discriminant_score;
double posterior_error;
double spectrum_q;
double peptide_q;
double protein_q;
double ms2_intensity;
};
/**
* Default constructor
*/
SageTsvHandler(pappso::UiMonitorInterface *p_monitor,
const SageReader &sage_reader,
PsmProteinMap &psm_protein_map);
/**
* Destructor
*/
virtual ~SageTsvHandler();
/**
* callback that indicates the begining of a data sheet. Override it in
* order to retrieve information about the current data sheet.
*
*/
virtual void startSheet(const QString &sheet_name) override;
/**
* callback that indicates the end of the current data sheet. Override it if
* needed
*/
virtual void endSheet() override;
/**
* callback that indicates a new line start. Override it if needed.
*/
virtual void startLine() override;
/**
* callback that indicates a line ending. Override it if needed.
*/
virtual void endLine() override;
/**
* callback that report the content of the current cell in a dedicated Cell
* object. Override it if you need to retrieve cell content.
*/
virtual void setCell(const OdsCell &cell) override;
virtual void endDocument() override;
void writeSampleList();
private:
struct Psm
{
QString proforma;
QStringList protein_list;
QString peptide_sequence_li;
QCborMap cbor_eval;
};
struct Scan
{
QCborMap cbor_id;
QCborMap cbor_precursor;
QCborMap cbor_ms2;
std::vector<Psm> psm_list;
};
struct Sample
{
QString name;
QCborMap cbor_core_sample;
std::map<QString, Scan> scan_map;
};
private:
void parsePeptide(const QString &peptide_str);
void parseProteins(const QString &proteins_str);
bool parseSpectrumStringId(const QString &spectrum_string_id);
void parseMsRunFilename(const QString &msrun_filename);
void recordLine();
void writeSample(const Sample &one_sample);
void writeScan(const Scan &one_scan);
void writePsm(const Psm &one_psm);
private:
const SageReader &m_sageReader;
PsmProteinMap &m_psmProteinMap;
pappso::UiMonitorInterface *mp_monitor = nullptr;
std::size_t m_progressIndex = 0;
std::size_t m_lineNumber = 0;
std::size_t m_columnNumber = 0;
std::vector<Columns> m_columnTypeList;
pappso::PeptideSp msp_peptide;
std::vector<SageReader::SageModification> m_staticModificationList;
std::vector<SageReader::SageModification> m_variableModificationList;
std::size_t m_spectrumIndex;
Line m_line;
QString m_decoyTag;
QStringList m_proteinList;
QString m_spectrumNativeId;
std::map<QString, Sample> m_sampleMap;
Sample *mp_currentSample;
};
} // namespace psm
} // namespace cbor
} // namespace pappso
pappso::UiMonitorInterface
Definition uimonitorinterface.h:50
pappso::cbor::psm::PsmProteinMap
store PsmProtein in a map with accession as key
Definition psmproteinmap.h:56
pappso::cbor::psm::SageReader
Definition sagereader.h:42
pappso::cbor::psm::SageTsvHandler::m_staticModificationList
std::vector< SageReader::SageModification > m_staticModificationList
Definition sagetsvhandler.h:225
pappso::cbor::psm::SageTsvHandler::m_proteinList
QStringList m_proteinList
Definition sagetsvhandler.h:230
pappso::cbor::psm::SageTsvHandler::parseProteins
void parseProteins(const QString &proteins_str)
Definition sagetsvhandler.cpp:492
pappso::cbor::psm::SageTsvHandler::m_decoyTag
QString m_decoyTag
Definition sagetsvhandler.h:229
pappso::cbor::psm::SageTsvHandler::Columns
Columns
Definition sagetsvhandler.h:53
pappso::cbor::psm::SageTsvHandler::Columns::predicted_mobility
@ predicted_mobility
Definition sagetsvhandler.h:81
pappso::cbor::psm::SageTsvHandler::Columns::expmass
@ expmass
Definition sagetsvhandler.h:64
pappso::cbor::psm::SageTsvHandler::Columns::delta_next
@ delta_next
Definition sagetsvhandler.h:74
pappso::cbor::psm::SageTsvHandler::Columns::matched_peaks
@ matched_peaks
Definition sagetsvhandler.h:83
pappso::cbor::psm::SageTsvHandler::Columns::ion_mobility
@ ion_mobility
Definition sagetsvhandler.h:80
pappso::cbor::psm::SageTsvHandler::Columns::longest_y_pct
@ longest_y_pct
Definition sagetsvhandler.h:86
pappso::cbor::psm::SageTsvHandler::Columns::protein_q
@ protein_q
Definition sagetsvhandler.h:94
pappso::cbor::psm::SageTsvHandler::Columns::psm_id
@ psm_id
Definition sagetsvhandler.h:54
pappso::cbor::psm::SageTsvHandler::Columns::missed_cleavages
@ missed_cleavages
Definition sagetsvhandler.h:68
pappso::cbor::psm::SageTsvHandler::Columns::poisson
@ poisson
Definition sagetsvhandler.h:89
pappso::cbor::psm::SageTsvHandler::Columns::longest_y
@ longest_y
Definition sagetsvhandler.h:85
pappso::cbor::psm::SageTsvHandler::Columns::fragment_ppm
@ fragment_ppm
Definition sagetsvhandler.h:72
pappso::cbor::psm::SageTsvHandler::Columns::semi_enzymatic
@ semi_enzymatic
Definition sagetsvhandler.h:69
pappso::cbor::psm::SageTsvHandler::Columns::num_proteins
@ num_proteins
Definition sagetsvhandler.h:58
pappso::cbor::psm::SageTsvHandler::Columns::charge
@ charge
Definition sagetsvhandler.h:66
pappso::cbor::psm::SageTsvHandler::Columns::filename
@ filename
Definition sagetsvhandler.h:60
pappso::cbor::psm::SageTsvHandler::Columns::longest_b
@ longest_b
Definition sagetsvhandler.h:84
pappso::cbor::psm::SageTsvHandler::Columns::scored_candidates
@ scored_candidates
Definition sagetsvhandler.h:88
pappso::cbor::psm::SageTsvHandler::Columns::peptide
@ peptide
Definition sagetsvhandler.h:55
pappso::cbor::psm::SageTsvHandler::Columns::sage_discriminant_score
@ sage_discriminant_score
Definition sagetsvhandler.h:90
pappso::cbor::psm::SageTsvHandler::Columns::peptide_q
@ peptide_q
Definition sagetsvhandler.h:93
pappso::cbor::psm::SageTsvHandler::Columns::aligned_rt
@ aligned_rt
Definition sagetsvhandler.h:77
pappso::cbor::psm::SageTsvHandler::Columns::hyperscore
@ hyperscore
Definition sagetsvhandler.h:73
pappso::cbor::psm::SageTsvHandler::Columns::protein_group_q
@ protein_group_q
Definition sagetsvhandler.h:95
pappso::cbor::psm::SageTsvHandler::Columns::isotope_error
@ isotope_error
Definition sagetsvhandler.h:70
pappso::cbor::psm::SageTsvHandler::Columns::calcmass
@ calcmass
Definition sagetsvhandler.h:65
pappso::cbor::psm::SageTsvHandler::Columns::rank
@ rank
Definition sagetsvhandler.h:62
pappso::cbor::psm::SageTsvHandler::Columns::delta_best
@ delta_best
Definition sagetsvhandler.h:75
pappso::cbor::psm::SageTsvHandler::Columns::protein_groups
@ protein_groups
Definition sagetsvhandler.h:57
pappso::cbor::psm::SageTsvHandler::Columns::peptide_len
@ peptide_len
Definition sagetsvhandler.h:67
pappso::cbor::psm::SageTsvHandler::Columns::scannr
@ scannr
Definition sagetsvhandler.h:61
pappso::cbor::psm::SageTsvHandler::Columns::precursor_ppm
@ precursor_ppm
Definition sagetsvhandler.h:71
pappso::cbor::psm::SageTsvHandler::Columns::rt
@ rt
Definition sagetsvhandler.h:76
pappso::cbor::psm::SageTsvHandler::Columns::proteins
@ proteins
Definition sagetsvhandler.h:56
pappso::cbor::psm::SageTsvHandler::Columns::delta_rt_model
@ delta_rt_model
Definition sagetsvhandler.h:79
pappso::cbor::psm::SageTsvHandler::Columns::ms2_intensity
@ ms2_intensity
Definition sagetsvhandler.h:96
pappso::cbor::psm::SageTsvHandler::Columns::posterior_error
@ posterior_error
Definition sagetsvhandler.h:91
pappso::cbor::psm::SageTsvHandler::Columns::delta_mobility
@ delta_mobility
Definition sagetsvhandler.h:82
pappso::cbor::psm::SageTsvHandler::Columns::num_protein_groups
@ num_protein_groups
Definition sagetsvhandler.h:59
pappso::cbor::psm::SageTsvHandler::Columns::matched_intensity_pct
@ matched_intensity_pct
Definition sagetsvhandler.h:87
pappso::cbor::psm::SageTsvHandler::Columns::label
@ label
Definition sagetsvhandler.h:63
pappso::cbor::psm::SageTsvHandler::Columns::spectrum_q
@ spectrum_q
Definition sagetsvhandler.h:92
pappso::cbor::psm::SageTsvHandler::Columns::predicted_rt
@ predicted_rt
Definition sagetsvhandler.h:78
pappso::cbor::psm::SageTsvHandler::m_spectrumNativeId
QString m_spectrumNativeId
Definition sagetsvhandler.h:231
pappso::cbor::psm::SageTsvHandler::m_sageReader
const SageReader & m_sageReader
Definition sagetsvhandler.h:216
pappso::cbor::psm::SageTsvHandler::endSheet
virtual void endSheet() override
Definition sagetsvhandler.cpp:79
pappso::cbor::psm::SageTsvHandler::writeSampleList
void writeSampleList()
Definition sagetsvhandler.cpp:62
pappso::cbor::psm::SageTsvHandler::mp_monitor
pappso::UiMonitorInterface * mp_monitor
Definition sagetsvhandler.h:218
pappso::cbor::psm::SageTsvHandler::startSheet
virtual void startSheet(const QString &sheet_name) override
Definition sagetsvhandler.cpp:444
pappso::cbor::psm::SageTsvHandler::m_variableModificationList
std::vector< SageReader::SageModification > m_variableModificationList
Definition sagetsvhandler.h:226
pappso::cbor::psm::SageTsvHandler::~SageTsvHandler
virtual ~SageTsvHandler()
Definition sagetsvhandler.cpp:57
pappso::cbor::psm::SageTsvHandler::parsePeptide
void parsePeptide(const QString &peptide_str)
Definition sagetsvhandler.cpp:457
pappso::cbor::psm::SageTsvHandler::parseSpectrumStringId
bool parseSpectrumStringId(const QString &spectrum_string_id)
Definition sagetsvhandler.cpp:512
pappso::cbor::psm::SageTsvHandler::m_line
Line m_line
Definition sagetsvhandler.h:228
pappso::cbor::psm::SageTsvHandler::writeSample
void writeSample(const Sample &one_sample)
Definition sagetsvhandler.cpp:708
pappso::cbor::psm::SageTsvHandler::m_progressIndex
std::size_t m_progressIndex
Definition sagetsvhandler.h:219
pappso::cbor::psm::SageTsvHandler::setCell
virtual void setCell(const OdsCell &cell) override
Definition sagetsvhandler.cpp:84
pappso::cbor::psm::SageTsvHandler::m_lineNumber
std::size_t m_lineNumber
Definition sagetsvhandler.h:220
pappso::cbor::psm::SageTsvHandler::writePsm
void writePsm(const Psm &one_psm)
Definition sagetsvhandler.cpp:758
pappso::cbor::psm::SageTsvHandler::SageTsvHandler
SageTsvHandler(pappso::UiMonitorInterface *p_monitor, const SageReader &sage_reader, PsmProteinMap &psm_protein_map)
Definition sagetsvhandler.cpp:46
pappso::cbor::psm::SageTsvHandler::writeScan
void writeScan(const Scan &one_scan)
Definition sagetsvhandler.cpp:736
pappso::cbor::psm::SageTsvHandler::recordLine
void recordLine()
Definition sagetsvhandler.cpp:596
pappso::cbor::psm::SageTsvHandler::m_columnNumber
std::size_t m_columnNumber
Definition sagetsvhandler.h:221
pappso::cbor::psm::SageTsvHandler::m_spectrumIndex
std::size_t m_spectrumIndex
Definition sagetsvhandler.h:227
pappso::cbor::psm::SageTsvHandler::m_sampleMap
std::map< QString, Sample > m_sampleMap
Definition sagetsvhandler.h:232
pappso::cbor::psm::SageTsvHandler::endDocument
virtual void endDocument() override
Definition sagetsvhandler.cpp:440
pappso::cbor::psm::SageTsvHandler::startLine
virtual void startLine() override
Definition sagetsvhandler.cpp:431
pappso::cbor::psm::SageTsvHandler::mp_currentSample
Sample * mp_currentSample
Definition sagetsvhandler.h:233
pappso::cbor::psm::SageTsvHandler::parseMsRunFilename
void parseMsRunFilename(const QString &msrun_filename)
Definition sagetsvhandler.cpp:553
pappso::cbor::psm::SageTsvHandler::endLine
virtual void endLine() override
Definition sagetsvhandler.cpp:71
pappso::cbor::psm::SageTsvHandler::msp_peptide
pappso::PeptideSp msp_peptide
Definition sagetsvhandler.h:224
pappso::cbor::psm::SageTsvHandler::m_columnTypeList
std::vector< Columns > m_columnTypeList
Definition sagetsvhandler.h:222
pappso::cbor::psm::SageTsvHandler::m_psmProteinMap
PsmProteinMap & m_psmProteinMap
Definition sagetsvhandler.h:217
pappso::cbor::psm
Definition cborscanmapbase.h:40
pappso::cbor
Definition cborstreamreader.cpp:35
pappso
tries to keep as much as possible monoisotopes, removing any possible C13 peaks and changes multichar...
Definition aa.cpp:39
pappso::PeptideSp
std::shared_ptr< const Peptide > PeptideSp
Definition aamodification.h:48
peptide.h
psmproteinmap.h
sagereader.h
pappso::cbor::psm::SageTsvHandler::Line
Definition sagetsvhandler.h:100
pappso::cbor::psm::SageTsvHandler::Line::predicted_mobility
double predicted_mobility
Definition sagetsvhandler.h:120
pappso::cbor::psm::SageTsvHandler::Line::poisson
double poisson
Definition sagetsvhandler.h:128
pappso::cbor::psm::SageTsvHandler::Line::peptide_len
std::size_t peptide_len
Definition sagetsvhandler.h:106
pappso::cbor::psm::SageTsvHandler::Line::ion_mobility
double ion_mobility
Definition sagetsvhandler.h:119
pappso::cbor::psm::SageTsvHandler::Line::rank
int rank
Definition sagetsvhandler.h:101
pappso::cbor::psm::SageTsvHandler::Line::longest_y_pct
double longest_y_pct
Definition sagetsvhandler.h:125
pappso::cbor::psm::SageTsvHandler::Line::matched_intensity_pct
double matched_intensity_pct
Definition sagetsvhandler.h:126
pappso::cbor::psm::SageTsvHandler::Line::predicted_rt
double predicted_rt
Definition sagetsvhandler.h:117
pappso::cbor::psm::SageTsvHandler::Line::hyperscore
double hyperscore
Definition sagetsvhandler.h:112
pappso::cbor::psm::SageTsvHandler::Line::missed_cleavages
int missed_cleavages
Definition sagetsvhandler.h:107
pappso::cbor::psm::SageTsvHandler::Line::longest_b
std::size_t longest_b
Definition sagetsvhandler.h:123
pappso::cbor::psm::SageTsvHandler::Line::fragment_ppm
double fragment_ppm
Definition sagetsvhandler.h:111
pappso::cbor::psm::SageTsvHandler::Line::charge
int charge
Definition sagetsvhandler.h:105
pappso::cbor::psm::SageTsvHandler::Line::delta_mobility
double delta_mobility
Definition sagetsvhandler.h:121
pappso::cbor::psm::SageTsvHandler::Line::rt
double rt
Definition sagetsvhandler.h:115
pappso::cbor::psm::SageTsvHandler::Line::delta_next
double delta_next
Definition sagetsvhandler.h:113
pappso::cbor::psm::SageTsvHandler::Line::delta_rt_model
double delta_rt_model
Definition sagetsvhandler.h:118
pappso::cbor::psm::SageTsvHandler::Line::posterior_error
double posterior_error
Definition sagetsvhandler.h:130
pappso::cbor::psm::SageTsvHandler::Line::aligned_rt
double aligned_rt
Definition sagetsvhandler.h:116
pappso::cbor::psm::SageTsvHandler::Line::expmass
double expmass
Definition sagetsvhandler.h:103
pappso::cbor::psm::SageTsvHandler::Line::matched_peaks
std::size_t matched_peaks
Definition sagetsvhandler.h:122
pappso::cbor::psm::SageTsvHandler::Line::peptide_q
double peptide_q
Definition sagetsvhandler.h:132
pappso::cbor::psm::SageTsvHandler::Line::delta_best
double delta_best
Definition sagetsvhandler.h:114
pappso::cbor::psm::SageTsvHandler::Line::spectrum_q
double spectrum_q
Definition sagetsvhandler.h:131
pappso::cbor::psm::SageTsvHandler::Line::ms2_intensity
double ms2_intensity
Definition sagetsvhandler.h:134
pappso::cbor::psm::SageTsvHandler::Line::sage_discriminant_score
double sage_discriminant_score
Definition sagetsvhandler.h:129
pappso::cbor::psm::SageTsvHandler::Line::isotope_error
double isotope_error
Definition sagetsvhandler.h:109
pappso::cbor::psm::SageTsvHandler::Line::label
int label
Definition sagetsvhandler.h:102
pappso::cbor::psm::SageTsvHandler::Line::calcmass
double calcmass
Definition sagetsvhandler.h:104
pappso::cbor::psm::SageTsvHandler::Line::protein_q
double protein_q
Definition sagetsvhandler.h:133
pappso::cbor::psm::SageTsvHandler::Line::longest_y
std::size_t longest_y
Definition sagetsvhandler.h:124
pappso::cbor::psm::SageTsvHandler::Line::scored_candidates
std::size_t scored_candidates
Definition sagetsvhandler.h:127
pappso::cbor::psm::SageTsvHandler::Line::precursor_ppm
double precursor_ppm
Definition sagetsvhandler.h:110
pappso::cbor::psm::SageTsvHandler::Line::semi_enzymatic
int semi_enzymatic
Definition sagetsvhandler.h:108
pappso::cbor::psm::SageTsvHandler::Psm
Definition sagetsvhandler.h:183
pappso::cbor::psm::SageTsvHandler::Psm::peptide_sequence_li
QString peptide_sequence_li
Definition sagetsvhandler.h:186
pappso::cbor::psm::SageTsvHandler::Psm::protein_list
QStringList protein_list
Definition sagetsvhandler.h:185
pappso::cbor::psm::SageTsvHandler::Psm::proforma
QString proforma
Definition sagetsvhandler.h:184
pappso::cbor::psm::SageTsvHandler::Psm::cbor_eval
QCborMap cbor_eval
Definition sagetsvhandler.h:187
pappso::cbor::psm::SageTsvHandler::Sample
Definition sagetsvhandler.h:198
pappso::cbor::psm::SageTsvHandler::Sample::cbor_core_sample
QCborMap cbor_core_sample
Definition sagetsvhandler.h:200
pappso::cbor::psm::SageTsvHandler::Sample::name
QString name
Definition sagetsvhandler.h:199
pappso::cbor::psm::SageTsvHandler::Sample::scan_map
std::map< QString, Scan > scan_map
Definition sagetsvhandler.h:201
pappso::cbor::psm::SageTsvHandler::Scan
Definition sagetsvhandler.h:190
pappso::cbor::psm::SageTsvHandler::Scan::cbor_precursor
QCborMap cbor_precursor
Definition sagetsvhandler.h:192
pappso::cbor::psm::SageTsvHandler::Scan::cbor_ms2
QCborMap cbor_ms2
Definition sagetsvhandler.h:193
pappso::cbor::psm::SageTsvHandler::Scan::cbor_id
QCborMap cbor_id
Definition sagetsvhandler.h:191
pappso::cbor::psm::SageTsvHandler::Scan::psm_list
std::vector< Psm > psm_list
Definition sagetsvhandler.h:194
uimonitorinterface.h