37#include <QtConcurrent>
41 const QString &tmp_dir_name,
42 const QJsonDocument &json_doc)
71 param.
name =
"mcq_version";
82 QJsonObject methods =
m_jsonDocument.object().value(
"masschroq_methods").toObject();
87 QJsonObject msrun_list =
documentFind(
"identification_data",
"msrun_list").toObject();
89 QJsonObject protein_list =
documentFind(
"identification_data",
"protein_list").toObject();
91 QJsonObject peptide_list =
documentFind(
"identification_data",
"peptide_list").toObject();
93 QJsonObject msrunpeptide_list =
94 documentFind(
"identification_data",
"msrunpeptide_list").toObject();
102 QJsonObject actions =
m_jsonDocument.object().value(
"actions").toObject();
112 auto it1 = obj1.find(key1);
113 if(it1 != obj1.end())
115 QJsonObject obj2 = it1.value().toObject();
116 auto it2 = obj2.find(key2);
117 if(it2 != obj2.end())
124 QObject::tr(
"key2 %1 not found in json document element %2").arg(key2).arg(key1));
138 std::map<QString, QString> msfilepathlist;
139 const QJsonObject msrun_list(
documentFind(
"identification_data",
"msrun_list").toObject());
140 auto it = msrun_list.begin();
141 while(it != msrun_list.end())
143 qDebug() << it.key();
144 qDebug() << it.value().toObject().value(
"file");
147 msfilepathlist.insert({it.key(), it.value().toObject().value(
"file").toString()});
154 mapFilenameList = [](
const std::pair<QString, QString> &mapit) {
159 std::vector<pappso::MsRunIdCstSPtr> msrunid_list = file_access.
getMsRunIds();
166 if(msrunid_list.size() == 0)
173 run_reader.get()->setMonoThread(
true);
175 run_reader.get()->releaseDevice();
176 run_reader.get()->setMonoThread(
false);
177 return std::make_shared<pappso::masschroq::MsRunPeptideList>(msrun);
182 m_uiMonitor.appendText(QObject::tr(
"reading %1 msruns").arg(msfilepathlist.size()));
186 std::map<QString, pappso::masschroq::MsRunPeptideListSp> *p_localPtrOnmsrunpeptidelist =
190 [local_monitor, p_localPtrOnmsrunpeptidelist](
192 local_monitor->
setStatus(QObject::tr(
"MS run '%1' from file %2: added ")
196 ->getMsRunReaderSPtr()
204 ->getMsRunReaderSPtr()
210 p_localPtrOnmsrunpeptidelist->insert({msrun.get()
213 ->getMsRunReaderSPtr()
222 QFuture<std::size_t> res = QtConcurrent::mappedReduced<std::size_t>(msfilepathlist.begin(),
223 msfilepathlist.end(),
226 QtConcurrent::OrderedReduce);
227 res.waitForFinished();
230 if(
m_msfileList.begin()->second.get()->getMsRunSp().get()->hasTimsTofMobilityIndex())
232 m_uiMonitor.appendText(
"ion mobility grid enabled");
243 documentFind(
"masschroq_methods",
"alignment_method").toObject());
253 documentFind(
"masschroq_methods",
"quantification_method").toObject());
275 const QJsonObject protein_list(
documentFind(
"identification_data",
"protein_list").toObject());
279 auto it = protein_list.begin();
280 while(it != protein_list.end())
282 qDebug() << it.key();
283 qDebug() << it.value().toObject().value(
"description");
289 p_protein = std::make_shared<pappso::masschroq::Protein>(
290 it.key(), it.value().toObject().value(
"description").toString());
295 QObject::tr(
"problem creating protein :\n%1").arg(it.key()));
308 const QJsonObject peptide_list(
documentFind(
"identification_data",
"peptide_list").toObject());
312 auto it = peptide_list.begin();
313 while(it != peptide_list.end())
315 qDebug() << it.key();
316 qDebug() << it.value().toObject().value(
"proforma");
323 std::vector<pappso::masschroq::ProteinSp> protein_list;
324 for(
auto prot_id : it.value().toObject().value(
"proteins").toArray())
329 protein_list.push_back(it->second);
334 QObject::tr(
"protein id %1 not found").arg(prot_id.toString()));
339 peptide_sp = std::make_shared<pappso::masschroq::Peptide>(
342 it.value().toObject().value(
"proforma").toString()),
345 peptide_sp.get()->
setMods(it.value().toObject().value(
"mods").toString());
349 QJsonObject json_label_list = it.value().toObject().value(
"label_list").toObject();
352 if(!json_label_list.isEmpty())
362 QObject::tr(
"problem creating protein :\n%1").arg(it.key()));
374 const QJsonObject msrunpeptide_list(
375 documentFind(
"identification_data",
"msrunpeptide_list").toObject());
376 auto it = msrunpeptide_list.begin();
377 while(it != msrunpeptide_list.end())
379 qDebug() << it.key();
380 QJsonObject jmsrun_peptidelist_object = it.value().toObject();
381 auto it_peptide_obs = jmsrun_peptidelist_object.find(
"peptide_obs");
382 if(it_peptide_obs == jmsrun_peptidelist_object.end())
385 QObject::tr(
"peptide_obs not found in msrunpeptide_list %1").arg(it.key()));
387 QJsonObject json_msrunobs = it_peptide_obs->toObject();
395 auto itpep = json_msrunobs.begin();
396 while(itpep != json_msrunobs.end())
398 qDebug() << itpep.key();
399 QJsonArray json_obs_list = itpep.value().toArray();
406 qDebug() <<
"json_obs_list.size()=" << json_obs_list.size();
407 for(
auto json_obs_value : json_obs_list)
409 QJsonObject observation = json_obs_value.toObject();
410 qint64 scan = observation.value(
"scan").toInteger();
411 qint64 index = observation.value(
"index").toInteger();
412 QString label = observation.value(
"label").toString();
413 std::uint8_t charge =
414 observation.value(
"precursor").toObject().value(
"charge").toInt();
425 peptide_sp, p_label, index, charge);
431 peptide_sp, p_label, scan, charge);
440 QObject::tr(
"error reading peptide %1 observation scan %2 "
452 if(peptide_sp.get() !=
nullptr)
470 if(ni_min_abundance > 0)
478 peptide_sp.get()->computeIsotopologues(ni_min_abundance);
482 QFuture<void> res = QtConcurrent::map<std::vector<pappso::masschroq::PeptideSp>::iterator>(
484 m_uiMonitor.appendText(QObject::tr(
"Computing isotopologues %1").arg(ni_min_abundance));
485 res.waitForFinished();
487 m_uiMonitor.appendText(
"Computing isotopologues OK");
495 const QJsonObject group_list(
documentFind(
"actions",
"group_list").toObject());
497 auto it_group = group_list.begin();
498 while(it_group != group_list.end())
500 QString
id = it_group.key();
501 QJsonArray json_msrun_list = it_group.value().toArray();
502 std::vector<pappso::masschroq::MsRunPeptideListSp> msrun_list;
503 for(
auto json_msrun : json_msrun_list)
506 auto it_msrun =
m_msfileList.find(json_msrun.toString());
510 QObject::tr(
"msrun %1 not found").arg(json_msrun.toString()));
512 msrun_list.push_back(it_msrun->second);
520 QJsonObject align_list;
523 align_list =
documentFind(
"actions",
"align_group").toObject();
528 if(!align_list.isEmpty())
533 std::size_t count_q = 1;
534 QStringList group_keys = align_list.keys();
535 for(
auto group_id : group_keys)
545 align_list.value(group_id).toObject().value(
"alignment_reference").toString();
546 if(!ref_id.isEmpty())
551 itgroup->second.get()->align(cbor_output, QString(
"a%1").arg(count_q),
m_uiMonitor);
558 QVariant quantify_all;
561 quantify_all =
documentFind(
"actions",
"quantify_all").toVariant();
566 if(!quantify_all.isNull())
568 if(quantify_all.toBool())
572 std::size_t count_q = 1;
578 pair_group.second.get()->quantify(cbor_output,
579 QString(
"q%1").arg(count_q),
596 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