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

catch exception in FDR and mass precision computation

parent e980ca92
No related branches found
No related tags found
No related merge requests found
......@@ -207,57 +207,76 @@ void ProjectWindow::refreshGroup(IdentificationGroup * p_ident_group) {
void ProjectWindow::computeFdr() {
qDebug() << "ProjectWindow::computeFdr begin";
ValidationState state = ValidationState::valid;
pappso::pappso_double total_prot=0;
pappso::pappso_double false_prot=0;
pappso::pappso_double total_peptide=0;
pappso::pappso_double false_peptide=0;
for (IdentificationGroup * identification_group : _project_sp.get()->getIdentificationGroupList()) {
total_prot += identification_group->countProteinMatch(state);
false_prot += identification_group->countDecoyProteinMatch(state);
//total_peptide += identification_group->countPeptideMatch(state);
//false_peptide += identification_group->countDecoyPeptideMatch(state);
total_peptide += identification_group->countPeptideMassSample(state);
false_peptide += identification_group->countDecoyPeptideMassSample(state);
}
ui->protein_fdr_label->setText(QString("%1 %").arg(QString::number((false_prot/total_prot)*100.0,'f',10)));
ui->peptide_fdr_label->setText(QString("%1 %").arg(QString::number((false_peptide/total_peptide)*100.0,'f',10)));
try {
ValidationState state = ValidationState::valid;
pappso::pappso_double total_prot=0;
pappso::pappso_double false_prot=0;
pappso::pappso_double total_peptide=0;
pappso::pappso_double false_peptide=0;
for (IdentificationGroup * identification_group : _project_sp.get()->getIdentificationGroupList()) {
total_prot += identification_group->countProteinMatch(state);
false_prot += identification_group->countDecoyProteinMatch(state);
//total_peptide += identification_group->countPeptideMatch(state);
//false_peptide += identification_group->countDecoyPeptideMatch(state);
total_peptide += identification_group->countPeptideMassSample(state);
false_peptide += identification_group->countDecoyPeptideMassSample(state);
}
ui->protein_fdr_label->setText(QString("%1 %").arg(QString::number((false_prot/total_prot)*100.0,'f',10)));
ui->peptide_fdr_label->setText(QString("%1 %").arg(QString::number((false_peptide/total_peptide)*100.0,'f',10)));
}
catch (pappso::PappsoException exception_pappso) {
QMessageBox::warning(this,
tr("Unable to compute FDR :"), exception_pappso.qwhat());
}
catch (std::exception exception_std) {
QMessageBox::warning(this,
tr("Unable to compute FDR :"), exception_std.what());
}
qDebug() << "ProjectWindow::computeFdr end";
}
void ProjectWindow::computeMassPrecision() {
qDebug() << "ProjectWindow::computeMassPrecision begin";
ValidationState state = ValidationState::validAndChecked;
std::vector< pappso::pappso_double> delta_list;
pappso::PrecisionUnit unit = pappso::PrecisionUnit::dalton;
if (ui->precision_unit_combobox->currentText() == "ppm") {
unit = pappso::PrecisionUnit::ppm;
}
try {
ValidationState state = ValidationState::validAndChecked;
std::vector< pappso::pappso_double> delta_list;
pappso::PrecisionUnit unit = pappso::PrecisionUnit::dalton;
if (ui->precision_unit_combobox->currentText() == "ppm") {
unit = pappso::PrecisionUnit::ppm;
}
for (IdentificationGroup * identification_group : _project_sp.get()->getIdentificationGroupList()) {
identification_group->collectMhDelta(delta_list, unit, state);
}
for (IdentificationGroup * identification_group : _project_sp.get()->getIdentificationGroupList()) {
identification_group->collectMhDelta(delta_list, unit, state);
}
pappso::pappso_double sum = std::accumulate(delta_list.begin(), delta_list.end(), 0);
pappso::pappso_double sum = std::accumulate(delta_list.begin(), delta_list.end(), 0);
pappso::pappso_double mean = sum / ((pappso::pappso_double) delta_list.size());
pappso::pappso_double mean = sum / ((pappso::pappso_double) delta_list.size());
std::sort(delta_list.begin(), delta_list.end());
pappso::pappso_double median = delta_list[(delta_list.size()/2)];
std::sort(delta_list.begin(), delta_list.end());
pappso::pappso_double median = delta_list[(delta_list.size()/2)];
pappso::pappso_double sd = 0;
for (pappso::pappso_double val : delta_list) {
//sd = sd + ((val - mean) * (val - mean));
sd += std::pow((val - mean), 2);
}
sd = sd / delta_list.size();
sd = std::sqrt(sd);
pappso::pappso_double sd = 0;
for (pappso::pappso_double val : delta_list) {
//sd = sd + ((val - mean) * (val - mean));
sd += std::pow((val - mean), 2);
}
sd = sd / delta_list.size();
sd = std::sqrt(sd);
ui->mass_precision_mean_label->setText(QString::number(mean,'f',10));
ui->mass_precision_median_label->setText(QString::number(median,'f',10));
ui->mass_precision_sd_label->setText(QString::number(sd,'f',10));
ui->mass_precision_mean_label->setText(QString::number(mean,'f',10));
ui->mass_precision_median_label->setText(QString::number(median,'f',10));
ui->mass_precision_sd_label->setText(QString::number(sd,'f',10));
}
catch (pappso::PappsoException exception_pappso) {
QMessageBox::warning(this,
tr("Unable to compute mass precision :"), exception_pappso.qwhat());
}
catch (std::exception exception_std) {
QMessageBox::warning(this,
tr("Unable to compute mass precision :"), exception_std.what());
}
qDebug() << "ProjectWindow::computeMassPrecision end";
}
......@@ -274,7 +293,7 @@ void ProjectWindow::doFdrChanged() {
p_fasta_file->setDecoys(_project_sp.get()->getProteinStore());
}
else {
throw pappso::PappsoException(QObject::tr("can not convert to FastaFile index.data().canConvert<FastaFile *>()"));
throw pappso::PappsoException(QObject::tr("can not convert to FastaFile index.data().canConvert<FastaFile *>()"));
}
}
}
......@@ -310,7 +329,7 @@ void ProjectWindow::doAutomaticFilterParametersChanged(AutomaticFilterParameters
p_fasta_file->setContaminants(_project_sp.get()->getProteinStore());
}
else {
throw pappso::PappsoException(QObject::tr("can not convert to FastaFile index.data().canConvert<FastaFile *>()"));
throw pappso::PappsoException(QObject::tr("can not convert to FastaFile index.data().canConvert<FastaFile *>()"));
}
}
}
......
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