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)
84 QStringList description_split = description_in.split(
" ", Qt::SkipEmptyParts);
85 QString accession = description_split.at(0);
88 const PsmProtein &psm_protein =
mp_self->m_psmProteinMap.getByAccession(accession);
89 psm_protein.
protein_sp.get()->setSequence(sequence_in);
90 psm_protein.
protein_sp.get()->setDescription(description_in);
97 QString rev_accession = accession.prepend(
m_decoyTag);
98 const PsmProtein &psm_protein =
mp_self->m_psmProteinMap.getByAccession(rev_accession);
99 psm_protein.
protein_sp.get()->setSequence(sequence_in);
101 description_split[0] = rev_accession;
102 psm_protein.
protein_sp.get()->setDescription(description_split.join(
" "));
124 QFileInfo tsv_file_info(file_str);
128 TsvReader tsv_reader(handler);
130 QFile tsv_file(tsv_file_info.absoluteFilePath());
131 tsv_reader.parse(tsv_file);
134 catch(OdsException &error_ods)
137 .arg(tsv_file_info.absoluteFilePath())
138 .arg(error_ods.qwhat()));
146 reader.
parse(fastaFile);
159 catch(OdsException &error_ods)
162 .arg(tsv_file_info.absoluteFilePath())
163 .arg(error_ods.qwhat()));
173 QJsonObject sage_object = json_doc.object();
174 QJsonValue json_mzml_path_list = sage_object.value(
"mzml_paths");
175 if(json_mzml_path_list.isUndefined())
181 for(
auto path_mzml : json_mzml_path_list.toArray())
192 if(file_path.endsWith(file_msrun))
196 QObject::tr(
"MS run %1 not found in Sage json document").append(file_msrun));
204 QJsonObject sage_object = json_doc.object();
205 QJsonValue output_path = sage_object.value(
"output_paths");
206 if(output_path.isUndefined())
211 if(!output_path.isArray())
215 for(
auto element : output_path.toArray())
217 if(element.isString())
219 if(element.toString().endsWith(
".tsv"))
221 path = element.toString();
233 QJsonObject sage_object = json_doc.object();
234 QJsonValue database = sage_object.value(
"database");
235 if(database.isUndefined())
239 path = database.toObject().value(
"fasta").toString();
255 if(path.startsWith(
"file:") || path.startsWith(
"http:") || path.startsWith(
"https:"))
258 if(tsv_url.isValid())
260 qDebug() <<
"tsv_url.isValid()";
261 if(tsv_url.isLocalFile())
263 qDebug() <<
"tsv_url.isLocalFile()";
264 return tsv_url.toLocalFile();
269 QObject::tr(
"Unable to load data from remote URL %1").arg(tsv_url.toString()));
276std::vector<pappso::cbor::psm::SageReader::SageModification>
279 std::vector<SageReader::SageModification> list;
281 QJsonValue database = sage_object.value(
"database");
282 if(database.isUndefined())
287 QJsonValue static_mods = database.toObject().value(
"static_mods");
288 if(static_mods.isUndefined())
292 for(QString residue_str : static_mods.toObject().keys())
295 modif.
residue = residue_str.at(0);
298 static_mods.toObject().value(residue_str).toDouble());
300 QString::number(static_mods.toObject().value(residue_str).toDouble(),
'f', 6);
313 list.push_back(modif);
318std::vector<pappso::cbor::psm::SageReader::SageModification>
321 std::vector<SageReader::SageModification> list;
323 QJsonValue database = sage_object.value(
"database");
324 if(database.isUndefined())
329 QJsonValue var_mods = database.toObject().value(
"variable_mods");
330 if(var_mods.isUndefined())
334 for(QString residue_str : var_mods.toObject().keys())
337 modif.
residue = residue_str.at(0);
338 for(QJsonValue one_mass : var_mods.toObject().value(residue_str).toArray())
355 list.push_back(modif);
366 QJsonValue database = sage_object.value(
"database");
367 if(database.isUndefined())
371 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