39#include <QtConcurrent>
43 const QString &tmp_dir_name,
44 const QJsonDocument &json_doc)
73 param.
name =
"mcq_version";
84 QJsonObject methods =
m_jsonDocument.object().value(
"masschroq_methods").toObject();
89 QJsonObject msrun_list =
documentFind(
"identification_data",
"msrun_list").toObject();
91 QJsonObject protein_list =
documentFind(
"identification_data",
"protein_list").toObject();
93 QJsonObject peptide_list =
documentFind(
"identification_data",
"peptide_list").toObject();
95 QJsonObject msrunpeptide_list =
96 documentFind(
"identification_data",
"msrunpeptide_list").toObject();
104 QJsonObject actions =
m_jsonDocument.object().value(
"actions").toObject();
114 auto it1 = obj1.find(key1);
115 if(it1 != obj1.end())
117 QJsonObject obj2 = it1.value().toObject();
118 auto it2 = obj2.find(key2);
119 if(it2 != obj2.end())
126 QObject::tr(
"key2 %1 not found in json document element %2").arg(key2).arg(key1));
140 std::map<QString, QString> msfilepathlist;
141 const QJsonObject msrun_list(
documentFind(
"identification_data",
"msrun_list").toObject());
142 auto it = msrun_list.begin();
143 while(it != msrun_list.end())
145 qDebug() << it.key();
146 qDebug() << it.value().toObject().value(
"file");
149 msfilepathlist.insert({it.key(), it.value().toObject().value(
"file").toString()});
156 mapFilenameList = [](
const std::pair<QString, QString> &mapit) {
161 std::vector<pappso::MsRunIdCstSPtr> msrunid_list = file_access.
getMsRunIds();
168 if(msrunid_list.size() == 0)
175 run_reader.get()->setMonoThread(
true);
177 run_reader.get()->releaseDevice();
178 run_reader.get()->setMonoThread(
false);
179 return std::make_shared<pappso::masschroq::MsRunPeptideList>(msrun);
184 m_uiMonitor.appendText(QObject::tr(
"reading %1 msruns").arg(msfilepathlist.size()));
188 std::map<QString, pappso::masschroq::MsRunPeptideListSp> *p_localPtrOnmsrunpeptidelist =
192 [local_monitor, p_localPtrOnmsrunpeptidelist](
194 local_monitor->
setStatus(QObject::tr(
"MS run '%1' from file %2: added ")
198 ->getMsRunReaderSPtr()
206 ->getMsRunReaderSPtr()
212 p_localPtrOnmsrunpeptidelist->insert({msrun.get()
215 ->getMsRunReaderSPtr()
224 QFuture<std::size_t> res = QtConcurrent::mappedReduced<std::size_t>(msfilepathlist.begin(),
225 msfilepathlist.end(),
228 QtConcurrent::OrderedReduce);
229 res.waitForFinished();
232 if(
m_msfileList.begin()->second.get()->getMsRunSp().get()->hasTimsTofMobilityIndex())
234 m_uiMonitor.appendText(
"ion mobility grid enabled");
245 documentFind(
"masschroq_methods",
"alignment_method").toObject());
255 documentFind(
"masschroq_methods",
"quantification_method").toObject());
277 const QJsonObject protein_list(
documentFind(
"identification_data",
"protein_list").toObject());
281 auto it = protein_list.begin();
282 while(it != protein_list.end())
284 qDebug() << it.key();
285 qDebug() << it.value().toObject().value(
"description");
291 p_protein = std::make_shared<pappso::masschroq::Protein>(
292 it.key(), it.value().toObject().value(
"description").toString());
297 QObject::tr(
"problem creating protein :\n%1").arg(it.key()));
310 const QJsonObject peptide_list(
documentFind(
"identification_data",
"peptide_list").toObject());
314 auto it = peptide_list.begin();
315 while(it != peptide_list.end())
317 qDebug() << it.key();
318 qDebug() << it.value().toObject().value(
"proforma");
325 std::vector<pappso::masschroq::ProteinSp> protein_list;
326 for(
auto prot_id : it.value().toObject().value(
"proteins").toArray())
331 protein_list.push_back(it->second);
336 QObject::tr(
"protein id %1 not found").arg(prot_id.toString()));
341 peptide_sp = std::make_shared<pappso::masschroq::Peptide>(
344 it.value().toObject().value(
"proforma").toString()),
347 peptide_sp.get()->
setMods(it.value().toObject().value(
"mods").toString());
351 QJsonObject json_label_list = it.value().toObject().value(
"label_list").toObject();
354 if(!json_label_list.isEmpty())
364 QObject::tr(
"problem creating protein :\n%1").arg(it.key()));
376 const QJsonObject msrunpeptide_list(
377 documentFind(
"identification_data",
"msrunpeptide_list").toObject());
378 auto it = msrunpeptide_list.begin();
379 while(it != msrunpeptide_list.end())
381 qDebug() << it.key();
382 QJsonObject jmsrun_peptidelist_object = it.value().toObject();
383 auto it_peptide_obs = jmsrun_peptidelist_object.find(
"peptide_obs");
384 if(it_peptide_obs == jmsrun_peptidelist_object.end())
387 QObject::tr(
"peptide_obs not found in msrunpeptide_list %1").arg(it.key()));
389 QJsonObject json_msrunobs = it_peptide_obs->toObject();
397 auto itpep = json_msrunobs.begin();
398 while(itpep != json_msrunobs.end())
400 qDebug() << itpep.key();
401 QJsonArray json_obs_list = itpep.value().toArray();
408 qDebug() <<
"json_obs_list.size()=" << json_obs_list.size();
409 for(
auto json_obs_value : json_obs_list)
411 QJsonObject observation = json_obs_value.toObject();
412 qint64 scan = observation.value(
"scan").toInteger();
413 qint64 index = observation.value(
"index").toInteger();
414 QString label = observation.value(
"label").toString();
415 std::uint8_t charge =
416 observation.value(
"precursor").toObject().value(
"charge").toInt();
427 peptide_sp, p_label, index, charge);
433 peptide_sp, p_label, scan, charge);
442 QObject::tr(
"error reading peptide %1 observation scan %2 "
454 if(peptide_sp.get() !=
nullptr)
472 if(ni_min_abundance > 0)
480 peptide_sp.get()->computeIsotopologues(ni_min_abundance);
484 QFuture<void> res = QtConcurrent::map<std::vector<pappso::masschroq::PeptideSp>::iterator>(
486 m_uiMonitor.appendText(QObject::tr(
"Computing isotopologues %1").arg(ni_min_abundance));
487 res.waitForFinished();
489 m_uiMonitor.appendText(
"Computing isotopologues OK");
497 const QJsonObject group_list(
documentFind(
"actions",
"group_list").toObject());
499 auto it_group = group_list.begin();
500 while(it_group != group_list.end())
502 QString
id = it_group.key();
503 QJsonArray json_msrun_list = it_group.value().toArray();
504 std::vector<pappso::masschroq::MsRunPeptideListSp> msrun_list;
505 for(
auto json_msrun : json_msrun_list)
508 auto it_msrun =
m_msfileList.find(json_msrun.toString());
512 QObject::tr(
"msrun %1 not found").arg(json_msrun.toString()));
514 msrun_list.push_back(it_msrun->second);
522 QJsonObject align_list;
525 align_list =
documentFind(
"actions",
"align_group").toObject();
530 if(!align_list.isEmpty())
535 std::size_t count_q = 1;
536 QStringList group_keys = align_list.keys();
537 for(
auto group_id : group_keys)
547 align_list.value(group_id).toObject().value(
"alignment_reference").toString();
548 if(!ref_id.isEmpty())
553 itgroup->second.get()->align(cbor_output, QString(
"a%1").arg(count_q),
m_uiMonitor);
560 QVariant quantify_all;
563 quantify_all =
documentFind(
"actions",
"quantify_all").toVariant();
568 if(!quantify_all.isNull())
570 if(quantify_all.toBool())
574 std::size_t count_q = 1;
580 pair_group.second.get()->quantify(cbor_output,
581 QString(
"q%1").arg(count_q),
598 QJsonObject params =
m_jsonDocument.object().value(
"project_parameters").toObject();
excetion to use when an item type is not recognized
void setPreferredFileReaderType(Enums::MsDataFormat format, Enums::FileReaderType reader_type)
given an mz format, explicitly set the preferred reader
Enums::MsDataFormat getFileFormat() const
get the raw format of mz data
std::vector< MsRunIdCstSPtr > getMsRunIds()
MsRunReaderSPtr getMsRunReaderSPtrByRunId(const QString &run_id, const QString &xml_id)
get an msrun reader by finding the run_id in file
virtual const QString & qwhat() const
virtual void setStatus(const QString &status)=0
current status of the process
void writeJsonObject(const QString &name, const QJsonObject &json_object)
void writeProjectParameters(const pappso::ProjectParameters &project_parameters)
QCborStreamWriter & getCborStreamWriter()
void writeActionBegin(const QString &operation)
const MsRunSp & getMsRunSp() const
void addPeptideScanNumberObservation(PeptideSp peptide_sp, PeptideLabel *p_label, std::size_t spectrum_index, std::uint8_t charge)
void addPeptideSpectrumIndexObservation(PeptideSp peptide_sp, PeptideLabel *p_label, std::size_t spectrum_index, std::uint8_t charge)
void addObservedChargeState(std::uint8_t charge)
void populateIonMobilityGrid(pappso::IonMobilityGrid *ion_mobility_grid_p) const
Populate ion mobility grid with observed XIC coordinates for this peptide on all MSruns The ion mobil...
void setJsonLabelList(const QJsonObject &json_label_list)
build peptide label map from JSON label_list object
void setMods(const QString &mods)
set optional information as text to this peptide
PeptideLabel * getPeptideLabelPtr(const QString &label) const
get a peptide label pointer with the corresponding label identifier
const QString & getId() const
get peptide unique identifier
void addObservedInMsRunSp(const MsRunSp &msrun_sp)
const QString & getId() const
static QString getVersion()
std::shared_ptr< Protein > ProteinSp
std::shared_ptr< MsRunPeptideList > MsRunPeptideListSp
std::shared_ptr< Peptide > PeptideSp
std::shared_ptr< MsRun > MsRunSp
std::shared_ptr< MsRunReader > MsRunReaderSPtr
@ quantification
quantification