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

compar specific spectra OK

parent 2089f2a6
No related branches found
No related tags found
No related merge requests found
......@@ -70,6 +70,7 @@ SET(CPP_FILES
input/xpipsaxhandler.cpp
input/xtandemsaxhandler.cpp
output/masschroqml.cpp
output/ods/comparspecificspectrasheet.cpp
output/ods/comparspectrasheet.cpp
output/ods/infosheet.cpp
output/ods/odsexport.cpp
......
......@@ -91,14 +91,21 @@ unsigned int GroupingGroup::countSubgroupPresence(const PeptideMatch * p_peptide
return subgroup_list.size();
}
std::size_t GroupingGroup::countSpecificSampleScan(const ProteinMatch * p_protein_match, ValidationState state) const {
std::size_t GroupingGroup::countSpecificSampleScan(const ProteinMatch * p_protein_match, ValidationState state, const MsRun * p_msrun_id) const {
if (_number_of_subgroup == 1) {
return p_protein_match->countSampleScan(state);
return p_protein_match->countSampleScan(state, p_msrun_id);
}
std::set<size_t> spectrum_list_in;
for (auto && p_peptide_match :p_protein_match->getPeptideMatchList()) {
if (p_peptide_match->getValidationState() >= state) {
spectrum_list_in.insert(p_peptide_match->getHashSampleScan());
if(p_msrun_id == nullptr) {
spectrum_list_in.insert(p_peptide_match->getHashSampleScan());
}
else {
if (p_peptide_match->getMsRunP() == p_msrun_id) {
spectrum_list_in.insert(p_peptide_match->getHashSampleScan());
}
}
}
}
std::set<size_t> spectrum_list_out;
......@@ -119,14 +126,21 @@ std::size_t GroupingGroup::countSpecificSampleScan(const ProteinMatch * p_protei
return count;
}
std::size_t GroupingGroup::countSpecificSequenceLi(const ProteinMatch * p_protein_match, ValidationState state) const {
std::size_t GroupingGroup::countSpecificSequenceLi(const ProteinMatch * p_protein_match, ValidationState state, const MsRun * p_msrun_id) const {
if (_number_of_subgroup == 1) {
return p_protein_match->countUniqueSequenceLi(state);
}
std::set<QString> sequence_list_in;
for (auto && p_peptide_match :p_protein_match->getPeptideMatchList()) {
if (p_peptide_match->getValidationState() >= state) {
sequence_list_in.insert(p_peptide_match->getPeptideXtpSp().get()->getSequenceLi());
if(p_msrun_id == nullptr) {
sequence_list_in.insert(p_peptide_match->getPeptideXtpSp().get()->getSequenceLi());
}
else {
if (p_peptide_match->getMsRunP() == p_msrun_id) {
sequence_list_in.insert(p_peptide_match->getPeptideXtpSp().get()->getSequenceLi());
}
}
}
}
std::set<QString> sequence_list_out;
......
......@@ -28,6 +28,7 @@
#include <vector>
#include <QStringList>
#include "../utils/types.h"
#include "../core/msrun.h"
class ProteinMatch;
class PeptideMatch;
......@@ -45,8 +46,8 @@ public:
unsigned int getGroupNumber() const ;
void add(const ProteinMatch * p_protein_match);
std::size_t countSpecificSampleScan(const ProteinMatch * p_protein_match, ValidationState state) const;
std::size_t countSpecificSequenceLi(const ProteinMatch * p_protein_match, ValidationState state) const;
std::size_t countSpecificSampleScan(const ProteinMatch * p_protein_match, ValidationState state, const MsRun * p_msrun_id=nullptr) const;
std::size_t countSpecificSequenceLi(const ProteinMatch * p_protein_match, ValidationState state, const MsRun * p_msrun_id=nullptr) const;
unsigned int getNumberOfSubgroups() const;
......
/**
* \file output/ods/comparspecificspectrasheet.cpp
* \date 1/5/2017
* \author Olivier Langella
* \brief ODS compar specific spectra sheet
*/
/*******************************************************************************
* Copyright (c) 2017 Olivier Langella <olivier.langella@u-psud.fr>.
*
* This file is part of XTPcpp.
*
* XTPcpp is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* XTPcpp is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with XTPcpp. If not, see <http://www.gnu.org/licenses/>.
*
* Contributors:
* Olivier Langella <olivier.langella@u-psud.fr> - initial API and implementation
******************************************************************************/
#include "comparspecificspectrasheet.h"
#include <tuple>
#include <pappsomspp/utils.h>
#include <QDebug>
ComparSpecificSpectraSheet::ComparSpecificSpectraSheet (OdsExport * p_ods_export, CalcWriterInterface * p_writer, const Project * p_project): _p_project(p_project) {
_p_ods_export = p_ods_export;
_p_writer = p_writer;
p_writer->writeSheet("compar specific spectra");
std::vector<IdentificationGroup *> identification_list = p_project->getIdentificationGroupList();
for (IdentificationGroup * p_ident:identification_list) {
//writeHeaders(p_ident);
writeIdentificationGroup(p_ident);
}
}
void ComparSpecificSpectraSheet::writeHeaders(IdentificationGroup * p_ident) {
// Peptide ID Protein ID accession description Sequence Modifs Start Stop MH+ theo
//MS Sample : 20120906_balliau_extract_1_A01_urnb-1
_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();
}
std::sort(_msrun_list.begin(), _msrun_list.end(),
[](MsRunSp & a, MsRunSp & b)
{
return a.get()->getXmlId() < b.get()->getXmlId();
});
_p_writer->writeLine();
_p_writer->writeCell("Group ID");
_p_writer->writeCell("Subgroup ID");
//_p_writer->setCellAnnotation("MS sample name (MS run)");
_p_writer->writeCell("Protein ID");
_p_writer->writeCell("accession");
_p_writer->writeCell("description");
_p_writer->writeCell("Number of proteins");
for (MsRunSp & msrun_sp: _msrun_list) {
_p_writer->writeCell(msrun_sp.get()->getSampleName());
}
}
void ComparSpecificSpectraSheet::writeProteinMatch(const ProteinMatch * p_protein_match) {
qDebug() << "ComparSpecificSpectraSheet::writeProteinMatch begin";
_p_writer->writeLine();
unsigned int group_number = p_protein_match->getGrpProteinSp().get()->getGroupNumber();
unsigned int subgroup_number = p_protein_match->getGrpProteinSp().get()->getSubGroupNumber();
unsigned int rank_number = p_protein_match->getGrpProteinSp().get()->getRank();
_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(pappso::Utils::getLexicalOrderedString(subgroup_number));
_p_ods_export->setEvenOrOddStyle(rank_number, _p_writer);
_p_writer->writeCell(p_protein_match->getGrpProteinSp().get()->getGroupingId());
_p_writer->clearTableCellStyleRef();
_p_writer->writeCell(p_protein_match->getProteinXtpSp().get()->getAccession());
_p_writer->writeCell(p_protein_match->getProteinXtpSp().get()->getDescription());
_p_writer->writeCell(p_protein_match->getGroupingGroupSp().get()->countProteinInSubgroup(subgroup_number));
for (MsRunSp & msrun_sp: _msrun_list) {
_p_writer->writeCell((unsigned int) p_protein_match->getGroupingGroupSp().get()->countSpecificSampleScan(p_protein_match, ValidationState::validAndChecked, msrun_sp.get()));
}
qDebug() << "ComparSpecificSpectraSheet::writeProteinMatch end";
}
void ComparSpecificSpectraSheet::writeIdentificationGroup(IdentificationGroup * p_ident) {
qDebug() << "ComparSpecificSpectraSheet::writeIdentificationGroup begin";
writeHeaders(p_ident);
std::vector<ProteinMatch *> protein_match_list;
for (ProteinMatch * p_protein_match: p_ident->getProteinMatchList()) {
if (p_protein_match->getValidationState() < ValidationState::grouped) continue;
if (p_protein_match->getGrpProteinSp().get()->getRank() == 1) {
protein_match_list.push_back(p_protein_match);
}
}
std::sort(protein_match_list.begin(), protein_match_list.end(),
[](const ProteinMatch * a, const ProteinMatch * b)
{
unsigned int agroup = a->getGrpProteinSp().get()->getGroupNumber();
unsigned int asubgroup = a->getGrpProteinSp().get()->getSubGroupNumber();
unsigned int arank = a->getGrpProteinSp().get()->getRank();
unsigned int bgroup = b->getGrpProteinSp().get()->getGroupNumber();
unsigned int bsubgroup = b->getGrpProteinSp().get()->getSubGroupNumber();
unsigned int brank = b->getGrpProteinSp().get()->getRank();
return std::tie(agroup, asubgroup, arank) < std::tie(bgroup, bsubgroup, brank);
});
for (ProteinMatch * p_protein_match : protein_match_list) {
writeProteinMatch(p_protein_match);
}
_p_writer->writeLine();
_p_writer->writeLine();
qDebug() << "ComparSpecificSpectraSheet::writeIdentificationGroup end";
}
/**
* \file output/ods/comparspecificspectrasheet.h
* \date 1/5/2017
* \author Olivier Langella
* \brief ODS compar specific spectra sheet
*/
/*******************************************************************************
* Copyright (c) 2017 Olivier Langella <olivier.langella@u-psud.fr>.
*
* This file is part of XTPcpp.
*
* XTPcpp is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* XTPcpp is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with XTPcpp. If not, see <http://www.gnu.org/licenses/>.
*
* Contributors:
* Olivier Langella <olivier.langella@u-psud.fr> - initial API and implementation
******************************************************************************/
#ifndef COMPARSPECIFICSPECTRASHEET_H
#define COMPARSPECIFICSPECTRASHEET_H
#include "../../core/project.h"
#include <odsstream/calcwriterinterface.h>
#include "../../core/proteinmatch.h"
#include "odsexport.h"
class ComparSpecificSpectraSheet
{
public :
ComparSpecificSpectraSheet (OdsExport * p_ods_export, CalcWriterInterface * p_writer, const Project * p_project);
private :
void writeIdentificationGroup(IdentificationGroup * p_ident);
void writeHeaders(IdentificationGroup * p_ident);
void writeProteinMatch(const ProteinMatch * p_protein_match);
private :
OdsExport * _p_ods_export;
const Project * _p_project;
CalcWriterInterface * _p_writer;
std::vector<MsRunSp> _msrun_list;
};
#endif // COMPARSPECIFICSPECTRASHEET_H
......@@ -34,6 +34,7 @@
#include "spectrasheet.h"
#include "peptidepossheet.h"
#include "comparspectrasheet.h"
#include "comparspecificspectrasheet.h"
#include "infosheet.h"
#include <QSettings>
......@@ -78,4 +79,7 @@ void OdsExport::write(CalcWriterInterface * p_writer) {
if (settings.value("export_ods/comparspectra", "true").toBool()) {
ComparSpectraSheet(this, p_writer, _p_project);
}
if (settings.value("export_ods/comparspecificspectra", "true").toBool()) {
ComparSpecificSpectraSheet(this, p_writer, _p_project);
}
}
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