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();
231 if(
m_msfileList.begin()->second.get()->getMsRunSp().get()->hasTimsTofMobilityIndex())
233 m_uiMonitor.appendText(
"ion mobility grid enabled");
244 documentFind(
"masschroq_methods",
"alignment_method").toObject());
254 documentFind(
"masschroq_methods",
"quantification_method").toObject());
276 const QJsonObject protein_list(
documentFind(
"identification_data",
"protein_list").toObject());
280 auto it = protein_list.begin();
281 while(it != protein_list.end())
283 qDebug() << it.key();
284 qDebug() << it.value().toObject().value(
"description");
290 p_protein = std::make_shared<pappso::masschroq::Protein>(
291 it.key(), it.value().toObject().value(
"description").toString());
296 QObject::tr(
"problem creating protein :\n%1").arg(it.key()));
309 const QJsonObject peptide_list(
documentFind(
"identification_data",
"peptide_list").toObject());
313 auto it = peptide_list.begin();
314 while(it != peptide_list.end())
316 qDebug() << it.key();
317 qDebug() << it.value().toObject().value(
"proforma");
324 std::vector<pappso::masschroq::ProteinSp> protein_list;
325 for(
auto prot_id : it.value().toObject().value(
"proteins").toArray())
330 protein_list.push_back(it->second);
335 QObject::tr(
"protein id %1 not found").arg(prot_id.toString()));
340 peptide_sp = std::make_shared<pappso::masschroq::Peptide>(
343 it.value().toObject().value(
"proforma").toString()),
346 peptide_sp.get()->
setMods(it.value().toObject().value(
"mods").toString());
350 QJsonObject json_label_list = it.value().toObject().value(
"label_list").toObject();
353 if(!json_label_list.isEmpty())
363 QObject::tr(
"problem creating protein :\n%1").arg(it.key()));
375 const QJsonObject msrunpeptide_list(
376 documentFind(
"identification_data",
"msrunpeptide_list").toObject());
377 auto it = msrunpeptide_list.begin();
378 while(it != msrunpeptide_list.end())
380 qDebug() << it.key();
381 QJsonObject jmsrun_peptidelist_object = it.value().toObject();
382 auto it_peptide_obs = jmsrun_peptidelist_object.find(
"peptide_obs");
383 if(it_peptide_obs == jmsrun_peptidelist_object.end())
386 QObject::tr(
"peptide_obs not found in msrunpeptide_list %1").arg(it.key()));
388 QJsonObject json_msrunobs = it_peptide_obs->toObject();
396 auto itpep = json_msrunobs.begin();
397 while(itpep != json_msrunobs.end())
399 qDebug() << itpep.key();
400 QJsonArray json_obs_list = itpep.value().toArray();
407 qDebug() <<
"json_obs_list.size()=" << json_obs_list.size();
408 for(
auto json_obs_value : json_obs_list)
410 QJsonObject observation = json_obs_value.toObject();
411 qint64 scan = observation.value(
"scan").toInteger();
412 qint64 index = observation.value(
"index").toInteger();
413 QString label = observation.value(
"label").toString();
414 std::uint8_t charge =
415 observation.value(
"precursor").toObject().value(
"charge").toInt();
426 peptide_sp, p_label, index, charge);
432 peptide_sp, p_label, scan, charge);
441 QObject::tr(
"error reading peptide %1 observation scan %2 "
453 if(peptide_sp.get() !=
nullptr)
471 if(ni_min_abundance > 0)
479 peptide_sp.get()->computeIsotopologues(ni_min_abundance);
483 QFuture<void> res = QtConcurrent::map<std::vector<pappso::masschroq::PeptideSp>::iterator>(
485 m_uiMonitor.appendText(QObject::tr(
"Computing isotopologues %1").arg(ni_min_abundance));
486 res.waitForFinished();
488 m_uiMonitor.appendText(
"Computing isotopologues OK");
496 const QJsonObject group_list(
documentFind(
"actions",
"group_list").toObject());
498 auto it_group = group_list.begin();
499 while(it_group != group_list.end())
501 QString
id = it_group.key();
502 QJsonArray json_msrun_list = it_group.value().toArray();
503 std::vector<pappso::masschroq::MsRunPeptideListSp> msrun_list;
504 for(
auto json_msrun : json_msrun_list)
507 auto it_msrun =
m_msfileList.find(json_msrun.toString());
511 QObject::tr(
"msrun %1 not found").arg(json_msrun.toString()));
513 msrun_list.push_back(it_msrun->second);
521 QJsonObject align_list;
524 align_list =
documentFind(
"actions",
"align_group").toObject();
529 if(!align_list.isEmpty())
534 std::size_t count_q = 1;
535 QStringList group_keys = align_list.keys();
536 for(
auto group_id : group_keys)
546 align_list.value(group_id).toObject().value(
"alignment_reference").toString();
547 if(!ref_id.isEmpty())
552 itgroup->second.get()->align(cbor_output, QString(
"a%1").arg(count_q),
m_uiMonitor);
559 QVariant quantify_all;
562 quantify_all =
documentFind(
"actions",
"quantify_all").toVariant();
567 if(!quantify_all.isNull())
569 if(quantify_all.toBool())
573 std::size_t count_q = 1;
579 pair_group.second.get()->quantify(cbor_output,
580 QString(
"q%1").arg(count_q),
597 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