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

fix divizion by zero problem

parent 85e8017d
No related branches found
No related tags found
No related merge requests found
......@@ -250,13 +250,23 @@ void ProjectWindow::computeMassPrecision() {
}
qDebug() << "ProjectWindow::computeMassPrecision accumulate";
pappso::pappso_double sum = std::accumulate(delta_list.begin(), delta_list.end(), 0);
pappso::pappso_double mean = sum / ((pappso::pappso_double) delta_list.size());
qDebug() << "ProjectWindow::computeMassPrecision delta_list.size()=" << delta_list.size();
pappso::pappso_double mean = 0;
if (delta_list.size() > 0) {
mean = sum / ((pappso::pappso_double) delta_list.size());
}
else {
throw pappso::PappsoException(QObject::tr("division by zero : no valid peptide found. Please check your filter parameters (decoy regexp or database particularly)"));
}
std::sort(delta_list.begin(), delta_list.end());
pappso::pappso_double median = delta_list[(delta_list.size()/2)];
qDebug() << "ProjectWindow::computeMassPrecision sd";
pappso::pappso_double sd = 0;
for (pappso::pappso_double val : delta_list) {
//sd = sd + ((val - mean) * (val - mean));
......@@ -270,10 +280,16 @@ void ProjectWindow::computeMassPrecision() {
ui->mass_precision_sd_label->setText(QString::number(sd,'f',10));
}
catch (pappso::PappsoException exception_pappso) {
ui->mass_precision_mean_label->setText("0");
ui->mass_precision_median_label->setText("0");
ui->mass_precision_sd_label->setText("0");
QMessageBox::warning(this,
tr("Unable to compute mass precision :"), exception_pappso.qwhat());
}
catch (std::exception exception_std) {
ui->mass_precision_mean_label->setText("0");
ui->mass_precision_median_label->setText("0");
ui->mass_precision_sd_label->setText("0");
QMessageBox::warning(this,
tr("Unable to compute mass precision :"), exception_std.what());
}
......
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