39#include <qregularexpression.h>
92 QString tag = cell.getStringValue();
97 else if(tag ==
"peptide")
101 else if(tag ==
"proteins")
105 else if(tag ==
"protein_groups")
109 else if(tag ==
"num_protein_groups")
113 else if(tag ==
"num_proteins")
117 else if(tag ==
"filename")
121 else if(tag ==
"scannr")
125 else if(tag ==
"rank")
129 else if(tag ==
"label")
133 else if(tag ==
"expmass")
138 else if(tag ==
"calcmass")
142 else if(tag ==
"charge")
146 else if(tag ==
"peptide_len")
150 else if(tag ==
"missed_cleavages")
154 else if(tag ==
"semi_enzymatic")
158 else if(tag ==
"isotope_error")
162 else if(tag ==
"precursor_ppm")
166 else if(tag ==
"fragment_ppm")
170 else if(tag ==
"hyperscore")
174 else if(tag ==
"delta_next")
178 else if(tag ==
"delta_best")
186 else if(tag ==
"aligned_rt")
190 else if(tag ==
"predicted_rt")
194 else if(tag ==
"delta_rt_model")
198 else if(tag ==
"ion_mobility")
202 else if(tag ==
"predicted_mobility")
206 else if(tag ==
"delta_mobility")
210 else if(tag ==
"matched_peaks")
214 else if(tag ==
"longest_b")
218 else if(tag ==
"longest_y")
222 else if(tag ==
"longest_y_pct")
226 else if(tag ==
"matched_intensity_pct")
230 else if(tag ==
"scored_candidates")
234 else if(tag ==
"poisson")
238 else if(tag ==
"sage_discriminant_score")
242 else if(tag ==
"posterior_error")
246 else if(tag ==
"spectrum_q")
250 else if(tag ==
"peptide_q")
254 else if(tag ==
"protein_q")
258 else if(tag ==
"protein_group_q")
262 else if(tag ==
"ms2_intensity")
276 QObject::tr(
"the value %1 is out of range").arg(cell.getStringValue()));
296 if((std::size_t)cell.getDoubleValue() != (std::size_t)
m_proteinList.size())
299 QObject::tr(
"column \"num_proteins\"!=%1").arg(
m_proteinList.size()));
309 m_line.rank = cell.getDoubleValue();
312 m_line.label = cell.getDoubleValue();
315 m_line.expmass = cell.getDoubleValue();
318 m_line.calcmass = cell.getDoubleValue();
321 m_line.charge = cell.getDoubleValue();
324 m_line.peptide_len = cell.getDoubleValue();
327 m_line.missed_cleavages = cell.getDoubleValue();
330 m_line.semi_enzymatic = cell.getDoubleValue();
333 m_line.isotope_error = cell.getDoubleValue();
337 m_line.precursor_ppm = cell.getDoubleValue();
340 m_line.fragment_ppm = cell.getDoubleValue();
343 m_line.hyperscore = cell.getDoubleValue();
346 m_line.delta_next = cell.getDoubleValue();
349 m_line.delta_best = cell.getDoubleValue();
352 m_line.rt = cell.getDoubleValue() * 60;
355 m_line.aligned_rt = cell.getDoubleValue();
358 m_line.predicted_rt = cell.getDoubleValue();
361 m_line.delta_rt_model = cell.getDoubleValue();
364 m_line.ion_mobility = cell.getDoubleValue();
367 m_line.predicted_mobility = cell.getDoubleValue();
370 m_line.delta_mobility = cell.getDoubleValue();
373 m_line.matched_peaks = cell.getDoubleValue();
376 m_line.longest_b = cell.getDoubleValue();
379 m_line.longest_y = cell.getDoubleValue();
382 m_line.longest_y_pct = cell.getDoubleValue();
385 m_line.matched_intensity_pct = cell.getDoubleValue();
388 m_line.scored_candidates = cell.getDoubleValue();
391 m_line.poisson = cell.getDoubleValue();
394 m_line.sage_discriminant_score = cell.getDoubleValue();
397 m_line.posterior_error = cell.getDoubleValue();
400 m_line.spectrum_q = cell.getDoubleValue();
403 m_line.peptide_q = cell.getDoubleValue();
406 m_line.protein_q = cell.getDoubleValue();
409 m_line.ms2_intensity = cell.getDoubleValue();
412 qDebug() <<
"m_line.calcmass=" <<
m_line.calcmass;
414 QObject::tr(
"column type %1 not implemented").arg((std::uint8_t)column_type));
451 mp_monitor->setStatus(QObject::tr(
"reading Sage TSV file"));
463 QString peptide_str_verif = peptide_str;
467 qDebug() << modif.strModification;
468 qDebug() << modif.modification->getAccession();
469 peptide_str_verif = peptide_str_verif.replace(
470 modif.strModification, QString(
"[%1]").arg(modif.modification->getAccession()));
475 qDebug() << modif.strModification;
476 qDebug() << modif.modification->getAccession();
477 peptide_str_verif = peptide_str_verif.replace(
478 modif.strModification, QString(
"[%1]").arg(modif.modification->getAccession()));
481 qDebug() << peptide_str_verif;
504 psm_protein.
protein_sp = std::make_shared<pappso::Protein>(accession,
"");
519 qDebug() << spectrum_string_id;
527 std::size_t precursor_number = spectrum_string_id.toULongLong(&is_ok);
534 .arg(precursor_number + 1)
535 .arg(precursor_number * 2 + 1);
541 QStringList scan_list = spectrum_string_id.split(
"scan=");
542 if(scan_list.size() == 2)
553 QStringList scan_list = spectrum_string_id.split(QRegularExpression(
"[^\\d]"));
554 if(scan_list.size() == 2)
581 qDebug() << spectrum_string_id;
591 auto it_insert =
m_sampleMap.insert({msrun_filename, {}});
596 it_insert.first->second.name = msrun_filename;
598 QCborMap identification_file;
600 it_insert.first->second.cbor_core_sample.insert(QString(
"name"),
601 QFileInfo(msrun_filename).baseName());
604 QCborArray identification_file_list;
605 identification_file.insert(QString(
"name"),
m_sageReader.getmJsonAbsoluteFilePath());
606 identification_file_list.push_back(identification_file);
607 it_insert.first->second.cbor_core_sample.insert(QString(
"identification_file_list"),
608 identification_file_list);
611 ms_file.insert(QString(
"name"),
m_sageReader.getMzmlPath(msrun_filename));
612 it_insert.first->second.cbor_core_sample.insert(QString(
"peaklist_file"), ms_file);
636 psm_protein.
protein_sp = std::make_shared<pappso::Protein>(accession,
"");
639 sage_eval.insert(QString(
"protein_q"),
m_line.protein_q);
642 it.first->second.cborEval.insert(QString(
"sage"), sage_eval);
671 Scan *current_cbor_scan_p = &(it_insert.first->second);
675 QCborMap &scan_id = it_insert.first->second.cbor_id;
684 QCborMap &scan_ms2 = it_insert.first->second.cbor_ms2;
685 scan_ms2.insert(QString(
"rt"),
m_line.rt);
687 QCborMap &scan_precursor = it_insert.first->second.cbor_precursor;
688 scan_precursor.insert(QString(
"z"),
m_line.charge);
690 scan_precursor.insert(QString(
"mh"), mh);
692 scan_precursor.insert(QString(
"mz"), exp_mz);
704 one_psm.
cbor_eval.insert(QString(
"delta_mobility"),
m_line.delta_mobility);
706 one_psm.
cbor_eval.insert(QString(
"delta_rt_model"),
m_line.delta_rt_model);
707 one_psm.
cbor_eval.insert(QString(
"fragment_ppm"),
m_line.fragment_ppm);
709 one_psm.
cbor_eval.insert(QString(
"ion_mobility"),
m_line.ion_mobility);
710 one_psm.
cbor_eval.insert(QString(
"isotope_error"),
m_line.isotope_error);
712 one_psm.
cbor_eval.insert(QString(
"longest_b"), (qint64)
m_line.longest_b);
713 one_psm.
cbor_eval.insert(QString(
"longest_y"), (qint64)
m_line.longest_y);
714 one_psm.
cbor_eval.insert(QString(
"longest_y_pct"),
m_line.longest_y_pct);
715 one_psm.
cbor_eval.insert(QString(
"matched_intensity_pct"),
m_line.matched_intensity_pct);
716 one_psm.
cbor_eval.insert(QString(
"matched_peaks"), (qint64)
m_line.matched_peaks);
717 one_psm.
cbor_eval.insert(QString(
"missed_cleavages"),
m_line.missed_cleavages);
718 one_psm.
cbor_eval.insert(QString(
"ms2_intensity"),
m_line.ms2_intensity);
719 one_psm.
cbor_eval.insert(QString(
"peptide_len"), (qint64)
m_line.peptide_len);
722 one_psm.
cbor_eval.insert(QString(
"posterior_error"),
m_line.posterior_error);
723 one_psm.
cbor_eval.insert(QString(
"precursor_ppm"),
m_line.precursor_ppm);
724 one_psm.
cbor_eval.insert(QString(
"predicted_mobility"),
m_line.predicted_mobility);
725 one_psm.
cbor_eval.insert(QString(
"predicted_rt"),
m_line.predicted_rt);
728 one_psm.
cbor_eval.insert(QString(
"sage_discriminant_score"),
m_line.sage_discriminant_score);
729 one_psm.
cbor_eval.insert(QString(
"scored_candidates"), (qint64)
m_line.scored_candidates);
730 one_psm.
cbor_eval.insert(QString(
"semi_enzymatic"),
m_line.semi_enzymatic);
733 current_cbor_scan_p->
psm_list.emplace_back(one_psm);
742 QObject::tr(
"Sage TSV data reading process interrupted"));
756 m_sageReader.getCborStreamWriter().append(
"identification_file_list");
761 m_sageReader.getCborStreamWriter().append(
"peaklist_file");
767 for(
auto &it_scan : one_sample.
scan_map)
790 for(
auto &it_psm : one_scan.
psm_list)
805 m_sageReader.getCborStreamWriter().append(
"protein_list");
807 QCborArray cbor_protein_list;
811 QCborMap cbor_protein;
812 cbor_protein.insert(QString(
"accession"), accession);
816 QString protein_sequence =
817 QString(
m_psmProteinMap.getByAccession(accession).protein_sp.get()->getSequence())
821 QCborArray positions;
824 positions.push_back(position);
828 cbor_protein.insert(QString(
"positions"), positions);
830 cbor_protein_list.append(cbor_protein);
834 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