Loading...
Searching...
No Matches
pappso::cbor::psm::SageReader Class Reference

`#include <sagereader.h>`

## Classes

struct | SageModification
class | FastaSeq

## Public Member Functions

| SageReader (pappso::UiMonitorInterface *p_monitor, pappso::cbor::CborStreamWriter *p_output, const SageFileReader &sage_file_reader, const QString &sage_json_file)
void | read ()
virtual | ~SageReader ()
std::vector< SageModification > | getStaticModificationList () const
std::vector< SageModification > | getVariableModificationList () const
QString | getDecoyTag () const
const SageFileReader & | getSageFileReader () const
pappso::cbor::CborStreamWriter & | getCborStreamWriter () const
const QString & | getmJsonAbsoluteFilePath () const
const QString & | getMzmlPath (const QString &file_msrun) const

## Private Member Functions

void | readTsvFile ()
void | extractMzmlPathList (const QJsonDocument &json_doc)
QString | getTsvFilePath (const QJsonDocument &json_doc)
QString | getFastaFilePath (const QJsonDocument &json_doc)

## Private Attributes

const SageFileReader & | m_sageFileReader
pappso::UiMonitorInterface * | mp_monitor
pappso::cbor::CborStreamWriter * | mp_cborWriter
PsmProteinMap | m_psmProteinMap
QString | m_jsonAbsoluteFilePath
QStringList | m_mzmlPathList

## Detailed Description

Todo
  write docs

Definition at line 41 of file sagereader.h.

## Constructor & Destructor Documentation

## SageReader()

pappso::cbor::psm::SageReader::SageReader | ( | pappso::UiMonitorInterface * | p_monitor,
|  | pappso::cbor::CborStreamWriter * | p_output,
|  | const SageFileReader & | sage_file_reader,
|  | const QString & | sage_json_file )

Default constructor

Definition at line 41 of file sagereader.cpp.

: m_sageFileReader(sage_file_reader)
{
mp_monitor = p_monitor;
mp_cborWriter = p_output;
m_jsonAbsoluteFilePath = sage_json_file;
}
pappso::cbor::psm::SageReader::mp_cborWriter
pappso::cbor::CborStreamWriter * mp_cborWriter
Definition sagereader.h:99
pappso::cbor::psm::SageReader::m_jsonAbsoluteFilePath
QString m_jsonAbsoluteFilePath
Definition sagereader.h:101
pappso::cbor::psm::SageReader::m_sageFileReader
const SageFileReader & m_sageFileReader
Definition sagereader.h:97
pappso::cbor::psm::SageReader::mp_monitor
pappso::UiMonitorInterface * mp_monitor
Definition sagereader.h:98

References m_jsonAbsoluteFilePath, m_sageFileReader, mp_cborWriter, and mp_monitor.

Referenced by pappso::cbor::psm::SageReader::FastaSeq::FastaSeq().

## ~SageReader()

pappso::cbor::psm::SageReader::~SageReader | ( |  | ) |

virtual

Destructor

Definition at line 52 of file sagereader.cpp.

{
}

## Member Function Documentation

## extractMzmlPathList()

void pappso::cbor::psm::SageReader::extractMzmlPathList | ( | const QJsonDocument & | json_doc | ) |

private

Definition at line 166 of file sagereader.cpp.

{
QJsonObject sage_object = json_doc.object();
QJsonValue json_mzml_path_list = sage_object.value("mzml_paths");
if(json_mzml_path_list.isUndefined())
{
throw pappso::ExceptionNotFound(QObject::tr("mzml_paths not found in Sage json document"));
}
m_mzmlPathList.clear();
for(auto path_mzml : json_mzml_path_list.toArray())
{
m_mzmlPathList << path_mzml.toString();
}
}
pappso::cbor::psm::SageReader::m_mzmlPathList
QStringList m_mzmlPathList
Definition sagereader.h:102

References m_mzmlPathList.

Referenced by readTsvFile().

## getCborStreamWriter()

pappso::cbor::CborStreamWriter & pappso::cbor::psm::SageReader::getCborStreamWriter | ( |  | ) | const

Definition at line 103 of file sagereader.cpp.

{
return *mp_cborWriter;
}

References mp_cborWriter.

## getDecoyTag()

QString pappso::cbor::psm::SageReader::getDecoyTag | ( |  | ) | const

Definition at line 329 of file sagereader.cpp.

{
QString path;
QJsonObject sage_object = m_sageFileReader.getJsonDocument().object();
QJsonValue database = sage_object.value("database");
if(database.isUndefined())
{
throw pappso::ExceptionNotFound(QObject::tr("database not found in Sage json document"));
}
path = database.toObject().value("decoy_tag").toString();
if(path.isEmpty())
{
throw pappso::ExceptionNotFound(QObject::tr("decoy_tag value is empty"));
}
return path;
}

References m_sageFileReader.

Referenced by pappso::cbor::psm::SageTsvHandler::SageTsvHandler().

## getFastaFilePath()

QString pappso::cbor::psm::SageReader::getFastaFilePath | ( | const QJsonDocument & | json_doc | ) |

private

Definition at line 225 of file sagereader.cpp.

{
QString path;
QJsonObject sage_object = json_doc.object();
QJsonValue database = sage_object.value("database");
if(database.isUndefined())
{
throw pappso::ExceptionNotFound(QObject::tr("database not found in Sage json document"));
}
path = database.toObject().value("fasta").toString();
if(path.isEmpty())
{
throw pappso::ExceptionNotFound(QObject::tr("fasta value is empty"));
}
return path;
}

Referenced by readTsvFile().

## getmJsonAbsoluteFilePath()

const QString & pappso::cbor::psm::SageReader::getmJsonAbsoluteFilePath | ( |  | ) | const

Definition at line 57 of file sagereader.cpp.

{
return m_jsonAbsoluteFilePath;
}

References m_jsonAbsoluteFilePath.

## getMzmlPath()

const QString & pappso::cbor::psm::SageReader::getMzmlPath | ( | const QString & | file_msrun | ) | const

Definition at line 184 of file sagereader.cpp.

{
for(auto &file_path : m_mzmlPathList)
{
if(file_path.endsWith(file_msrun))
return file_path;
}
throw pappso::ExceptionNotFound(
QObject::tr("MS run %1 not found in Sage json document").append(file_msrun));
}

References m_mzmlPathList.

## getSageFileReader()

const pappso::cbor::psm::SageFileReader & pappso::cbor::psm::SageReader::getSageFileReader | ( |  | ) | const

Definition at line 347 of file sagereader.cpp.

{
return m_sageFileReader;
}

References m_sageFileReader.

## getStaticModificationList()

std::vector< pappso::cbor::psm::SageReader::SageModification > pappso::cbor::psm::SageReader::getStaticModificationList | ( |  | ) | const

Definition at line 244 of file sagereader.cpp.

{
std::vector<SageReader::SageModification> list;
QJsonObject sage_object = m_sageFileReader.getJsonDocument().object();
QJsonValue database = sage_object.value("database");
if(database.isUndefined())
{
throw pappso::ExceptionNotFound(QObject::tr("database not found in Sage json document"));
}
QJsonValue static_mods = database.toObject().value("static_mods");
if(static_mods.isUndefined())
{
throw pappso::ExceptionNotFound(QObject::tr("static_mods not found in Sage json document"));
}
for(QString residue_str : static_mods.toObject().keys())
{
SageModification modif;
modif.residue = residue_str.at(0);
modif.modification = pappso::Utils::guessAaModificationPbyMonoisotopicMassDelta(
(Enums::AminoAcidChar)modif.residue.toLatin1(),
static_mods.toObject().value(residue_str).toDouble());
modif.strModification =
QString::number(static_mods.toObject().value(residue_str).toDouble(), 'f', 6);
if(modif.strModification.isEmpty())
{
throw pappso::PappsoException(QObject::tr(" modif.strModification is empty"));
}
if(modif.modification->getMass() < 0)
{
modif.strModification = QString("[%1]").arg(modif.strModification);
}
else
{
modif.strModification = QString("[+%1]").arg(modif.strModification);
}
list.push_back(modif);
}
return list;
}
pappso::Utils::guessAaModificationPbyMonoisotopicMassDelta
static AaModificationP guessAaModificationPbyMonoisotopicMassDelta(Enums::AminoAcidChar aa, pappso_double mass)
Definition utils.cpp:658
pappso::Enums::AminoAcidChar
AminoAcidChar
Definition types.h:196
pappso::cbor::psm::SageReader::SageModification
Definition sagereader.h:60
pappso::cbor::psm::SageReader::SageModification::residue
QChar residue
Definition sagereader.h:62

References pappso::AaModification::getMass(), pappso::Utils::guessAaModificationPbyMonoisotopicMassDelta(), m_sageFileReader, pappso::cbor::psm::SageReader::SageModification::modification, pappso::cbor::psm::SageReader::SageModification::residue, and pappso::cbor::psm::SageReader::SageModification::strModification.

Referenced by pappso::cbor::psm::SageTsvHandler::SageTsvHandler().

## getTsvFilePath()

QString pappso::cbor::psm::SageReader::getTsvFilePath | ( | const QJsonDocument & | json_doc | ) |

private

Definition at line 197 of file sagereader.cpp.

{
QString path;
QJsonObject sage_object = json_doc.object();
QJsonValue output_path = sage_object.value("output_paths");
if(output_path.isUndefined())
{
throw pappso::ExceptionNotFound(QObject::tr("output_paths not found in Sage json document"));
}
if(!output_path.isArray())
{
throw pappso::ExceptionNotFound(QObject::tr("output_paths is not an array"));
}
for(auto element : output_path.toArray())
{
if(element.isString())
{
if(element.toString().endsWith(".tsv"))
{
path = element.toString();
}
}
}
return path;
}

Referenced by readTsvFile().

## getVariableModificationList()

std::vector< pappso::cbor::psm::SageReader::SageModification > pappso::cbor::psm::SageReader::getVariableModificationList | ( |  | ) | const

Definition at line 286 of file sagereader.cpp.

{
std::vector<SageReader::SageModification> list;
QJsonObject sage_object = m_sageFileReader.getJsonDocument().object();
QJsonValue database = sage_object.value("database");
if(database.isUndefined())
{
throw pappso::ExceptionNotFound(QObject::tr("database not found in Sage json document"));
}
QJsonValue var_mods = database.toObject().value("variable_mods");
if(var_mods.isUndefined())
{
throw pappso::ExceptionNotFound(QObject::tr("static_mods not found in Sage json document"));
}
for(QString residue_str : var_mods.toObject().keys())
{
SageModification modif;
modif.residue = residue_str.at(0);
for(QJsonValue one_mass : var_mods.toObject().value(residue_str).toArray())
{
modif.modification = pappso::Utils::guessAaModificationPbyMonoisotopicMassDelta(
(Enums::AminoAcidChar)modif.residue.toLatin1(), one_mass.toDouble());
modif.strModification = QString::number(one_mass.toDouble(), 'f', 6);
if(modif.strModification.isEmpty())
{
throw pappso::PappsoException(QObject::tr(" modif.strModification is empty"));
}
if(modif.modification->getMass() < 0)
{
modif.strModification = QString("[%1]").arg(modif.strModification);
}
else
{
modif.strModification = QString("[+%1]").arg(modif.strModification);
}
list.push_back(modif);
}
}
return list;
}

References pappso::AaModification::getMass(), pappso::Utils::guessAaModificationPbyMonoisotopicMassDelta(), m_sageFileReader, pappso::cbor::psm::SageReader::SageModification::modification, pappso::cbor::psm::SageReader::SageModification::residue, and pappso::cbor::psm::SageReader::SageModification::strModification.

Referenced by pappso::cbor::psm::SageTsvHandler::SageTsvHandler().

## read()

void pappso::cbor::psm::SageReader::read | ( |  | ) |

Definition at line 64 of file sagereader.cpp.

{
readTsvFile();
}
pappso::cbor::psm::SageReader::readTsvFile
void readTsvFile()
Definition sagereader.cpp:110

References readTsvFile().

Referenced by pappso::cbor::psm::SageFileReader::SageFileReader().

## readTsvFile()

void pappso::cbor::psm::SageReader::readTsvFile | ( |  | ) |

private

Definition at line 110 of file sagereader.cpp.

{
extractMzmlPathList(m_sageFileReader.getJsonDocument());
// getTsvFilePath(mp_identificationDataSource->getJsonDocument().object());
QUrl tsv_url(getTsvFilePath(m_sageFileReader.getJsonDocument()));
QFileInfo tsv_file_info(tsv_url.toLocalFile());
if(!tsv_url.isLocalFile())
{
tsv_file_info.setFile(getTsvFilePath(m_sageFileReader.getJsonDocument()));
}
SageTsvHandler handler(mp_monitor, *this, m_psmProteinMap);
try
{
TsvReader tsv_reader(handler);
QFile tsv_file(tsv_file_info.absoluteFilePath());
tsv_reader.parse(tsv_file);
tsv_file.close();
}
catch(OdsException &error_ods)
{
throw pappso::PappsoException(QObject::tr("Error reading %1 file:\n %2")
.arg(tsv_file_info.absoluteFilePath())
.arg(error_ods.qwhat()));
}
// collect protein sequences
QFile fastaFile(getFastaFilePath(m_sageFileReader.getJsonDocument()));
SageReader::FastaSeq seq(this);
pappso::FastaReader reader(seq);
reader.parse(fastaFile);
qDebug();
mp_cborWriter->append("protein_map");
m_psmProteinMap.writeMap(*mp_cborWriter);
mp_cborWriter->append("sample_list");
mp_cborWriter->startArray();
try
{
handler.writeSampleList();
}
catch(OdsException &error_ods)
{
throw pappso::PappsoException(QObject::tr("Error reading %1 file:\n %2")
.arg(tsv_file_info.absoluteFilePath())
.arg(error_ods.qwhat()));
}
mp_cborWriter->endArray();
}
pappso::cbor::psm::SageReader::m_psmProteinMap
PsmProteinMap m_psmProteinMap
Definition sagereader.h:100
pappso::cbor::psm::SageReader::extractMzmlPathList
void extractMzmlPathList(const QJsonDocument &json_doc)
Definition sagereader.cpp:166
pappso::cbor::psm::SageReader::getFastaFilePath
QString getFastaFilePath(const QJsonDocument &json_doc)
Definition sagereader.cpp:225
pappso::cbor::psm::SageReader::getTsvFilePath
QString getTsvFilePath(const QJsonDocument &json_doc)
Definition sagereader.cpp:197

References extractMzmlPathList(), getFastaFilePath(), getTsvFilePath(), m_psmProteinMap, m_sageFileReader, mp_cborWriter, mp_monitor, pappso::FastaReader::parse(), and pappso::cbor::psm::SageTsvHandler::writeSampleList().

Referenced by read().

## Member Data Documentation

## m_jsonAbsoluteFilePath

QString pappso::cbor::psm::SageReader::m_jsonAbsoluteFilePath

private

Definition at line 101 of file sagereader.h.

Referenced by SageReader(), and getmJsonAbsoluteFilePath().

## m_mzmlPathList

QStringList pappso::cbor::psm::SageReader::m_mzmlPathList

private

Definition at line 102 of file sagereader.h.

Referenced by extractMzmlPathList(), and getMzmlPath().

## m_psmProteinMap

PsmProteinMap pappso::cbor::psm::SageReader::m_psmProteinMap

private

Definition at line 100 of file sagereader.h.

Referenced by readTsvFile().

## m_sageFileReader

const SageFileReader& pappso::cbor::psm::SageReader::m_sageFileReader

private

Definition at line 97 of file sagereader.h.

Referenced by SageReader(), getDecoyTag(), getSageFileReader(), getStaticModificationList(), getVariableModificationList(), and readTsvFile().

## mp_cborWriter

pappso::cbor::CborStreamWriter* pappso::cbor::psm::SageReader::mp_cborWriter

private

Definition at line 99 of file sagereader.h.

Referenced by SageReader(), getCborStreamWriter(), and readTsvFile().

## mp_monitor

pappso::UiMonitorInterface* pappso::cbor::psm::SageReader::mp_monitor

private

Definition at line 98 of file sagereader.h.

Referenced by SageReader(), and readTsvFile().

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

- pappsomspp/core/processing/cbor/psm/sage/sagereader.h
- pappsomspp/core/processing/cbor/psm/sage/sagereader.cpp