32#include <odsstream/tsvreader.h>
33#include <odsstream/odsexception.h>
35#include <qcontainerfwd.h>
48 const QString &sage_json_file)
81 const QString &sequence_in)
83 QString accession = description_in.split(
" ", Qt::SkipEmptyParts).at(0);
86 const PsmProtein &psm_protein =
mp_self->m_psmProteinMap.getByAccession(accession);
87 psm_protein.
protein_sp.get()->setSequence(sequence_in);
88 psm_protein.
protein_sp.get()->setDescription(description_in);
96 const PsmProtein &psm_protein =
mp_self->m_psmProteinMap.getByAccession(accession);
97 psm_protein.
protein_sp.get()->setSequence(sequence_in);
98 psm_protein.
protein_sp.get()->setDescription(description_in);
120 QFileInfo tsv_file_info(file_str);
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()));
142 reader.
parse(fastaFile);
155 catch(OdsException &error_ods)
158 .arg(tsv_file_info.absoluteFilePath())
159 .arg(error_ods.qwhat()));
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())
177 for(
auto path_mzml : json_mzml_path_list.toArray())
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();
229 QJsonObject sage_object = json_doc.object();
230 QJsonValue database = sage_object.value(
"database");
231 if(database.isUndefined())
235 path = database.toObject().value(
"fasta").toString();
251 if(path.startsWith(
"file:") || path.startsWith(
"http:") || path.startsWith(
"https:"))
254 if(tsv_url.isValid())
256 qDebug() <<
"tsv_url.isValid()";
257 if(tsv_url.isLocalFile())
259 qDebug() <<
"tsv_url.isLocalFile()";
260 return tsv_url.toLocalFile();
265 QObject::tr(
"Unable to load data from remote URL %1").arg(tsv_url.toString()));
272std::vector<pappso::cbor::psm::SageReader::SageModification>
275 std::vector<SageReader::SageModification> list;
277 QJsonValue database = sage_object.value(
"database");
278 if(database.isUndefined())
283 QJsonValue static_mods = database.toObject().value(
"static_mods");
284 if(static_mods.isUndefined())
288 for(QString residue_str : static_mods.toObject().keys())
291 modif.
residue = residue_str.at(0);
294 static_mods.toObject().value(residue_str).toDouble());
296 QString::number(static_mods.toObject().value(residue_str).toDouble(),
'f', 6);
309 list.push_back(modif);
314std::vector<pappso::cbor::psm::SageReader::SageModification>
317 std::vector<SageReader::SageModification> list;
319 QJsonValue database = sage_object.value(
"database");
320 if(database.isUndefined())
325 QJsonValue var_mods = database.toObject().value(
"variable_mods");
326 if(var_mods.isUndefined())
330 for(QString residue_str : var_mods.toObject().keys())
333 modif.
residue = residue_str.at(0);
334 for(QJsonValue one_mass : var_mods.toObject().value(residue_str).toArray())
351 list.push_back(modif);
362 QJsonValue database = sage_object.value(
"database");
363 if(database.isUndefined())
367 path = database.toObject().value(
"decoy_tag").toString();
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)
PsmProteinMap m_psmProteinMap
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
QStringList m_mzmlPathList
pappso::cbor::CborStreamWriter * mp_cborWriter
const QString & getmJsonAbsoluteFilePath() const
void extractMzmlPathList(const QJsonDocument &json_doc)
pappso::cbor::CborStreamWriter & getCborStreamWriter() const
QString m_jsonAbsoluteFilePath
const SageFileReader & m_sageFileReader
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
QString convertToLocalFileOrDie(const QString &file_str) const
std::shared_ptr< Protein > protein_sp
pappso::AaModificationP modification