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

preparing new MassChroqR spectral count output

parent ea0be59e
No related branches found
No related tags found
No related merge requests found
......@@ -101,6 +101,8 @@ SET(CPP_FILES
input/xtandemparamsaxhandler.cpp
input/xtandemsaxhandler.cpp
input/xtpxpipsaxhandler.cpp
output/mcqr/mcqrscprotein.cpp
output/mcqr/mcqrscpeptide.cpp
output/ods/ptm/ptmislandsheet.cpp
output/ods/ptm/ptmspectrasheet.cpp
output/ods/comparbasesheet.cpp
......
......@@ -357,8 +357,8 @@ void WorkerThread::doWritingMcqrSpectralCountFile(QString filename, ProjectSp pr
QTextStream * p_outputStream = new QTextStream(&outFile);
TsvOutputStream * p_writer = new TsvOutputStream(*p_outputStream);
p_writer->setNoSheetName(true);
McqrSpectralCount spectra_sheet(p_writer, project_sp.get());
spectra_sheet.writeSheet();
McqrSpectralCount spectra_sheet(project_sp.get());
spectra_sheet.write(p_writer, _p_work_monitor);
p_writer->close();
delete p_writer;
......
/**
* \file /output/mcqr/mcqrscpeptide.cpp
* \date 28/3/2018
* \author Olivier Langella
* \brief write peptide sheet in MassChroqR format
*/
/*******************************************************************************
* Copyright (c) 2018 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 "mcqrscpeptide.h"
#include <pappsomspp/pappsoexception.h>
McqRscPeptide::McqRscPeptide (CalcWriterInterface * p_writer, const Project * p_project): _p_project(p_project) {
_p_writer = p_writer;
}
void McqRscPeptide::writeSheet () {
_p_writer->writeSheet("peptide_sc");
std::vector<IdentificationGroup *> identification_list = _p_project->getIdentificationGroupList();
if (identification_list.size() > 1) {
throw pappso::PappsoException(QObject::tr("error : cannot write MassChroqR spectral count file in individual mode"));
}
for (IdentificationGroup * p_ident:identification_list) {
//writeHeaders(p_ident);
writeIdentificationGroup(p_ident);
}
}
void McqRscPeptide::writeHeaders(IdentificationGroup * p_ident) {
//ProteinID, msrun, msrunfile, accession, description, q
_p_writer->writeCell("peptide");
_p_writer->writeCell("label");
_p_writer->writeCell("msrun");
_p_writer->writeCell("msrunfile");
_p_writer->writeCell("sequence");
_p_writer->writeCell("sc");
//_p_writer->writeCell(p_protein_match->countSampleScan(state, p_msrun));
}
void McqRscPeptide::writeIdentificationGroup(IdentificationGroup * p_ident) {
_ms_run_sp_list = p_ident->getMsRunSpList();
writeHeaders(p_ident);
for (const std::pair<unsigned int, GroupingGroupSp> & group_pair : p_ident->getGroupStore().getGroupMap()) {
std::vector<const ProteinMatch *> protein_match_list = group_pair.second.get()->getProteinMatchList();
std::sort(protein_match_list.begin(), protein_match_list.end(),
[](const ProteinMatch * a, const ProteinMatch * b)
{
return a->getGrpProteinSp().get()->getSubGroupNumber() < b->getGrpProteinSp().get()->getSubGroupNumber();
});
for (auto & protein_match:protein_match_list) {
writeOneProtein(group_pair.second.get(), protein_match);
}
}
_p_writer->writeLine();
}
void McqRscPeptide::writeOneProtein(const GroupingGroup * p_group, const ProteinMatch * p_protein_match) {
try {
qDebug() << "McqRscPeptide::writeOneProtein begin" ;
ValidationState validation_state = ValidationState::grouped;
pappso::GrpProtein * p_grp_protein = p_protein_match->getGrpProteinSp().get();
ProteinXtp * p_protein = p_protein_match->getProteinXtpSp().get();
//for (MsRunSp & msrun_sp : _ms_run_sp_list) {
std::set<QString> peptide_list;
for (PeptideMatch & peptide_match : p_protein_match->getPeptideMatchList(validation_state)) {
peptide_list.insert( peptide_match.getPeptideEvidence()->getGrpPeptideSp().get()->getGroupingId());
}
for (const QString & peptide_str :peptide_list) {
_p_writer->writeLine();
_p_writer->writeCell(peptide_str);
_p_writer->writeCell(p_grp_protein->getGroupingId());
_p_writer->writeCell(p_protein->getAccession());
_p_writer->writeCell(p_protein->getDescription());
}
qDebug() << "McqRscPeptide::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()));
}
}
/**
* \file /output/mcqr/mcqrscpeptide.h
* \date 28/3/2018
* \author Olivier Langella
* \brief write peptide sheet in MassChroqR format
*/
/*******************************************************************************
* Copyright (c) 2018 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 MCQRSCPEPTIDE_H
#define MCQRSCPEPTIDE_H
#include <odsstream/calcwriterinterface.h>
#include "../../core/project.h"
class McqRscPeptide
{
public :
McqRscPeptide (CalcWriterInterface * p_writer, const Project * p_project);
void writeSheet();
private :
void writeIdentificationGroup(IdentificationGroup * p_ident);
void writeHeaders(IdentificationGroup * p_ident);
void writeOneProtein(const GroupingGroup * p_group, const ProteinMatch * p_protein_match);
private :
const Project * _p_project;
CalcWriterInterface * _p_writer;
std::vector<MsRunSp> _ms_run_sp_list;
};
#endif // MCQRSCPEPTIDE_H
/**
* \file /output/mcqr/mcqrscprotein.cpp
* \date 28/3/2018
* \author Olivier Langella
* \brief write protein sheet in MassChroqR format
*/
/*******************************************************************************
* Copyright (c) 2018 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 "mcqrscprotein.h"
#include <pappsomspp/pappsoexception.h>
McqRscProtein::McqRscProtein (CalcWriterInterface * p_writer, const Project * p_project): _p_project(p_project) {
_p_writer = p_writer;
}
void McqRscProtein::writeSheet () {
_p_writer->writeSheet("protein_sc");
std::vector<IdentificationGroup *> identification_list = _p_project->getIdentificationGroupList();
if (identification_list.size() > 1) {
throw pappso::PappsoException(QObject::tr("error : cannot write MassChroqR spectral count file in individual mode"));
}
for (IdentificationGroup * p_ident:identification_list) {
//writeHeaders(p_ident);
writeIdentificationGroup(p_ident);
}
}
void McqRscProtein::writeHeaders(IdentificationGroup * p_ident) {
//ProteinID, msrun, msrunfile, accession, description, q
_p_writer->writeCell("peptide");
_p_writer->writeCell("protein");
_p_writer->writeCell("accession");
_p_writer->writeCell("description");
//_p_writer->writeCell(p_protein_match->countSampleScan(state, p_msrun));
}
void McqRscProtein::writeIdentificationGroup(IdentificationGroup * p_ident) {
_ms_run_sp_list = p_ident->getMsRunSpList();
writeHeaders(p_ident);
for (const std::pair<unsigned int, GroupingGroupSp> & group_pair : p_ident->getGroupStore().getGroupMap()) {
std::vector<const ProteinMatch *> protein_match_list = group_pair.second.get()->getProteinMatchList();
std::sort(protein_match_list.begin(), protein_match_list.end(),
[](const ProteinMatch * a, const ProteinMatch * b)
{
return a->getGrpProteinSp().get()->getSubGroupNumber() < b->getGrpProteinSp().get()->getSubGroupNumber();
});
for (auto & protein_match:protein_match_list) {
writeOneProtein(group_pair.second.get(), protein_match);
}
}
_p_writer->writeLine();
}
void McqRscProtein::writeOneProtein(const GroupingGroup * p_group, const ProteinMatch * p_protein_match) {
try {
qDebug() << "McqRscProtein::writeOneProtein begin" ;
ValidationState validation_state = ValidationState::grouped;
pappso::GrpProtein * p_grp_protein = p_protein_match->getGrpProteinSp().get();
ProteinXtp * p_protein = p_protein_match->getProteinXtpSp().get();
//for (MsRunSp & msrun_sp : _ms_run_sp_list) {
std::set<QString> peptide_list;
for (PeptideMatch & peptide_match : p_protein_match->getPeptideMatchList(validation_state)) {
peptide_list.insert( peptide_match.getPeptideEvidence()->getGrpPeptideSp().get()->getGroupingId());
}
for (const QString & peptide_str :peptide_list) {
_p_writer->writeLine();
_p_writer->writeCell(peptide_str);
_p_writer->writeCell(p_grp_protein->getGroupingId());
_p_writer->writeCell(p_protein->getAccession());
_p_writer->writeCell(p_protein->getDescription());
}
qDebug() << "McqRscProtein::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()));
}
}
/**
* \file /output/mcqr/mcqrscprotein.h
* \date 28/3/2018
* \author Olivier Langella
* \brief write protein sheet in MassChroqR format
*/
/*******************************************************************************
* Copyright (c) 2018 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 MCQRSCPROTEIN_H
#define MCQRSCPROTEIN_H
#include <odsstream/calcwriterinterface.h>
#include "../../core/project.h"
class McqRscProtein
{
public :
McqRscProtein (CalcWriterInterface * p_writer, const Project * p_project);
void writeSheet();
private :
void writeIdentificationGroup(IdentificationGroup * p_ident);
void writeHeaders(IdentificationGroup * p_ident);
void writeOneProtein(const GroupingGroup * p_group, const ProteinMatch * p_protein_match);
private :
const Project * _p_project;
CalcWriterInterface * _p_writer;
std::vector<MsRunSp> _ms_run_sp_list;
};
#endif // MCQRSCPROTEIN_H
......@@ -29,98 +29,21 @@
#include "mcqrspectralcount.h"
#include <pappsomspp/pappsoexception.h>
#include <QSettings>
#include "mcqr/mcqrscpeptide.h"
#include "mcqr/mcqrscprotein.h"
McqrSpectralCount::McqrSpectralCount (CalcWriterInterface * p_writer, const Project * p_project): _p_project(p_project) {
_p_writer = p_writer;
McqrSpectralCount::McqrSpectralCount (const Project * p_project): _p_project(p_project) {
}
void McqrSpectralCount::writeSheet () {
_p_writer->writeSheet("MassChroqR spectral counting");
std::vector<IdentificationGroup *> identification_list = _p_project->getIdentificationGroupList();
if (identification_list.size() > 1) {
throw pappso::PappsoException(QObject::tr("error : cannot write MassChroqR spectral count file in individual mode"));
}
for (IdentificationGroup * p_ident:identification_list) {
//writeHeaders(p_ident);
writeIdentificationGroup(p_ident);
}
}
void McqrSpectralCount::writeHeaders(IdentificationGroup * p_ident) {
//ProteinID, msrun, msrunfile, accession, description, q
_p_writer->writeCell("protein");
_p_writer->writeCell("msrun");
_p_writer->writeCell("msrunfile");
_p_writer->writeCell("accession");
_p_writer->writeCell("description");
_p_writer->writeCell("sc");
//_p_writer->writeCell(p_protein_match->countSampleScan(state, p_msrun));
}
void McqrSpectralCount::writeIdentificationGroup(IdentificationGroup * p_ident) {
_ms_run_sp_list = p_ident->getMsRunSpList();
writeHeaders(p_ident);
for (const std::pair<unsigned int, GroupingGroupSp> & group_pair : p_ident->getGroupStore().getGroupMap()) {
std::vector<const ProteinMatch *> protein_match_list = group_pair.second.get()->getProteinMatchList();
std::sort(protein_match_list.begin(), protein_match_list.end(),
[](const ProteinMatch * a, const ProteinMatch * b)
{
return a->getGrpProteinSp().get()->getSubGroupNumber() < b->getGrpProteinSp().get()->getSubGroupNumber();
});
for (auto & protein_match:protein_match_list) {
writeOneProtein(group_pair.second.get(), protein_match);
}
}
_p_writer->writeLine();
}
void McqrSpectralCount::writeOneProtein(const GroupingGroup * p_group, const ProteinMatch * p_protein_match) {
try {
qDebug() << "McqrSpectralCount::writeOneProtein begin" ;
ValidationState validation_state = ValidationState::validAndChecked;
pappso::GrpProtein * p_grp_protein = p_protein_match->getGrpProteinSp().get();
ProteinXtp * p_protein = p_protein_match->getProteinXtpSp().get();
for (MsRunSp & msrun_sp : _ms_run_sp_list) {
_p_writer->writeLine();
_p_writer->writeCell(p_grp_protein->getGroupingId());
_p_writer->writeCell(msrun_sp.get()->getXmlId());
_p_writer->writeCell(msrun_sp.get()->getFilename());
void McqrSpectralCount::write(CalcWriterInterface * p_writer, WorkMonitorInterface * p_monitor) {
QSettings settings;
//const std::list<DbXref> & dbxref_list = p_protein->getDbxrefList();
//if (dbxref_list.size() == 0) {
_p_writer->writeCell(p_protein->getAccession());
//}
//else {
// _p_writer->writeCell(dbxref_list.front().getUrl(), p_protein->getAccession());
//}
_p_writer->writeCell(p_protein->getDescription());
_p_writer->writeCell(p_protein_match->countSampleScan(validation_state, msrun_sp.get()));
}
qDebug() << "McqrSpectralCount::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()));
}
p_monitor->message(QObject::tr("writing MassChroqR protein file"));
McqRscProtein( p_writer, _p_project).writeSheet();
p_monitor->message(QObject::tr("writing MassChroqR peptide file"));
McqRscPeptide( p_writer, _p_project).writeSheet();
}
......@@ -36,18 +36,12 @@
class McqrSpectralCount
{
public :
McqrSpectralCount (CalcWriterInterface * p_writer, const Project * p_project);
McqrSpectralCount (const Project * project);
void writeSheet();
private :
void writeIdentificationGroup(IdentificationGroup * p_ident);
void writeHeaders(IdentificationGroup * p_ident);
void writeOneProtein(const GroupingGroup * p_group, const ProteinMatch * p_protein_match);
void write(CalcWriterInterface * p_writer, WorkMonitorInterface * p_monitor);
private :
const Project * _p_project;
CalcWriterInterface * _p_writer;
std::vector<MsRunSp> _ms_run_sp_list;
};
#endif // MCQRSPECTRALCOUNT_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