32#include <odsstream/tsvreader.h>
33#include <odsstream/odsexception.h>
39#include "../../../../fasta/fastareader.h"
44 const QString &sage_json_file)
45 : m_sageFileReader(sage_file_reader)
59 return m_jsonAbsoluteFilePath;
77 const QString &sequence_in)
79 QString accession = description_in.split(
" ", Qt::SkipEmptyParts).at(0);
82 const PsmProtein &psm_protein = mp_self->m_psmProteinMap.getByAccession(accession);
83 psm_protein.
protein_sp.get()->setSequence(sequence_in);
84 psm_protein.
protein_sp.get()->setDescription(description_in);
91 accession = accession.prepend(m_decoyTag);
92 const PsmProtein &psm_protein = mp_self->m_psmProteinMap.getByAccession(accession);
93 psm_protein.
protein_sp.get()->setSequence(sequence_in);
94 psm_protein.
protein_sp.get()->setDescription(description_in);
105 return *mp_cborWriter;
113 extractMzmlPathList(m_sageFileReader.getJsonDocument());
115 QUrl tsv_url(getTsvFilePath(m_sageFileReader.getJsonDocument()));
116 QFileInfo tsv_file_info(tsv_url.toLocalFile());
117 if(!tsv_url.isLocalFile())
119 tsv_file_info.setFile(getTsvFilePath(m_sageFileReader.getJsonDocument()));
124 TsvReader tsv_reader(handler);
126 QFile tsv_file(tsv_file_info.absoluteFilePath());
127 tsv_reader.parse(tsv_file);
130 catch(OdsException &error_ods)
133 .arg(tsv_file_info.absoluteFilePath())
134 .arg(error_ods.qwhat()));
139 QFile fastaFile(getFastaFilePath(m_sageFileReader.getJsonDocument()));
142 reader.
parse(fastaFile);
145 mp_cborWriter->append(
"protein_map");
146 m_psmProteinMap.writeMap(*mp_cborWriter);
149 mp_cborWriter->append(
"sample_list");
150 mp_cborWriter->startArray();
155 catch(OdsException &error_ods)
158 .arg(tsv_file_info.absoluteFilePath())
159 .arg(error_ods.qwhat()));
162 mp_cborWriter->endArray();
169 QJsonObject sage_object = json_doc.object();
170 QJsonValue json_mzml_path_list = sage_object.value(
"mzml_paths");
171 if(json_mzml_path_list.isUndefined())
175 m_mzmlPathList.clear();
177 for(
auto path_mzml : json_mzml_path_list.toArray())
179 m_mzmlPathList << path_mzml.toString();
186 for(
auto &file_path : m_mzmlPathList)
188 if(file_path.endsWith(file_msrun))
192 QObject::tr(
"MS run %1 not found in Sage json document").append(file_msrun));
200 QJsonObject sage_object = json_doc.object();
201 QJsonValue output_path = sage_object.value(
"output_paths");
202 if(output_path.isUndefined())
207 if(!output_path.isArray())
211 for(
auto element : output_path.toArray())
213 if(element.isString())
215 if(element.toString().endsWith(
".tsv"))
217 path = element.toString();
228 QJsonObject sage_object = json_doc.object();
229 QJsonValue database = sage_object.value(
"database");
230 if(database.isUndefined())
234 path = database.toObject().value(
"fasta").toString();
243std::vector<pappso::cbor::psm::SageReader::SageModification>
246 std::vector<SageReader::SageModification> list;
247 QJsonObject sage_object = m_sageFileReader.getJsonDocument().object();
248 QJsonValue database = sage_object.value(
"database");
249 if(database.isUndefined())
254 QJsonValue static_mods = database.toObject().value(
"static_mods");
255 if(static_mods.isUndefined())
259 for(QString residue_str : static_mods.toObject().keys())
262 modif.
residue = residue_str.at(0);
265 static_mods.toObject().value(residue_str).toDouble());
267 QString::number(static_mods.toObject().value(residue_str).toDouble(),
'f', 6);
280 list.push_back(modif);
285std::vector<pappso::cbor::psm::SageReader::SageModification>
288 std::vector<SageReader::SageModification> list;
289 QJsonObject sage_object = m_sageFileReader.getJsonDocument().object();
290 QJsonValue database = sage_object.value(
"database");
291 if(database.isUndefined())
296 QJsonValue var_mods = database.toObject().value(
"variable_mods");
297 if(var_mods.isUndefined())
301 for(QString residue_str : var_mods.toObject().keys())
304 modif.
residue = residue_str.at(0);
305 for(QJsonValue one_mass : var_mods.toObject().value(residue_str).toArray())
322 list.push_back(modif);
332 QJsonObject sage_object = m_sageFileReader.getJsonDocument().object();
333 QJsonValue database = sage_object.value(
"database");
334 if(database.isUndefined())
338 path = database.toObject().value(
"decoy_tag").toString();
349 return m_sageFileReader;
pappso_double getMass() const
void parse(QFile &fastaFile)
static AaModificationP guessAaModificationPbyMonoisotopicMassDelta(Enums::AminoAcidChar aa, pappso_double mass)
overrides QCborStreamWriter base class to provide convenient functions
void setSequence(const QString &description_in, const QString &sequence_in) override
FastaSeq(SageReader *self)
const QString & getMzmlPath(const QString &file_msrun) const
SageReader(pappso::UiMonitorInterface *p_monitor, pappso::cbor::CborStreamWriter *p_output, const SageFileReader &sage_file_reader, const QString &sage_json_file)
std::vector< SageModification > getStaticModificationList() const
pappso::cbor::CborStreamWriter * mp_cborWriter
const QString & getmJsonAbsoluteFilePath() const
void extractMzmlPathList(const QJsonDocument &json_doc)
pappso::cbor::CborStreamWriter & getCborStreamWriter() const
QString m_jsonAbsoluteFilePath
std::vector< SageModification > getVariableModificationList() const
QString getFastaFilePath(const QJsonDocument &json_doc)
QString getDecoyTag() const
const SageFileReader & getSageFileReader() const
QString getTsvFilePath(const QJsonDocument &json_doc)
pappso::UiMonitorInterface * mp_monitor
std::shared_ptr< Protein > protein_sp
pappso::AaModificationP modification