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

NSAF indice handles labeling methods

parent 00899292
No related branches found
No related tags found
No related merge requests found
...@@ -55,14 +55,15 @@ IdentificationGroup::getGroupStore() const ...@@ -55,14 +55,15 @@ IdentificationGroup::getGroupStore() const
} }
pappso::pappso_double pappso::pappso_double
IdentificationGroup::computeProtoNsafSum(const MsRun *p_msrun_id) const IdentificationGroup::computeProtoNsafSum(const MsRun *p_msrun_id,
const Label *p_label) const
{ {
pappso::pappso_double nsaf_sum = 0; pappso::pappso_double nsaf_sum = 0;
for(auto &p_protein_match : _protein_match_list) for(auto &p_protein_match : _protein_match_list)
{ {
if(p_protein_match->getValidationState() >= ValidationState::grouped) if(p_protein_match->getValidationState() >= ValidationState::grouped)
{ {
nsaf_sum += p_protein_match->getProtoNsaf(p_msrun_id); nsaf_sum += p_protein_match->getProtoNsaf(p_msrun_id, p_label);
} }
} }
return nsaf_sum; return nsaf_sum;
...@@ -130,7 +131,8 @@ unsigned int ...@@ -130,7 +131,8 @@ unsigned int
IdentificationGroup::countDecoyProteinMatch(ValidationState state) const IdentificationGroup::countDecoyProteinMatch(ValidationState state) const
{ {
return std::count_if( return std::count_if(
_protein_match_list.begin(), _protein_match_list.end(), _protein_match_list.begin(),
_protein_match_list.end(),
[state](const ProteinMatch *p_protein_match) { [state](const ProteinMatch *p_protein_match) {
if((p_protein_match->getProteinXtpSp().get()->isDecoy()) && if((p_protein_match->getProteinXtpSp().get()->isDecoy()) &&
(p_protein_match->getValidationState() >= state)) (p_protein_match->getValidationState() >= state))
...@@ -209,7 +211,8 @@ IdentificationGroup::countDecoyPeptideMatch(ValidationState state) const ...@@ -209,7 +211,8 @@ IdentificationGroup::countDecoyPeptideMatch(ValidationState state) const
unsigned int unsigned int
IdentificationGroup::countProteinMatch(ValidationState state) const IdentificationGroup::countProteinMatch(ValidationState state) const
{ {
return std::count_if(_protein_match_list.begin(), _protein_match_list.end(), return std::count_if(_protein_match_list.begin(),
_protein_match_list.end(),
[state](const ProteinMatch *p_protein_match) { [state](const ProteinMatch *p_protein_match) {
if(p_protein_match->getValidationState() >= state) if(p_protein_match->getValidationState() >= state)
{ {
...@@ -302,8 +305,8 @@ IdentificationGroup::addIdentificationDataSourceP( ...@@ -302,8 +305,8 @@ IdentificationGroup::addIdentificationDataSourceP(
IdentificationDataSource *p_identification_source) IdentificationDataSource *p_identification_source)
{ {
addMsRunSp(p_identification_source->getMsRunSp()); addMsRunSp(p_identification_source->getMsRunSp());
auto it = std::find(_id_source_list.begin(), _id_source_list.end(), auto it = std::find(
p_identification_source); _id_source_list.begin(), _id_source_list.end(), p_identification_source);
if(it == _id_source_list.end()) if(it == _id_source_list.end())
{ {
_id_source_list.push_back(p_identification_source); _id_source_list.push_back(p_identification_source);
...@@ -353,7 +356,8 @@ IdentificationGroup::countSubGroup() const ...@@ -353,7 +356,8 @@ IdentificationGroup::countSubGroup() const
void void
IdentificationGroup::collectMhDelta( IdentificationGroup::collectMhDelta(
std::vector<pappso::pappso_double> &delta_list, pappso::PrecisionUnit unit, std::vector<pappso::pappso_double> &delta_list,
pappso::PrecisionUnit unit,
ValidationState state) const ValidationState state) const
{ {
std::set<const PeptideEvidence *> peptide_evidence_list; std::set<const PeptideEvidence *> peptide_evidence_list;
...@@ -466,7 +470,9 @@ IdentificationGroup::getProteinFdr(ValidationState state) const ...@@ -466,7 +470,9 @@ IdentificationGroup::getProteinFdr(ValidationState state) const
void void
IdentificationGroup::getSameXicPeptideEvidenceList( IdentificationGroup::getSameXicPeptideEvidenceList(
std::vector<const PeptideEvidence *> &peptide_evidence_list, std::vector<const PeptideEvidence *> &peptide_evidence_list,
const MsRun *p_msrun, const PeptideXtp *p_peptide, unsigned int charge) const const MsRun *p_msrun,
const PeptideXtp *p_peptide,
unsigned int charge) const
{ {
if(!contains(p_msrun)) if(!contains(p_msrun))
return; return;
...@@ -475,8 +481,8 @@ IdentificationGroup::getSameXicPeptideEvidenceList( ...@@ -475,8 +481,8 @@ IdentificationGroup::getSameXicPeptideEvidenceList(
if(p_msrun == p_identification_source->getMsRunSp().get()) if(p_msrun == p_identification_source->getMsRunSp().get())
{ {
p_identification_source->getPeptideEvidenceStore() p_identification_source->getPeptideEvidenceStore()
.getSameXicPeptideEvidenceList(peptide_evidence_list, p_msrun, .getSameXicPeptideEvidenceList(
p_peptide, charge); peptide_evidence_list, p_msrun, p_peptide, charge);
} }
} }
} }
...@@ -62,7 +62,9 @@ class IdentificationGroup ...@@ -62,7 +62,9 @@ class IdentificationGroup
* Warning: this is not NSAF, just a part * Warning: this is not NSAF, just a part
* @param p_msrun_id pointer on the msrun to get NSAF. * @param p_msrun_id pointer on the msrun to get NSAF.
* */ * */
pappso::pappso_double computeProtoNsafSum(const MsRun *p_msrun_id) const; pappso::pappso_double
computeProtoNsafSum(const MsRun *p_msrun_id,
const Label *p_label = nullptr) const;
/** @brief count groups /** @brief count groups
* */ * */
...@@ -152,7 +154,8 @@ class IdentificationGroup ...@@ -152,7 +154,8 @@ class IdentificationGroup
* each peptide evidence is only counted once * each peptide evidence is only counted once
*/ */
void collectMhDelta(std::vector<pappso::pappso_double> &delta_list, void collectMhDelta(std::vector<pappso::pappso_double> &delta_list,
pappso::PrecisionUnit unit, ValidationState state) const; pappso::PrecisionUnit unit,
ValidationState state) const;
/** @brief look for a peptide in the same XIC /** @brief look for a peptide in the same XIC
...@@ -163,7 +166,8 @@ class IdentificationGroup ...@@ -163,7 +166,8 @@ class IdentificationGroup
*/ */
void getSameXicPeptideEvidenceList( void getSameXicPeptideEvidenceList(
std::vector<const PeptideEvidence *> &peptide_evidence_list, std::vector<const PeptideEvidence *> &peptide_evidence_list,
const MsRun *p_msrun, const PeptideXtp *p_peptide, const MsRun *p_msrun,
const PeptideXtp *p_peptide,
unsigned int charge) const; unsigned int charge) const;
private: private:
......
...@@ -434,8 +434,10 @@ ProteinMatch::countPeptideMassCharge(ValidationState state, ...@@ -434,8 +434,10 @@ ProteinMatch::countPeptideMassCharge(ValidationState state,
{ {
if(p_label != nullptr) if(p_label != nullptr)
{ {
if(peptide_match.getPeptideEvidence()->getPeptideXtpSp().get()->getLabel() == if(peptide_match.getPeptideEvidence()
p_label) ->getPeptideXtpSp()
.get()
->getLabel() == p_label)
{ {
sequence_list.insert( sequence_list.insert(
QString("%1-%2-%3") QString("%1-%2-%3")
...@@ -559,7 +561,8 @@ ProteinMatch::getLogEvalue(const MsRun *sp_msrun_id) const ...@@ -559,7 +561,8 @@ ProteinMatch::getLogEvalue(const MsRun *sp_msrun_id) const
} }
pappso::pappso_double pappso::pappso_double
ProteinMatch::getNsaf(pappso::pappso_double proto_nsaf_sum, ProteinMatch::getNsaf(pappso::pappso_double proto_nsaf_sum,
const MsRun *p_msrun_id) const const MsRun *p_msrun_id,
const Label *p_label) const
{ {
if(proto_nsaf_sum == 0) if(proto_nsaf_sum == 0)
{ {
...@@ -568,11 +571,11 @@ ProteinMatch::getNsaf(pappso::pappso_double proto_nsaf_sum, ...@@ -568,11 +571,11 @@ ProteinMatch::getNsaf(pappso::pappso_double proto_nsaf_sum,
"Error computing NSAF for protein %1 :\nproto_nsaf_sum is null") "Error computing NSAF for protein %1 :\nproto_nsaf_sum is null")
.arg(this->getProteinXtpSp().get()->getAccession())); .arg(this->getProteinXtpSp().get()->getAccession()));
} }
return (getProtoNsaf(p_msrun_id) / proto_nsaf_sum); return (getProtoNsaf(p_msrun_id, p_label) / proto_nsaf_sum);
} }
pappso::pappso_double pappso::pappso_double
ProteinMatch::getProtoNsaf(const MsRun *sp_msrun_id) const ProteinMatch::getProtoNsaf(const MsRun *sp_msrun_id, const Label *p_label) const
{ {
try try
{ {
...@@ -582,8 +585,8 @@ ProteinMatch::getProtoNsaf(const MsRun *sp_msrun_id) const ...@@ -582,8 +585,8 @@ ProteinMatch::getProtoNsaf(const MsRun *sp_msrun_id) const
QObject::tr("protein has no amino acid sequence")); QObject::tr("protein has no amino acid sequence"));
} }
pappso::pappso_double proto_nsaf = pappso::pappso_double proto_nsaf =
(pappso::pappso_double)countSampleScan(ValidationState::validAndChecked, (pappso::pappso_double)countSampleScan(
sp_msrun_id) / ValidationState::validAndChecked, sp_msrun_id, p_label) /
(pappso::pappso_double)_protein_sp.get()->size(); (pappso::pappso_double)_protein_sp.get()->size();
return proto_nsaf; return proto_nsaf;
} }
...@@ -617,11 +620,11 @@ ProteinMatch::getPAI(const MsRun *sp_msrun_id, const Label *p_label) const ...@@ -617,11 +620,11 @@ ProteinMatch::getPAI(const MsRun *sp_msrun_id, const Label *p_label) const
} }
pappso::pappso_double pappso::pappso_double
ProteinMatch::getEmPAI(const MsRun *sp_msrun_id) const ProteinMatch::getEmPAI(const MsRun *sp_msrun_id, const Label *p_label) const
{ {
// compute emPAI, Ishihama 2005 // compute emPAI, Ishihama 2005
pappso::pappso_double value = pappso::pappso_double value =
std::pow(10.0, getPAI(sp_msrun_id)) - (pappso::pappso_double)1.0; std::pow(10.0, getPAI(sp_msrun_id, p_label)) - (pappso::pappso_double)1.0;
return value; return value;
} }
......
...@@ -72,7 +72,8 @@ class ProteinMatch ...@@ -72,7 +72,8 @@ class ProteinMatch
* Warning: this is not NSAF, just a part * Warning: this is not NSAF, just a part
* @param p_msrun_id pointer on the msrun to get NSAF. * @param p_msrun_id pointer on the msrun to get NSAF.
* */ * */
pappso::pappso_double getProtoNsaf(const MsRun *p_msrun_id) const; pappso::pappso_double getProtoNsaf(const MsRun *p_msrun_id,
const Label *p_label = nullptr) const;
/** @brief compute NSAF within msrun : normalized spectral abundance factor /** @brief compute NSAF within msrun : normalized spectral abundance factor
* (NSAF) Florens L., Carozza M. J. C., Swanson S. K., et al. Analyzing * (NSAF) Florens L., Carozza M. J. C., Swanson S. K., et al. Analyzing
...@@ -84,7 +85,8 @@ class ProteinMatch ...@@ -84,7 +85,8 @@ class ProteinMatch
* @param p_msrun_id pointer on the msrun to get NSAF * @param p_msrun_id pointer on the msrun to get NSAF
* */ * */
pappso::pappso_double getNsaf(pappso::pappso_double proto_nsaf_sum, pappso::pappso_double getNsaf(pappso::pappso_double proto_nsaf_sum,
const MsRun *p_msrun_id) const; const MsRun *p_msrun_id,
const Label *p_label = nullptr) const;
/** @brief compute Protein Abundance Index (PAI) within sample /** @brief compute Protein Abundance Index (PAI) within sample
* PAI computation (Rappsilber et al. 2002) * PAI computation (Rappsilber et al. 2002)
...@@ -95,7 +97,8 @@ class ProteinMatch ...@@ -95,7 +97,8 @@ class ProteinMatch
/** @brief compute emPAI within sample /** @brief compute emPAI within sample
* Ishihama 2005 * Ishihama 2005
* */ * */
pappso::pappso_double getEmPAI(const MsRun *sp_msrun_id = nullptr) const; pappso::pappso_double getEmPAI(const MsRun *sp_msrun_id = nullptr,
const Label *p_label = nullptr) const;
void setProteinXtpSp(ProteinXtpSp protein_sp); void setProteinXtpSp(ProteinXtpSp protein_sp);
void addPeptideMatch(const PeptideMatch &peptide_match); void addPeptideMatch(const PeptideMatch &peptide_match);
......
...@@ -110,7 +110,7 @@ ComparEmpaiSheet::writeComparValue(const ProteinMatch *p_protein_match, ...@@ -110,7 +110,7 @@ ComparEmpaiSheet::writeComparValue(const ProteinMatch *p_protein_match,
const Label *p_label) const Label *p_label)
{ {
qDebug() << "ComparEmpaiSheet::writeComparValue begin"; qDebug() << "ComparEmpaiSheet::writeComparValue begin";
_p_writer->writeCell(p_protein_match->getEmPAI(p_msrun)); _p_writer->writeCell(p_protein_match->getEmPAI(p_msrun, p_label));
qDebug() << "ComparEmpaiSheet::writeComparValue end"; qDebug() << "ComparEmpaiSheet::writeComparValue end";
} }
...@@ -130,21 +130,47 @@ ComparNsafSheet::writeComparValue(const ProteinMatch *p_protein_match, ...@@ -130,21 +130,47 @@ ComparNsafSheet::writeComparValue(const ProteinMatch *p_protein_match,
{ {
qDebug() << "ComparNsafSheet::writeComparValue begin"; qDebug() << "ComparNsafSheet::writeComparValue begin";
pappso::pappso_double proto_nsaf_sum = 0; pappso::pappso_double proto_nsaf_sum = 0;
std::pair<std::map<const MsRun *, pappso::pappso_double>::iterator, bool>
ret = _map_proto_nsaf_sum_by_msrun.insert( if(_label_list.size() > 0)
std::pair<const MsRun *, pappso::pappso_double>(p_msrun, 0));
if(ret.second == false)
{ {
//"element 'z' already existed"; std::pair<std::map<QString, pappso::pappso_double>::iterator, bool> ret =
proto_nsaf_sum = ret.first->second; _map_proto_nsaf_sum_by_msrun.insert(
std::pair<QString, pappso::pappso_double>(
QString("%1--%2").arg(p_msrun->getXmlId()).arg(p_label->getXmlId()),
0));
if(ret.second == false)
{
//"element 'z' already existed";
proto_nsaf_sum = ret.first->second;
}
else
{
proto_nsaf_sum = _p_current_identification_group->computeProtoNsafSum(
p_msrun, p_label);
ret.first->second = proto_nsaf_sum;
}
_p_writer->writeCell(
p_protein_match->getNsaf(proto_nsaf_sum, p_msrun, p_label));
} }
else else
{ {
proto_nsaf_sum = std::pair<std::map<QString, pappso::pappso_double>::iterator, bool> ret =
_p_current_identification_group->computeProtoNsafSum(p_msrun); _map_proto_nsaf_sum_by_msrun.insert(
ret.first->second = proto_nsaf_sum; std::pair<QString, pappso::pappso_double>(p_msrun->getXmlId(), 0));
if(ret.second == false)
{
//"element 'z' already existed";
proto_nsaf_sum = ret.first->second;
}
else
{
proto_nsaf_sum =
_p_current_identification_group->computeProtoNsafSum(p_msrun);
ret.first->second = proto_nsaf_sum;
}
_p_writer->writeCell(p_protein_match->getNsaf(proto_nsaf_sum, p_msrun));
} }
_p_writer->writeCell(p_protein_match->getNsaf(proto_nsaf_sum, p_msrun));
qDebug() << "ComparNsafSheet::writeComparValue end"; qDebug() << "ComparNsafSheet::writeComparValue end";
} }
...@@ -104,7 +104,7 @@ class ComparNsafSheet : public ComparBaseSheet ...@@ -104,7 +104,7 @@ class ComparNsafSheet : public ComparBaseSheet
const Label *p_label = nullptr) override; const Label *p_label = nullptr) override;
private: private:
std::map<const MsRun *, pappso::pappso_double> _map_proto_nsaf_sum_by_msrun; std::map<QString, pappso::pappso_double> _map_proto_nsaf_sum_by_msrun;
}; };
#endif // COMPARSPECTRASHEET_H #endif // COMPARSPECTRASHEET_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