38#include <qregularexpression.h>
91 QString tag = cell.getStringValue();
96 else if(tag ==
"peptide")
100 else if(tag ==
"proteins")
104 else if(tag ==
"protein_groups")
108 else if(tag ==
"num_protein_groups")
112 else if(tag ==
"num_proteins")
116 else if(tag ==
"filename")
120 else if(tag ==
"scannr")
124 else if(tag ==
"rank")
128 else if(tag ==
"label")
132 else if(tag ==
"expmass")
137 else if(tag ==
"calcmass")
141 else if(tag ==
"charge")
145 else if(tag ==
"peptide_len")
149 else if(tag ==
"missed_cleavages")
153 else if(tag ==
"semi_enzymatic")
157 else if(tag ==
"isotope_error")
161 else if(tag ==
"precursor_ppm")
165 else if(tag ==
"fragment_ppm")
169 else if(tag ==
"hyperscore")
173 else if(tag ==
"delta_next")
177 else if(tag ==
"delta_best")
185 else if(tag ==
"aligned_rt")
189 else if(tag ==
"predicted_rt")
193 else if(tag ==
"delta_rt_model")
197 else if(tag ==
"ion_mobility")
201 else if(tag ==
"predicted_mobility")
205 else if(tag ==
"delta_mobility")
209 else if(tag ==
"matched_peaks")
213 else if(tag ==
"longest_b")
217 else if(tag ==
"longest_y")
221 else if(tag ==
"longest_y_pct")
225 else if(tag ==
"matched_intensity_pct")
229 else if(tag ==
"scored_candidates")
233 else if(tag ==
"poisson")
237 else if(tag ==
"sage_discriminant_score")
241 else if(tag ==
"posterior_error")
245 else if(tag ==
"spectrum_q")
249 else if(tag ==
"peptide_q")
253 else if(tag ==
"protein_q")
257 else if(tag ==
"protein_group_q")
261 else if(tag ==
"ms2_intensity")
275 QObject::tr(
"the value %1 is out of range").arg(cell.getStringValue()));
295 if((std::size_t)cell.getDoubleValue() != (std::size_t)
m_proteinList.size())
298 QObject::tr(
"column \"num_proteins\"!=%1").arg(
m_proteinList.size()));
308 m_line.rank = cell.getDoubleValue();
311 m_line.label = cell.getDoubleValue();
314 m_line.expmass = cell.getDoubleValue();
317 m_line.calcmass = cell.getDoubleValue();
320 m_line.charge = cell.getDoubleValue();
323 m_line.peptide_len = cell.getDoubleValue();
326 m_line.missed_cleavages = cell.getDoubleValue();
329 m_line.semi_enzymatic = cell.getDoubleValue();
332 m_line.isotope_error = cell.getDoubleValue();
336 m_line.precursor_ppm = cell.getDoubleValue();
339 m_line.fragment_ppm = cell.getDoubleValue();
342 m_line.hyperscore = cell.getDoubleValue();
345 m_line.delta_next = cell.getDoubleValue();
348 m_line.delta_best = cell.getDoubleValue();
351 m_line.rt = cell.getDoubleValue() * 60;
354 m_line.aligned_rt = cell.getDoubleValue();
357 m_line.predicted_rt = cell.getDoubleValue();
360 m_line.delta_rt_model = cell.getDoubleValue();
363 m_line.ion_mobility = cell.getDoubleValue();
366 m_line.predicted_mobility = cell.getDoubleValue();
369 m_line.delta_mobility = cell.getDoubleValue();
372 m_line.matched_peaks = cell.getDoubleValue();
375 m_line.longest_b = cell.getDoubleValue();
378 m_line.longest_y = cell.getDoubleValue();
381 m_line.longest_y_pct = cell.getDoubleValue();
384 m_line.matched_intensity_pct = cell.getDoubleValue();
387 m_line.scored_candidates = cell.getDoubleValue();
390 m_line.poisson = cell.getDoubleValue();
393 m_line.sage_discriminant_score = cell.getDoubleValue();
396 m_line.posterior_error = cell.getDoubleValue();
399 m_line.spectrum_q = cell.getDoubleValue();
402 m_line.peptide_q = cell.getDoubleValue();
405 m_line.protein_q = cell.getDoubleValue();
408 m_line.ms2_intensity = cell.getDoubleValue();
411 qDebug() <<
"m_line.calcmass=" <<
m_line.calcmass;
413 QObject::tr(
"column type %1 not implemented").arg((std::uint8_t)column_type));
450 mp_monitor->setStatus(QObject::tr(
"reading Sage TSV file"));
462 QString peptide_str_verif = peptide_str;
466 qDebug() << modif.strModification;
467 qDebug() << modif.modification->getAccession();
468 peptide_str_verif = peptide_str_verif.replace(
469 modif.strModification, QString(
"[%1]").arg(modif.modification->getAccession()));
474 qDebug() << modif.strModification;
475 qDebug() << modif.modification->getAccession();
476 peptide_str_verif = peptide_str_verif.replace(
477 modif.strModification, QString(
"[%1]").arg(modif.modification->getAccession()));
480 qDebug() << peptide_str_verif;
502 psm_protein.
protein_sp = std::make_shared<pappso::Protein>(accession,
"");
517 qDebug() << spectrum_string_id;
525 std::size_t precursor_number = spectrum_string_id.toULongLong(&is_ok);
532 .arg(precursor_number + 1)
533 .arg(precursor_number * 2 + 1);
539 QStringList scan_list = spectrum_string_id.split(
"scan=");
540 if(scan_list.size() == 2)
551 QStringList scan_list = spectrum_string_id.split(QRegularExpression(
"[^\\d]"));
552 if(scan_list.size() == 2)
579 qDebug() << spectrum_string_id;
589 auto it_insert =
m_sampleMap.insert({msrun_filename, {}});
594 it_insert.first->second.name = msrun_filename;
596 QCborMap identification_file;
598 it_insert.first->second.cbor_core_sample.insert(QString(
"name"),
599 QFileInfo(msrun_filename).baseName());
602 QCborArray identification_file_list;
603 identification_file.insert(QString(
"name"),
m_sageReader.getmJsonAbsoluteFilePath());
604 identification_file_list.push_back(identification_file);
605 it_insert.first->second.cbor_core_sample.insert(QString(
"identification_file_list"),
606 identification_file_list);
609 ms_file.insert(QString(
"name"),
m_sageReader.getMzmlPath(msrun_filename));
610 it_insert.first->second.cbor_core_sample.insert(QString(
"peaklist_file"), ms_file);
634 psm_protein.
protein_sp = std::make_shared<pappso::Protein>(accession,
"");
637 sage_eval.insert(QString(
"protein_q"),
m_line.protein_q);
640 it.first->second.cborEval.insert(QString(
"sage"), sage_eval);
669 Scan *current_cbor_scan_p = &(it_insert.first->second);
673 QCborMap &scan_id = it_insert.first->second.cbor_id;
682 QCborMap &scan_ms2 = it_insert.first->second.cbor_ms2;
683 scan_ms2.insert(QString(
"rt"),
m_line.rt);
685 QCborMap &scan_precursor = it_insert.first->second.cbor_precursor;
686 scan_precursor.insert(QString(
"z"),
m_line.charge);
688 scan_precursor.insert(QString(
"mh"), mh);
690 scan_precursor.insert(QString(
"mz"), exp_mz);
702 one_psm.
cbor_eval.insert(QString(
"delta_mobility"),
m_line.delta_mobility);
704 one_psm.
cbor_eval.insert(QString(
"delta_rt_model"),
m_line.delta_rt_model);
705 one_psm.
cbor_eval.insert(QString(
"fragment_ppm"),
m_line.fragment_ppm);
707 one_psm.
cbor_eval.insert(QString(
"ion_mobility"),
m_line.ion_mobility);
708 one_psm.
cbor_eval.insert(QString(
"isotope_error"),
m_line.isotope_error);
710 one_psm.
cbor_eval.insert(QString(
"longest_b"), (qint64)
m_line.longest_b);
711 one_psm.
cbor_eval.insert(QString(
"longest_y"), (qint64)
m_line.longest_y);
712 one_psm.
cbor_eval.insert(QString(
"longest_y_pct"),
m_line.longest_y_pct);
713 one_psm.
cbor_eval.insert(QString(
"matched_intensity_pct"),
m_line.matched_intensity_pct);
714 one_psm.
cbor_eval.insert(QString(
"matched_peaks"), (qint64)
m_line.matched_peaks);
715 one_psm.
cbor_eval.insert(QString(
"missed_cleavages"),
m_line.missed_cleavages);
716 one_psm.
cbor_eval.insert(QString(
"ms2_intensity"),
m_line.ms2_intensity);
717 one_psm.
cbor_eval.insert(QString(
"peptide_len"), (qint64)
m_line.peptide_len);
720 one_psm.
cbor_eval.insert(QString(
"posterior_error"),
m_line.posterior_error);
721 one_psm.
cbor_eval.insert(QString(
"precursor_ppm"),
m_line.precursor_ppm);
722 one_psm.
cbor_eval.insert(QString(
"predicted_mobility"),
m_line.predicted_mobility);
723 one_psm.
cbor_eval.insert(QString(
"predicted_rt"),
m_line.predicted_rt);
726 one_psm.
cbor_eval.insert(QString(
"sage_discriminant_score"),
m_line.sage_discriminant_score);
727 one_psm.
cbor_eval.insert(QString(
"scored_candidates"), (qint64)
m_line.scored_candidates);
728 one_psm.
cbor_eval.insert(QString(
"semi_enzymatic"),
m_line.semi_enzymatic);
731 current_cbor_scan_p->
psm_list.emplace_back(one_psm);
740 QObject::tr(
"Sage TSV data reading process interrupted"));
754 m_sageReader.getCborStreamWriter().append(
"identification_file_list");
759 m_sageReader.getCborStreamWriter().append(
"peaklist_file");
765 for(
auto &it_scan : one_sample.
scan_map)
788 for(
auto &it_psm : one_scan.
psm_list)
803 m_sageReader.getCborStreamWriter().append(
"protein_list");
805 QCborArray cbor_protein_list;
809 QCborMap cbor_protein;
810 cbor_protein.insert(QString(
"accession"), accession);
814 QString protein_sequence =
815 QString(
m_psmProteinMap.getByAccession(accession).protein_sp.get()->getSequence())
819 QCborArray positions;
822 positions.push_back(position);
826 cbor_protein.insert(QString(
"positions"), positions);
828 cbor_protein_list.append(cbor_protein);
832 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