Loading...
Searching...
No Matches
psmfilereaderbase.h
Go to the documentation of this file.
/**
* \file pappsomspp/processing/cbor/psm/psmfilereaderbase.h
* \date 05/07/2025
* \author Olivier Langella
* \brief Base class to read CBOR PSM file
*/
/*******************************************************************************
* Copyright (c) 2025 Olivier Langella <Olivier.Langella@universite-paris-saclay.fr>.
*
* This file is part of PAPPSOms-tools.
*
* PAPPSOms-tools 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.
*
* PAPPSOms-tools 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 PAPPSOms-tools. If not, see <http://www.gnu.org/licenses/>.
*
******************************************************************************/
#pragma once
#include "pappsomspp/export-import-config.h"
#include "pappsomspp/core/processing/cbor/cborstreamreaderinterface.h"
#include "pappsomspp/core/processing/uimonitor/uimonitorinterface.h"
#include "psmproteinmap.h"
#include "pappsomspp/core/peptide/peptide.h"
#include "pappsomspp/core/massspectrum/qualifiedmassspectrum.h"
#include <QCborArray>
namespace pappso
{
namespace cbor
{
namespace psm
{
struct PsmFile
{
QString name;
};
/**
* @todo write docs
*/
class PMSPP_LIB_DECL PsmFileReaderBase : public CborStreamReaderInterface
{
public:
/**
* Default constructor
*/
PsmFileReaderBase();
/**
* Destructor
*/
virtual ~PsmFileReaderBase() override;
void readCbor(QFile *cborp, pappso::UiMonitorInterface &monitor);
void readCbor(QIODevice *cborp, pappso::UiMonitorInterface &monitor);
struct PsmProteinRef
{
QString accession;
std::vector<std::size_t> positions;
};
protected:
void readRoot(pappso::UiMonitorInterface &monitor);
virtual void readInformations(pappso::UiMonitorInterface &monitor);
virtual void readLog(pappso::UiMonitorInterface &monitor);
virtual void readParameterMap(pappso::UiMonitorInterface &monitor);
virtual void readProteinMap(pappso::UiMonitorInterface &monitor);
virtual void readSample(pappso::UiMonitorInterface &monitor);
virtual void readScan(pappso::UiMonitorInterface &monitor);
virtual void readPsm(pappso::UiMonitorInterface &monitor);
virtual void psmReady(pappso::UiMonitorInterface &monitor);
virtual void logReady(pappso::UiMonitorInterface &monitor);
virtual void informationsReady(pappso::UiMonitorInterface &monitor);
virtual void parameterMapReady(pappso::UiMonitorInterface &monitor);
virtual void fastaFilesReady(pappso::UiMonitorInterface &monitor);
virtual void proteinMapReady(pappso::UiMonitorInterface &monitor);
virtual void sampleListStarted(pappso::UiMonitorInterface &monitor);
virtual void sampleStarted(pappso::UiMonitorInterface &monitor);
virtual void scanStarted(pappso::UiMonitorInterface &monitor);
virtual void scanFinished(pappso::UiMonitorInterface &monitor);
virtual void sampleFinished(pappso::UiMonitorInterface &monitor);
virtual void sampleListFinished(pappso::UiMonitorInterface &monitor);
PsmFile readPsmFile(bool &is_ok);
void writePsmFile(CborStreamWriter &writer, const PsmFile &psm_file);
void writePsmFileList(CborStreamWriter &writer, const std::vector<PsmFile> &file_list);
PsmProteinRef readPsmProteinRef(bool &is_ok);
pappso::PeptideSp getCurrentPsmPeptideSp() const;
/** @brief get the qualified Spectrum for the current PSM
* @return a qualified mass spectrum
*/
pappso::QualifiedMassSpectrumSPtr getCurrentQualifiedMassSpectrumSPtr() const;
/** @brief tells if the current PSM has a decoy accession
* @return boolean
*/
bool currentProteinRefListContainsDecoy() const;
/** @brief tells if the current PSM has a target accession
* @return boolean
*/
bool currentProteinRefListContainsTarget() const;
/** @brief convenient function do compute precusor ion mass
*/
double getPrecursorMass(double mz_prec, uint charge) const;
protected:
QStringList m_targetFastaFiles;
QStringList m_decoyFastaFiles;
PsmProteinMap m_proteinMap;
QString m_currentSampleName;
PsmFile m_currentPeaklistFile;
std::vector<PsmFile> m_currentIdentificationFileList;
QCborMap m_cborInformations;
QCborArray m_cborLog;
QCborMap m_cborParameterMap;
QCborMap m_cborScanId;
QCborMap m_cborScanPrecursor;
QCborMap m_cborScanMs2;
QCborMap m_cborScanProps;
QCborMap m_cborScanPsmEval;
QCborMap m_cborScanPsmProps;
QString m_currentPsmProforma;
std::vector<PsmProteinRef> m_currentPsmProteinRefList;
};
} // namespace psm
} // namespace cbor
} // namespace pappso
cborstreamreaderinterface.h
pappso::UiMonitorInterface
Definition uimonitorinterface.h:50
pappso::cbor::CborStreamReaderInterface::CborStreamReaderInterface
CborStreamReaderInterface()
Definition cborstreamreaderinterface.cpp:30
pappso::cbor::CborStreamWriter
overrides QCborStreamWriter base class to provide convenient functions
Definition cborstreamwriter.h:45
pappso::cbor::psm::PsmFileReaderBase::m_cborLog
QCborArray m_cborLog
Definition psmfilereaderbase.h:134
pappso::cbor::psm::PsmFileReaderBase::m_currentPsmProteinRefList
std::vector< PsmProteinRef > m_currentPsmProteinRefList
Definition psmfilereaderbase.h:143
pappso::cbor::psm::PsmFileReaderBase::m_currentPeaklistFile
PsmFile m_currentPeaklistFile
Definition psmfilereaderbase.h:131
pappso::cbor::psm::PsmFileReaderBase::getCurrentQualifiedMassSpectrumSPtr
pappso::QualifiedMassSpectrumSPtr getCurrentQualifiedMassSpectrumSPtr() const
get the qualified Spectrum for the current PSM
Definition psmfilereaderbase.cpp:745
pappso::cbor::psm::PsmFileReaderBase::getCurrentPsmPeptideSp
pappso::PeptideSp getCurrentPsmPeptideSp() const
Definition psmfilereaderbase.cpp:730
pappso::cbor::psm::PsmFileReaderBase::m_targetFastaFiles
QStringList m_targetFastaFiles
Definition psmfilereaderbase.h:127
pappso::cbor::psm::PsmFileReaderBase::currentProteinRefListContainsTarget
bool currentProteinRefListContainsTarget() const
tells if the current PSM has a target accession
Definition psmfilereaderbase.cpp:96
pappso::cbor::psm::PsmFileReaderBase::m_decoyFastaFiles
QStringList m_decoyFastaFiles
Definition psmfilereaderbase.h:128
pappso::cbor::psm::PsmFileReaderBase::sampleListStarted
virtual void sampleListStarted(pappso::UiMonitorInterface &monitor)
Definition psmfilereaderbase.cpp:832
pappso::cbor::psm::PsmFileReaderBase::writePsmFileList
void writePsmFileList(CborStreamWriter &writer, const std::vector< PsmFile > &file_list)
Definition psmfilereaderbase.cpp:333
pappso::cbor::psm::PsmFileReaderBase::m_currentSampleName
QString m_currentSampleName
Definition psmfilereaderbase.h:130
pappso::cbor::psm::PsmFileReaderBase::m_cborScanProps
QCborMap m_cborScanProps
Definition psmfilereaderbase.h:139
pappso::cbor::psm::PsmFileReaderBase::getPrecursorMass
double getPrecursorMass(double mz_prec, uint charge) const
convenient function do compute precusor ion mass
Definition psmfilereaderbase.cpp:843
pappso::cbor::psm::PsmFileReaderBase::logReady
virtual void logReady(pappso::UiMonitorInterface &monitor)
Definition psmfilereaderbase.cpp:694
pappso::cbor::psm::PsmFileReaderBase::scanStarted
virtual void scanStarted(pappso::UiMonitorInterface &monitor)
Definition psmfilereaderbase.cpp:715
pappso::cbor::psm::PsmFileReaderBase::readPsm
virtual void readPsm(pappso::UiMonitorInterface &monitor)
Definition psmfilereaderbase.cpp:573
pappso::cbor::psm::PsmFileReaderBase::readLog
virtual void readLog(pappso::UiMonitorInterface &monitor)
Definition psmfilereaderbase.cpp:221
pappso::cbor::psm::PsmFileReaderBase::proteinMapReady
virtual void proteinMapReady(pappso::UiMonitorInterface &monitor)
Definition psmfilereaderbase.cpp:705
pappso::cbor::psm::PsmFileReaderBase::m_cborScanPsmProps
QCborMap m_cborScanPsmProps
Definition psmfilereaderbase.h:141
pappso::cbor::psm::PsmFileReaderBase::sampleStarted
virtual void sampleStarted(pappso::UiMonitorInterface &monitor)
Definition psmfilereaderbase.cpp:710
pappso::cbor::psm::PsmFileReaderBase::PsmFileReaderBase
PsmFileReaderBase()
Definition psmfilereaderbase.cpp:44
pappso::cbor::psm::PsmFileReaderBase::currentProteinRefListContainsDecoy
bool currentProteinRefListContainsDecoy() const
tells if the current PSM has a decoy accession
Definition psmfilereaderbase.cpp:85
pappso::cbor::psm::PsmFileReaderBase::readPsmFile
PsmFile readPsmFile(bool &is_ok)
Definition psmfilereaderbase.cpp:300
pappso::cbor::psm::PsmFileReaderBase::m_proteinMap
PsmProteinMap m_proteinMap
Definition psmfilereaderbase.h:129
pappso::cbor::psm::PsmFileReaderBase::readParameterMap
virtual void readParameterMap(pappso::UiMonitorInterface &monitor)
Definition psmfilereaderbase.cpp:235
pappso::cbor::psm::PsmFileReaderBase::m_currentPsmProforma
QString m_currentPsmProforma
Definition psmfilereaderbase.h:142
pappso::cbor::psm::PsmFileReaderBase::readCbor
void readCbor(QFile *cborp, pappso::UiMonitorInterface &monitor)
Definition psmfilereaderbase.cpp:70
pappso::cbor::psm::PsmFileReaderBase::m_cborScanPrecursor
QCborMap m_cborScanPrecursor
Definition psmfilereaderbase.h:137
pappso::cbor::psm::PsmFileReaderBase::readScan
virtual void readScan(pappso::UiMonitorInterface &monitor)
Definition psmfilereaderbase.cpp:442
pappso::cbor::psm::PsmFileReaderBase::readInformations
virtual void readInformations(pappso::UiMonitorInterface &monitor)
Definition psmfilereaderbase.cpp:194
pappso::cbor::psm::PsmFileReaderBase::scanFinished
virtual void scanFinished(pappso::UiMonitorInterface &monitor)
Definition psmfilereaderbase.cpp:720
pappso::cbor::psm::PsmFileReaderBase::sampleListFinished
virtual void sampleListFinished(pappso::UiMonitorInterface &monitor)
Definition psmfilereaderbase.cpp:837
pappso::cbor::psm::PsmFileReaderBase::psmReady
virtual void psmReady(pappso::UiMonitorInterface &monitor)
Definition psmfilereaderbase.cpp:678
pappso::cbor::psm::PsmFileReaderBase::informationsReady
virtual void informationsReady(pappso::UiMonitorInterface &monitor)
Definition psmfilereaderbase.cpp:684
pappso::cbor::psm::PsmFileReaderBase::m_cborParameterMap
QCborMap m_cborParameterMap
Definition psmfilereaderbase.h:135
pappso::cbor::psm::PsmFileReaderBase::m_cborInformations
QCborMap m_cborInformations
Definition psmfilereaderbase.h:133
pappso::cbor::psm::PsmFileReaderBase::readRoot
void readRoot(pappso::UiMonitorInterface &monitor)
Definition psmfilereaderbase.cpp:108
pappso::cbor::psm::PsmFileReaderBase::m_currentIdentificationFileList
std::vector< PsmFile > m_currentIdentificationFileList
Definition psmfilereaderbase.h:132
pappso::cbor::psm::PsmFileReaderBase::writePsmFile
void writePsmFile(CborStreamWriter &writer, const PsmFile &psm_file)
Definition psmfilereaderbase.cpp:324
pappso::cbor::psm::PsmFileReaderBase::fastaFilesReady
virtual void fastaFilesReady(pappso::UiMonitorInterface &monitor)
Definition psmfilereaderbase.cpp:700
pappso::cbor::psm::PsmFileReaderBase::m_cborScanId
QCborMap m_cborScanId
Definition psmfilereaderbase.h:136
pappso::cbor::psm::PsmFileReaderBase::m_cborScanMs2
QCborMap m_cborScanMs2
Definition psmfilereaderbase.h:138
pappso::cbor::psm::PsmFileReaderBase::parameterMapReady
virtual void parameterMapReady(pappso::UiMonitorInterface &monitor)
Definition psmfilereaderbase.cpp:689
pappso::cbor::psm::PsmFileReaderBase::readProteinMap
virtual void readProteinMap(pappso::UiMonitorInterface &monitor)
Definition psmfilereaderbase.cpp:249
pappso::cbor::psm::PsmFileReaderBase::readSample
virtual void readSample(pappso::UiMonitorInterface &monitor)
Definition psmfilereaderbase.cpp:346
pappso::cbor::psm::PsmFileReaderBase::m_cborScanPsmEval
QCborMap m_cborScanPsmEval
Definition psmfilereaderbase.h:140
pappso::cbor::psm::PsmFileReaderBase::readPsmProteinRef
PsmProteinRef readPsmProteinRef(bool &is_ok)
Definition psmfilereaderbase.cpp:257
pappso::cbor::psm::PsmFileReaderBase::sampleFinished
virtual void sampleFinished(pappso::UiMonitorInterface &monitor)
Definition psmfilereaderbase.cpp:725
pappso::cbor::psm::PsmProteinMap
store PsmProtein in a map with accession as key
Definition psmproteinmap.h:56
export-import-config.h
PMSPP_LIB_DECL
#define PMSPP_LIB_DECL
Definition export-import-config.h:14
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::QualifiedMassSpectrumSPtr
std::shared_ptr< QualifiedMassSpectrum > QualifiedMassSpectrumSPtr
Definition qualifiedmassspectrum.h:43
pappso::PeptideSp
std::shared_ptr< const Peptide > PeptideSp
Definition aamodification.h:48
pappso::uint
unsigned int uint
Definition types.h:67
peptide.h
psmproteinmap.h
qualifiedmassspectrum.h
pappso::cbor::psm::PsmFileReaderBase::PsmProteinRef
Definition psmfilereaderbase.h:71
pappso::cbor::psm::PsmFileReaderBase::PsmProteinRef::accession
QString accession
Definition psmfilereaderbase.h:72
pappso::cbor::psm::PsmFileReaderBase::PsmProteinRef::positions
std::vector< std::size_t > positions
Definition psmfilereaderbase.h:73
pappso::cbor::psm::PsmFile
Definition psmfilereaderbase.h:47
pappso::cbor::psm::PsmFile::name
QString name
Definition psmfilereaderbase.h:48
uimonitorinterface.h