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

normalized spectral abundance factor done

parent 35316a37
No related branches found
No related tags found
No related merge requests found
...@@ -326,11 +326,17 @@ pappso::pappso_double ProteinMatch::getLogEvalue(const MsRun * sp_msrun_id) cons ...@@ -326,11 +326,17 @@ pappso::pappso_double ProteinMatch::getLogEvalue(const MsRun * sp_msrun_id) cons
} }
pappso::pappso_double ProteinMatch::getNsaf(pappso::pappso_double proto_nsaf_sum, const MsRun * p_msrun_id) const { pappso::pappso_double ProteinMatch::getNsaf(pappso::pappso_double proto_nsaf_sum, const MsRun * p_msrun_id) const {
if (proto_nsaf_sum == 0) {
throw pappso::PappsoException(QObject::tr("Error computing NSAF for protein %1 :\nproto_nsaf_sum is null").arg(this->getProteinXtpSp().get()->getAccession()));
}
return (getProtoNsaf(p_msrun_id)/proto_nsaf_sum); return (getProtoNsaf(p_msrun_id)/proto_nsaf_sum);
} }
pappso::pappso_double ProteinMatch::getProtoNsaf(const MsRun * sp_msrun_id) const { pappso::pappso_double ProteinMatch::getProtoNsaf(const MsRun * sp_msrun_id) const {
try { try {
if (_protein_sp.get()->size() < 1) {
throw pappso::PappsoException(QObject::tr("protein has no amino acid sequence"));
}
pappso::pappso_double proto_nsaf = (pappso::pappso_double) countSampleScan(ValidationState::validAndChecked ,sp_msrun_id) / (pappso::pappso_double) _protein_sp.get()->size(); pappso::pappso_double proto_nsaf = (pappso::pappso_double) countSampleScan(ValidationState::validAndChecked ,sp_msrun_id) / (pappso::pappso_double) _protein_sp.get()->size();
return proto_nsaf; return proto_nsaf;
......
...@@ -45,7 +45,7 @@ public: ...@@ -45,7 +45,7 @@ public:
~ProteinMatch(); ~ProteinMatch();
const ProteinXtpSp & getProteinXtpSp() const; const ProteinXtpSp & getProteinXtpSp() const;
/** @brief compute protein log10(Evalue) within samples /** @brief compute protein log10(Evalue) within samples
* */ * */
pappso::pappso_double getLogEvalue(const MsRun * sp_msrun_id = nullptr) const; pappso::pappso_double getLogEvalue(const MsRun * sp_msrun_id = nullptr) const;
...@@ -64,17 +64,18 @@ public: ...@@ -64,17 +64,18 @@ public:
**/ **/
const QString getHtmlSequence(PeptideEvidence * peptide_evidence_to_locate = nullptr) const; const QString getHtmlSequence(PeptideEvidence * peptide_evidence_to_locate = nullptr) const;
/** @brief compute proto NSAF within msrun /** @brief compute proto NSAF within msrun : spectral abundance factor (SAF)
* 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;
/** @brief compute NSAF within msrun /** @brief compute NSAF within msrun : normalized spectral abundance factor (NSAF)
* Warning: this is not NSAF, just a part * Florens L., Carozza M. J. C., Swanson S. K., et al. Analyzing chromatin remodeling complexes using shotgun proteomics and normalized spectral abundance factors. Methods. 2006;40(4):303–311. doi: 10.1016/j.ymeth.2006.07.028.
* @param proto_nsaf_sum the sum of proto nsaf of all proteins within the msrun * https://www.ncbi.nlm.nih.gov/pmc/articles/PMC1815300/
* @param p_msrun_id pointer on the msrun to get NSAF * @param proto_nsaf_sum the sum of SAF of all proteins within the msrun
* */ * @param p_msrun_id pointer on the msrun to get NSAF
* */
pappso::pappso_double getNsaf(pappso::pappso_double proto_nsaf_sum, const MsRun * p_msrun_id) const; pappso::pappso_double getNsaf(pappso::pappso_double proto_nsaf_sum, const MsRun * p_msrun_id) const;
/** @brief compute Protein Abundance Index (PAI) within sample /** @brief compute Protein Abundance Index (PAI) within sample
...@@ -91,7 +92,7 @@ public: ...@@ -91,7 +92,7 @@ public:
void addPeptideMatch(const PeptideMatch & peptide_match); void addPeptideMatch(const PeptideMatch & peptide_match);
std::vector<PeptideMatch> & getPeptideMatchList(); std::vector<PeptideMatch> & getPeptideMatchList();
const std::vector<PeptideMatch> & getPeptideMatchList() const; const std::vector<PeptideMatch> & getPeptideMatchList() const;
/** @brief get peptide match sublist with required validation state /** @brief get peptide match sublist with required validation state
* @param state the validation state to select * @param state the validation state to select
* @param sp_msrun_id the msrun to look for, if nullptr, then get peptide match overall MSruns * @param sp_msrun_id the msrun to look for, if nullptr, then get peptide match overall MSruns
...@@ -106,15 +107,15 @@ public: ...@@ -106,15 +107,15 @@ public:
bool isGrouped() const; bool isGrouped() const;
ValidationState getValidationState() const; ValidationState getValidationState() const;
/** @brief count peptide match (psm) listed in this protein match /** @brief count peptide match (psm) listed in this protein match
*/ */
unsigned int countPeptideMatch(ValidationState state) const; unsigned int countPeptideMatch(ValidationState state) const;
/** @brief count distinct sample + scans implied in this protein identification /** @brief count distinct sample + scans implied in this protein identification
*/ */
unsigned int countSampleScan(ValidationState state, const MsRun * p_msrun_id=nullptr) const; unsigned int countSampleScan(ValidationState state, const MsRun * p_msrun_id=nullptr) const;
/** @brief count peptide (peptide+mass) /** @brief count peptide (peptide+mass)
*/ */
void countPeptideMass(std::vector<pappso::GrpPeptide *> & count_peptide_mass, ValidationState state) const; void countPeptideMass(std::vector<pappso::GrpPeptide *> & count_peptide_mass, ValidationState state) const;
...@@ -130,17 +131,17 @@ public: ...@@ -130,17 +131,17 @@ public:
* */ * */
void updateAutomaticFilters(const AutomaticFilterParameters & automatic_filter_parameters); void updateAutomaticFilters(const AutomaticFilterParameters & automatic_filter_parameters);
/** @brief collect distinct peptide evidences /** @brief collect distinct peptide evidences
*/ */
void collectPeptideEvidences(std::set<const PeptideEvidence *> & peptide_evidence_set, ValidationState state) const; void collectPeptideEvidences(std::set<const PeptideEvidence *> & peptide_evidence_set, ValidationState state) const;
/** @brief count distinct sequence taking into account equivalence between Leucine and Isoleucine /** @brief count distinct sequence taking into account equivalence between Leucine and Isoleucine
* @param state validation state of peptides to count * @param state validation state of peptides to count
* @param p_msrun_id count within the specified sample * @param p_msrun_id count within the specified sample
*/ */
size_t countSequenceLi(ValidationState state,const MsRun * p_msrun_id=nullptr) const; size_t countSequenceLi(ValidationState state,const MsRun * p_msrun_id=nullptr) const;
/** @brief count distinct peptide+mass+charge /** @brief count distinct peptide+mass+charge
* peptide is the peptide sequence LI (Leucine => Isoleucine) * peptide is the peptide sequence LI (Leucine => Isoleucine)
* mass is the peptide mass, not considering labelled residues (if any) * mass is the peptide mass, not considering labelled residues (if any)
...@@ -148,7 +149,7 @@ public: ...@@ -148,7 +149,7 @@ public:
* @param p_msrun_id count within the specified sample * @param p_msrun_id count within the specified sample
*/ */
unsigned int countPeptideMassCharge(ValidationState state, const MsRun * sp_msrun_id=nullptr) const; unsigned int countPeptideMassCharge(ValidationState state, const MsRun * sp_msrun_id=nullptr) const;
/** @brief count distinct MS samples in which the protein is observed /** @brief count distinct MS samples in which the protein is observed
* @param state validation state of peptides to count * @param state validation state of peptides to count
*/ */
......
...@@ -64,6 +64,9 @@ ...@@ -64,6 +64,9 @@
</item> </item>
<item> <item>
<widget class="QGroupBox" name="compar_groupbox"> <widget class="QGroupBox" name="compar_groupbox">
<property name="toolTip">
<string/>
</property>
<property name="title"> <property name="title">
<string>Compar</string> <string>Compar</string>
</property> </property>
...@@ -110,6 +113,16 @@ ...@@ -110,6 +113,16 @@
</property> </property>
</widget> </widget>
</item> </item>
<item row="0" column="3">
<widget class="QCheckBox" name="comparnsaf_checkbox">
<property name="toolTip">
<string>normalized spectral abundance factor (NSAF)</string>
</property>
<property name="text">
<string>NSAF</string>
</property>
</widget>
</item>
</layout> </layout>
</widget> </widget>
</item> </item>
...@@ -328,7 +341,7 @@ ...@@ -328,7 +341,7 @@
<slot>doComparUniqueSequence(bool)</slot> <slot>doComparUniqueSequence(bool)</slot>
<hints> <hints>
<hint type="sourcelabel"> <hint type="sourcelabel">
<x>437</x> <x>359</x>
<y>296</y> <y>296</y>
</hint> </hint>
<hint type="destinationlabel"> <hint type="destinationlabel">
...@@ -344,7 +357,7 @@ ...@@ -344,7 +357,7 @@
<slot>doComparSpecificSpectra(bool)</slot> <slot>doComparSpecificSpectra(bool)</slot>
<hints> <hints>
<hint type="sourcelabel"> <hint type="sourcelabel">
<x>231</x> <x>167</x>
<y>328</y> <y>328</y>
</hint> </hint>
<hint type="destinationlabel"> <hint type="destinationlabel">
...@@ -360,7 +373,7 @@ ...@@ -360,7 +373,7 @@
<slot>doComparSpecificUniqueSequence(bool)</slot> <slot>doComparSpecificUniqueSequence(bool)</slot>
<hints> <hints>
<hint type="sourcelabel"> <hint type="sourcelabel">
<x>437</x> <x>359</x>
<y>328</y> <y>328</y>
</hint> </hint>
<hint type="destinationlabel"> <hint type="destinationlabel">
...@@ -376,7 +389,7 @@ ...@@ -376,7 +389,7 @@
<slot>doComparPai(bool)</slot> <slot>doComparPai(bool)</slot>
<hints> <hints>
<hint type="sourcelabel"> <hint type="sourcelabel">
<x>642</x> <x>501</x>
<y>296</y> <y>296</y>
</hint> </hint>
<hint type="destinationlabel"> <hint type="destinationlabel">
...@@ -392,7 +405,7 @@ ...@@ -392,7 +405,7 @@
<slot>doComparEmpai(bool)</slot> <slot>doComparEmpai(bool)</slot>
<hints> <hints>
<hint type="sourcelabel"> <hint type="sourcelabel">
<x>642</x> <x>501</x>
<y>328</y> <y>328</y>
</hint> </hint>
<hint type="destinationlabel"> <hint type="destinationlabel">
...@@ -433,6 +446,22 @@ ...@@ -433,6 +446,22 @@
</hint> </hint>
</hints> </hints>
</connection> </connection>
<connection>
<sender>comparnsaf_checkbox</sender>
<signal>toggled(bool)</signal>
<receiver>ExportSpreadsheetDialog</receiver>
<slot>doComparNsaf(bool)</slot>
<hints>
<hint type="sourcelabel">
<x>550</x>
<y>286</y>
</hint>
<hint type="destinationlabel">
<x>806</x>
<y>294</y>
</hint>
</hints>
</connection>
</connections> </connections>
<slots> <slots>
<slot>reject()</slot> <slot>reject()</slot>
...@@ -452,5 +481,6 @@ ...@@ -452,5 +481,6 @@
<slot>doComparEmpai(bool)</slot> <slot>doComparEmpai(bool)</slot>
<slot>doPtmIslands(bool)</slot> <slot>doPtmIslands(bool)</slot>
<slot>doPtmSpectra(bool)</slot> <slot>doPtmSpectra(bool)</slot>
<slot>doComparNsaf(bool)</slot>
</slots> </slots>
</ui> </ui>
...@@ -88,6 +88,10 @@ ExportSpreadsheetDialog::ExportSpreadsheetDialog(QWidget * parent): ...@@ -88,6 +88,10 @@ ExportSpreadsheetDialog::ExportSpreadsheetDialog(QWidget * parent):
if (settings.value("export_ods/comparempai", "true").toBool()) { if (settings.value("export_ods/comparempai", "true").toBool()) {
ui->comparempai_checkbox->setCheckState(Qt::Checked); ui->comparempai_checkbox->setCheckState(Qt::Checked);
} }
ui->comparnsaf_checkbox->setCheckState(Qt::Unchecked);
if (settings.value("export_ods/comparnsaf", "true").toBool()) {
ui->comparnsaf_checkbox->setCheckState(Qt::Checked);
}
ui->samples_checkbox->setCheckState(Qt::Unchecked); ui->samples_checkbox->setCheckState(Qt::Unchecked);
if (settings.value("export_ods/samples", "true").toBool()) { if (settings.value("export_ods/samples", "true").toBool()) {
ui->samples_checkbox->setCheckState(Qt::Checked); ui->samples_checkbox->setCheckState(Qt::Checked);
...@@ -170,6 +174,11 @@ void ExportSpreadsheetDialog::doComparPai(bool simple) { ...@@ -170,6 +174,11 @@ void ExportSpreadsheetDialog::doComparPai(bool simple) {
QSettings settings; QSettings settings;
settings.setValue("export_ods/comparpai", QString("%1").arg(simple)); settings.setValue("export_ods/comparpai", QString("%1").arg(simple));
} }
void ExportSpreadsheetDialog::doComparNsaf(bool simple) {
QSettings settings;
settings.setValue("export_ods/comparnsaf", QString("%1").arg(simple));
}
void ExportSpreadsheetDialog::doPeptidePos(bool simple) { void ExportSpreadsheetDialog::doPeptidePos(bool simple) {
QSettings settings; QSettings settings;
......
...@@ -50,6 +50,7 @@ public slots: ...@@ -50,6 +50,7 @@ public slots:
void doGroups(bool simple); void doGroups(bool simple);
void doPeptidePos(bool simple); void doPeptidePos(bool simple);
void doComparEmpai(bool simple); void doComparEmpai(bool simple);
void doComparNsaf(bool simple);
void doComparPai(bool simple); void doComparPai(bool simple);
void doComparSpecificUniqueSequence(bool simple); void doComparSpecificUniqueSequence(bool simple);
void doComparUniqueSequence(bool simple); void doComparUniqueSequence(bool simple);
......
...@@ -493,18 +493,28 @@ bool XtpXpipSaxHandler::startElement_protein(QXmlAttributes attributes) { ...@@ -493,18 +493,28 @@ bool XtpXpipSaxHandler::startElement_protein(QXmlAttributes attributes) {
</protein> </protein>
*/ */
_sp_current_protein = ProteinXtp().makeProteinXtpSp(); _sp_current_protein = ProteinXtp().makeProteinXtpSp();
_sp_current_protein.get()->setFastaFileP(_map_fasta_files.at(attributes.value("fasta_id")).get()); auto fasta_it = _map_fasta_files.find(attributes.value("fasta_id"));
if (fasta_it == _map_fasta_files.end()) {
throw pappso::ExceptionNotFound(QObject::tr("ERROR fasta_id %1 not found").arg(attributes.value("fasta_id")));
}
//qDebug() << "startElement_protein fastaid=" << attributes.value("fasta_id");
_sp_current_protein.get()->setFastaFileP(fasta_it->second.get());
_sp_current_protein.get()->setAccession(attributes.value("acc")); _sp_current_protein.get()->setAccession(attributes.value("acc"));
//qDebug() << "startElement_protein acc=" << attributes.value("acc");
//qDebug() << "startElement_protein description=" << attributes.value("description");
_sp_current_protein.get()->setDescription(attributes.value("description")); _sp_current_protein.get()->setDescription(attributes.value("description"));
_sp_current_protein.get()->setIsContaminant(false); _sp_current_protein.get()->setIsContaminant(false);
if (attributes.value("is_contaminant").simplified().toLower() == "true") { if (attributes.value("is_contaminant").simplified().toLower() == "true") {
_sp_current_protein.get()->setIsContaminant(true); _sp_current_protein.get()->setIsContaminant(true);
} }
//qDebug() << "startElement_protein iscontaminant";
_sp_current_protein.get()->setIsDecoy(false); _sp_current_protein.get()->setIsDecoy(false);
if (attributes.value("is_decoy").simplified().toLower() == "true") { if (attributes.value("is_decoy").simplified().toLower() == "true") {
_sp_current_protein.get()->setIsDecoy(true); _sp_current_protein.get()->setIsDecoy(true);
} }
//qDebug() << "startElement_protein isdecoy";
qDebug() << "startElement_protein end" ; qDebug() << "startElement_protein end" ;
return true; return true;
......
...@@ -129,6 +129,7 @@ void ComparBaseSheet::writeProteinMatch(const ProteinMatch * p_protein_match) { ...@@ -129,6 +129,7 @@ void ComparBaseSheet::writeProteinMatch(const ProteinMatch * p_protein_match) {
void ComparBaseSheet::writeIdentificationGroup(IdentificationGroup * p_ident) { void ComparBaseSheet::writeIdentificationGroup(IdentificationGroup * p_ident) {
qDebug() << "ComparBaseSheet::writeIdentificationGroup begin"; qDebug() << "ComparBaseSheet::writeIdentificationGroup begin";
_p_current_identification_group = p_ident;
writeHeaders(p_ident); writeHeaders(p_ident);
......
...@@ -42,12 +42,12 @@ public : ...@@ -42,12 +42,12 @@ public :
private : private :
void writeIdentificationGroup(IdentificationGroup * p_ident); void writeIdentificationGroup(IdentificationGroup * p_ident);
void writeHeaders(IdentificationGroup * p_ident); void writeHeaders(IdentificationGroup * p_ident);
void writeProteinMatch(const ProteinMatch * p_protein_match);
public : public :
void writeSheet(); void writeSheet();
protected : protected :
virtual void writeComparValue(const ProteinMatch * p_protein_match, ValidationState state, const MsRun * p_msrun)=0; virtual void writeComparValue(const ProteinMatch * p_protein_match, ValidationState state, const MsRun * p_msrun)=0;
void writeProteinMatch(const ProteinMatch * p_protein_match);
protected : protected :
OdsExport * _p_ods_export; OdsExport * _p_ods_export;
...@@ -58,6 +58,8 @@ protected : ...@@ -58,6 +58,8 @@ protected :
QString _first_cell_coordinate; QString _first_cell_coordinate;
IdentificationGroup * _p_current_identification_group;
}; };
#endif // COMPARBASESHEET_H #endif // COMPARBASESHEET_H
...@@ -74,3 +74,24 @@ void ComparEmpaiSheet::writeComparValue(const ProteinMatch * p_protein_match, Va ...@@ -74,3 +74,24 @@ void ComparEmpaiSheet::writeComparValue(const ProteinMatch * p_protein_match, Va
_p_writer->writeCell(p_protein_match->getEmPAI(p_msrun)); _p_writer->writeCell(p_protein_match->getEmPAI(p_msrun));
qDebug() << "ComparEmpaiSheet::writeComparValue end"; qDebug() << "ComparEmpaiSheet::writeComparValue end";
} }
ComparNsafSheet::ComparNsafSheet(OdsExport* p_ods_export, CalcWriterInterface* p_writer, const Project* p_project): ComparBaseSheet(p_ods_export, p_writer, p_project) {
_title_sheet = "compar NSAF";
}
void ComparNsafSheet::writeComparValue(const ProteinMatch * p_protein_match, ValidationState state, const MsRun * p_msrun) {
qDebug() << "ComparNsafSheet::writeComparValue begin";
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(std::pair<const MsRun *,pappso::pappso_double>(p_msrun,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));
qDebug() << "ComparNsafSheet::writeComparValue end";
}
...@@ -69,4 +69,16 @@ protected : ...@@ -69,4 +69,16 @@ protected :
virtual void writeComparValue(const ProteinMatch * p_protein_match, ValidationState state, const MsRun * p_msrun) override; virtual void writeComparValue(const ProteinMatch * p_protein_match, ValidationState state, const MsRun * p_msrun) override;
}; };
class ComparNsafSheet:public ComparBaseSheet
{
public :
ComparNsafSheet (OdsExport * p_ods_export, CalcWriterInterface * p_writer, const Project * p_project);
protected :
virtual void writeComparValue(const ProteinMatch * p_protein_match, ValidationState state, const MsRun * p_msrun) override;
private:
std::map<const MsRun *, pappso::pappso_double> _map_proto_nsaf_sum_by_msrun;
};
#endif // COMPARSPECTRASHEET_H #endif // COMPARSPECTRASHEET_H
...@@ -114,6 +114,10 @@ void OdsExport::write(CalcWriterInterface * p_writer, WorkMonitorInterface * p_m ...@@ -114,6 +114,10 @@ void OdsExport::write(CalcWriterInterface * p_writer, WorkMonitorInterface * p_m
p_monitor->message(QObject::tr("writing emPAI comparisons")); p_monitor->message(QObject::tr("writing emPAI comparisons"));
ComparEmpaiSheet(this, p_writer, _p_project).writeSheet(); ComparEmpaiSheet(this, p_writer, _p_project).writeSheet();
} }
if (settings.value("export_ods/comparnsaf", "true").toBool()) {
p_monitor->message(QObject::tr("writing NSAF comparisons"));
ComparNsafSheet(this, p_writer, _p_project).writeSheet();
}
} }
if (settings.value("export_ods/samples", "true").toBool()) { if (settings.value("export_ods/samples", "true").toBool()) {
p_monitor->message(QObject::tr("writing samples")); p_monitor->message(QObject::tr("writing samples"));
......
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