libpappsomspp
Library for mass spectrometry
Loading...
Searching...
No Matches
pappso::cbor::psm::PsmCbor2Json Class Reference

#include <psmcbor2json.h>

Inheritance diagram for pappso::cbor::psm::PsmCbor2Json:
pappso::cbor::psm::PsmFileReaderBase pappso::cbor::CborStreamReaderInterface

Public Member Functions

 PsmCbor2Json (pappso::cbor::JsonStreamWriter *json_output_p)
virtual ~PsmCbor2Json ()
void close () override
 convenient function to clean pointer before leaving
Public Member Functions inherited from pappso::cbor::psm::PsmFileReaderBase
 PsmFileReaderBase ()
virtual ~PsmFileReaderBase () override
void readCbor (QFile *cborp, pappso::UiMonitorInterface &monitor)
void readCbor (QIODevice *cborp, pappso::UiMonitorInterface &monitor)
Public Member Functions inherited from pappso::cbor::CborStreamReaderInterface
 CborStreamReaderInterface ()
virtual ~CborStreamReaderInterface ()

Protected Member Functions

void informationsReady (pappso::UiMonitorInterface &monitor) override
void logReady (pappso::UiMonitorInterface &monitor) override
void parameterMapReady (pappso::UiMonitorInterface &monitor) override
void fastaFilesReady (pappso::UiMonitorInterface &monitor) override
void sampleStarted (pappso::UiMonitorInterface &monitor) override
void sampleFinished (pappso::UiMonitorInterface &monitor) override
void sampleListStarted (pappso::UiMonitorInterface &monitor) override
void sampleListFinished (pappso::UiMonitorInterface &monitor) override
void scanStarted (pappso::UiMonitorInterface &monitor) override
void scanFinished (pappso::UiMonitorInterface &monitor) override
void psmReady (pappso::UiMonitorInterface &monitor) override
void readProteinMap (pappso::UiMonitorInterface &monitor) override
Protected Member Functions inherited from pappso::cbor::psm::PsmFileReaderBase
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 readSample (pappso::UiMonitorInterface &monitor)
virtual void readScan (pappso::UiMonitorInterface &monitor)
virtual void readPsm (pappso::UiMonitorInterface &monitor)
virtual void proteinMapReady (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
pappso::QualifiedMassSpectrumSPtr getCurrentQualifiedMassSpectrumSPtr () const
 get the qualified Spectrum for the current PSM
bool currentProteinRefListContainsDecoy () const
 tells if the current PSM has a decoy accession
bool currentProteinRefListContainsTarget () const
 tells if the current PSM has a target accession
double getPrecursorMass (double mz_prec, uint charge) const
 convenient function do compute precusor ion mass
Protected Member Functions inherited from pappso::cbor::CborStreamReaderInterface
bool getExpectedString ()
void initCborReader (QFile *pcborfile)
void initCborReader (QIODevice *pcborfile)

Protected Attributes

pappso::cbor::JsonStreamWritermp_jsonOutput
Protected Attributes inherited from pappso::cbor::psm::PsmFileReaderBase
QStringList m_targetFastaFiles
QStringList m_decoyFastaFiles
PsmProteinMap m_proteinMap
QString m_currentSampleName
PsmFile m_currentPeaklistFile
std::vector< PsmFilem_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< PsmProteinRefm_currentPsmProteinRefList
Protected Attributes inherited from pappso::cbor::CborStreamReaderInterface
CborStreamReadermpa_cborReader = nullptr
QString m_expectedString
QByteArray m_data

Detailed Description

Todo
write docs

Definition at line 41 of file psmcbor2json.h.

Constructor & Destructor Documentation

◆ PsmCbor2Json()

pappso::cbor::psm::PsmCbor2Json::PsmCbor2Json ( pappso::cbor::JsonStreamWriter * json_output_p)

Default constructor

Definition at line 35 of file psmcbor2json.cpp.

36{
37 mp_jsonOutput = json_output_p;
38
39 *mp_jsonOutput << "{" << Qt::endl;
40}
pappso::cbor::JsonStreamWriter * mp_jsonOutput

References mp_jsonOutput.

◆ ~PsmCbor2Json()

pappso::cbor::psm::PsmCbor2Json::~PsmCbor2Json ( )
virtual

Destructor

Definition at line 43 of file psmcbor2json.cpp.

44{
45}

Member Function Documentation

◆ close()

void pappso::cbor::psm::PsmCbor2Json::close ( )
overridevirtual

convenient function to clean pointer before leaving

Reimplemented from pappso::cbor::CborStreamReaderInterface.

Definition at line 48 of file psmcbor2json.cpp.

49{
50
51 mp_jsonOutput->endMap();
52}

References mp_jsonOutput.

◆ fastaFilesReady()

void pappso::cbor::psm::PsmCbor2Json::fastaFilesReady ( pappso::UiMonitorInterface & monitor)
overrideprotectedvirtual

Reimplemented from pappso::cbor::psm::PsmFileReaderBase.

Definition at line 55 of file psmcbor2json.cpp.

57{
58 if(!m_targetFastaFiles.isEmpty())
59 {
60 mp_jsonOutput->appendKey("target_fasta_files");
62 }
63 if(!m_decoyFastaFiles.isEmpty())
64 {
65 mp_jsonOutput->appendKey("decoy_fasta_files");
67 }
68}

References pappso::cbor::psm::PsmFileReaderBase::m_decoyFastaFiles, pappso::cbor::psm::PsmFileReaderBase::m_targetFastaFiles, and mp_jsonOutput.

◆ informationsReady()

void pappso::cbor::psm::PsmCbor2Json::informationsReady ( pappso::UiMonitorInterface & monitor)
overrideprotectedvirtual

Reimplemented from pappso::cbor::psm::PsmFileReaderBase.

Definition at line 71 of file psmcbor2json.cpp.

73{
74
75 mp_jsonOutput->appendKey("informations");
76 mp_jsonOutput->writeCborMap(m_cborInformations);
77}

References pappso::cbor::psm::PsmFileReaderBase::m_cborInformations, and mp_jsonOutput.

◆ logReady()

void pappso::cbor::psm::PsmCbor2Json::logReady ( pappso::UiMonitorInterface & monitor)
overrideprotectedvirtual

Reimplemented from pappso::cbor::psm::PsmFileReaderBase.

Definition at line 80 of file psmcbor2json.cpp.

81{
82 mp_jsonOutput->appendKey("log");
83 mp_jsonOutput->writeCborArray(m_cborLog);
84}

References pappso::cbor::psm::PsmFileReaderBase::m_cborLog, and mp_jsonOutput.

◆ parameterMapReady()

void pappso::cbor::psm::PsmCbor2Json::parameterMapReady ( pappso::UiMonitorInterface & monitor)
overrideprotectedvirtual

Reimplemented from pappso::cbor::psm::PsmFileReaderBase.

Definition at line 88 of file psmcbor2json.cpp.

90{
91 mp_jsonOutput->appendKey("parameter_map");
92 mp_jsonOutput->writeCborMap(m_cborParameterMap);
93}

References pappso::cbor::psm::PsmFileReaderBase::m_cborParameterMap, and mp_jsonOutput.

◆ psmReady()

void pappso::cbor::psm::PsmCbor2Json::psmReady ( pappso::UiMonitorInterface & monitor)
overrideprotectedvirtual

Reimplemented from pappso::cbor::psm::PsmFileReaderBase.

Definition at line 206 of file psmcbor2json.cpp.

207{
208 mp_jsonOutput->startMap(); // psm
209 mp_jsonOutput->appendKey("proforma");
211 mp_jsonOutput->appendKey("protein_list");
212 mp_jsonOutput->startArray();
213 for(auto &protein_ref : m_currentPsmProteinRefList)
214 {
215 mp_jsonOutput->startMap();
216 mp_jsonOutput->appendKey("accession");
217 mp_jsonOutput->appendValue(protein_ref.accession);
218 mp_jsonOutput->appendKey("positions");
219 mp_jsonOutput->startArray();
220 for(auto position : protein_ref.positions)
221 {
222 mp_jsonOutput->appendValue(position);
223 }
224 mp_jsonOutput->endArray();
225 mp_jsonOutput->endMap();
226 }
227 mp_jsonOutput->endArray();
228 if(!m_cborScanPsmProps.isEmpty())
229 {
230 mp_jsonOutput->appendKey("props");
231 mp_jsonOutput->writeCborMap(m_cborScanPsmProps);
232 }
233 mp_jsonOutput->appendKey("eval");
234 mp_jsonOutput->writeCborMap(m_cborScanPsmEval);
235
236 mp_jsonOutput->endMap(); // psm
237}
std::vector< PsmProteinRef > m_currentPsmProteinRefList

References pappso::cbor::psm::PsmFileReaderBase::m_cborScanPsmEval, pappso::cbor::psm::PsmFileReaderBase::m_cborScanPsmProps, pappso::cbor::psm::PsmFileReaderBase::m_currentPsmProforma, pappso::cbor::psm::PsmFileReaderBase::m_currentPsmProteinRefList, and mp_jsonOutput.

◆ readProteinMap()

void pappso::cbor::psm::PsmCbor2Json::readProteinMap ( pappso::UiMonitorInterface & monitor)
overrideprotectedvirtual

Reimplemented from pappso::cbor::psm::PsmFileReaderBase.

Definition at line 113 of file psmcbor2json.cpp.

115{
116 mp_jsonOutput->appendKey("protein_map");
117 mp_jsonOutput->startMap();
118 if(!mpa_cborReader->enterContainer())
119 {
120 throw pappso::PappsoException(QObject::tr("enterContainer in protein map failed"));
121 }
122 QString accession;
123 while(!mpa_cborReader->lastError() && mpa_cborReader->hasNext())
124 {
125 mpa_cborReader->decodeString(accession);
126 mp_jsonOutput->appendKey(accession);
127
128 QCborMap cbor_protein;
129 mpa_cborReader->readCborMap(cbor_protein);
130 mp_jsonOutput->writeCborMap(cbor_protein);
131 }
132
133 mpa_cborReader->leaveContainer();
134 mp_jsonOutput->endMap();
135}

References mp_jsonOutput, and pappso::cbor::CborStreamReaderInterface::mpa_cborReader.

◆ sampleFinished()

void pappso::cbor::psm::PsmCbor2Json::sampleFinished ( pappso::UiMonitorInterface & monitor)
overrideprotectedvirtual

Reimplemented from pappso::cbor::psm::PsmFileReaderBase.

Definition at line 198 of file psmcbor2json.cpp.

200{
201 mp_jsonOutput->endArray(); // scan_list
202 mp_jsonOutput->endMap(); // sample
203}

References mp_jsonOutput.

◆ sampleListFinished()

void pappso::cbor::psm::PsmCbor2Json::sampleListFinished ( pappso::UiMonitorInterface & monitor)
overrideprotectedvirtual

Reimplemented from pappso::cbor::psm::PsmFileReaderBase.

Definition at line 105 of file psmcbor2json.cpp.

107{
108
109 mp_jsonOutput->endArray();
110}

References mp_jsonOutput.

◆ sampleListStarted()

void pappso::cbor::psm::PsmCbor2Json::sampleListStarted ( pappso::UiMonitorInterface & monitor)
overrideprotectedvirtual

Reimplemented from pappso::cbor::psm::PsmFileReaderBase.

Definition at line 96 of file psmcbor2json.cpp.

98{
99
100 mp_jsonOutput->appendKey("sample_list");
101 mp_jsonOutput->startArray();
102}

References mp_jsonOutput.

◆ sampleStarted()

void pappso::cbor::psm::PsmCbor2Json::sampleStarted ( pappso::UiMonitorInterface & monitor)
overrideprotectedvirtual

Reimplemented from pappso::cbor::psm::PsmFileReaderBase.

Definition at line 166 of file psmcbor2json.cpp.

167{
168 //"name": "tandem2017_nopatch_20120906_balliau_extract_1_A01_urnb-1",
169 qDebug();
170 mp_jsonOutput->startMap(); // sample
171 mp_jsonOutput->appendKey("name");
173
174
175 mp_jsonOutput->appendKey("identification_file_list");
176 mp_jsonOutput->startArray();
177 for(auto &identification_file : m_currentIdentificationFileList)
178 {
179 mp_jsonOutput->startMap();
180 mp_jsonOutput->appendKey("name");
181 mp_jsonOutput->appendValue(identification_file.name);
182 mp_jsonOutput->endMap();
183 }
184 mp_jsonOutput->endArray();
185
186
187 mp_jsonOutput->appendKey("peaklist_file");
188 mp_jsonOutput->startMap();
189 mp_jsonOutput->appendKey("name");
190 mp_jsonOutput->appendValue(m_currentPeaklistFile.name);
191 mp_jsonOutput->endMap();
192
193 mp_jsonOutput->appendKey("scan_list");
194 mp_jsonOutput->startArray();
195}
std::vector< PsmFile > m_currentIdentificationFileList

References pappso::cbor::psm::PsmFileReaderBase::m_currentIdentificationFileList, pappso::cbor::psm::PsmFileReaderBase::m_currentPeaklistFile, pappso::cbor::psm::PsmFileReaderBase::m_currentSampleName, and mp_jsonOutput.

◆ scanFinished()

void pappso::cbor::psm::PsmCbor2Json::scanFinished ( pappso::UiMonitorInterface & monitor)
overrideprotectedvirtual

Reimplemented from pappso::cbor::psm::PsmFileReaderBase.

Definition at line 158 of file psmcbor2json.cpp.

159{
160 mp_jsonOutput->endArray(); // psm_list
161 mp_jsonOutput->endMap(); // scan
162}

References mp_jsonOutput.

◆ scanStarted()

void pappso::cbor::psm::PsmCbor2Json::scanStarted ( pappso::UiMonitorInterface & monitor)
overrideprotectedvirtual

Member Data Documentation

◆ mp_jsonOutput


The documentation for this class was generated from the following files: