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

first sc output : it works, but needs refinement to take into account labelled experiments

parent 07ce3ff0
No related branches found
No related tags found
No related merge requests found
......@@ -182,13 +182,21 @@ void ProteinMatch::countPeptideMassSample(std::vector<size_t> & count_peptide_ma
}
}
}
std::vector<PeptideMatch> ProteinMatch::getPeptideMatchList(ValidationState state) const {
std::vector<PeptideMatch> ProteinMatch::getPeptideMatchList(ValidationState state, const MsRun * p_msrun_id) const {
std::vector<PeptideMatch> peptide_match_list;
for (auto & peptide_match : _peptide_match_list) {
if (peptide_match.getPeptideEvidence()->getValidationState() >= state) {
peptide_match_list.push_back(peptide_match);
if (p_msrun_id == nullptr) {
peptide_match_list.push_back(peptide_match);
}
else {
if (peptide_match.getPeptideEvidence()->getMsRunP() == p_msrun_id) {
peptide_match_list.push_back(peptide_match);
}
}
}
}
//it should automatically use the move semantic :
return peptide_match_list;
}
......
......@@ -80,8 +80,11 @@ public:
const std::vector<PeptideMatch> & getPeptideMatchList() const;
/** @brief get peptide match sublist with required validation state
* @param state the validation state to select
* @param sp_msrun_id the msrun to look for, if nullptr, then get peptide match overall MSruns
* */
std::vector<PeptideMatch> getPeptideMatchList(ValidationState state) const;
std::vector<PeptideMatch> getPeptideMatchList(ValidationState state, const MsRun * sp_msrun_id = nullptr) const;
void setChecked(bool arg1);
bool isChecked() const;
......
......@@ -57,7 +57,7 @@ void McqRscPeptide::writeHeaders(IdentificationGroup * p_ident) {
_p_writer->writeCell("label");
_p_writer->writeCell("msrun");
_p_writer->writeCell("msrunfile");
_p_writer->writeCell("sequence");
//_p_writer->writeCell("sequence");
_p_writer->writeCell("sc");
//_p_writer->writeCell(p_protein_match->countSampleScan(state, p_msrun));
......@@ -66,8 +66,9 @@ void McqRscPeptide::writeHeaders(IdentificationGroup * p_ident) {
void McqRscPeptide::writeIdentificationGroup(IdentificationGroup * p_ident) {
ValidationState validation_state = ValidationState::grouped;
_ms_run_sp_list = p_ident->getMsRunSpList();
std::vector<MsRunSp> ms_run_sp_list = p_ident->getMsRunSpList();
writeHeaders(p_ident);
for (const std::pair<unsigned int, GroupingGroupSp> & group_pair : p_ident->getGroupStore().getGroupMap()) {
......@@ -80,7 +81,17 @@ void McqRscPeptide::writeIdentificationGroup(IdentificationGroup * p_ident) {
});
for (auto & protein_match:protein_match_list) {
writeOneProtein(group_pair.second.get(), protein_match);
//count number of scan fore each GrpPeptide
std::map<const pappso::GrpPeptide *, std::size_t> count_scan_zero;
for (const PeptideMatch & peptide_match:protein_match->getPeptideMatchList(validation_state) ) {
count_scan_zero.insert ( std::pair<const pappso::GrpPeptide *, std::size_t>(peptide_match.getPeptideEvidence()->getGrpPeptideSp().get(),0) );
}
for (auto & msrun_sp : ms_run_sp_list) {
std::vector<PeptideMatch> peptide_match_in_msrun = protein_match->getPeptideMatchList(validation_state, msrun_sp.get());
writePeptidesInMsrun(msrun_sp.get(), peptide_match_in_msrun, count_scan_zero);
}
}
}
......@@ -88,33 +99,40 @@ void McqRscPeptide::writeIdentificationGroup(IdentificationGroup * p_ident) {
}
void McqRscPeptide::writeOneProtein(const GroupingGroup * p_group, const ProteinMatch * p_protein_match) {
void McqRscPeptide::writePeptidesInMsrun(const MsRun * p_msrun,const std::vector<PeptideMatch> & peptide_match_in_msrun, const std::map<const pappso::GrpPeptide *, std::size_t> & count_scan_zero) {
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());
qDebug() << "McqRscPeptide::writePeptidesInMsrun begin" ;
//count number of scan fore each GrpPeptide
std::map<const pappso::GrpPeptide *, std::size_t> count_scan(count_scan_zero);
for (const PeptideMatch & peptide_match:peptide_match_in_msrun) {
std::pair<std::map<const pappso::GrpPeptide *, std::size_t>::iterator,bool> ret;
ret = count_scan.insert ( std::pair<const pappso::GrpPeptide *, std::size_t>(peptide_match.getPeptideEvidence()->getGrpPeptideSp().get(),0) );
if (ret.second==false) {
//already exists
ret.first->second++;
}
else {
//error : it should exists
throw pappso::PappsoException(QObject::tr("error in %1 %2 %3").arg(__FILE__).arg(__FUNCTION__).arg(__LINE__));
}
}
for (const QString & peptide_str :peptide_list) {
for (const std::pair<const pappso::GrpPeptide *, std::size_t> & pair_count :count_scan) {
_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());
_p_writer->writeCell(pair_count.first->getGroupingId());
_p_writer->writeCell("");
_p_writer->writeCell(p_msrun->getXmlId());
_p_writer->writeCell(p_msrun->getSampleName());
//_p_writer->writeCell(pair.first->getSequence());
_p_writer->writeCell((unsigned int) pair_count.second);
}
qDebug() << "McqRscPeptide::writeOneProtein end" ;
qDebug() << "McqRscPeptide::writePeptidesInMsrun 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()));
throw pappso::PappsoException(QObject::tr("Error writing scan count in msrun %1 :\n%2").arg(p_msrun->getXmlId()).arg(error.qwhat()));
}
}
......@@ -32,22 +32,22 @@
#include <odsstream/calcwriterinterface.h>
#include "../../core/project.h"
#include <pappsomspp/grouping/grppeptide.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);
void writePeptidesInMsrun(const MsRun * p_msrun,const std::vector<PeptideMatch> & peptide_match_in_msrun, const std::map<const pappso::GrpPeptide *, std::size_t> & count_scan_zero);
private :
const Project * _p_project;
CalcWriterInterface * _p_writer;
std::vector<MsRunSp> _ms_run_sp_list;
};
#endif // MCQRSCPEPTIDE_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