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

compar spectra is OK

parent 638d5fb5
No related branches found
No related tags found
No related merge requests found
......@@ -186,11 +186,18 @@ void ProteinMatch::countPeptideMassSample(std::vector<size_t> & count_peptide_ma
}
}
unsigned int ProteinMatch::countSampleScan(ValidationState state) const {
unsigned int ProteinMatch::countSampleScan(ValidationState state, const MsRun * p_msrun_id) const {
std::vector<std::size_t> count_sample_scan;
for (auto & p_peptide_match : _peptide_match_list) {
if (p_peptide_match->getValidationState() >= state) {
count_sample_scan.push_back(p_peptide_match->getHashSampleScan());
if(p_msrun_id == nullptr) {
count_sample_scan.push_back(p_peptide_match->getHashSampleScan());
}
else {
if (p_peptide_match->getMsRunP() == p_msrun_id) {
count_sample_scan.push_back(p_peptide_match->getHashSampleScan());
}
}
}
}
std::sort(count_sample_scan.begin(), count_sample_scan.end());
......@@ -310,9 +317,9 @@ pappso::pappso_double ProteinMatch::getEvalue(const MsRun * sp_msrun_id) const {
pappso::pappso_double ProteinMatch::getPAI(const MsRun * sp_msrun_id) const {
try {
pappso::pappso_double PAI = (pappso::pappso_double) countPeptideMassCharge(ValidationState::validAndChecked ,sp_msrun_id) / (pappso::pappso_double) _protein_sp.get()->countTrypticPeptidesForPAI();
return PAI;
pappso::pappso_double PAI = (pappso::pappso_double) countPeptideMassCharge(ValidationState::validAndChecked ,sp_msrun_id) / (pappso::pappso_double) _protein_sp.get()->countTrypticPeptidesForPAI();
return PAI;
}
catch (pappso::PappsoException error) {
throw pappso::PappsoException(QObject::tr("Error computing PAI for protein %1 :\n%2").arg(this->getProteinXtpSp().get()->getAccession()).arg(error.qwhat()));
......
......@@ -85,7 +85,7 @@ public:
/** @brief count distinct sample + scans implied in this protein identification
*/
unsigned int countSampleScan(ValidationState state) const;
unsigned int countSampleScan(ValidationState state, const MsRun * p_msrun_id=nullptr) const;
/** @brief count peptide (peptide+mass+sample)
*/
......
......@@ -75,7 +75,7 @@ void ComparSpectraSheet::writeHeaders(IdentificationGroup * p_ident) {
_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());
}
......@@ -83,8 +83,8 @@ void ComparSpectraSheet::writeHeaders(IdentificationGroup * p_ident) {
}
void ComparSpectraSheet::writeBestPeptideMatch(const ProteinMatch * p_protein_match,const PeptideMatch * p_peptide_match) {
void ComparSpectraSheet::writeProteinMatch(const ProteinMatch * p_protein_match) {
qDebug() << "ComparSpectraSheet::writeProteinMatch begin";
_p_writer->writeLine();
......@@ -101,14 +101,15 @@ void ComparSpectraSheet::writeBestPeptideMatch(const ProteinMatch * p_protein_ma
_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(p_protein_match->countSampleScan(ValidationState::));
_p_writer->writeCell(p_protein_match->countSampleScan(ValidationState::validAndChecked, msrun_sp.get()));
}
qDebug() << "ComparSpectraSheet::writeProteinMatch end";
}
......@@ -140,52 +141,7 @@ void ComparSpectraSheet::writeIdentificationGroup(IdentificationGroup * p_ident)
});
for (ProteinMatch * p_protein_match : protein_match_list) {
std::vector<PeptideMatch *> peptide_match_list;
for (auto & peptide_match: p_protein_match->getPeptideMatchList()) {
if (peptide_match->getValidationState() < ValidationState::grouped) continue;
peptide_match_list.push_back(peptide_match);
}
std::sort(peptide_match_list.begin(), peptide_match_list.end(),
[](const PeptideMatch * a, const PeptideMatch * b)
{
unsigned int arank = a->getGrpPeptideSp().get()->getRank();
unsigned int aposition = a->getStart();
unsigned int brank = b->getGrpPeptideSp().get()->getRank();
unsigned int bposition = b->getStart();
return std::tie(arank, aposition) < std::tie(brank, bposition);
});
const PeptideMatch * p_best_peptide_match = nullptr;
for (auto & peptide_match:peptide_match_list) {
if (p_best_peptide_match == nullptr) {
p_best_peptide_match = peptide_match;
}
//change spectra :
unsigned int arank = p_best_peptide_match->getGrpPeptideSp().get()->getRank();
unsigned int aposition = p_best_peptide_match->getStart();
unsigned int brank = peptide_match->getGrpPeptideSp().get()->getRank();
unsigned int bposition = peptide_match->getStart();
if (std::tie(arank, aposition) != std::tie(brank, bposition)) {
//write p_best_peptide_match
writeBestPeptideMatch(p_protein_match, p_best_peptide_match);
p_best_peptide_match = peptide_match;
}
else {
if (p_best_peptide_match->getEvalue()> peptide_match->getEvalue()) {
p_best_peptide_match = peptide_match;
}
}
}
if (p_best_peptide_match != nullptr) {
writeBestPeptideMatch(p_protein_match, p_best_peptide_match);
}
writeProteinMatch(p_protein_match);
}
_p_writer->writeLine();
_p_writer->writeLine();
......
......@@ -42,7 +42,7 @@ public :
private :
void writeIdentificationGroup(IdentificationGroup * p_ident);
void writeHeaders(IdentificationGroup * p_ident);
void writeBestPeptideMatch(const ProteinMatch * p_protein_match, const PeptideMatch * p_peptide_match);
void writeProteinMatch(const ProteinMatch * p_protein_match);
private :
OdsExport * _p_ods_export;
......
......@@ -33,6 +33,7 @@
#include "peptidesheet.h"
#include "spectrasheet.h"
#include "peptidepossheet.h"
#include "comparspectrasheet.h"
#include "infosheet.h"
#include <QSettings>
......@@ -74,4 +75,7 @@ void OdsExport::write(CalcWriterInterface * p_writer) {
if (settings.value("export_ods/peptidepos", "true").toBool()) {
PeptidePosSheet(this, p_writer, _p_project);
}
if (settings.value("export_ods/comparspectra", "true").toBool()) {
ComparSpectraSheet(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