libpappsomspp
Library for mass spectrometry
Loading...
Searching...
No Matches
sagetsvhandler.cpp
Go to the documentation of this file.
1/**
2 * \file input/sage/sagereader.h
3 * \date 21/08/2024
4 * \author Olivier Langella
5 * \brief read data files from Sage output
6 */
7
8/*******************************************************************************
9 * Copyright (c) 2024 Olivier Langella
10 *<Olivier.Langella@universite-paris-saclay.fr>.
11 *
12 * This file is part of i2MassChroQ.
13 *
14 * i2MassChroQ is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU General Public License as published by
16 * the Free Software Foundation, either version 3 of the License, or
17 * (at your option) any later version.
18 *
19 * i2MassChroQ is distributed in the hope that it will be useful,
20 * but WITHOUT ANY WARRANTY; without even the implied warranty of
21 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 * GNU General Public License for more details.
23 *
24 * You should have received a copy of the GNU General Public License
25 * along with i2MassChroQ. If not, see <http://www.gnu.org/licenses/>.
26 *
27 ******************************************************************************/
28
29
30#include "sagetsvhandler.h"
37#include <qcbormap.h>
38#include <qlogging.h>
39#include <qnamespace.h>
40#include <qregularexpression.h>
41
42
43namespace pappso
44{
45namespace cbor
46{
47namespace psm
48{
49
51 const SageReader &sage_reader,
52 PsmProteinMap &psm_protein_map)
53 : m_sageReader(sage_reader), m_psmProteinMap(psm_protein_map)
54{
55 mp_monitor = p_monitor;
58 m_decoyTag = sage_reader.getDecoyTag();
59}
60
64
65void
67{
68 for(auto it_sample_map : m_sampleMap)
69 {
70 writeSample(it_sample_map.second);
71 }
72}
73
74void
76{
77 if(m_line.charge != 0)
78 recordLine();
80}
81
82void
86
87void
88SageTsvHandler::setCell(const OdsCell &cell)
89{
90 if(m_lineNumber == 0)
91 {
92 // header
93 QString tag = cell.getStringValue();
94 if(tag == "psm_id")
95 {
97 }
98 else if(tag == "peptide")
99 {
101 }
102 else if(tag == "proteins")
103 {
105 }
106 else if(tag == "protein_groups")
107 {
109 }
110 else if(tag == "num_protein_groups")
111 {
113 }
114 else if(tag == "num_proteins")
115 {
117 }
118 else if(tag == "filename")
119 {
121 }
122 else if(tag == "scannr")
123 {
125 }
126 else if(tag == "rank")
127 {
129 }
130 else if(tag == "label")
131 {
133 }
134 else if(tag == "expmass")
135 {
137 }
138
139 else if(tag == "calcmass")
140 {
142 }
143 else if(tag == "charge")
144 {
146 }
147 else if(tag == "peptide_len")
148 {
150 }
151 else if(tag == "missed_cleavages")
152 {
154 }
155 else if(tag == "semi_enzymatic")
156 {
158 }
159 else if(tag == "isotope_error")
160 {
162 }
163 else if(tag == "precursor_ppm")
164 {
166 }
167 else if(tag == "fragment_ppm")
168 {
170 }
171 else if(tag == "hyperscore")
172 {
174 }
175 else if(tag == "delta_next")
176 {
178 }
179 else if(tag == "delta_best")
180 {
182 }
183 else if(tag == "rt")
184 {
185 m_columnTypeList.push_back(Columns::rt);
186 }
187 else if(tag == "aligned_rt")
188 {
190 }
191 else if(tag == "predicted_rt")
192 {
194 }
195 else if(tag == "delta_rt_model")
196 {
198 }
199 else if(tag == "ion_mobility")
200 {
202 }
203 else if(tag == "predicted_mobility")
204 {
206 }
207 else if(tag == "delta_mobility")
208 {
210 }
211 else if(tag == "matched_peaks")
212 {
214 }
215 else if(tag == "longest_b")
216 {
218 }
219 else if(tag == "longest_y")
220 {
222 }
223 else if(tag == "longest_y_pct")
224 {
226 }
227 else if(tag == "matched_intensity_pct")
228 {
230 }
231 else if(tag == "scored_candidates")
232 {
234 }
235 else if(tag == "poisson")
236 {
238 }
239 else if(tag == "sage_discriminant_score")
240 {
242 }
243 else if(tag == "posterior_error")
244 {
246 }
247 else if(tag == "spectrum_q")
248 {
250 }
251 else if(tag == "peptide_q")
252 {
254 }
255 else if(tag == "protein_q")
256 {
258 }
259 else if(tag == "protein_group_q")
260 {
262 }
263 else if(tag == "ms2_intensity")
264 {
266 }
267 else
268 {
269 throw pappso::ExceptionNotPossible(QObject::tr("column \"%1\" not defined").arg(tag));
270 }
271 }
272 else
273 {
274 if(m_columnNumber >= m_columnTypeList.size())
275 {
277 QObject::tr("the value %1 is out of range").arg(cell.getStringValue()));
278 }
280 switch(column_type)
281 {
282 case Columns::psm_id:
283 break;
285 break;
287 break;
289 break;
290 case Columns::peptide:
291 parsePeptide(cell.toString());
292 break;
294 parseProteins(cell.toString());
295 break;
297 if((std::size_t)cell.getDoubleValue() != (std::size_t)m_proteinList.size())
298 {
300 QObject::tr("column \"num_proteins\"!=%1").arg(m_proteinList.size()));
301 }
302 break;
304 parseMsRunFilename(cell.toString());
305 break;
306 case Columns::scannr:
307 parseScanNrColumn(cell.toString());
308 break;
309 case Columns::rank:
310 m_line.rank = cell.getDoubleValue();
311 break;
312 case Columns::label:
313 m_line.label = cell.getDoubleValue();
314 break;
315 case Columns::expmass:
316 m_line.expmass = cell.getDoubleValue();
317 break;
319 m_line.calcmass = cell.getDoubleValue();
320 break;
321 case Columns::charge:
322 m_line.charge = cell.getDoubleValue();
323 break;
325 m_line.peptide_len = cell.getDoubleValue();
326 break;
328 m_line.missed_cleavages = cell.getDoubleValue();
329 break;
331 m_line.semi_enzymatic = cell.getDoubleValue();
332 break;
334 m_line.isotope_error = cell.getDoubleValue();
335 break;
336
338 m_line.precursor_ppm = cell.getDoubleValue();
339 break;
341 m_line.fragment_ppm = cell.getDoubleValue();
342 break;
344 m_line.hyperscore = cell.getDoubleValue();
345 break;
347 m_line.delta_next = cell.getDoubleValue();
348 break;
350 m_line.delta_best = cell.getDoubleValue();
351 break;
352 case Columns::rt:
353 m_line.rt = cell.getDoubleValue() * 60; // to convert retention time in seconds
354 break;
356 m_line.aligned_rt = cell.getDoubleValue();
357 break;
359 m_line.predicted_rt = cell.getDoubleValue();
360 break;
362 m_line.delta_rt_model = cell.getDoubleValue();
363 break;
365 m_line.ion_mobility = cell.getDoubleValue();
366 break;
368 m_line.predicted_mobility = cell.getDoubleValue();
369 break;
371 m_line.delta_mobility = cell.getDoubleValue();
372 break;
374 m_line.matched_peaks = cell.getDoubleValue();
375 break;
377 m_line.longest_b = cell.getDoubleValue();
378 break;
380 m_line.longest_y = cell.getDoubleValue();
381 break;
383 m_line.longest_y_pct = cell.getDoubleValue();
384 break;
386 m_line.matched_intensity_pct = cell.getDoubleValue();
387 break;
389 m_line.scored_candidates = cell.getDoubleValue();
390 break;
391 case Columns::poisson:
392 m_line.poisson = cell.getDoubleValue();
393 break;
395 m_line.sage_discriminant_score = cell.getDoubleValue();
396 break;
398 m_line.posterior_error = cell.getDoubleValue();
399 break;
401 m_line.spectrum_q = cell.getDoubleValue();
402 break;
404 m_line.peptide_q = cell.getDoubleValue();
405 break;
407 m_line.protein_q = cell.getDoubleValue();
408 break;
410 m_line.ms2_intensity = cell.getDoubleValue();
411 break;
412 default:
413 qDebug() << "m_line.calcmass=" << m_line.calcmass;
415 QObject::tr("column type %1 not implemented").arg((std::uint8_t)column_type));
416 break;
417 }
418
419 /*
420
421 2333 TMISDSDYTEFENFTK
422 GRMZM2G018197_P01;GRMZM2G068952_P01;GRMZM5G822976_P01 3
423 20120906_balliau_extract_1_A01_urnb-1.mzML controllerType=0
424 controllerNumber=1 scan=12542 1 1 1926.8225 1926.8193 2 16 0 0
425 0.0 1.6471838 1.9796097 54.06803492297634 28.049970383419556 0.0 38.192993
426 0.76385987 0.7671368 0.0032769442 0.0 0.0 0.0 16 2 14 0.875 32.54396 380
427 -13.375352220427656 1.1570586 -34.13482 0.00016041065 0.00022231363
428 0.00040124074 1271951.1
429 */
430 }
432}
433
434void
436{
437 m_columnNumber = 0;
438 msp_peptide = nullptr;
439 m_proteinList.clear();
440 m_line = Line();
441}
442
443void
447void
448SageTsvHandler::startSheet(const QString &sheet_name [[maybe_unused]])
449{
450 m_columnNumber = 0;
451 m_lineNumber = 0;
452 mp_monitor->setStatus(QObject::tr("reading Sage TSV file"));
453
454 if(mp_monitor->shouldIstop())
455 {
456 throw pappso::ExceptionInterrupted(QObject::tr("Sage TSV data reading process interrupted"));
457 }
458}
459
460void
461SageTsvHandler::parsePeptide(const QString &peptide_str)
462{
463 qDebug();
464 QString peptide_str_verif = peptide_str;
465 // fixed modifications :
467 {
468 qDebug() << modif.strModification;
469 qDebug() << modif.modification->getAccession();
470 peptide_str_verif = peptide_str_verif.replace(
471 modif.strModification, QString("[%1]").arg(modif.modification->getAccession()));
472 }
473 // variable modifications :
475 {
476 qDebug() << modif.strModification;
477 qDebug() << modif.modification->getAccession();
478 peptide_str_verif = peptide_str_verif.replace(
479 modif.strModification, QString("[%1]").arg(modif.modification->getAccession()));
480 }
481
482 qDebug() << peptide_str_verif;
483 // LPMFGC[+57.0216]NDATQVYK
485 qDebug();
486 // variable modifications :
487 /*
488 setVariableModifications(peptide_sp,
489 peptide_line.peptide_string_list.at(6));
490*/
491 qDebug() << msp_peptide.get()->toProForma();
492}
493
494
495void
496SageTsvHandler::parseProteins(const QString &proteins_str)
497{
498
499 m_proteinList.clear();
500 m_proteinList = proteins_str.split(";", Qt::SkipEmptyParts);
501 for(QString accession : m_proteinList)
502 {
503
504 PsmProtein psm_protein;
505 psm_protein.protein_sp = std::make_shared<pappso::Protein>(accession, "");
506 psm_protein.isTarget = true;
507 if(accession.startsWith(m_decoyTag))
508 {
509 psm_protein.isTarget = false;
510 }
511
512 m_psmProteinMap.insert(psm_protein);
513 }
514}
515
516bool
517SageTsvHandler::parseScanNrColumn(const QString &spectrum_string_id)
518{
519 m_spectrumNativeId = spectrum_string_id;
520 qDebug() << spectrum_string_id;
521 m_scanNumber = 0;
522 bool is_ok = false;
523 m_scanNumberIsOk = false;
524 // controllerType=0 controllerNumber=1 scan=176056
525 if(mp_currentSample->name.endsWith(".d"))
526 { // assume this is a Bruker's timTOF sample
527 // 200ngHeLaPASEF_2min_compressed.d 2005
528 std::size_t precursor_number = spectrum_string_id.toULongLong(&is_ok);
529 if(is_ok)
530 {
531 // precursor=2006 idxms2=4011
532 m_scanNumberIsOk = is_ok;
533 m_spectrumIndex = precursor_number * 2 + 1;
534 m_spectrumNativeId = QString("precursor=%1 idxms2=%2")
535 .arg(precursor_number + 1)
536 .arg(precursor_number * 2 + 1);
537 }
538 }
539
540 if(!is_ok)
541 {
542 QStringList scan_list = spectrum_string_id.split("scan=");
543 if(scan_list.size() == 2)
544 {
545 // we bet that there is a scan number, easy to parse
546 m_scanNumber = scan_list.at(1).toULongLong(&is_ok);
547 m_scanNumberIsOk = is_ok;
548 if(m_scanNumber > 0)
550 }
551 if(is_ok == false)
552 {
553 ;
554 QStringList scan_list = spectrum_string_id.split(QRegularExpression("[^\\d]"));
555 if(scan_list.size() == 2)
556 {
557 m_scanNumber = scan_list.at(0).toULongLong(&is_ok);
558 m_scanNumberIsOk = is_ok;
559 if(m_scanNumber > 0)
561 }
562 /*
563 if(msp_previousMsrun != msp_msrun)
564 {
565 mp_monitor->setStatus(
566 QObject::tr("Reading mz data file %1").arg(msp_msrun.get()->getFileName()));
567 msp_previousMsrun = msp_msrun;
568 }
569
570 pappso::MsRunReader *msrunreader_p = msp_msrun.get()->getMsRunReaderSPtr().get();
571 if(msrunreader_p->getMsRunId()->getMsDataFormat() == pappso::MsDataFormat::brukerTims)
572 {
573 m_spectrumIndex = spectrum_string_id.toInt() * 2 - 1;
574 }
575 else
576 {
577 m_spectrumIndex =
578 msrunreader_p->spectrumStringIdentifier2SpectrumIndex(spectrum_string_id);
579 }*/
580 }
581 }
582 qDebug() << spectrum_string_id;
583 return is_ok;
584}
585
586void
587SageTsvHandler::parseMsRunFilename(const QString &msrun_filename)
588{
589
590
591 // find the sample :
592 auto it_insert = m_sampleMap.insert({msrun_filename, {}});
593 mp_currentSample = &(it_insert.first->second);
594 if(it_insert.second)
595 {
596 // new sample
597 it_insert.first->second.name = msrun_filename;
598 QCborMap ms_file;
599 QCborMap identification_file;
600
601 it_insert.first->second.cbor_core_sample.insert(QString("name"),
602 QFileInfo(msrun_filename).baseName());
603
604 // identification_file_list
605 QCborArray identification_file_list;
606 identification_file.insert(QString("name"), m_sageReader.getmJsonAbsoluteFilePath());
607 identification_file_list.push_back(identification_file);
608 it_insert.first->second.cbor_core_sample.insert(QString("identification_file_list"),
609 identification_file_list);
610
611
612 ms_file.insert(QString("name"), m_sageReader.getMzmlPath(msrun_filename));
613 it_insert.first->second.cbor_core_sample.insert(QString("peaklist_file"), ms_file);
614 }
615
616 /*
617 msp_msrun = m_sageReader.getSageFileReader().getMsRunSpWithFileName(msrun_filename);
618 qDebug() << msp_msrun.get()->getFileName();
619
620 msp_identificationSageJsonFileSp =
621 m_sageReader.getSageFileReader().getIdentificationSageJsonFileSpWithFileName(msrun_filename);
622
623 mp_identificationGroup =
624 m_sageReader.getSageFileReader().getIdentificationGroupPtrWithFileName(msrun_filename);
625 qDebug() << msp_msrun.get()->getFileName();
626 */
627}
628
629void
631{
632 qDebug();
633
634 for(const QString &accession : m_proteinList)
635 {
636 PsmProtein psm_protein;
637 psm_protein.protein_sp = std::make_shared<pappso::Protein>(accession, "");
638
639 QCborMap sage_eval;
640 sage_eval.insert(QString("protein_q"), m_line.protein_q);
641
642 auto it = m_psmProteinMap.insert(psm_protein);
643 it.first->second.cborEval.insert(QString("sage"), sage_eval);
644 }
645 /*
646 PeptideEvidence pe(msp_msrun.get(), m_spectrumIndex, true);
647 pe.setCharge(m_line.charge);
648 pe.setChecked(true);
649 pe.setExperimentalMass(m_line.expmass);
650 pe.setPeptideXtpSp(msp_peptide);
651 pe.setIdentificationDataSource(msp_identificationSageJsonFileSp.get());
652 pe.setIdentificationEngine(m_identificationEngine);
653 pe.setRetentionTime(m_line.rt);
654 pe.setParam(PeptideEvidenceParam::tandem_hyperscore, m_line.hyperscore);
655 pe.setParam(PeptideEvidenceParam::sage_sage_discriminant_score,
656 m_line.sage_discriminant_score);
657 pe.setParam(PeptideEvidenceParam::sage_peptide_q, m_line.peptide_q);
658 pe.setParam(PeptideEvidenceParam::sage_posterior_error, m_line.posterior_error);
659 pe.setParam(PeptideEvidenceParam::sage_spectrum_q, m_line.spectrum_q);
660 pe.setParam(PeptideEvidenceParam::sage_predicted_rt, m_line.predicted_rt);
661 pe.setParam(PeptideEvidenceParam::sage_isotope_error, m_line.isotope_error);
662
663
664 PeptideMatch peptide_match;
665 // peptide_match.setStart(mz_peptide_evidence.start);
666 peptide_match.setPeptideEvidenceSp(
667 msp_identificationSageJsonFileSp.get()->getPeptideEvidenceStore().getInstance(&pe));
668 */
669
670 // find the scan in sample
671 auto it_insert = mp_currentSample->scan_map.insert({m_spectrumNativeId, Scan()});
672 Scan *current_cbor_scan_p = &(it_insert.first->second);
673 if(it_insert.second)
674 {
675 // new scan
676 QCborMap &scan_id = it_insert.first->second.cbor_id;
678 {
679 scan_id.insert(QString("index"), (qint64)m_spectrumIndex);
680 if(m_scanNumber > 0)
681 scan_id.insert(QString("scan"), (qint64)m_scanNumber);
682 }
683 scan_id.insert(QString("native_id"), m_spectrumNativeId);
684
685 QCborMap &scan_ms2 = it_insert.first->second.cbor_ms2;
686 scan_ms2.insert(QString("rt"), m_line.rt);
687
688 QCborMap &scan_precursor = it_insert.first->second.cbor_precursor;
689 scan_precursor.insert(QString("z"), m_line.charge);
690 double mh = m_line.expmass + MHPLUS;
691 scan_precursor.insert(QString("mh"), mh);
692 double exp_mz = (m_line.expmass + (MHPLUS * m_line.charge)) / m_line.charge;
693 scan_precursor.insert(QString("mz"), exp_mz);
694 }
695
696 Psm one_psm;
697 one_psm.peptide_sequence_li = msp_peptide.get()->getSequenceLi();
698 one_psm.proforma = msp_peptide.get()->toProForma();
699 one_psm.protein_list = m_proteinList;
700
701
702 one_psm.cbor_eval.insert(QString("aligned_rt"), m_line.aligned_rt);
703 one_psm.cbor_eval.insert(QString("calcmass"), m_line.calcmass);
704 one_psm.cbor_eval.insert(QString("delta_best"), m_line.delta_best);
705 one_psm.cbor_eval.insert(QString("delta_mobility"), m_line.delta_mobility);
706 one_psm.cbor_eval.insert(QString("delta_next"), m_line.delta_next);
707 one_psm.cbor_eval.insert(QString("delta_rt_model"), m_line.delta_rt_model);
708 one_psm.cbor_eval.insert(QString("fragment_ppm"), m_line.fragment_ppm);
709 one_psm.cbor_eval.insert(QString("hyperscore"), m_line.hyperscore);
710 one_psm.cbor_eval.insert(QString("ion_mobility"), m_line.ion_mobility);
711 one_psm.cbor_eval.insert(QString("isotope_error"), m_line.isotope_error);
712 one_psm.cbor_eval.insert(QString("label"), m_line.label);
713 one_psm.cbor_eval.insert(QString("longest_b"), (qint64)m_line.longest_b);
714 one_psm.cbor_eval.insert(QString("longest_y"), (qint64)m_line.longest_y);
715 one_psm.cbor_eval.insert(QString("longest_y_pct"), m_line.longest_y_pct);
716 one_psm.cbor_eval.insert(QString("matched_intensity_pct"), m_line.matched_intensity_pct);
717 one_psm.cbor_eval.insert(QString("matched_peaks"), (qint64)m_line.matched_peaks);
718 one_psm.cbor_eval.insert(QString("missed_cleavages"), m_line.missed_cleavages);
719 one_psm.cbor_eval.insert(QString("ms2_intensity"), m_line.ms2_intensity);
720 one_psm.cbor_eval.insert(QString("peptide_len"), (qint64)m_line.peptide_len);
721 one_psm.cbor_eval.insert(QString("peptide_q"), m_line.peptide_q);
722 one_psm.cbor_eval.insert(QString("poisson"), m_line.poisson);
723 one_psm.cbor_eval.insert(QString("posterior_error"), m_line.posterior_error);
724 one_psm.cbor_eval.insert(QString("precursor_ppm"), m_line.precursor_ppm);
725 one_psm.cbor_eval.insert(QString("predicted_mobility"), m_line.predicted_mobility);
726 one_psm.cbor_eval.insert(QString("predicted_rt"), m_line.predicted_rt);
727 one_psm.cbor_eval.insert(QString("protein_q"), m_line.protein_q);
728 one_psm.cbor_eval.insert(QString("rank"), m_line.rank);
729 one_psm.cbor_eval.insert(QString("sage_discriminant_score"), m_line.sage_discriminant_score);
730 one_psm.cbor_eval.insert(QString("scored_candidates"), (qint64)m_line.scored_candidates);
731 one_psm.cbor_eval.insert(QString("semi_enzymatic"), m_line.semi_enzymatic);
732 one_psm.cbor_eval.insert(QString("spectrum_q"), m_line.spectrum_q);
733
734 current_cbor_scan_p->psm_list.emplace_back(one_psm);
735
736
737 std::size_t progress = m_lineNumber / 10000;
738 if(progress > m_progressIndex)
739 {
740 if(mp_monitor->shouldIstop())
741 {
743 QObject::tr("Sage TSV data reading process interrupted"));
744 }
745 m_progressIndex = progress;
746 mp_monitor->setStatus(QString("%1K ").arg(m_progressIndex * 10));
747 }
748}
749
750void
752{
753 m_sageReader.getCborStreamWriter().startMap();
754 m_sageReader.getCborStreamWriter().append("name");
755 one_sample.cbor_core_sample.value("name").toCbor(m_sageReader.getCborStreamWriter());
756
757 m_sageReader.getCborStreamWriter().append("identification_file_list");
758 one_sample.cbor_core_sample.value("identification_file_list")
759 .toCbor(m_sageReader.getCborStreamWriter());
760
761
762 m_sageReader.getCborStreamWriter().append("peaklist_file");
763 one_sample.cbor_core_sample.value("peaklist_file").toCbor(m_sageReader.getCborStreamWriter());
764 //"scan_list": [
765
766 m_sageReader.getCborStreamWriter().append("scan_list");
767 m_sageReader.getCborStreamWriter().startArray(one_sample.scan_map.size());
768 for(auto &it_scan : one_sample.scan_map)
769 {
770 writeScan(it_scan.second);
771 }
772 m_sageReader.getCborStreamWriter().endArray();
773
774
775 m_sageReader.getCborStreamWriter().endMap();
776}
777
778void
780{
781 m_sageReader.getCborStreamWriter().startMap();
782 m_sageReader.getCborStreamWriter().append("id");
783 QCborValue(one_scan.cbor_id).toCbor(m_sageReader.getCborStreamWriter());
784 m_sageReader.getCborStreamWriter().append("precursor");
785 QCborValue(one_scan.cbor_precursor).toCbor(m_sageReader.getCborStreamWriter());
786 m_sageReader.getCborStreamWriter().append("ms2");
787 QCborValue(one_scan.cbor_ms2).toCbor(m_sageReader.getCborStreamWriter());
788
789 m_sageReader.getCborStreamWriter().append("psm_list");
790 m_sageReader.getCborStreamWriter().startArray(one_scan.psm_list.size());
791 for(auto &it_psm : one_scan.psm_list)
792 {
793 writePsm(it_psm);
794 }
795 m_sageReader.getCborStreamWriter().endArray();
796
797 m_sageReader.getCborStreamWriter().endMap();
798}
799
800void
802{
803 m_sageReader.getCborStreamWriter().startMap();
804 m_sageReader.getCborStreamWriter().append("proforma");
805 m_sageReader.getCborStreamWriter().append(one_psm.proforma);
806 m_sageReader.getCborStreamWriter().append("protein_list");
807
808 QCborArray cbor_protein_list;
809 for(const QString &accession : one_psm.protein_list)
810 {
811 // qWarning() << "accession=" << accession;
812 QCborMap cbor_protein;
813 cbor_protein.insert(QString("accession"), accession);
814
815
816 // start/end positions
817 QString protein_sequence =
818 QString(m_psmProteinMap.getByAccession(accession).protein_sp.get()->getSequence())
819 .replace("L", "I");
820 int position = protein_sequence.indexOf(one_psm.peptide_sequence_li);
821
822 QCborArray positions;
823 while(position >= 0)
824 {
825 positions.push_back(position);
826 position = protein_sequence.indexOf(one_psm.peptide_sequence_li, position + 1);
827 }
828
829 cbor_protein.insert(QString("positions"), positions);
830
831 cbor_protein_list.append(cbor_protein);
832 }
833
834
835 QCborValue(cbor_protein_list).toCbor(m_sageReader.getCborStreamWriter());
836
837 m_sageReader.getCborStreamWriter().append("eval");
838 m_sageReader.getCborStreamWriter().startMap();
839 m_sageReader.getCborStreamWriter().append("sage");
840 QCborValue(one_psm.cbor_eval).toCbor(m_sageReader.getCborStreamWriter());
841 m_sageReader.getCborStreamWriter().endMap();
842
843 m_sageReader.getCborStreamWriter().endMap();
844}
845
846
847} // namespace psm
848} // namespace cbor
849} // namespace pappso
static PeptideSp parseString(const QString &pepstr)
store PsmProtein in a map with accession as key
std::vector< SageModification > getStaticModificationList() const
std::vector< SageModification > getVariableModificationList() const
std::vector< SageReader::SageModification > m_staticModificationList
void parseProteins(const QString &proteins_str)
virtual void endSheet() override
pappso::UiMonitorInterface * mp_monitor
virtual void startSheet(const QString &sheet_name) override
std::vector< SageReader::SageModification > m_variableModificationList
void parsePeptide(const QString &peptide_str)
void writeSample(const Sample &one_sample)
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::map< QString, Sample > m_sampleMap
virtual void endDocument() override
virtual void startLine() override
void parseMsRunFilename(const QString &msrun_filename)
bool parseScanNrColumn(const QString &spectrum_string_id)
virtual void endLine() override
std::vector< Columns > m_columnTypeList
tries to keep as much as possible monoisotopes, removing any possible C13 peaks and changes multichar...
Definition aa.cpp:39
const pappso_double MHPLUS(1.007276466879)
std::shared_ptr< Protein > protein_sp