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

`#include <sagefilereader.h>`

## Public Member Functions

| SageFileReader (pappso::UiMonitorInterface *p_monitor, pappso::cbor::CborStreamWriter *p_output, const QFileInfo &sage_json_file)
| main function to convert Sage results to CBOR output
virtual | ~SageFileReader ()
const QJsonDocument & | getJsonDocument () const
QString | getMsRunSpWithFileName (const QString &msrun_filename) const

## Private Member Functions

void | readJson ()

## Private Attributes

const QFileInfo | m_sageJsonFile
QJsonDocument | m_jsonData
std::map< QString, QString > | m_mapFilePath2MsRunSp
QString | m_sageVersion
pappso::cbor::CborStreamWriter * | mp_cborWriter
QString | m_decoyTag
bool | m_generateDecoy = false
QStringList | m_targetFastaFile

## Detailed Description

Todo
  write docs

Definition at line 47 of file sagefilereader.h.

## Constructor & Destructor Documentation

## SageFileReader()

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

main function to convert Sage results to CBOR output

given the Sage JSON result file, this class reads the TSV output and convert the Sage PSMs to the PSMcbor format

Parameters

  p_monitor | pointer to monitor read progress
  p_output | cbor output pointer
  sage_json_file | Sage JSON result file

Definition at line 46 of file sagefilereader.cpp.

: m_sageJsonFile(sage_json_file)
{
qDebug() << m_sageJsonFile.absoluteFilePath() << "'";
try
{
mp_cborWriter = p_output;
mp_cborWriter->startMap();
mp_cborWriter->writeInformations(
"sage_file_reader", Utils::getVersion(), "psm", "sage reader");
QDir::setCurrent(sage_json_file.absolutePath());
readJson();
mp_cborWriter->append("parameter_map");
mp_cborWriter->startMap();
mp_cborWriter->append("sage");
QCborValue::fromJsonValue(m_jsonData.object()).toCbor(*mp_cborWriter);
mp_cborWriter->endMap();
p_monitor->setStatus(
QObject::tr("reading Sage json file %1").arg(sage_json_file.absoluteFilePath()));
// "decoy_tag": "rev_",
// "generate_decoys": true,
// "target_fasta_files": ["zea_mays.fasta", "contaminant.fasta"],
//"decoy_fasta_files": ["rev_zea_mays.fasta", "rev_contaminant.fasta"],
mp_cborWriter->append("target_fasta_files");
mp_cborWriter->writeArray(m_targetFastaFile);
SageReader sage_reader(p_monitor, mp_cborWriter, *this, sage_json_file.absoluteFilePath());
sage_reader.read();
// mp_cborWriter->append("protein_map");
// sage_reader.getPsmProteinMap().
mp_cborWriter->endMap();
}
catch(pappso::ExceptionNotRecognized &err)
{
throw err;
}
catch(pappso::PappsoException &other_err)
{
throw pappso::PappsoException(QObject::tr("Error reading Sage JSON file %1:\n%2")
.arg(m_sageJsonFile.absoluteFilePath())
.arg(other_err.qwhat()));
}
}
pappso::PappsoException::qwhat
virtual const QString & qwhat() const
Definition pappsoexception.h:66
pappso::UiMonitorInterface::setStatus
virtual void setStatus(const QString &status)=0
current status of the process
pappso::Utils::getVersion
static QString getVersion()
Definition utils.cpp:669
pappso::cbor::psm::SageFileReader::mp_cborWriter
pappso::cbor::CborStreamWriter * mp_cborWriter
Definition sagefilereader.h:79
pappso::cbor::psm::SageFileReader::m_targetFastaFile
QStringList m_targetFastaFile
Definition sagefilereader.h:82
pappso::cbor::psm::SageFileReader::readJson
void readJson()
Definition sagefilereader.cpp:107
pappso::cbor::psm::SageFileReader::m_jsonData
QJsonDocument m_jsonData
Definition sagefilereader.h:75
pappso::cbor::psm::SageFileReader::m_sageJsonFile
const QFileInfo m_sageJsonFile
Definition sagefilereader.h:74

References pappso::Utils::getVersion(), m_jsonData, m_sageJsonFile, m_targetFastaFile, mp_cborWriter, pappso::PappsoException::qwhat(), pappso::cbor::psm::SageReader::read(), readJson(), and pappso::UiMonitorInterface::setStatus().

## ~SageFileReader()

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

virtual

Destructor

Definition at line 101 of file sagefilereader.cpp.

{
}

## Member Function Documentation

## getJsonDocument()

const QJsonDocument & pappso::cbor::psm::SageFileReader::getJsonDocument | ( |  | ) | const

Definition at line 159 of file sagefilereader.cpp.

{
return m_jsonData;
}

References m_jsonData.

## getMsRunSpWithFileName()

QString pappso::cbor::psm::SageFileReader::getMsRunSpWithFileName | ( | const QString & | msrun_filename | ) | const

Definition at line 166 of file sagefilereader.cpp.

{
auto it = m_mapFilePath2MsRunSp.find(msrun_filename);
if(it != m_mapFilePath2MsRunSp.end())
return it->second;
throw pappso::PappsoException(QObject::tr("msrun filename %1 not found").arg(msrun_filename));
}
pappso::cbor::psm::SageFileReader::m_mapFilePath2MsRunSp
std::map< QString, QString > m_mapFilePath2MsRunSp
Definition sagefilereader.h:77

References m_mapFilePath2MsRunSp.

## readJson()

void pappso::cbor::psm::SageFileReader::readJson | ( |  | ) |

private

Definition at line 107 of file sagefilereader.cpp.

{
QFile mfile(m_sageJsonFile.absoluteFilePath());
if(!mfile.open(QFile::ReadOnly))
{
throw pappso::ExceptionNotRecognized(
QObject::tr("Unable to read Sage JSON file %1").arg(m_sageJsonFile.absoluteFilePath()));
}
QByteArray iContents = mfile.readAll();
QJsonParseError parseError;
m_jsonData = QJsonDocument::fromJson(iContents, &parseError);
if(parseError.error != QJsonParseError::NoError)
{
throw pappso::ExceptionNotRecognized(QObject::tr("Error reading Sage JSON file %1 at %2:%3")
.arg(m_sageJsonFile.absoluteFilePath())
.arg(parseError.offset)
.arg(parseError.errorString()));
}
QJsonValue mzml_value = m_jsonData.object().value("mzml_paths");
if(mzml_value.isNull())
{
throw pappso::ExceptionNotRecognized(
QObject::tr("Sage JSON file %1 does not contain mzml_paths")
.arg(m_sageJsonFile.absoluteFilePath()));
}
for(const QJsonValue &value : m_jsonData.object().value("mzml_paths").toArray())
{
qDebug() << value.toString();
// MsRunSp msrun_sp = p_project->getMsRunStore().getInstance(value.toString());
m_mapFilePath2MsRunSp.insert(
{QFileInfo(value.toString()).fileName(), QFileInfo(value.toString()).absoluteFilePath()});
}
m_sageVersion = m_jsonData.object().value("version").toString();
QJsonObject sage_object = m_jsonData.object();
QJsonObject database = sage_object.value("database").toObject();
m_decoyTag = database.value("decoy_tag").toString();
m_generateDecoy = database.value("generate_decoy").toBool();
m_targetFastaFile << database.value("fasta").toString();
}
pappso::cbor::psm::SageFileReader::m_generateDecoy
bool m_generateDecoy
Definition sagefilereader.h:81
pappso::cbor::psm::SageFileReader::m_sageVersion
QString m_sageVersion
Definition sagefilereader.h:78
pappso::cbor::psm::SageFileReader::m_decoyTag
QString m_decoyTag
Definition sagefilereader.h:80

References m_decoyTag, m_generateDecoy, m_jsonData, m_mapFilePath2MsRunSp, m_sageJsonFile, m_sageVersion, and m_targetFastaFile.

Referenced by SageFileReader().

## Member Data Documentation

## m_decoyTag

QString pappso::cbor::psm::SageFileReader::m_decoyTag

private

Definition at line 80 of file sagefilereader.h.

Referenced by readJson().

## m_generateDecoy

bool pappso::cbor::psm::SageFileReader::m_generateDecoy = false

private

Definition at line 81 of file sagefilereader.h.

Referenced by readJson().

## m_jsonData

QJsonDocument pappso::cbor::psm::SageFileReader::m_jsonData

private

Definition at line 75 of file sagefilereader.h.

Referenced by SageFileReader(), getJsonDocument(), and readJson().

## m_mapFilePath2MsRunSp

std::map<QString, QString> pappso::cbor::psm::SageFileReader::m_mapFilePath2MsRunSp

private

Definition at line 77 of file sagefilereader.h.

Referenced by getMsRunSpWithFileName(), and readJson().

## m_sageJsonFile

const QFileInfo pappso::cbor::psm::SageFileReader::m_sageJsonFile

private

Definition at line 74 of file sagefilereader.h.

Referenced by SageFileReader(), and readJson().

## m_sageVersion

QString pappso::cbor::psm::SageFileReader::m_sageVersion

private

Definition at line 78 of file sagefilereader.h.

Referenced by readJson().

## m_targetFastaFile

QStringList pappso::cbor::psm::SageFileReader::m_targetFastaFile

private

Definition at line 82 of file sagefilereader.h.

Referenced by SageFileReader(), and readJson().

## mp_cborWriter

pappso::cbor::CborStreamWriter* pappso::cbor::psm::SageFileReader::mp_cborWriter

private

Definition at line 79 of file sagefilereader.h.

Referenced by SageFileReader().

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

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