37#include <qregularexpression.h>
90 QString tag = cell.getStringValue();
95 else if(tag ==
"peptide")
99 else if(tag ==
"proteins")
103 else if(tag ==
"protein_groups")
107 else if(tag ==
"num_protein_groups")
111 else if(tag ==
"num_proteins")
115 else if(tag ==
"filename")
119 else if(tag ==
"scannr")
123 else if(tag ==
"rank")
127 else if(tag ==
"label")
131 else if(tag ==
"expmass")
136 else if(tag ==
"calcmass")
140 else if(tag ==
"charge")
144 else if(tag ==
"peptide_len")
148 else if(tag ==
"missed_cleavages")
152 else if(tag ==
"semi_enzymatic")
156 else if(tag ==
"isotope_error")
160 else if(tag ==
"precursor_ppm")
164 else if(tag ==
"fragment_ppm")
168 else if(tag ==
"hyperscore")
172 else if(tag ==
"delta_next")
176 else if(tag ==
"delta_best")
184 else if(tag ==
"aligned_rt")
188 else if(tag ==
"predicted_rt")
192 else if(tag ==
"delta_rt_model")
196 else if(tag ==
"ion_mobility")
200 else if(tag ==
"predicted_mobility")
204 else if(tag ==
"delta_mobility")
208 else if(tag ==
"matched_peaks")
212 else if(tag ==
"longest_b")
216 else if(tag ==
"longest_y")
220 else if(tag ==
"longest_y_pct")
224 else if(tag ==
"matched_intensity_pct")
228 else if(tag ==
"scored_candidates")
232 else if(tag ==
"poisson")
236 else if(tag ==
"sage_discriminant_score")
240 else if(tag ==
"posterior_error")
244 else if(tag ==
"spectrum_q")
248 else if(tag ==
"peptide_q")
252 else if(tag ==
"protein_q")
256 else if(tag ==
"protein_group_q")
260 else if(tag ==
"ms2_intensity")
274 QObject::tr(
"the value %1 is out of range").arg(cell.getStringValue()));
294 if((std::size_t)cell.getDoubleValue() != (std::size_t)
m_proteinList.size())
297 QObject::tr(
"column \"num_proteins\"!=%1").arg(
m_proteinList.size()));
307 m_line.rank = cell.getDoubleValue();
310 m_line.label = cell.getDoubleValue();
313 m_line.expmass = cell.getDoubleValue();
316 m_line.calcmass = cell.getDoubleValue();
319 m_line.charge = cell.getDoubleValue();
322 m_line.peptide_len = cell.getDoubleValue();
325 m_line.missed_cleavages = cell.getDoubleValue();
328 m_line.semi_enzymatic = cell.getDoubleValue();
331 m_line.isotope_error = cell.getDoubleValue();
335 m_line.precursor_ppm = cell.getDoubleValue();
338 m_line.fragment_ppm = cell.getDoubleValue();
341 m_line.hyperscore = cell.getDoubleValue();
344 m_line.delta_next = cell.getDoubleValue();
347 m_line.delta_best = cell.getDoubleValue();
350 m_line.rt = cell.getDoubleValue() * 60;
353 m_line.aligned_rt = cell.getDoubleValue();
356 m_line.predicted_rt = cell.getDoubleValue();
359 m_line.delta_rt_model = cell.getDoubleValue();
362 m_line.ion_mobility = cell.getDoubleValue();
365 m_line.predicted_mobility = cell.getDoubleValue();
368 m_line.delta_mobility = cell.getDoubleValue();
371 m_line.matched_peaks = cell.getDoubleValue();
374 m_line.longest_b = cell.getDoubleValue();
377 m_line.longest_y = cell.getDoubleValue();
380 m_line.longest_y_pct = cell.getDoubleValue();
383 m_line.matched_intensity_pct = cell.getDoubleValue();
386 m_line.scored_candidates = cell.getDoubleValue();
389 m_line.poisson = cell.getDoubleValue();
392 m_line.sage_discriminant_score = cell.getDoubleValue();
395 m_line.posterior_error = cell.getDoubleValue();
398 m_line.spectrum_q = cell.getDoubleValue();
401 m_line.peptide_q = cell.getDoubleValue();
404 m_line.protein_q = cell.getDoubleValue();
407 m_line.ms2_intensity = cell.getDoubleValue();
410 qDebug() <<
"m_line.calcmass=" <<
m_line.calcmass;
412 QObject::tr(
"column type %1 not implemented").arg((std::uint8_t)column_type));
449 mp_monitor->setStatus(QObject::tr(
"reading Sage TSV file"));
461 QString peptide_str_verif = peptide_str;
465 qDebug() << modif.strModification;
466 qDebug() << modif.modification->getAccession();
467 peptide_str_verif = peptide_str_verif.replace(
468 modif.strModification, QString(
"[%1]").arg(modif.modification->getAccession()));
473 qDebug() << modif.strModification;
474 qDebug() << modif.modification->getAccession();
475 peptide_str_verif = peptide_str_verif.replace(
476 modif.strModification, QString(
"[%1]").arg(modif.modification->getAccession()));
479 qDebug() << peptide_str_verif;
501 psm_protein.
protein_sp = std::make_shared<pappso::Protein>(accession,
"");
516 qDebug() << spectrum_string_id;
524 std::size_t precursor_number = spectrum_string_id.toULongLong(&is_ok);
531 .arg(precursor_number + 1)
532 .arg(precursor_number * 2 + 1);
538 QStringList scan_list = spectrum_string_id.split(
"scan=");
539 if(scan_list.size() == 2)
550 QStringList scan_list = spectrum_string_id.split(QRegularExpression(
"[^\\d]"));
551 if(scan_list.size() == 2)
578 qDebug() << spectrum_string_id;
588 auto it_insert =
m_sampleMap.insert({msrun_filename, {}});
593 it_insert.first->second.name = msrun_filename;
595 QCborMap identification_file;
597 it_insert.first->second.cbor_core_sample.insert(QString(
"name"),
598 QFileInfo(msrun_filename).baseName());
601 QCborArray identification_file_list;
602 identification_file.insert(QString(
"name"),
m_sageReader.getmJsonAbsoluteFilePath());
603 identification_file_list.push_back(identification_file);
604 it_insert.first->second.cbor_core_sample.insert(QString(
"identification_file_list"),
605 identification_file_list);
608 ms_file.insert(QString(
"name"),
m_sageReader.getMzmlPath(msrun_filename));
609 it_insert.first->second.cbor_core_sample.insert(QString(
"peaklist_file"), ms_file);
633 psm_protein.
protein_sp = std::make_shared<pappso::Protein>(accession,
"");
636 it.first->second.cborEval.insert(QString(
"protein_q"),
m_line.protein_q);
665 Scan *current_cbor_scan_p = &(it_insert.first->second);
669 QCborMap &scan_id = it_insert.first->second.cbor_id;
678 QCborMap &scan_ms2 = it_insert.first->second.cbor_ms2;
679 scan_ms2.insert(QString(
"rt"),
m_line.rt);
681 QCborMap &scan_precursor = it_insert.first->second.cbor_precursor;
682 scan_precursor.insert(QString(
"z"),
m_line.charge);
684 scan_precursor.insert(QString(
"mh"), mh);
686 scan_precursor.insert(QString(
"mz"), exp_mz);
698 one_psm.
cbor_eval.insert(QString(
"delta_mobility"),
m_line.delta_mobility);
700 one_psm.
cbor_eval.insert(QString(
"delta_rt_model"),
m_line.delta_rt_model);
701 one_psm.
cbor_eval.insert(QString(
"fragment_ppm"),
m_line.fragment_ppm);
703 one_psm.
cbor_eval.insert(QString(
"ion_mobility"),
m_line.ion_mobility);
704 one_psm.
cbor_eval.insert(QString(
"isotope_error"),
m_line.isotope_error);
706 one_psm.
cbor_eval.insert(QString(
"longest_b"), (qint64)
m_line.longest_b);
707 one_psm.
cbor_eval.insert(QString(
"longest_y"), (qint64)
m_line.longest_y);
708 one_psm.
cbor_eval.insert(QString(
"longest_y_pct"),
m_line.longest_y_pct);
709 one_psm.
cbor_eval.insert(QString(
"matched_intensity_pct"),
m_line.matched_intensity_pct);
710 one_psm.
cbor_eval.insert(QString(
"matched_peaks"), (qint64)
m_line.matched_peaks);
711 one_psm.
cbor_eval.insert(QString(
"missed_cleavages"),
m_line.missed_cleavages);
712 one_psm.
cbor_eval.insert(QString(
"ms2_intensity"),
m_line.ms2_intensity);
713 one_psm.
cbor_eval.insert(QString(
"peptide_len"), (qint64)
m_line.peptide_len);
716 one_psm.
cbor_eval.insert(QString(
"posterior_error"),
m_line.posterior_error);
717 one_psm.
cbor_eval.insert(QString(
"precursor_ppm"),
m_line.precursor_ppm);
718 one_psm.
cbor_eval.insert(QString(
"predicted_mobility"),
m_line.predicted_mobility);
719 one_psm.
cbor_eval.insert(QString(
"predicted_rt"),
m_line.predicted_rt);
722 one_psm.
cbor_eval.insert(QString(
"sage_discriminant_score"),
m_line.sage_discriminant_score);
723 one_psm.
cbor_eval.insert(QString(
"scored_candidates"), (qint64)
m_line.scored_candidates);
724 one_psm.
cbor_eval.insert(QString(
"semi_enzymatic"),
m_line.semi_enzymatic);
727 current_cbor_scan_p->
psm_list.emplace_back(one_psm);
736 QObject::tr(
"Sage TSV data reading process interrupted"));
750 m_sageReader.getCborStreamWriter().append(
"identification_file_list");
755 m_sageReader.getCborStreamWriter().append(
"peaklist_file");
761 for(
auto &it_scan : one_sample.
scan_map)
784 for(
auto &it_psm : one_scan.
psm_list)
799 m_sageReader.getCborStreamWriter().append(
"protein_list");
801 QCborArray cbor_protein_list;
805 QCborMap cbor_protein;
806 cbor_protein.insert(QString(
"accession"), accession);
810 QString protein_sequence =
811 QString(
m_psmProteinMap.getByAccession(accession).protein_sp.get()->getSequence())
815 QCborArray positions;
818 positions.push_back(position);
822 cbor_protein.insert(QString(
"positions"), positions);
824 cbor_protein_list.append(cbor_protein);
828 QCborValue(cbor_protein_list).toCbor(
m_sageReader.getCborStreamWriter());
store PsmProtein in a map with accession as key
std::vector< SageModification > getStaticModificationList() const
std::vector< SageModification > getVariableModificationList() const
QString getDecoyTag() const
std::vector< SageReader::SageModification > m_staticModificationList
QStringList m_proteinList
void parseProteins(const QString &proteins_str)
@ sage_discriminant_score
QString m_spectrumNativeId
const SageReader & m_sageReader
virtual void endSheet() override
pappso::UiMonitorInterface * mp_monitor
virtual void startSheet(const QString &sheet_name) override
std::vector< SageReader::SageModification > m_variableModificationList
virtual ~SageTsvHandler()
void parsePeptide(const QString &peptide_str)
void writeSample(const Sample &one_sample)
std::size_t m_progressIndex
virtual void setCell(const OdsCell &cell) override
void writePsm(const Psm &one_psm)
SageTsvHandler(pappso::UiMonitorInterface *p_monitor, const SageReader &sage_reader, PsmProteinMap &psm_protein_map)
void writeScan(const Scan &one_scan)
std::size_t m_columnNumber
std::size_t m_spectrumIndex
std::map< QString, Sample > m_sampleMap
virtual void endDocument() override
virtual void startLine() override
Sample * mp_currentSample
void parseMsRunFilename(const QString &msrun_filename)
bool parseScanNrColumn(const QString &spectrum_string_id)
virtual void endLine() override
pappso::PeptideSp msp_peptide
std::vector< Columns > m_columnTypeList
PsmProteinMap & m_psmProteinMap
tries to keep as much as possible monoisotopes, removing any possible C13 peaks and changes multichar...
const pappso_double MHPLUS(1.007276466879)
std::shared_ptr< Protein > protein_sp
QString peptide_sequence_li
QCborMap cbor_core_sample
std::map< QString, Scan > scan_map
std::vector< Psm > psm_list