diff --git a/src/core/identification_sources/identificationdatasource.cpp b/src/core/identification_sources/identificationdatasource.cpp
index 0f21750d3a4793713edd73a124d765b42693dfe5..9ef578db626871d017589e5cc8cdedad9dbfbbed 100644
--- a/src/core/identification_sources/identificationdatasource.cpp
+++ b/src/core/identification_sources/identificationdatasource.cpp
@@ -1,25 +1,26 @@
 
 /*******************************************************************************
-* Copyright (c) 2016 Olivier Langella <Olivier.Langella@moulon.inra.fr>.
-*
-* This file is part of XTPcpp.
-*
-*     XTPcpp is free software: you can redistribute it and/or modify
-*     it under the terms of the GNU General Public License as published by
-*     the Free Software Foundation, either version 3 of the License, or
-*     (at your option) any later version.
-*
-*     XTPcpp is distributed in the hope that it will be useful,
-*     but WITHOUT ANY WARRANTY; without even the implied warranty of
-*     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-*     GNU General Public License for more details.
-*
-*     You should have received a copy of the GNU General Public License
-*     along with XTPcpp.  If not, see <http://www.gnu.org/licenses/>.
-*
-* Contributors:
-*     Olivier Langella <Olivier.Langella@moulon.inra.fr> - initial API and implementation
-******************************************************************************/
+ * Copyright (c) 2016 Olivier Langella <Olivier.Langella@moulon.inra.fr>.
+ *
+ * This file is part of XTPcpp.
+ *
+ *     XTPcpp is free software: you can redistribute it and/or modify
+ *     it under the terms of the GNU General Public License as published by
+ *     the Free Software Foundation, either version 3 of the License, or
+ *     (at your option) any later version.
+ *
+ *     XTPcpp is distributed in the hope that it will be useful,
+ *     but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *     GNU General Public License for more details.
+ *
+ *     You should have received a copy of the GNU General Public License
+ *     along with XTPcpp.  If not, see <http://www.gnu.org/licenses/>.
+ *
+ * Contributors:
+ *     Olivier Langella <Olivier.Langella@moulon.inra.fr> - initial API and
+ *implementation
+ ******************************************************************************/
 
 #include "identificationdatasource.h"
 #include "identificationxtandemfile.h"
@@ -30,144 +31,226 @@
 
 IdentificationDataSource::IdentificationDataSource(const QString resource_name)
 {
-    _resource_name = resource_name;
+  _resource_name = resource_name;
 }
 
-IdentificationDataSource::IdentificationDataSource(const IdentificationDataSource& other)
+IdentificationDataSource::IdentificationDataSource(
+  const IdentificationDataSource &other)
 {
-    _ms_run_sp = other._ms_run_sp;
-    _resource_name = other._resource_name;
-    _xml_id = other._xml_id;
-    _version = other._version;
-    _params = other._params;
-    _param_stats = other._param_stats;
-    _fastafile_list = other._fastafile_list;
+  _ms_run_sp      = other._ms_run_sp;
+  _resource_name  = other._resource_name;
+  _xml_id         = other._xml_id;
+  _version        = other._version;
+  _params         = other._params;
+  _param_stats    = other._param_stats;
+  _fastafile_list = other._fastafile_list;
 
-    //PeptideEvidenceStore _peptide_evidence_store;
+  // PeptideEvidenceStore _peptide_evidence_store;
 }
 
 IdentificationDataSource::~IdentificationDataSource()
 {
-
 }
 
-const std::map<IdentificationEngineStatistics, QVariant> & IdentificationDataSource::getIdentificationEngineStatisticsMap() const {
-    return _param_stats;
+const std::map<IdentificationEngineStatistics, QVariant> &
+IdentificationDataSource::getIdentificationEngineStatisticsMap() const
+{
+  return _param_stats;
 }
 
-const std::map<IdentificationEngineParam, QVariant> & IdentificationDataSource::getIdentificationEngineParamMap() const {
-    return _params;
+const std::map<IdentificationEngineParam, QVariant> &
+IdentificationDataSource::getIdentificationEngineParamMap() const
+{
+  return _params;
 }
 
-const PeptideEvidenceStore & IdentificationDataSource::getPeptideEvidenceStore() const {
-    return _peptide_evidence_store;
+const PeptideEvidenceStore &
+IdentificationDataSource::getPeptideEvidenceStore() const
+{
+  return _peptide_evidence_store;
 }
-PeptideEvidenceStore & IdentificationDataSource::getPeptideEvidenceStore() {
-    return _peptide_evidence_store;
+PeptideEvidenceStore &
+IdentificationDataSource::getPeptideEvidenceStore()
+{
+  return _peptide_evidence_store;
 }
 
-void IdentificationDataSource::setXmlId(const QString xmlid) {
-    _xml_id = xmlid;
+void
+IdentificationDataSource::setXmlId(const QString xmlid)
+{
+  _xml_id = xmlid;
 }
-const QString & IdentificationDataSource::getXmlId() const {
-    return _xml_id;
+const QString &
+IdentificationDataSource::getXmlId() const
+{
+  return _xml_id;
 }
-bool IdentificationDataSource::operator==(const IdentificationDataSource& other) const
+bool
+IdentificationDataSource::
+operator==(const IdentificationDataSource &other) const
 {
-
 }
 
-const QString & IdentificationDataSource::getResourceName () const {
-    return _resource_name;
+const QString &
+IdentificationDataSource::getResourceName() const
+{
+  return _resource_name;
 }
 
-const QString IdentificationDataSource::getSampleName () const {
-    return _ms_run_sp.get()->getSampleName();
+const QString
+IdentificationDataSource::getSampleName() const
+{
+  return _ms_run_sp.get()->getSampleName();
 }
 
-void IdentificationDataSource::setMsRunSp (MsRunSp ms_run_sp) {
-    _ms_run_sp = ms_run_sp;
+void
+IdentificationDataSource::setMsRunSp(MsRunSp ms_run_sp)
+{
+  _ms_run_sp = ms_run_sp;
 }
-MsRunSp IdentificationDataSource::getMsRunSp () const {
-    return (_ms_run_sp);
+MsRunSp
+IdentificationDataSource::getMsRunSp() const
+{
+  return (_ms_run_sp);
 }
-void IdentificationDataSource::setIdentificationEngine(IdentificationEngine engine) {
-    _engine = engine;
+void
+IdentificationDataSource::setIdentificationEngine(IdentificationEngine engine)
+{
+  _engine = engine;
 }
 
-IdentificationEngine IdentificationDataSource::getIdentificationEngine() const {
-    return _engine;
+IdentificationEngine
+IdentificationDataSource::getIdentificationEngine() const
+{
+  return _engine;
 }
-const QString IdentificationDataSource::getIdentificationEngineName() const {
-    QString name = "unknown";
-    switch (_engine) {
-    case IdentificationEngine::XTandem :
+const QString
+IdentificationDataSource::getIdentificationEngineName() const
+{
+  QString name = "unknown";
+  switch(_engine)
+    {
+      case IdentificationEngine::XTandem:
         name = "X!Tandem";
         break;
-    case IdentificationEngine::peptider :
+      case IdentificationEngine::peptider:
         name = "peptider";
         break;
     }
-    return name;
+  return name;
 }
-const QString& IdentificationDataSource::getIdentificationEngineVersion() const {
-    return _version;
+const QString &
+IdentificationDataSource::getIdentificationEngineVersion() const
+{
+  return _version;
 }
-void IdentificationDataSource::setIdentificationEngineVersion(const QString& version) {
-    _version = version;
+void
+IdentificationDataSource::setIdentificationEngineVersion(const QString &version)
+{
+  _version = version;
 }
-void IdentificationDataSource::setIdentificationEngineParam(IdentificationEngineParam param, const QVariant& value) {
-    _params.insert(std::pair<IdentificationEngineParam, QVariant>(param, value));
+void
+IdentificationDataSource::setIdentificationEngineParam(
+  IdentificationEngineParam param, const QVariant &value)
+{
+  _params.insert(std::pair<IdentificationEngineParam, QVariant>(param, value));
 }
 
-const QVariant IdentificationDataSource::getIdentificationEngineParam(IdentificationEngineParam param) const {
-    try {
-        return _params.at(param);
+const QVariant
+IdentificationDataSource::getIdentificationEngineParam(
+  IdentificationEngineParam param) const
+{
+  try
+    {
+      return _params.at(param);
     }
-    catch (std::out_of_range) {
-        return QVariant();
+  catch(std::out_of_range)
+    {
+      return QVariant();
     }
 }
 
-void IdentificationDataSource::setIdentificationEngineStatistics(IdentificationEngineStatistics param, const QVariant& value) {
-    _param_stats.insert(std::pair<IdentificationEngineStatistics, QVariant>(param, value));
+void
+IdentificationDataSource::setIdentificationEngineStatistics(
+  IdentificationEngineStatistics param, const QVariant &value)
+{
+  _param_stats.insert(
+    std::pair<IdentificationEngineStatistics, QVariant>(param, value));
 }
-const QVariant IdentificationDataSource::getIdentificationEngineStatistics(IdentificationEngineStatistics param) const {
-    try {
-        return _param_stats.at(param);
+const QVariant
+IdentificationDataSource::getIdentificationEngineStatistics(
+  IdentificationEngineStatistics param) const
+{
+  try
+    {
+      return _param_stats.at(param);
     }
-    catch (std::out_of_range) {
-        return QVariant();
+  catch(std::out_of_range)
+    {
+      return QVariant();
     }
 }
 
-pappso::SpectrumSp IdentificationDataSource::getSpectrumSp(unsigned int scan_number) const {
-    qDebug() << __FILE__ << " " << __FUNCTION__ << " " << __LINE__  ;
-    if (_ms_run_sp.get()->getMzFormat() == pappso::MzFormat::MGF) {
-        scan_number = scan_number-1;
+pappso::SpectrumSp
+IdentificationDataSource::getSpectrumSp(unsigned int scan_number) const
+{
+
+  qDebug() << __FILE__ << " " << __FUNCTION__ << " " << __LINE__;
+  if(_ms_run_sp.get()->getMzFormat() == pappso::MzFormat::MGF)
+    {
+      scan_number = scan_number - 1;
     }
-    if (_ms_run_sp.get()->findMsRunFile() == false) {
-        throw pappso::ExceptionNotFound(QObject::tr("mz data \"%1\" file not found").arg(_ms_run_sp.get()->getFilename()));
+  pappso::MsRunReaderSp msrun_reader_sp = _ms_run_sp.get()->getMsRunReaderSp();
+
+  if(msrun_reader_sp == nullptr)
+    {
+      if(_ms_run_sp.get()->findMsRunFile() == false)
+        {
+          throw pappso::ExceptionNotFound(
+            QObject::tr("mz data \"%1\" file not found")
+              .arg(_ms_run_sp.get()->getFilename()));
+        }
     }
-    
-    //qDebug() << __FILE__ << " " << __FUNCTION__ << " " << __LINE__  << _ms_run_sp.get()->getMsRunReaderSp().get()->getSpectrumListSize();
-    pappso::SpectrumSp spectrum_sp = _ms_run_sp.get()->getMsRunReaderSp().get()->getSpectrumSp(scan_number);
-    qDebug() << __FILE__ << " " << __FUNCTION__ << " " << __LINE__ ;
-    return spectrum_sp;
+  msrun_reader_sp = _ms_run_sp.get()->getMsRunReaderSp();
+  if(msrun_reader_sp == nullptr)
+    {
+      throw pappso::ExceptionNotFound(
+        QObject::tr("mz data \"%1\" file not found")
+          .arg(_ms_run_sp.get()->getFilename()));
+    }
+
+
+  // qDebug() << __FILE__ << " " << __FUNCTION__ << " " << __LINE__  <<
+  // _ms_run_sp.get()->getMsRunReaderSp().get()->getSpectrumListSize();
+  pappso::SpectrumSp spectrum_sp =
+    msrun_reader_sp.get()->getSpectrumSp(scan_number);
+  qDebug() << __FILE__ << " " << __FUNCTION__ << " " << __LINE__;
+  return spectrum_sp;
 }
 
-void IdentificationDataSource::addFastaFile (FastaFileSp file) {
-    _fastafile_list.push_back(file);
+void
+IdentificationDataSource::addFastaFile(FastaFileSp file)
+{
+  _fastafile_list.push_back(file);
 }
-const std::vector<FastaFileSp> & IdentificationDataSource::getFastaFileList() const {
-    qDebug()<<  "IdentificationDataSource::getFastaFileList begin" << _fastafile_list.size();
-    return _fastafile_list;
+const std::vector<FastaFileSp> &
+IdentificationDataSource::getFastaFileList() const
+{
+  qDebug() << "IdentificationDataSource::getFastaFileList begin"
+           << _fastafile_list.size();
+  return _fastafile_list;
 }
 
-const bool IdentificationDataSource::isValid(const PeptideEvidence * p_peptide_evidence, const AutomaticFilterParameters & automatic_filter_parameters) const {
-    
-    if (p_peptide_evidence->getEvalue() <= automatic_filter_parameters.getFilterPeptideEvalue()) {
-       return true;
+const bool
+IdentificationDataSource::isValid(
+  const PeptideEvidence *p_peptide_evidence,
+  const AutomaticFilterParameters &automatic_filter_parameters) const
+{
+
+  if(p_peptide_evidence->getEvalue() <=
+     automatic_filter_parameters.getFilterPeptideEvalue())
+    {
+      return true;
     }
-    return false;
+  return false;
 }
diff --git a/src/core/identificationgroup.cpp b/src/core/identificationgroup.cpp
index 666e75c8194577803f8a329e43b5f56e03c9385f..ef5736adff4de3aa6544b5821218f9969e75df30 100644
--- a/src/core/identificationgroup.cpp
+++ b/src/core/identificationgroup.cpp
@@ -1,25 +1,26 @@
 
 /*******************************************************************************
-* Copyright (c) 2017 Olivier Langella <olivier.langella@u-psud.fr>.
-*
-* This file is part of XTPcpp.
-*
-*     XTPcpp is free software: you can redistribute it and/or modify
-*     it under the terms of the GNU General Public License as published by
-*     the Free Software Foundation, either version 3 of the License, or
-*     (at your option) any later version.
-*
-*     XTPcpp is distributed in the hope that it will be useful,
-*     but WITHOUT ANY WARRANTY; without even the implied warranty of
-*     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-*     GNU General Public License for more details.
-*
-*     You should have received a copy of the GNU General Public License
-*     along with XTPcpp.  If not, see <http://www.gnu.org/licenses/>.
-*
-* Contributors:
-*     Olivier Langella <olivier.langella@u-psud.fr> - initial API and implementation
-******************************************************************************/
+ * Copyright (c) 2017 Olivier Langella <olivier.langella@u-psud.fr>.
+ *
+ * This file is part of XTPcpp.
+ *
+ *     XTPcpp is free software: you can redistribute it and/or modify
+ *     it under the terms of the GNU General Public License as published by
+ *     the Free Software Foundation, either version 3 of the License, or
+ *     (at your option) any later version.
+ *
+ *     XTPcpp is distributed in the hope that it will be useful,
+ *     but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *     GNU General Public License for more details.
+ *
+ *     You should have received a copy of the GNU General Public License
+ *     along with XTPcpp.  If not, see <http://www.gnu.org/licenses/>.
+ *
+ * Contributors:
+ *     Olivier Langella <olivier.langella@u-psud.fr> - initial API and
+ *implementation
+ ******************************************************************************/
 
 #include "identificationgroup.h"
 #include "project.h"
@@ -27,317 +28,460 @@
 #include <pappsomspp/pappsoexception.h>
 
 
-IdentificationGroup::IdentificationGroup(Project * project)
+IdentificationGroup::IdentificationGroup(Project *project)
 {
-    _p_project = project;
+  _p_project = project;
 }
 
 IdentificationGroup::~IdentificationGroup()
 {
-    auto it = _protein_match_list.begin();
-    while (it != _protein_match_list.end()) {
-        delete (*it);
-        it++;
+  auto it = _protein_match_list.begin();
+  while(it != _protein_match_list.end())
+    {
+      delete(*it);
+      it++;
     }
 }
 
-const PtmGroupingExperiment * IdentificationGroup::getPtmGroupingExperiment() const {
-    return _p_grp_ptm_experiment;
+const PtmGroupingExperiment *
+IdentificationGroup::getPtmGroupingExperiment() const
+{
+  return _p_grp_ptm_experiment;
 }
-const GroupStore & IdentificationGroup::getGroupStore() const {
-    return _group_store;
+const GroupStore &
+IdentificationGroup::getGroupStore() const
+{
+  return _group_store;
 }
 
-pappso::pappso_double IdentificationGroup::computeProtoNsafSum(const MsRun * p_msrun_id ) const {
-    pappso::pappso_double nsaf_sum = 0;
-    for (auto & p_protein_match : _protein_match_list) {
-        if (p_protein_match->getValidationState() >= ValidationState::grouped) {
-            nsaf_sum += p_protein_match->getProtoNsaf(p_msrun_id);
+pappso::pappso_double
+IdentificationGroup::computeProtoNsafSum(const MsRun *p_msrun_id) const
+{
+  pappso::pappso_double nsaf_sum = 0;
+  for(auto &p_protein_match : _protein_match_list)
+    {
+      if(p_protein_match->getValidationState() >= ValidationState::grouped)
+        {
+          nsaf_sum += p_protein_match->getProtoNsaf(p_msrun_id);
         }
     }
-    return nsaf_sum;
+  return nsaf_sum;
 }
 
-unsigned int IdentificationGroup::countPeptideMass(ValidationState state) const {
+unsigned int
+IdentificationGroup::countPeptideMass(ValidationState state) const
+{
 
-    std::vector<pappso::GrpPeptide *> count_peptide_mass;
-    for (auto & p_protein_match : _protein_match_list) {
-        if (p_protein_match->getValidationState() >= state) {
-            p_protein_match->countPeptideMass(count_peptide_mass, state);
+  std::vector<pappso::GrpPeptide *> count_peptide_mass;
+  for(auto &p_protein_match : _protein_match_list)
+    {
+      if(p_protein_match->getValidationState() >= state)
+        {
+          p_protein_match->countPeptideMass(count_peptide_mass, state);
         }
     }
-    std::sort(count_peptide_mass.begin(), count_peptide_mass.end());
-    auto last = std::unique(count_peptide_mass.begin(),count_peptide_mass.end());
-    return std::distance(count_peptide_mass.begin(),last);
+  std::sort(count_peptide_mass.begin(), count_peptide_mass.end());
+  auto last = std::unique(count_peptide_mass.begin(), count_peptide_mass.end());
+  return std::distance(count_peptide_mass.begin(), last);
 }
 
-unsigned int IdentificationGroup::countPeptideMassSample(ValidationState state) const {
+unsigned int
+IdentificationGroup::countPeptideMassSample(ValidationState state) const
+{
 
-    std::vector<std::size_t> count_peptide_mass_sample;
-    for (auto & p_protein_match : _protein_match_list) {
-        if (p_protein_match->getValidationState() >= state) {
-            p_protein_match->countPeptideMassSample(count_peptide_mass_sample, state);
+  std::vector<std::size_t> count_peptide_mass_sample;
+  for(auto &p_protein_match : _protein_match_list)
+    {
+      if(p_protein_match->getValidationState() >= state)
+        {
+          p_protein_match->countPeptideMassSample(count_peptide_mass_sample,
+                                                  state);
         }
     }
-    std::sort(count_peptide_mass_sample.begin(), count_peptide_mass_sample.end());
-    auto last = std::unique(count_peptide_mass_sample.begin(),count_peptide_mass_sample.end());
-    return std::distance(count_peptide_mass_sample.begin(),last);
+  std::sort(count_peptide_mass_sample.begin(), count_peptide_mass_sample.end());
+  auto last = std::unique(count_peptide_mass_sample.begin(),
+                          count_peptide_mass_sample.end());
+  return std::distance(count_peptide_mass_sample.begin(), last);
 }
 
-unsigned int IdentificationGroup::countDecoyPeptideMassSample(ValidationState state) const {
-    std::vector<std::size_t> count_peptide_mass_sample;
-    for (auto & p_protein_match : _protein_match_list) {
-        if (p_protein_match->getProteinXtpSp().get()->isDecoy()) {
-            if (p_protein_match->getValidationState() >= state) {
-                p_protein_match->countPeptideMassSample(count_peptide_mass_sample, state);
+unsigned int
+IdentificationGroup::countDecoyPeptideMassSample(ValidationState state) const
+{
+  std::vector<std::size_t> count_peptide_mass_sample;
+  for(auto &p_protein_match : _protein_match_list)
+    {
+      if(p_protein_match->getProteinXtpSp().get()->isDecoy())
+        {
+          if(p_protein_match->getValidationState() >= state)
+            {
+              p_protein_match->countPeptideMassSample(count_peptide_mass_sample,
+                                                      state);
             }
         }
     }
-    std::sort(count_peptide_mass_sample.begin(), count_peptide_mass_sample.end());
-    auto last = std::unique(count_peptide_mass_sample.begin(),count_peptide_mass_sample.end());
-    return std::distance(count_peptide_mass_sample.begin(),last);
+  std::sort(count_peptide_mass_sample.begin(), count_peptide_mass_sample.end());
+  auto last = std::unique(count_peptide_mass_sample.begin(),
+                          count_peptide_mass_sample.end());
+  return std::distance(count_peptide_mass_sample.begin(), last);
 }
 
 
-unsigned int IdentificationGroup::countDecoyProteinMatch(ValidationState state) const {
-    return std::count_if (_protein_match_list.begin(), _protein_match_list.end(), [state](const ProteinMatch * p_protein_match) {
-        if ((p_protein_match->getProteinXtpSp().get()->isDecoy()) && (p_protein_match->getValidationState() >= state)) {
-            return true;
+unsigned int
+IdentificationGroup::countDecoyProteinMatch(ValidationState state) const
+{
+  return std::count_if(
+    _protein_match_list.begin(),
+    _protein_match_list.end(),
+    [state](const ProteinMatch *p_protein_match) {
+      if((p_protein_match->getProteinXtpSp().get()->isDecoy()) &&
+         (p_protein_match->getValidationState() >= state))
+        {
+          return true;
         }
-        else              {
-            return false;
+      else
+        {
+          return false;
         }
     });
 }
 
-unsigned int IdentificationGroup::countPeptideEvidence(ValidationState state) const {
-    std::set<const PeptideEvidence *> peptide_evidence_set;
-    for (auto & p_protein_match : _protein_match_list) {
-        if (p_protein_match->getValidationState() >= state) {
-            p_protein_match->collectPeptideEvidences(peptide_evidence_set,state);
+unsigned int
+IdentificationGroup::countPeptideEvidence(ValidationState state) const
+{
+  std::set<const PeptideEvidence *> peptide_evidence_set;
+  for(auto &p_protein_match : _protein_match_list)
+    {
+      if(p_protein_match->getValidationState() >= state)
+        {
+          p_protein_match->collectPeptideEvidences(peptide_evidence_set, state);
         }
     }
-    return peptide_evidence_set.size();
+  return peptide_evidence_set.size();
 }
 
-unsigned int IdentificationGroup::countDecoyPeptideEvidence(ValidationState state) const {
-    std::set<const PeptideEvidence *> peptide_evidence_set;
-    for (auto & p_protein_match : _protein_match_list) {
-        if (p_protein_match->getValidationState() >= state) {
-            if (p_protein_match->getProteinXtpSp().get()->isDecoy()) {
-                p_protein_match->collectPeptideEvidences(peptide_evidence_set,state);
+unsigned int
+IdentificationGroup::countDecoyPeptideEvidence(ValidationState state) const
+{
+  std::set<const PeptideEvidence *> peptide_evidence_set;
+  for(auto &p_protein_match : _protein_match_list)
+    {
+      if(p_protein_match->getValidationState() >= state)
+        {
+          if(p_protein_match->getProteinXtpSp().get()->isDecoy())
+            {
+              p_protein_match->collectPeptideEvidences(peptide_evidence_set,
+                                                       state);
             }
         }
     }
-    return peptide_evidence_set.size();
+  return peptide_evidence_set.size();
 }
 
-unsigned int IdentificationGroup::countPeptideMatch(ValidationState state) const {
-    unsigned int i=0;
-    for (auto & p_protein_match : _protein_match_list) {
-        if (p_protein_match->getValidationState() >= state) {
-            i+=p_protein_match->countPeptideMatch(state);
+unsigned int
+IdentificationGroup::countPeptideMatch(ValidationState state) const
+{
+  unsigned int i = 0;
+  for(auto &p_protein_match : _protein_match_list)
+    {
+      if(p_protein_match->getValidationState() >= state)
+        {
+          i += p_protein_match->countPeptideMatch(state);
         }
     }
-    return i;
+  return i;
 }
 
-unsigned int IdentificationGroup::countDecoyPeptideMatch(ValidationState state) const {
-    unsigned int i=0;
-    for (auto & p_protein_match : _protein_match_list) {
-        if (p_protein_match->getValidationState() >= state) {
-            if (p_protein_match->getProteinXtpSp().get()->isDecoy()) {
-                i+=p_protein_match->countPeptideMatch(state);
+unsigned int
+IdentificationGroup::countDecoyPeptideMatch(ValidationState state) const
+{
+  unsigned int i = 0;
+  for(auto &p_protein_match : _protein_match_list)
+    {
+      if(p_protein_match->getValidationState() >= state)
+        {
+          if(p_protein_match->getProteinXtpSp().get()->isDecoy())
+            {
+              i += p_protein_match->countPeptideMatch(state);
             }
         }
     }
-    return i;
+  return i;
 }
-unsigned int IdentificationGroup::countProteinMatch(ValidationState state) const {
-    return std::count_if (_protein_match_list.begin(), _protein_match_list.end(), [state](const ProteinMatch * p_protein_match) {
-        if (p_protein_match->getValidationState() >= state) {
-            return true;
-        }
-        else              {
-            return false;
-        }
-    });
-}
-
-void IdentificationGroup::updateAutomaticFilters(const AutomaticFilterParameters & automatic_filter_parameters) {
-    qDebug() << "IdentificationGroup::updateAutomaticFilters begin" ;
-    for (IdentificationDataSource * p_identification_source_list:_id_source_list) {
-        p_identification_source_list->getPeptideEvidenceStore().updateAutomaticFilters(automatic_filter_parameters);
-    }
-    
-    qDebug() << "IdentificationGroup::updateAutomaticFilters begin p_protein_match" ;
-    for (auto & p_protein_match : _protein_match_list) {
-        p_protein_match->updateAutomaticFilters(automatic_filter_parameters);
+unsigned int
+IdentificationGroup::countProteinMatch(ValidationState state) const
+{
+  return std::count_if(_protein_match_list.begin(),
+                       _protein_match_list.end(),
+                       [state](const ProteinMatch *p_protein_match) {
+                         if(p_protein_match->getValidationState() >= state)
+                           {
+                             return true;
+                           }
+                         else
+                           {
+                             return false;
+                           }
+                       });
+}
+
+void
+IdentificationGroup::updateAutomaticFilters(
+  const AutomaticFilterParameters &automatic_filter_parameters)
+{
+  qDebug() << "IdentificationGroup::updateAutomaticFilters begin";
+  for(IdentificationDataSource *p_identification_source_list : _id_source_list)
+    {
+      p_identification_source_list->getPeptideEvidenceStore()
+        .updateAutomaticFilters(automatic_filter_parameters);
     }
 
-    if (_p_grp_experiment != nullptr) {
+  qDebug()
+    << "IdentificationGroup::updateAutomaticFilters begin p_protein_match";
+  for(auto &p_protein_match : _protein_match_list)
+    {
+      p_protein_match->updateAutomaticFilters(automatic_filter_parameters);
     }
-    qDebug() << "IdentificationGroup::updateAutomaticFilters end" ;
 
+  if(_p_grp_experiment != nullptr)
+    {
+    }
+  qDebug() << "IdentificationGroup::updateAutomaticFilters end";
 }
-ProteinMatch * IdentificationGroup::getProteinMatchInstance(const QString accession) {
-    if (accession.isEmpty()) {
-        throw pappso::PappsoException(QObject::tr("Error protein match not found : accession is empty"));
+ProteinMatch *
+IdentificationGroup::getProteinMatchInstance(const QString accession)
+{
+  if(accession.isEmpty())
+    {
+      throw pappso::PappsoException(
+        QObject::tr("Error protein match not found : accession is empty"));
     }
-    auto it_cache = _cache_accession_protein_match.find(accession);
-    if (it_cache == _cache_accession_protein_match.end()) {
-        //accession not found in cache
-        ProteinMatch * p_protein_match = new ProteinMatch();
-        _cache_accession_protein_match.insert(std::pair<QString, ProteinMatch *>(accession, p_protein_match));
-        _protein_match_list.push_back(p_protein_match);
-        return p_protein_match;
+  auto it_cache = _cache_accession_protein_match.find(accession);
+  if(it_cache == _cache_accession_protein_match.end())
+    {
+      // accession not found in cache
+      ProteinMatch *p_protein_match = new ProteinMatch();
+      _cache_accession_protein_match.insert(
+        std::pair<QString, ProteinMatch *>(accession, p_protein_match));
+      _protein_match_list.push_back(p_protein_match);
+      return p_protein_match;
     }
-    else {
-        return it_cache->second;
+  else
+    {
+      return it_cache->second;
     }
-    return nullptr;
+  return nullptr;
 }
-void IdentificationGroup::addProteinMatch(ProteinMatch * protein_match) {
-    _protein_match_list.push_back(protein_match);
+void
+IdentificationGroup::addProteinMatch(ProteinMatch *protein_match)
+{
+  _protein_match_list.push_back(protein_match);
 }
 
-bool IdentificationGroup::contains (const MsRun * p_msrun) const {
-    for (const MsRunSp & msrun: _ms_run_list) {
-        if (msrun.get() == p_msrun) return true;
+bool
+IdentificationGroup::contains(const MsRun *p_msrun) const
+{
+  for(const MsRunSp &msrun : _ms_run_list)
+    {
+      if(msrun.get() == p_msrun)
+        return true;
     }
-    return false;
+  return false;
 }
 
-bool IdentificationGroup::containSample (const QString & sample) const {
-    for (const MsRunSp & msrun: _ms_run_list) {
-        if (msrun.get()->getSampleName() == sample) return true;
+bool
+IdentificationGroup::containSample(const QString &sample) const
+{
+  for(const MsRunSp &msrun : _ms_run_list)
+    {
+      if(msrun.get()->getSampleName() == sample)
+        return true;
     }
-    return false;
+  return false;
 }
 
-void IdentificationGroup::addIdentificationDataSourceP(IdentificationDataSource *  p_identification_source) {
-    addMsRunSp(p_identification_source->getMsRunSp());
-    auto it = std::find (_id_source_list.begin() ,_id_source_list.end(),p_identification_source);
-    if (it == _id_source_list.end()) {
-        _id_source_list.push_back(p_identification_source);
+void
+IdentificationGroup::addIdentificationDataSourceP(
+  IdentificationDataSource *p_identification_source)
+{
+  addMsRunSp(p_identification_source->getMsRunSp());
+  auto it = std::find(
+    _id_source_list.begin(), _id_source_list.end(), p_identification_source);
+  if(it == _id_source_list.end())
+    {
+      _id_source_list.push_back(p_identification_source);
     }
 }
-void IdentificationGroup::addMsRunSp(MsRunSp ms_run_sp) {
-    auto it = std::find (_ms_run_list.begin() ,_ms_run_list.end(),ms_run_sp);
-    if (it == _ms_run_list.end()) {
-        _ms_run_list.push_back(ms_run_sp);
+void
+IdentificationGroup::addMsRunSp(MsRunSp ms_run_sp)
+{
+  auto it = std::find(_ms_run_list.begin(), _ms_run_list.end(), ms_run_sp);
+  if(it == _ms_run_list.end())
+    {
+      _ms_run_list.push_back(ms_run_sp);
     }
 }
-const std::vector<MsRunSp> & IdentificationGroup::getMsRunSpList() const {
-    return _ms_run_list;
+const std::vector<MsRunSp> &
+IdentificationGroup::getMsRunSpList() const
+{
+  return _ms_run_list;
 }
-const std::vector<IdentificationDataSource *> & IdentificationGroup::getIdentificationDataSourceList() const {
-    return _id_source_list;
+const std::vector<IdentificationDataSource *> &
+IdentificationGroup::getIdentificationDataSourceList() const
+{
+  return _id_source_list;
 }
-const std::vector<ProteinMatch *> & IdentificationGroup::getProteinMatchList() const {
-    return _protein_match_list;
+const std::vector<ProteinMatch *> &
+IdentificationGroup::getProteinMatchList() const
+{
+  return _protein_match_list;
 }
-std::vector<ProteinMatch *> & IdentificationGroup::getProteinMatchList() {
-    return _protein_match_list;
+std::vector<ProteinMatch *> &
+IdentificationGroup::getProteinMatchList()
+{
+  return _protein_match_list;
 }
 
-std::size_t IdentificationGroup::countGroup()const {
-    return _group_store.countGroup();
+std::size_t
+IdentificationGroup::countGroup() const
+{
+  return _group_store.countGroup();
 }
 
-std::size_t IdentificationGroup::countSubGroup()const {
-    return _group_store.countSubGroup();
+std::size_t
+IdentificationGroup::countSubGroup() const
+{
+  return _group_store.countSubGroup();
 }
 
-void IdentificationGroup::collectMhDelta(std::vector< pappso::pappso_double> & delta_list, pappso::PrecisionUnit unit, ValidationState state) const {
-    std::set<const PeptideEvidence *> peptide_evidence_list;
-    for (auto & p_protein_match : _protein_match_list) {
-        if (p_protein_match->getValidationState() >= state) {
-            if (!p_protein_match->getProteinXtpSp().get()->isDecoy()) {
-                //p_protein_match->collectMhDelta(already_counted, delta_list, unit, state);
-                p_protein_match->collectPeptideEvidences(peptide_evidence_list, state);
+void
+IdentificationGroup::collectMhDelta(
+  std::vector<pappso::pappso_double> &delta_list,
+  pappso::PrecisionUnit unit,
+  ValidationState state) const
+{
+  std::set<const PeptideEvidence *> peptide_evidence_list;
+  for(auto &p_protein_match : _protein_match_list)
+    {
+      if(p_protein_match->getValidationState() >= state)
+        {
+          if(!p_protein_match->getProteinXtpSp().get()->isDecoy())
+            {
+              // p_protein_match->collectMhDelta(already_counted, delta_list,
+              // unit, state);
+              p_protein_match->collectPeptideEvidences(peptide_evidence_list,
+                                                       state);
             }
         }
     }
-    for (const PeptideEvidence * p_peptide_evidence: peptide_evidence_list) {
-        if (unit == pappso::PrecisionUnit::ppm) {
-            delta_list.push_back(p_peptide_evidence->getPpmDeltaMass());
+  for(const PeptideEvidence *p_peptide_evidence : peptide_evidence_list)
+    {
+      if(unit == pappso::PrecisionUnit::ppm)
+        {
+          delta_list.push_back(p_peptide_evidence->getPpmDeltaMass());
         }
-        else {
-            delta_list.push_back(p_peptide_evidence->getDeltaMass());
+      else
+        {
+          delta_list.push_back(p_peptide_evidence->getDeltaMass());
         }
     }
-
 }
-void IdentificationGroup::startGrouping (const GroupingType & grouping_type, WorkMonitorInterface * p_work_monitor) {
-    qDebug() << "IdentificationGroup::startGrouping begin ";
-    if (_p_grp_experiment != nullptr) {
-        delete _p_grp_experiment;
+void
+IdentificationGroup::startGrouping(const GroupingType &grouping_type,
+                                   WorkMonitorInterface *p_work_monitor)
+{
+  qDebug() << "IdentificationGroup::startGrouping begin ";
+  if(_p_grp_experiment != nullptr)
+    {
+      delete _p_grp_experiment;
     }
-    _p_grp_experiment = GroupingExperiment::newInstance(grouping_type, p_work_monitor);
-    for (ProteinMatch * p_protein_match : _protein_match_list) {
-        p_protein_match->setGroupingExperiment(_p_grp_experiment);
+  _p_grp_experiment =
+    GroupingExperiment::newInstance(grouping_type, p_work_monitor);
+  for(ProteinMatch *p_protein_match : _protein_match_list)
+    {
+      p_protein_match->setGroupingExperiment(_p_grp_experiment);
     }
 
-    _p_grp_experiment->startGrouping();
-    _group_store.clear();
-    for (ProteinMatch * p_protein_match : _protein_match_list) {
-        p_protein_match->setGroupInstance(_group_store);
+  _p_grp_experiment->startGrouping();
+  _group_store.clear();
+  for(ProteinMatch *p_protein_match : _protein_match_list)
+    {
+      p_protein_match->setGroupInstance(_group_store);
     }
 
-    if (_p_grp_ptm_experiment != nullptr) {
-        delete _p_grp_ptm_experiment;
-        _p_grp_ptm_experiment = nullptr;
+  if(_p_grp_ptm_experiment != nullptr)
+    {
+      delete _p_grp_ptm_experiment;
+      _p_grp_ptm_experiment = nullptr;
     }
-    qDebug() << "IdentificationGroup::startGrouping end ";
+  qDebug() << "IdentificationGroup::startGrouping end ";
 }
 
-void IdentificationGroup::startPtmGrouping () {
-    qDebug() << "IdentificationGroup::startPtmGrouping begin ";
-    if (_p_grp_ptm_experiment != nullptr) {
-        delete _p_grp_ptm_experiment;
-        _p_grp_ptm_experiment = nullptr;
+void
+IdentificationGroup::startPtmGrouping()
+{
+  qDebug() << "IdentificationGroup::startPtmGrouping begin ";
+  if(_p_grp_ptm_experiment != nullptr)
+    {
+      delete _p_grp_ptm_experiment;
+      _p_grp_ptm_experiment = nullptr;
     }
-    _p_grp_ptm_experiment = new PtmGroupingExperiment();
-    _p_grp_ptm_experiment->setValidationState(ValidationState::grouped);
-    for (ProteinMatch * p_protein_match : _protein_match_list) {
-        _p_grp_ptm_experiment->addProteinMatch(p_protein_match);
+  _p_grp_ptm_experiment = new PtmGroupingExperiment();
+  _p_grp_ptm_experiment->setValidationState(ValidationState::grouped);
+  for(ProteinMatch *p_protein_match : _protein_match_list)
+    {
+      _p_grp_ptm_experiment->addProteinMatch(p_protein_match);
     }
 
-    _p_grp_ptm_experiment->startGrouping();
+  _p_grp_ptm_experiment->startGrouping();
 
-    qDebug() << "IdentificationGroup::startPtmGrouping end ";
+  qDebug() << "IdentificationGroup::startPtmGrouping end ";
 }
 
-const QString IdentificationGroup::getTabName() const {
-    return _ms_run_list[0]->getSampleName();
+const QString
+IdentificationGroup::getTabName() const
+{
+  return _ms_run_list[0]->getSampleName();
 }
 
 
+pappso::pappso_double
+IdentificationGroup::getPeptideMassFdr(ValidationState state) const
+{
+  // ValidationState state = ValidationState::valid;
+  pappso::pappso_double total_peptide = countPeptideMassSample(state);
+  pappso::pappso_double false_peptide = countDecoyPeptideMassSample(state);
 
-pappso::pappso_double IdentificationGroup::getPeptideMassFdr(ValidationState state) const {
-    //ValidationState state = ValidationState::valid;
-    pappso::pappso_double total_peptide=countPeptideMassSample(state);
-    pappso::pappso_double false_peptide=countDecoyPeptideMassSample(state);
-
-    return (false_peptide/total_peptide);
+  return (false_peptide / total_peptide);
 }
 
-pappso::pappso_double IdentificationGroup::getProteinFdr(ValidationState state) const {
-    //ValidationState state = ValidationState::valid;
-    pappso::pappso_double total_prot=countProteinMatch(state);
-    pappso::pappso_double false_prot=countDecoyProteinMatch(state);
+pappso::pappso_double
+IdentificationGroup::getProteinFdr(ValidationState state) const
+{
+  // ValidationState state = ValidationState::valid;
+  pappso::pappso_double total_prot = countProteinMatch(state);
+  pappso::pappso_double false_prot = countDecoyProteinMatch(state);
 
 
-    return (false_prot/total_prot);
+  return (false_prot / total_prot);
 }
 
 
-void IdentificationGroup::getSameXicPeptideEvidenceList(std::vector<const PeptideEvidence *> & peptide_evidence_list, const MsRun * p_msrun, const PeptideXtp * p_peptide, unsigned int charge) const {
-    if (!contains(p_msrun)) return;
-    for (const IdentificationDataSource * p_identification_source:_id_source_list) {
-        if (p_msrun == p_identification_source->getMsRunSp().get()) {
-            p_identification_source->getPeptideEvidenceStore().getSameXicPeptideEvidenceList(peptide_evidence_list, p_msrun, p_peptide, charge);
+void
+IdentificationGroup::getSameXicPeptideEvidenceList(
+  std::vector<const PeptideEvidence *> &peptide_evidence_list,
+  const MsRun *p_msrun,
+  const PeptideXtp *p_peptide,
+  unsigned int charge) const
+{
+  if(!contains(p_msrun))
+    return;
+  for(const IdentificationDataSource *p_identification_source : _id_source_list)
+    {
+      if(p_msrun == p_identification_source->getMsRunSp().get())
+        {
+          p_identification_source->getPeptideEvidenceStore()
+            .getSameXicPeptideEvidenceList(
+              peptide_evidence_list, p_msrun, p_peptide, charge);
         }
     }
 }
diff --git a/src/core/msrun.cpp b/src/core/msrun.cpp
index 0ec6f36e7f4cf2818e34e0883b65b45588f2f932..d817296e5192eec87a1d8aa7403969b1a6e30e91 100644
--- a/src/core/msrun.cpp
+++ b/src/core/msrun.cpp
@@ -56,6 +56,21 @@ MsRun::~MsRun()
 pappso::MsRunReaderSp &
 MsRun::getMsRunReaderSp()
 {
+  qDebug() << __FILE__ << " " << __FUNCTION__ << " " << __LINE__
+           << " filename=" << getFilename();
+  if(_msrun_reader_sp == nullptr)
+    {
+      try
+        {
+          _msrun_reader_sp =
+            pappso::MsRunReaderFactory::getInstance().buildPwizMsRunReaderSp(
+              *this);
+        }
+      catch(pappso::PappsoException &error)
+        {
+          _msrun_reader_sp = nullptr;
+        }
+    }
   return _msrun_reader_sp;
 }
 
@@ -87,6 +102,8 @@ MsRun::getMsRunStatistics(MsRunStatistics param) const
 bool
 MsRun::findMsRunFile()
 {
+  // first look at the file path :)
+  _msrun_reader_sp = getMsRunReaderSp();
   if(_msrun_reader_sp != nullptr)
     return true;
   QFileInfo file_original(this->getFilename());