diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index 798433f06801063b65c6c18f21bf58fa1880283d..65b17ed763700490f005c9e7980084b01b380f79 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -146,6 +146,7 @@ SET(CPP_FILES
   output/ods/samplesheet.cpp
   output/ods/simplesheet.cpp
   output/ods/spectrasheet.cpp
+  output/exportfastafile.cpp
   output/masschroqml.cpp
   output/masschroqprm.cpp
   output/mcqrspectralcount.cpp
diff --git a/src/gui/mainwindow.cpp b/src/gui/mainwindow.cpp
index 938cfcd81d454444b40c7f06731b625a7e63f6bd..492888c67f63167bc5ed0ef62684e15e43c5d04d 100644
--- a/src/gui/mainwindow.cpp
+++ b/src/gui/mainwindow.cpp
@@ -32,7 +32,6 @@
 
 #include "ui_main.h"
 #include <pappsomspp/pappsoexception.h>
-#include <pappsomspp/fasta/fastaoutputstream.h>
 #include "../utils/utils.h"
 #include "workerthread.h"
 #include "output/xpip.h"
@@ -503,6 +502,9 @@ MainWindow::doActionFasta()
 {
   try
     {
+      // export all grouped proteins
+      // or only one protein by sub grouped
+      // or only one protein by group
 
       QSettings settings;
       QString default_location =
@@ -521,41 +523,10 @@ MainWindow::doActionFasta()
 
       settings.setValue("path/fastafile", QFileInfo(filename).absolutePath());
 
+      showWaitingMessage(
+        tr("Writing %1 FASTA file").arg(QFileInfo(filename).fileName()));
+      emit operateWritingFastaFile(filename, _project_sp, ExportFastaType::all);
 
-      QFile outFile;
-      outFile.setFileName(filename);
-      outFile.open(QIODevice::WriteOnly);
-      QTextStream *p_outputStream = new QTextStream(&outFile);
-
-
-      pappso::FastaOutputStream fasta_output(*p_outputStream);
-
-      for(IdentificationGroup *identification :
-          _project_sp.get()->getIdentificationGroupList())
-        {
-          for(ProteinMatch *protein_match :
-              identification->getProteinMatchList())
-            {
-              if(protein_match->getValidationState() >=
-                 ValidationState::grouped)
-                {
-                  pappso::Protein protein(
-                    QString("%1 %2")
-                      .arg(
-                        protein_match->getProteinXtpSp().get()->getAccession())
-                      .arg(protein_match->getProteinXtpSp()
-                             .get()
-                             ->getDescription()),
-                    protein_match->getProteinXtpSp().get()->getSequence());
-                  fasta_output.writeProtein(protein);
-                }
-            }
-        }
-
-      p_outputStream->flush();
-      delete p_outputStream;
-      outFile.close();
-      // emit operateXpipFile(filename);
     }
   catch(pappso::PappsoException &error)
     {
diff --git a/src/gui/mainwindow.h b/src/gui/mainwindow.h
index 21762189b04c8b67fef052062331d1c8850abd1e..4acaa6c1cb0a836ff707e86296575314d70f7daf 100644
--- a/src/gui/mainwindow.h
+++ b/src/gui/mainwindow.h
@@ -109,6 +109,9 @@ class MainWindow : public QMainWindow
   void operateWritingProticFile(QString filename, ProjectSp project_sp);
   void operateWritingMcqrSpectralCountFile(QString filename,
                                            ProjectSp project_sp);
+  void operateWritingFastaFile(QString filename,
+                               ProjectSp project_sp,
+                               ExportFastaType type);
   void operateGrouping(ProjectSp project_sp);
   void operateRunningXtandem(TandemRunBatch tandem_run_batch);
 
diff --git a/src/gui/workerthread.cpp b/src/gui/workerthread.cpp
index 5c0d3dd469b39c04d40f4d8dbea4737d5311fc7e..add639e0d8c9ad03d5ca87f93ab6560fb4e48e50 100644
--- a/src/gui/workerthread.cpp
+++ b/src/gui/workerthread.cpp
@@ -34,6 +34,7 @@
 #include <odsstream/odsexception.h>
 #include <pappsomspp/pappsoexception.h>
 #include <QDebug>
+#include "../output/exportfastafile.h"
 #include "../output/masschroqml.h"
 #include "../output/masschroqprm.h"
 #include "../output/proticdbml.h"
@@ -153,6 +154,11 @@ WorkerThread::WorkerThread(MainWindow *p_main_window)
           &WorkerThread::operationFinished,
           p_main_window,
           &MainWindow::doOperationFinished);
+  // FASTA file write
+  connect(p_main_window,
+          &MainWindow::operateWritingFastaFile,
+          this,
+          &WorkerThread::doWritingFastaFile);
 
 #else
   // Qt4 code
@@ -730,3 +736,31 @@ WorkerThread::doRunningXtandem(TandemRunBatch tandem_run_batch)
     }
   qDebug() << __FILE__ << " " << __FUNCTION__ << " " << __LINE__;
 }
+
+
+void
+WorkerThread::doWritingFastaFile(QString filename,
+                                 ProjectSp project_sp,
+                                 ExportFastaType type)
+{
+
+  try
+    {
+
+      qDebug() << __FILE__ << " " << __FUNCTION__ << " " << __LINE__;
+      emit loadingMessage(tr("writing FASTA file, please wait"));
+
+      
+      ExportFastaFile output(filename, type);
+      output.write(project_sp);
+      output.close();
+
+      // emit operateXpipFile(filename);
+      emit operationFinished();
+    }
+  catch(pappso::PappsoException &error)
+    {
+      emit operationFailed(
+        tr("Error while writing FASTA file :\n%1").arg(error.qwhat()));
+    }
+}
diff --git a/src/gui/workerthread.h b/src/gui/workerthread.h
index 309a35dc0705d25550c1592ef1cd797f6c4fc73e..6bb87eaec8440cc69fffdd74519423fab16f11e3 100644
--- a/src/gui/workerthread.h
+++ b/src/gui/workerthread.h
@@ -64,6 +64,9 @@ class WorkerThread : public QObject
   void doWritingMassChroqPrmFile(QString filename, ProjectSp project_sp);
   void doWritingProticFile(QString filename, ProjectSp project_sp);
   void doWritingMcqrSpectralCountFile(QString filename, ProjectSp project_sp);
+  void doWritingFastaFile(QString filename,
+                          ProjectSp project_sp,
+                          ExportFastaType type);
   void doGrouping(ProjectSp project_sp);
   void doGroupingOnIdentification(IdentificationGroup *p_identification_group,
                                   GroupingType grouping_type);
diff --git a/src/main.cpp b/src/main.cpp
index c42ce2257ee01f84d985c526d5c2ff38a0c6dbd2..8cf6312fcddda9842c5064800dc64bd949c91a9f 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -48,6 +48,7 @@ main(int argc, char *argv[])
   qRegisterMetaType<MsRunSp>("MsRunSp");
   qRegisterMetaType<std::vector<pappso::PeptideNaturalIsotopeAverageSp>>(
     "std::vector<pappso::PeptideNaturalIsotopeAverageSp>");
+  qRegisterMetaType<ExportFastaType>("ExportFastaType");
 
   try
     {
diff --git a/src/output/exportfastafile.cpp b/src/output/exportfastafile.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..c8cbf49e10b677e832de14ea7238c48e7607dfc5
--- /dev/null
+++ b/src/output/exportfastafile.cpp
@@ -0,0 +1,74 @@
+/**
+ * \file output/exportfastafile.cpp
+ * \date 15/01/2019
+ * \author Olivier Langella
+ * \brief FASTA file writer
+ */
+
+/*******************************************************************************
+ * Copyright (c) 2019 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/>.
+ *
+ ******************************************************************************/
+
+#include "exportfastafile.h"
+#include <pappsomspp/fasta/fastaoutputstream.h>
+
+ExportFastaFile::ExportFastaFile(QString filename, ExportFastaType type)
+{
+  p_outputFastaFile = new QFile(filename);
+}
+
+void
+ExportFastaFile::write(ProjectSp project_sp)
+{
+
+  p_outputFastaFile->open(QIODevice::WriteOnly);
+  QTextStream *p_outputStream = new QTextStream(p_outputFastaFile);
+
+
+  pappso::FastaOutputStream fasta_output(*p_outputStream);
+
+  for(IdentificationGroup *identification :
+      project_sp.get()->getIdentificationGroupList())
+    {
+      for(ProteinMatch *protein_match : identification->getProteinMatchList())
+        {
+          if(protein_match->getValidationState() >= ValidationState::grouped)
+            {
+              pappso::Protein protein(
+                QString("%1 %2")
+                  .arg(protein_match->getProteinXtpSp().get()->getAccession())
+                  .arg(
+                    protein_match->getProteinXtpSp().get()->getDescription()),
+                protein_match->getProteinXtpSp().get()->getSequence());
+              fasta_output.writeProtein(protein);
+            }
+        }
+    }
+
+  p_outputStream->flush();
+  delete p_outputStream;
+  p_outputFastaFile->close();
+}
+
+void
+ExportFastaFile::close()
+{
+  delete p_outputFastaFile;
+  p_outputFastaFile = nullptr;
+}
diff --git a/src/output/exportfastafile.h b/src/output/exportfastafile.h
new file mode 100644
index 0000000000000000000000000000000000000000..c681f63d0bb5622f5ba7a9e7addf944f1940d7c9
--- /dev/null
+++ b/src/output/exportfastafile.h
@@ -0,0 +1,43 @@
+/**
+ * \file output/exportfastafile.h
+ * \date 15/01/2019
+ * \author Olivier Langella
+ * \brief FASTA file writer
+ */
+
+/*******************************************************************************
+ * Copyright (c) 2019 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/>.
+ *
+ ******************************************************************************/
+
+#pragma once
+
+#include <QString>
+#include "../utils/types.h"
+#include "../core/project.h"
+
+class ExportFastaFile
+{
+  private:
+  QFile *p_outputFastaFile = nullptr;
+
+  public:
+  ExportFastaFile(QString filename, ExportFastaType type);
+  void write(ProjectSp project_sp);
+  void close();
+};
diff --git a/src/utils/types.h b/src/utils/types.h
index 91f06ca306b7d68dd635afc5021ce5ac49796bce..03d3cb6d61136ff089158047c5d44bfd23ff6ea2 100644
--- a/src/utils/types.h
+++ b/src/utils/types.h
@@ -168,4 +168,16 @@ enum class ValidationState : std::int8_t
 };
 
 
+/** \def export fasta files
+ *
+ */
+
+enum class ExportFastaType : std::int8_t
+{
+  all           = 0, ///< all grouped proteins
+  oneBySubgroup = 1, ///< export only one by subgroup
+  oneByGroup    = 2, ///< export only one by group
+};
+
+
 #endif /* _TYPES_H_ */