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 <qregularexpression.h>
39
40
41namespace pappso
42{
43namespace cbor
44{
45namespace psm
46{
47
49 const SageReader &sage_reader,
50 PsmProteinMap &psm_protein_map)
51 : m_sageReader(sage_reader), m_psmProteinMap(psm_protein_map)
52{
53 mp_monitor = p_monitor;
56 m_decoyTag = sage_reader.getDecoyTag();
57}
58
62
63void
65{
66 for(auto it_sample_map : m_sampleMap)
67 {
68 writeSample(it_sample_map.second);
69 }
70}
71
72void
74{
75 if(m_line.charge != 0)
76 recordLine();
78}
79
80void
84
85void
86SageTsvHandler::setCell(const OdsCell &cell)
87{
88 if(m_lineNumber == 0)
89 {
90 // header
91 QString tag = cell.getStringValue();
92 if(tag == "psm_id")
93 {
95 }
96 else if(tag == "peptide")
97 {
99 }
100 else if(tag == "proteins")
101 {
103 }
104 else if(tag == "protein_groups")
105 {
107 }
108 else if(tag == "num_protein_groups")
109 {
111 }
112 else if(tag == "num_proteins")
113 {
115 }
116 else if(tag == "filename")
117 {
119 }
120 else if(tag == "scannr")
121 {
123 }
124 else if(tag == "rank")
125 {
127 }
128 else if(tag == "label")
129 {
131 }
132 else if(tag == "expmass")
133 {
135 }
136
137 else if(tag == "calcmass")
138 {
140 }
141 else if(tag == "charge")
142 {
144 }
145 else if(tag == "peptide_len")
146 {
148 }
149 else if(tag == "missed_cleavages")
150 {
152 }
153 else if(tag == "semi_enzymatic")
154 {
156 }
157 else if(tag == "isotope_error")
158 {
160 }
161 else if(tag == "precursor_ppm")
162 {
164 }
165 else if(tag == "fragment_ppm")
166 {
168 }
169 else if(tag == "hyperscore")
170 {
172 }
173 else if(tag == "delta_next")
174 {
176 }
177 else if(tag == "delta_best")
178 {
180 }
181 else if(tag == "rt")
182 {
183 m_columnTypeList.push_back(Columns::rt);
184 }
185 else if(tag == "aligned_rt")
186 {
188 }
189 else if(tag == "predicted_rt")
190 {
192 }
193 else if(tag == "delta_rt_model")
194 {
196 }
197 else if(tag == "ion_mobility")
198 {
200 }
201 else if(tag == "predicted_mobility")
202 {
204 }
205 else if(tag == "delta_mobility")
206 {
208 }
209 else if(tag == "matched_peaks")
210 {
212 }
213 else if(tag == "longest_b")
214 {
216 }
217 else if(tag == "longest_y")
218 {
220 }
221 else if(tag == "longest_y_pct")
222 {
224 }
225 else if(tag == "matched_intensity_pct")
226 {
228 }
229 else if(tag == "scored_candidates")
230 {
232 }
233 else if(tag == "poisson")
234 {
236 }
237 else if(tag == "sage_discriminant_score")
238 {
240 }
241 else if(tag == "posterior_error")
242 {
244 }
245 else if(tag == "spectrum_q")
246 {
248 }
249 else if(tag == "peptide_q")
250 {
252 }
253 else if(tag == "protein_q")
254 {
256 }
257 else if(tag == "protein_group_q")
258 {
260 }
261 else if(tag == "ms2_intensity")
262 {
264 }
265 else
266 {
267 throw pappso::ExceptionNotPossible(QObject::tr("column \"%1\" not defined").arg(tag));
268 }
269 }
270 else
271 {
272 if(m_columnNumber >= m_columnTypeList.size())
273 {
275 QObject::tr("the value %1 is out of range").arg(cell.getStringValue()));
276 }
278 switch(column_type)
279 {
280 case Columns::psm_id:
281 break;
283 break;
285 break;
287 break;
288 case Columns::peptide:
289 parsePeptide(cell.toString());
290 break;
292 parseProteins(cell.toString());
293 break;
295 if((std::size_t)cell.getDoubleValue() != (std::size_t)m_proteinList.size())
296 {
298 QObject::tr("column \"num_proteins\"!=%1").arg(m_proteinList.size()));
299 }
300 break;
302 parseMsRunFilename(cell.toString());
303 break;
304 case Columns::scannr:
305 parseScanNrColumn(cell.toString());
306 break;
307 case Columns::rank:
308 m_line.rank = cell.getDoubleValue();
309 break;
310 case Columns::label:
311 m_line.label = cell.getDoubleValue();
312 break;
313 case Columns::expmass:
314 m_line.expmass = cell.getDoubleValue();
315 break;
317 m_line.calcmass = cell.getDoubleValue();
318 break;
319 case Columns::charge:
320 m_line.charge = cell.getDoubleValue();
321 break;
323 m_line.peptide_len = cell.getDoubleValue();
324 break;
326 m_line.missed_cleavages = cell.getDoubleValue();
327 break;
329 m_line.semi_enzymatic = cell.getDoubleValue();
330 break;
332 m_line.isotope_error = cell.getDoubleValue();
333 break;
334
336 m_line.precursor_ppm = cell.getDoubleValue();
337 break;
339 m_line.fragment_ppm = cell.getDoubleValue();
340 break;
342 m_line.hyperscore = cell.getDoubleValue();
343 break;
345 m_line.delta_next = cell.getDoubleValue();
346 break;
348 m_line.delta_best = cell.getDoubleValue();
349 break;
350 case Columns::rt:
351 m_line.rt = cell.getDoubleValue() * 60; // to convert retention time in seconds
352 break;
354 m_line.aligned_rt = cell.getDoubleValue();
355 break;
357 m_line.predicted_rt = cell.getDoubleValue();
358 break;
360 m_line.delta_rt_model = cell.getDoubleValue();
361 break;
363 m_line.ion_mobility = cell.getDoubleValue();
364 break;
366 m_line.predicted_mobility = cell.getDoubleValue();
367 break;
369 m_line.delta_mobility = cell.getDoubleValue();
370 break;
372 m_line.matched_peaks = cell.getDoubleValue();
373 break;
375 m_line.longest_b = cell.getDoubleValue();
376 break;
378 m_line.longest_y = cell.getDoubleValue();
379 break;
381 m_line.longest_y_pct = cell.getDoubleValue();
382 break;
384 m_line.matched_intensity_pct = cell.getDoubleValue();
385 break;
387 m_line.scored_candidates = cell.getDoubleValue();
388 break;
389 case Columns::poisson:
390 m_line.poisson = cell.getDoubleValue();
391 break;
393 m_line.sage_discriminant_score = cell.getDoubleValue();
394 break;
396 m_line.posterior_error = cell.getDoubleValue();
397 break;
399 m_line.spectrum_q = cell.getDoubleValue();
400 break;
402 m_line.peptide_q = cell.getDoubleValue();
403 break;
405 m_line.protein_q = cell.getDoubleValue();
406 break;
408 m_line.ms2_intensity = cell.getDoubleValue();
409 break;
410 default:
411 qDebug() << "m_line.calcmass=" << m_line.calcmass;
413 QObject::tr("column type %1 not implemented").arg((std::uint8_t)column_type));
414 break;
415 }
416
417 /*
418
419 2333 TMISDSDYTEFENFTK
420 GRMZM2G018197_P01;GRMZM2G068952_P01;GRMZM5G822976_P01 3
421 20120906_balliau_extract_1_A01_urnb-1.mzML controllerType=0
422 controllerNumber=1 scan=12542 1 1 1926.8225 1926.8193 2 16 0 0
423 0.0 1.6471838 1.9796097 54.06803492297634 28.049970383419556 0.0 38.192993
424 0.76385987 0.7671368 0.0032769442 0.0 0.0 0.0 16 2 14 0.875 32.54396 380
425 -13.375352220427656 1.1570586 -34.13482 0.00016041065 0.00022231363
426 0.00040124074 1271951.1
427 */
428 }
430}
431
432void
434{
435 m_columnNumber = 0;
436 msp_peptide = nullptr;
437 m_proteinList.clear();
438 m_line = Line();
439}
440
441void
445void
446SageTsvHandler::startSheet(const QString &sheet_name [[maybe_unused]])
447{
448 m_columnNumber = 0;
449 m_lineNumber = 0;
450 mp_monitor->setStatus(QObject::tr("reading Sage TSV file"));
451
452 if(mp_monitor->shouldIstop())
453 {
454 throw pappso::ExceptionInterrupted(QObject::tr("Sage TSV data reading process interrupted"));
455 }
456}
457
458void
459SageTsvHandler::parsePeptide(const QString &peptide_str)
460{
461 qDebug();
462 QString peptide_str_verif = peptide_str;
463 // fixed modifications :
465 {
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()));
470 }
471 // variable modifications :
473 {
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()));
478 }
479
480 qDebug() << peptide_str_verif;
481 // LPMFGC[+57.0216]NDATQVYK
483 qDebug();
484 // variable modifications :
485 /*
486 setVariableModifications(peptide_sp,
487 peptide_line.peptide_string_list.at(6));
488*/
489 qDebug() << msp_peptide.get()->toProForma();
490}
491
492
493void
494SageTsvHandler::parseProteins(const QString &proteins_str)
495{
496 m_proteinList.clear();
497 m_proteinList = proteins_str.split(";");
498 for(QString accession : m_proteinList)
499 {
500
501 PsmProtein psm_protein;
502 psm_protein.protein_sp = std::make_shared<pappso::Protein>(accession, "");
503 psm_protein.isTarget = true;
504 if(accession.startsWith(m_decoyTag))
505 {
506 psm_protein.isTarget = false;
507 }
508
509 m_psmProteinMap.insert(psm_protein);
510 }
511}
512
513bool
514SageTsvHandler::parseScanNrColumn(const QString &spectrum_string_id)
515{
516 m_spectrumNativeId = spectrum_string_id;
517 qDebug() << spectrum_string_id;
518 m_scanNumber = 0;
519 bool is_ok = false;
520 m_scanNumberIsOk = false;
521 // controllerType=0 controllerNumber=1 scan=176056
522 if(mp_currentSample->name.endsWith(".d"))
523 { // assume this is a Bruker's timTOF sample
524 // 200ngHeLaPASEF_2min_compressed.d 2005
525 std::size_t precursor_number = spectrum_string_id.toULongLong(&is_ok);
526 if(is_ok)
527 {
528 // precursor=2006 idxms2=4011
529 m_scanNumberIsOk = is_ok;
530 m_spectrumIndex = precursor_number * 2 + 1;
531 m_spectrumNativeId = QString("precursor=%1 idxms2=%2")
532 .arg(precursor_number + 1)
533 .arg(precursor_number * 2 + 1);
534 }
535 }
536
537 if(!is_ok)
538 {
539 QStringList scan_list = spectrum_string_id.split("scan=");
540 if(scan_list.size() == 2)
541 {
542 // we bet that there is a scan number, easy to parse
543 m_scanNumber = scan_list.at(1).toULongLong(&is_ok);
544 m_scanNumberIsOk = is_ok;
545 if(m_scanNumber > 0)
547 }
548 if(is_ok == false)
549 {
550 ;
551 QStringList scan_list = spectrum_string_id.split(QRegularExpression("[^\\d]"));
552 if(scan_list.size() == 2)
553 {
554 m_scanNumber = scan_list.at(0).toULongLong(&is_ok);
555 m_scanNumberIsOk = is_ok;
556 if(m_scanNumber > 0)
558 }
559 /*
560 if(msp_previousMsrun != msp_msrun)
561 {
562 mp_monitor->setStatus(
563 QObject::tr("Reading mz data file %1").arg(msp_msrun.get()->getFileName()));
564 msp_previousMsrun = msp_msrun;
565 }
566
567 pappso::MsRunReader *msrunreader_p = msp_msrun.get()->getMsRunReaderSPtr().get();
568 if(msrunreader_p->getMsRunId()->getMsDataFormat() == pappso::MsDataFormat::brukerTims)
569 {
570 m_spectrumIndex = spectrum_string_id.toInt() * 2 - 1;
571 }
572 else
573 {
574 m_spectrumIndex =
575 msrunreader_p->spectrumStringIdentifier2SpectrumIndex(spectrum_string_id);
576 }*/
577 }
578 }
579 qDebug() << spectrum_string_id;
580 return is_ok;
581}
582
583void
584SageTsvHandler::parseMsRunFilename(const QString &msrun_filename)
585{
586
587
588 // find the sample :
589 auto it_insert = m_sampleMap.insert({msrun_filename, {}});
590 mp_currentSample = &(it_insert.first->second);
591 if(it_insert.second)
592 {
593 // new sample
594 it_insert.first->second.name = msrun_filename;
595 QCborMap ms_file;
596 QCborMap identification_file;
597
598 it_insert.first->second.cbor_core_sample.insert(QString("name"),
599 QFileInfo(msrun_filename).baseName());
600
601 // identification_file_list
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);
607
608
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);
611 }
612
613 /*
614 msp_msrun = m_sageReader.getSageFileReader().getMsRunSpWithFileName(msrun_filename);
615 qDebug() << msp_msrun.get()->getFileName();
616
617 msp_identificationSageJsonFileSp =
618 m_sageReader.getSageFileReader().getIdentificationSageJsonFileSpWithFileName(msrun_filename);
619
620 mp_identificationGroup =
621 m_sageReader.getSageFileReader().getIdentificationGroupPtrWithFileName(msrun_filename);
622 qDebug() << msp_msrun.get()->getFileName();
623 */
624}
625
626void
628{
629 qDebug();
630
631 for(const QString &accession : m_proteinList)
632 {
633 PsmProtein psm_protein;
634 psm_protein.protein_sp = std::make_shared<pappso::Protein>(accession, "");
635
636 QCborMap sage_eval;
637 sage_eval.insert(QString("protein_q"), m_line.protein_q);
638
639 auto it = m_psmProteinMap.insert(psm_protein);
640 it.first->second.cborEval.insert(QString("sage"), sage_eval);
641 }
642 /*
643 PeptideEvidence pe(msp_msrun.get(), m_spectrumIndex, true);
644 pe.setCharge(m_line.charge);
645 pe.setChecked(true);
646 pe.setExperimentalMass(m_line.expmass);
647 pe.setPeptideXtpSp(msp_peptide);
648 pe.setIdentificationDataSource(msp_identificationSageJsonFileSp.get());
649 pe.setIdentificationEngine(m_identificationEngine);
650 pe.setRetentionTime(m_line.rt);
651 pe.setParam(PeptideEvidenceParam::tandem_hyperscore, m_line.hyperscore);
652 pe.setParam(PeptideEvidenceParam::sage_sage_discriminant_score,
653 m_line.sage_discriminant_score);
654 pe.setParam(PeptideEvidenceParam::sage_peptide_q, m_line.peptide_q);
655 pe.setParam(PeptideEvidenceParam::sage_posterior_error, m_line.posterior_error);
656 pe.setParam(PeptideEvidenceParam::sage_spectrum_q, m_line.spectrum_q);
657 pe.setParam(PeptideEvidenceParam::sage_predicted_rt, m_line.predicted_rt);
658 pe.setParam(PeptideEvidenceParam::sage_isotope_error, m_line.isotope_error);
659
660
661 PeptideMatch peptide_match;
662 // peptide_match.setStart(mz_peptide_evidence.start);
663 peptide_match.setPeptideEvidenceSp(
664 msp_identificationSageJsonFileSp.get()->getPeptideEvidenceStore().getInstance(&pe));
665 */
666
667 // find the scan in sample
668 auto it_insert = mp_currentSample->scan_map.insert({m_spectrumNativeId, Scan()});
669 Scan *current_cbor_scan_p = &(it_insert.first->second);
670 if(it_insert.second)
671 {
672 // new scan
673 QCborMap &scan_id = it_insert.first->second.cbor_id;
675 {
676 scan_id.insert(QString("index"), (qint64)m_spectrumIndex);
677 if(m_scanNumber > 0)
678 scan_id.insert(QString("scan"), (qint64)m_scanNumber);
679 }
680 scan_id.insert(QString("native_id"), m_spectrumNativeId);
681
682 QCborMap &scan_ms2 = it_insert.first->second.cbor_ms2;
683 scan_ms2.insert(QString("rt"), m_line.rt);
684
685 QCborMap &scan_precursor = it_insert.first->second.cbor_precursor;
686 scan_precursor.insert(QString("z"), m_line.charge);
687 double mh = m_line.expmass + MHPLUS;
688 scan_precursor.insert(QString("mh"), mh);
689 double exp_mz = (m_line.expmass + (MHPLUS * m_line.charge)) / m_line.charge;
690 scan_precursor.insert(QString("mz"), exp_mz);
691 }
692
693 Psm one_psm;
694 one_psm.peptide_sequence_li = msp_peptide.get()->getSequenceLi();
695 one_psm.proforma = msp_peptide.get()->toProForma();
696 one_psm.protein_list = m_proteinList;
697
698
699 one_psm.cbor_eval.insert(QString("aligned_rt"), m_line.aligned_rt);
700 one_psm.cbor_eval.insert(QString("calcmass"), m_line.calcmass);
701 one_psm.cbor_eval.insert(QString("delta_best"), m_line.delta_best);
702 one_psm.cbor_eval.insert(QString("delta_mobility"), m_line.delta_mobility);
703 one_psm.cbor_eval.insert(QString("delta_next"), m_line.delta_next);
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);
706 one_psm.cbor_eval.insert(QString("hyperscore"), m_line.hyperscore);
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);
709 one_psm.cbor_eval.insert(QString("label"), m_line.label);
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);
718 one_psm.cbor_eval.insert(QString("peptide_q"), m_line.peptide_q);
719 one_psm.cbor_eval.insert(QString("poisson"), m_line.poisson);
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);
724 one_psm.cbor_eval.insert(QString("protein_q"), m_line.protein_q);
725 one_psm.cbor_eval.insert(QString("rank"), m_line.rank);
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);
729 one_psm.cbor_eval.insert(QString("spectrum_q"), m_line.spectrum_q);
730
731 current_cbor_scan_p->psm_list.emplace_back(one_psm);
732
733
734 std::size_t progress = m_lineNumber / 10000;
735 if(progress > m_progressIndex)
736 {
737 if(mp_monitor->shouldIstop())
738 {
740 QObject::tr("Sage TSV data reading process interrupted"));
741 }
742 m_progressIndex = progress;
743 mp_monitor->setStatus(QString("%1K ").arg(m_progressIndex * 10));
744 }
745}
746
747void
749{
750 m_sageReader.getCborStreamWriter().startMap();
751 m_sageReader.getCborStreamWriter().append("name");
752 one_sample.cbor_core_sample.value("name").toCbor(m_sageReader.getCborStreamWriter());
753
754 m_sageReader.getCborStreamWriter().append("identification_file_list");
755 one_sample.cbor_core_sample.value("identification_file_list")
756 .toCbor(m_sageReader.getCborStreamWriter());
757
758
759 m_sageReader.getCborStreamWriter().append("peaklist_file");
760 one_sample.cbor_core_sample.value("peaklist_file").toCbor(m_sageReader.getCborStreamWriter());
761 //"scan_list": [
762
763 m_sageReader.getCborStreamWriter().append("scan_list");
764 m_sageReader.getCborStreamWriter().startArray(one_sample.scan_map.size());
765 for(auto &it_scan : one_sample.scan_map)
766 {
767 writeScan(it_scan.second);
768 }
769 m_sageReader.getCborStreamWriter().endArray();
770
771
772 m_sageReader.getCborStreamWriter().endMap();
773}
774
775void
777{
778 m_sageReader.getCborStreamWriter().startMap();
779 m_sageReader.getCborStreamWriter().append("id");
780 QCborValue(one_scan.cbor_id).toCbor(m_sageReader.getCborStreamWriter());
781 m_sageReader.getCborStreamWriter().append("precursor");
782 QCborValue(one_scan.cbor_precursor).toCbor(m_sageReader.getCborStreamWriter());
783 m_sageReader.getCborStreamWriter().append("ms2");
784 QCborValue(one_scan.cbor_ms2).toCbor(m_sageReader.getCborStreamWriter());
785
786 m_sageReader.getCborStreamWriter().append("psm_list");
787 m_sageReader.getCborStreamWriter().startArray(one_scan.psm_list.size());
788 for(auto &it_psm : one_scan.psm_list)
789 {
790 writePsm(it_psm);
791 }
792 m_sageReader.getCborStreamWriter().endArray();
793
794 m_sageReader.getCborStreamWriter().endMap();
795}
796
797void
799{
800 m_sageReader.getCborStreamWriter().startMap();
801 m_sageReader.getCborStreamWriter().append("proforma");
802 m_sageReader.getCborStreamWriter().append(one_psm.proforma);
803 m_sageReader.getCborStreamWriter().append("protein_list");
804
805 QCborArray cbor_protein_list;
806 for(const QString &accession : one_psm.protein_list)
807 {
808 // qWarning() << "accession=" << accession;
809 QCborMap cbor_protein;
810 cbor_protein.insert(QString("accession"), accession);
811
812
813 // start/end positions
814 QString protein_sequence =
815 QString(m_psmProteinMap.getByAccession(accession).protein_sp.get()->getSequence())
816 .replace("L", "I");
817 int position = protein_sequence.indexOf(one_psm.peptide_sequence_li);
818
819 QCborArray positions;
820 while(position >= 0)
821 {
822 positions.push_back(position);
823 position = protein_sequence.indexOf(one_psm.peptide_sequence_li, position + 1);
824 }
825
826 cbor_protein.insert(QString("positions"), positions);
827
828 cbor_protein_list.append(cbor_protein);
829 }
830
831
832 QCborValue(cbor_protein_list).toCbor(m_sageReader.getCborStreamWriter());
833
834 m_sageReader.getCborStreamWriter().append("eval");
835 m_sageReader.getCborStreamWriter().startMap();
836 m_sageReader.getCborStreamWriter().append("sage");
837 QCborValue(one_psm.cbor_eval).toCbor(m_sageReader.getCborStreamWriter());
838 m_sageReader.getCborStreamWriter().endMap();
839
840 m_sageReader.getCborStreamWriter().endMap();
841}
842
843
844} // namespace psm
845} // namespace cbor
846} // 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