Skip to content
Snippets Groups Projects
Commit 1e940072 authored by Olivier Langella's avatar Olivier Langella
Browse files

WIP: writing PTM islands

parent 0d3cb97c
No related branches found
No related tags found
No related merge requests found
......@@ -29,5 +29,157 @@
#include "ptmislandsheet.h"
#include "../../core/identificationgroup.h"
#include <pappsomspp/utils.h>
#include <pappsomspp/pappsoexception.h>
PtmIslandSheet::PtmIslandSheet (OdsExport * p_ods_export, CalcWriterInterface * p_writer, const Project * p_project): _p_project(p_project) {
_p_writer = p_writer;
_p_ods_export = p_ods_export;
p_writer->writeSheet("PTM islands");
std::vector<IdentificationGroup *> identification_list = p_project->getIdentificationGroupList();
for (IdentificationGroup * p_ident:identification_list) {
//writeHeaders(p_ident);
writeIdentificationGroup(p_ident);
}
}
void PtmIslandSheet::writeCellHeader(PtmIslandListColumn column) {
qDebug() << "PtmIslandSheet::writeCellHeader begin " << (std::int8_t) column;
_p_writer->setCellAnnotation(PtmIslandTableModel::getDescription(column));
_p_writer->writeCell(PtmIslandTableModel::getTitle(column));
qDebug() << "PtmIslandSheet::writeCellHeader end" ;
}
void PtmIslandSheet::writeHeaders(IdentificationGroup * p_ident) {
//Group ID Sub-group ID PhosphoIsland ID Description MW Phosphosites positions Spectra Uniques number of proteins sharing these phosphosites
//a1 a1.a1 a1.a1.a1 AT1G01100.1 | Symbols: | 60S acidic ribosomal protein family | chr1:50284-50954 REVERSE LENGTH=112 11,1000003814697 102 435 3 6
const std::vector<MsRunSp> msrun_list = p_ident->getMsRunSpList();
if (msrun_list.size() == 1) {
_p_writer->writeCell("sample");
_p_writer->writeLine();
_p_writer->writeCell(msrun_list[0].get()->getSampleName());
_p_writer->writeLine();
}
_p_writer->writeLine();
_p_writer->setCellAnnotation("PTM group number");
_p_writer->writeCell("PTM group ID");
_p_writer->setCellAnnotation("PTM subgroup number");
_p_writer->writeCell("PTM sub-group ID");
writeCellHeader(PtmIslandListColumn::ptm_island_id);
//_p_writer->PtmIslandListColumn("unique protein identifier within this grouping experiment");
//_p_writer->writeCell("Protein ID");
writeCellHeader(PtmIslandTableModel::accession);
writeCellHeader(PtmIslandTableModel::description);
_p_writer->setCellAnnotation("computed molecular weight for this protein (sum of amino acid masses)");
_p_writer->writeCell("MW");
writeCellHeader(PtmIslandListColumn::ptm_position_list);
writeCellHeader(PtmIslandListColumn::spectrum);
//_p_writer->setCellAnnotation("number of scans (spectra) attributed to this protein");
// _p_writer->writeCell("Spectra");
writeCellHeader(PtmIslandListColumn::sequence);
_p_writer->setCellAnnotation("Number of proteins sharing this PTM island");
_p_writer->writeCell("Number of proteins");
}
void PtmIslandSheet::writeIdentificationGroup(IdentificationGroup * p_ident) {
_p_ptm_grouping_experiment = p_ident->getPtmGroupingExperiment();
if (_p_ptm_grouping_experiment = nullptr) {
throw pappso::PappsoException(QObject::tr("Error writing PTM island :\n_p_ptm_grouping_experiment = nullptr"));
}
writeHeaders(p_ident);
std::vector<PtmIslandSp> ptm_island_list = _p_ptm_grouping_experiment->getPtmIslandList();
std::sort(ptm_island_list.begin(), ptm_island_list.end(),
[](PtmIslandSp & a, PtmIslandSp & b)
{
return a.get()->getGroupingId() < b.get()->getGroupingId();
});
for (auto & ptm_island:ptm_island_list) {
writeOnePtmIsland(ptm_island);
}
_p_writer->writeLine();
}
void PtmIslandSheet::writeOnePtmIsland(PtmIslandSp & sp_ptm_island) {
try {
_p_writer->writeLine();
qDebug() << "PtmIslandSheet::writeOnePtmIsland begin" ;
ValidationState validation_state = ValidationState::validAndChecked;
//pappso::GrpProtein * p_grp_protein = p_protein_match->getGrpProteinSp().get();
ProteinXtp * p_protein = sp_ptm_island.get()->getProteinMatch()->getProteinXtpSp().get();
unsigned int group_number = sp_ptm_island.get()->->getGroupNumber();
unsigned int subgroup_number = p_grp_protein->getSubGroupNumber();
_p_ods_export->setEvenOrOddStyle(group_number, _p_writer);
_p_writer->writeCell(pappso::Utils::getLexicalOrderedString(group_number));
_p_ods_export->setEvenOrOddStyle(subgroup_number, _p_writer);
_p_writer->writeCell(QString("%1.%2").arg(pappso::Utils::getLexicalOrderedString(group_number)).arg(pappso::Utils::getLexicalOrderedString(subgroup_number)));
_p_writer->clearTableCellStyleRef();
_p_writer->writeCell(p_grp_protein->getGroupingId());
_p_writer->writeCell(p_protein->getAccession());
_p_writer->writeCell(p_protein->getDescription());
_p_writer->writeCell(p_protein_match->getLogEvalue());
// _p_writer->writeCell("Coverage");
_p_writer->writeCellPercentage(p_protein_match->getCoverage());
// _p_writer->writeCell("MW");
_p_writer->writeCell(p_protein->getMass());
_p_writer->writeCell(p_protein->size());
// _p_writer->writeCell("Spectra");
_p_writer->writeCell(p_protein_match->countSampleScan(validation_state));
// _p_writer->writeCell("Specific");
_p_writer->writeCell((unsigned int) p_group->countSpecificSampleScan(p_protein_match, validation_state));
// _p_writer->writeCell("Uniques");
_p_writer->writeCell((unsigned int) p_protein_match->countSequenceLi(validation_state));
// _p_writer->writeCell("Specific uniques");
_p_writer->writeCell((unsigned int) p_group->countSpecificSequenceLi(p_protein_match, validation_state));
_p_writer->writeCell(p_protein_match->countPeptideMassCharge(validation_state));
qDebug() << "ProteinSheet::writeOneProtein tryptic" ;
_p_writer->writeCell(p_protein->countTrypticPeptidesForPAI());
// _p_writer->writeCell("PAI");
// _p_writer->writeCell(new Double((float) hashProt
// .getTotalHashSampleScan() / prot.get_PAI_count()));
_p_writer->writeCell(p_protein_match->getPAI());
// _p_writer->writeCell(match.getPAI());//this is the same
/*
* ancien PAI _p_writer->writeCell(new Double((float)
* top.get_spectra_numbers_to(sample) /
* top.get_protein_match().get_PAI_count()));
*/
_p_writer->writeCell(p_protein_match->getEmPAI());
//_p_writer->writeCell(p_protein_match->getSpectralCountAI());
// _p_writer->writeCell("Redundancy");
_p_writer->writeCell(p_group->countProteinInSubgroup(p_grp_protein->getSubGroupNumber()));
//number of MS sample
_p_writer->writeCell(p_protein_match->countDistinctMsSamples(validation_state));
qDebug() << "ProteinSheet::writeOneProtein end" ;
}
catch (pappso::PappsoException error) {
throw pappso::PappsoException(QObject::tr("Error writing protein %1 :\n%2").arg(p_protein_match->getProteinXtpSp().get()->getAccession()).arg(error.qwhat()));
}
}
......@@ -30,8 +30,28 @@
#ifndef PTMISLANDSHEET_H
#define PTMISLANDSHEET_H
#include "../../core/project.h"
#include <odsstream/calcwriterinterface.h>
#include "../../grouping/ptm/ptmisland.h"
#include "odsexport.h"
#include "../../gui/ptm_island_list_view/ptmislandtablemodel.h"
class PtmIslandSheet
{
public :
PtmIslandSheet (OdsExport * p_ods_export, CalcWriterInterface * p_writer, const Project * p_project);
private :
void writeIdentificationGroup(IdentificationGroup * p_ident);
void writeHeaders(IdentificationGroup * p_ident);
void writeOnePtmIsland(PtmIslandSp & sp_ptm_island);
protected:
void writeCellHeader(PtmIslandListColumn column);
private :
OdsExport * _p_ods_export;
const Project * _p_project;
CalcWriterInterface * _p_writer;
const PtmGroupingExperiment * _p_ptm_grouping_experiment;
};
#endif // PTMISLANDSHEET_H
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment