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

read decoy peptide in mascot dat file

parent a2e3d68f
No related branches found
No related tags found
No related merge requests found
......@@ -395,90 +395,109 @@ void MascotDatParser::saveQuery() {
qDebug() << __FILE__ << " " << __FUNCTION__<< " " << __LINE__;
if (_current_query.query_index > 0) {
std::vector< PeptideLine> peptide_list = _query_peptide_results[_current_query.query_index-1];
savePeptideList(peptide_list, false);
peptide_list = _decoy_query_peptide_results[_current_query.query_index-1];
savePeptideList(peptide_list, true);
}
qDebug() << __FILE__ << " " << __FUNCTION__<< " " << __LINE__;
}
void MascotDatParser::savePeptideList(std::vector< PeptideLine> & peptide_list, bool is_decoy) {
qDebug() << __FILE__ << " " << __FUNCTION__<< " " << __LINE__;
PeptideEvidence peptide_evidence(_p_identification_data_source->getMsRunSp().get(),_current_query.query_index);
peptide_evidence.setCharge(_current_query.charge);
peptide_evidence.setChecked(true);
peptide_evidence.setExperimentalMass(_summary_list[_current_query.query_index-1].exp_mass);
peptide_evidence.setRetentionTime(_current_query.rt);
PeptideEvidence peptide_evidence(_p_identification_data_source->getMsRunSp().get(),_current_query.query_index);
peptide_evidence.setCharge(_current_query.charge);
peptide_evidence.setChecked(true);
peptide_evidence.setExperimentalMass(_summary_list[_current_query.query_index-1].exp_mass);
peptide_evidence.setRetentionTime(_current_query.rt);
peptide_evidence.setIdentificationDataSource( _p_identification_data_source);
//parse and save
for(PeptideLine & peptide_line:peptide_list) {
peptide_evidence.setIdentificationDataSource( _p_identification_data_source);
//parse and save
for(PeptideLine & peptide_line:peptide_list) {
pappso::pappso_double ion_score = peptide_line.peptide_string_list.at(7).toDouble();
peptide_evidence.setParam(PeptideEvidenceParam::mascot_score, QVariant(ion_score));
pappso::pappso_double ion_score = peptide_line.peptide_string_list.at(7).toDouble();
peptide_evidence.setParam(PeptideEvidenceParam::mascot_score, QVariant(ion_score));
peptide_evidence.setEvalue(getEvalue(ion_score, _current_query.query_index, 0.05));
if (is_decoy) {
peptide_evidence.setEvalue(getEvalue(ion_score, _decoy_summary_list.at(_current_query.query_index-1), 0.05));
}
else {
peptide_evidence.setEvalue(getEvalue(ion_score, _summary_list.at(_current_query.query_index-1), 0.05));
}
peptide_evidence.setParam(PeptideEvidenceParam::mascot_expectation_value, QVariant(peptide_evidence.getEvalue()));
peptide_evidence.setParam(PeptideEvidenceParam::mascot_expectation_value, QVariant(peptide_evidence.getEvalue()));
QString peptide_str =peptide_line.peptide_string_list.at(4);
if (!peptide_line.subst.isEmpty()) {
//q856_p9_subst=1,X,W
//q24379_p2_subst=1,B,D,8,B,D
QStringList subst_list = peptide_line.subst.split(",");
for (unsigned int i=0; i < subst_list.size(); i+=3) {
peptide_str = peptide_str.replace(subst_list.at(0+i).toInt()-1,1,subst_list.at(2+i));
}
QString peptide_str =peptide_line.peptide_string_list.at(4);
if (!peptide_line.subst.isEmpty()) {
//q856_p9_subst=1,X,W
//q24379_p2_subst=1,B,D,8,B,D
QStringList subst_list = peptide_line.subst.split(",");
for (unsigned int i=0; i < subst_list.size(); i+=3) {
peptide_str = peptide_str.replace(subst_list.at(0+i).toInt()-1,1,subst_list.at(2+i));
}
PeptideXtpSp peptide_sp;
peptide_sp = PeptideXtp(peptide_str).makePeptideXtpSp();
}
PeptideXtpSp peptide_sp;
peptide_sp = PeptideXtp(peptide_str).makePeptideXtpSp();
peptide_evidence.setPeptideXtpSp(_p_project->getPeptideStore().getInstance(peptide_sp));
peptide_evidence.setPeptideXtpSp(_p_project->getPeptideStore().getInstance(peptide_sp));
//qDebug() << __FILE__ << " " << __FUNCTION__<< " peptide=" << peptide_str << " evalue=" << peptide_evidence.getEvalue() << " ionscore=" << ion_score;
//qDebug() << __FILE__ << " " << __FUNCTION__<< " peptide=" << peptide_str << " evalue=" << peptide_evidence.getEvalue() << " ionscore=" << ion_score;
if (peptide_line.protein_string_list.size() != peptide_line.fasta_file_list.size()) {
throw pappso::PappsoException(QObject::tr("ERROR (peptide_line.protein_string_list.size() != peptide_line.fasta_file_list.size()) %1").arg(peptide_line.protein_string_list.join(",\"")));
}
if (peptide_line.protein_string_list.size() != peptide_line.fasta_file_list.size()) {
throw pappso::PappsoException(QObject::tr("ERROR (peptide_line.protein_string_list.size() != peptide_line.fasta_file_list.size()) %1").arg(peptide_line.protein_string_list.join(",\"")));
unsigned int i=0;
foreach (const QString &str, peptide_line.protein_string_list) {
//sp|O95006|OR2F2_HUMAN":0:299:303:1
int position = str.indexOf("\"", 0);
QString accession = str.mid(0, position);
if (is_decoy) {
accession = QString("%1|reversed").arg(accession);
}
qDebug() << "accession=" << accession;
QStringList position_list = str.mid(position+2).split(":");
if (position_list.size() != 4) {
throw pappso::PappsoException(QObject::tr("ERROR position_list.size() != 4 %1").arg(str));
}
unsigned int start = position_list.at(1).toUInt()-1;
unsigned int stop = position_list.at(2).toUInt()-1;
//qDebug() << __FILE__ << " " << __FUNCTION__<< " " << __LINE__;
ProteinXtp protein;
protein.setAccession(accession);
protein.setFastaFileP(peptide_line.fasta_file_list[i].get());
if (is_decoy) {
protein.setIsDecoy(true);
}
unsigned int i=0;
foreach (const QString &str, peptide_line.protein_string_list) {
//sp|O95006|OR2F2_HUMAN":0:299:303:1
int position = str.indexOf("\"", 0);
QString accession = str.mid(0, position);
qDebug() << "accession=" << accession;
QStringList position_list = str.mid(position+2).split(":");
if (position_list.size() != 4) {
throw pappso::PappsoException(QObject::tr("ERROR position_list.size() != 4 %1").arg(str));
}
unsigned int start = position_list.at(1).toUInt()-1;
unsigned int stop = position_list.at(2).toUInt()-1;
//qDebug() << __FILE__ << " " << __FUNCTION__<< " " << __LINE__;
ProteinXtp protein;
protein.setAccession(accession);
protein.setFastaFileP(peptide_line.fasta_file_list[i].get());
ProteinMatch * p_protein_match = _p_identification_group->getProteinMatchInstance(accession);
if (p_protein_match == nullptr) {
throw pappso::PappsoException(QObject::tr("ERROR (p_protein_match == nullptr) %1").arg(str));
}
//qDebug() << __FILE__ << " " << __FUNCTION__<< " " << __LINE__;
ProteinXtpSp sp_xtp_protein = protein.makeProteinXtpSp();
p_protein_match->setProteinXtpSp(_p_project->getProteinStore().getInstance(sp_xtp_protein));
p_protein_match->setChecked(true);
ProteinMatch * p_protein_match = _p_identification_group->getProteinMatchInstance(accession);
if (p_protein_match == nullptr) {
throw pappso::PappsoException(QObject::tr("ERROR (p_protein_match == nullptr) %1").arg(str));
}
//qDebug() << __FILE__ << " " << __FUNCTION__<< " " << __LINE__;
ProteinXtpSp sp_xtp_protein = protein.makeProteinXtpSp();
p_protein_match->setProteinXtpSp(_p_project->getProteinStore().getInstance(sp_xtp_protein));
p_protein_match->setChecked(true);
PeptideMatch peptide_match;
peptide_match.setStart(start);
peptide_match.setPeptideEvidenceSp(_p_identification_data_source->getPeptideEvidenceStore().getInstance(&peptide_evidence));
PeptideMatch peptide_match;
peptide_match.setStart(start);
peptide_match.setPeptideEvidenceSp(_p_identification_data_source->getPeptideEvidenceStore().getInstance(&peptide_evidence));
p_protein_match->addPeptideMatch(peptide_match);
i++;
}
p_protein_match->addPeptideMatch(peptide_match);
i++;
}
}
qDebug() << __FILE__ << " " << __FUNCTION__<< " " << __LINE__;
}
pappso::pappso_double MascotDatParser::getEvalue(pappso::pappso_double ion_score, unsigned int query_index, pappso::pappso_double confidence_interval) const {
pappso::pappso_double identity_threshold = (pappso::pappso_double)10.0 * std::log(_summary_list.at(query_index-1).match / (confidence_interval * (pappso::pappso_double)20.0)) / log((pappso::pappso_double)10);;
pappso::pappso_double MascotDatParser::getEvalue(pappso::pappso_double ion_score, SummaryLine & summary_line, pappso::pappso_double confidence_interval) const {
pappso::pappso_double identity_threshold = (pappso::pappso_double)10.0 * std::log(summary_line.match / (confidence_interval * (pappso::pappso_double)20.0)) / log((pappso::pappso_double)10);;
return (confidence_interval * pow((pappso::pappso_double)10, ((identity_threshold - ion_score) / (pappso::pappso_double)10)));
}
pappso::pappso_double MascotDatParser::getEvalueExperimental(pappso::pappso_double ion_score, unsigned int query_index, pappso::pappso_double confidence_interval) const {
pappso::pappso_double MascotDatParser::getEvalueExperimental(pappso::pappso_double ion_score, SummaryLine & summary_line, pappso::pappso_double confidence_interval) const {
// Evalue experimental Homology threshold (QPlughole value from .dat file).
pappso::pappso_double eval = (ion_score - _summary_list.at(query_index-1).plug_hole) / (pappso::pappso_double)10;
pappso::pappso_double eval = (ion_score - summary_line.plug_hole) / (pappso::pappso_double)10;
eval = confidence_interval / pow((pappso::pappso_double)10, eval);
}
......@@ -49,8 +49,6 @@ private:
void saveAndClearPeptide();
pappso::pappso_double getEvalue(pappso::pappso_double ion_score, unsigned int query_index, pappso::pappso_double confidence_interval = 0.05) const;
pappso::pappso_double getEvalueExperimental(pappso::pappso_double ion_score, unsigned int query_index, pappso::pappso_double confidence_interval = 0.05) const;
......@@ -74,6 +72,10 @@ private:
pappso::pappso_double exp_mass=0;
pappso::pappso_double plug_hole=0; //qplughole, homology threshold
};
void savePeptideList(std::vector< PeptideLine> & peptide_list, bool is_decoy);
pappso::pappso_double getEvalue(pappso::pappso_double ion_score, SummaryLine & summary_line, pappso::pappso_double confidence_interval = 0.05) const;
pappso::pappso_double getEvalueExperimental(pappso::pappso_double ion_score, SummaryLine & summary_line, pappso::pappso_double confidence_interval = 0.05) const;
private:
Project * _p_project;
IdentificationGroup * _p_identification_group;
......
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