From a480fb235971a65334a929fff7685bc7b140948d Mon Sep 17 00:00:00 2001
From: Olivier Langella <Olivier.Langella@moulon.inra.fr>
Date: Thu, 3 Aug 2017 23:48:22 +0200
Subject: [PATCH] WIP: writing PTM islands

---
 src/core/project.cpp                          |  5 ++
 src/core/project.h                            |  2 +
 .../export_spreadsheet_dialog.ui              | 90 +++++++++++++------
 .../exportspreadsheetdialog.cpp               | 15 ++++
 .../exportspreadsheetdialog.h                 |  3 +
 src/gui/mainwindow.cpp                        |  6 ++
 6 files changed, 94 insertions(+), 27 deletions(-)

diff --git a/src/core/project.cpp b/src/core/project.cpp
index 07eea92f..8bcf4dc7 100644
--- a/src/core/project.cpp
+++ b/src/core/project.cpp
@@ -156,3 +156,8 @@ void Project::setLabelingMethodSp(LabelingMethodSp labeling_method_sp) {
 LabelingMethodSp Project::getLabelingMethodSp() const {
     return _labeling_method_sp;
 }
+
+ bool Project::hasPtmExperiment() const {
+     if (getIdentificationGroupList().at(0)->getPtmGroupingExperiment() != nullptr) return true;
+     return false;
+ }
diff --git a/src/core/project.h b/src/core/project.h
index d42647d3..a591edc7 100644
--- a/src/core/project.h
+++ b/src/core/project.h
@@ -83,6 +83,8 @@ public:
      * */
     LabelingMethodSp getLabelingMethodSp() const;
     
+    bool hasPtmExperiment() const;
+    
 private :
     LabelingMethodSp _labeling_method_sp;
     bool _is_combine_mode =true;
diff --git a/src/gui/export_spreadsheet_dialog/export_spreadsheet_dialog.ui b/src/gui/export_spreadsheet_dialog/export_spreadsheet_dialog.ui
index 4574c5ac..ae332061 100644
--- a/src/gui/export_spreadsheet_dialog/export_spreadsheet_dialog.ui
+++ b/src/gui/export_spreadsheet_dialog/export_spreadsheet_dialog.ui
@@ -123,6 +123,25 @@
         </layout>
        </widget>
       </item>
+      <item>
+       <widget class="QGroupBox" name="ptm_groupbox">
+        <property name="enabled">
+         <bool>false</bool>
+        </property>
+        <property name="title">
+         <string>PTM</string>
+        </property>
+        <layout class="QVBoxLayout" name="verticalLayout">
+         <item>
+          <widget class="QCheckBox" name="ptmislands_checkbox">
+           <property name="text">
+            <string>PTM islands</string>
+           </property>
+          </widget>
+         </item>
+        </layout>
+       </widget>
+      </item>
      </layout>
     </widget>
    </item>
@@ -169,7 +188,7 @@
    <hints>
     <hint type="sourcelabel">
      <x>665</x>
-     <y>454</y>
+     <y>523</y>
     </hint>
     <hint type="destinationlabel">
      <x>286</x>
@@ -184,8 +203,8 @@
    <slot>reject()</slot>
    <hints>
     <hint type="sourcelabel">
-     <x>574</x>
-     <y>454</y>
+     <x>579</x>
+     <y>523</y>
     </hint>
     <hint type="destinationlabel">
      <x>286</x>
@@ -216,8 +235,8 @@
    <slot>doGroups(bool)</slot>
    <hints>
     <hint type="sourcelabel">
-     <x>189</x>
-     <y>74</y>
+     <x>210</x>
+     <y>101</y>
     </hint>
     <hint type="destinationlabel">
      <x>839</x>
@@ -232,8 +251,8 @@
    <slot>doProteins(bool)</slot>
    <hints>
     <hint type="sourcelabel">
-     <x>87</x>
-     <y>101</y>
+     <x>108</x>
+     <y>133</y>
     </hint>
     <hint type="destinationlabel">
      <x>814</x>
@@ -248,8 +267,8 @@
    <slot>doPeptides(bool)</slot>
    <hints>
     <hint type="sourcelabel">
-     <x>361</x>
-     <y>130</y>
+     <x>382</x>
+     <y>165</y>
     </hint>
     <hint type="destinationlabel">
      <x>857</x>
@@ -264,8 +283,8 @@
    <slot>doSpectra(bool)</slot>
    <hints>
     <hint type="sourcelabel">
-     <x>78</x>
-     <y>159</y>
+     <x>99</x>
+     <y>197</y>
     </hint>
     <hint type="destinationlabel">
      <x>760</x>
@@ -280,8 +299,8 @@
    <slot>doPeptidePos(bool)</slot>
    <hints>
     <hint type="sourcelabel">
-     <x>296</x>
-     <y>184</y>
+     <x>317</x>
+     <y>229</y>
     </hint>
     <hint type="destinationlabel">
      <x>764</x>
@@ -296,8 +315,8 @@
    <slot>doSamples(bool)</slot>
    <hints>
     <hint type="sourcelabel">
-     <x>223</x>
-     <y>206</y>
+     <x>244</x>
+     <y>261</y>
     </hint>
     <hint type="destinationlabel">
      <x>835</x>
@@ -312,8 +331,8 @@
    <slot>doComparSpectra(bool)</slot>
    <hints>
     <hint type="sourcelabel">
-     <x>91</x>
-     <y>261</y>
+     <x>124</x>
+     <y>328</y>
     </hint>
     <hint type="destinationlabel">
      <x>785</x>
@@ -328,8 +347,8 @@
    <slot>doComparUniqueSequence(bool)</slot>
    <hints>
     <hint type="sourcelabel">
-     <x>378</x>
-     <y>262</y>
+     <x>437</x>
+     <y>328</y>
     </hint>
     <hint type="destinationlabel">
      <x>836</x>
@@ -344,8 +363,8 @@
    <slot>doComparSpecificSpectra(bool)</slot>
    <hints>
     <hint type="sourcelabel">
-     <x>198</x>
-     <y>304</y>
+     <x>231</x>
+     <y>360</y>
     </hint>
     <hint type="destinationlabel">
      <x>736</x>
@@ -360,8 +379,8 @@
    <slot>doComparSpecificUniqueSequence(bool)</slot>
    <hints>
     <hint type="sourcelabel">
-     <x>322</x>
-     <y>290</y>
+     <x>437</x>
+     <y>360</y>
     </hint>
     <hint type="destinationlabel">
      <x>753</x>
@@ -376,8 +395,8 @@
    <slot>doComparPai(bool)</slot>
    <hints>
     <hint type="sourcelabel">
-     <x>535</x>
-     <y>268</y>
+     <x>642</x>
+     <y>328</y>
     </hint>
     <hint type="destinationlabel">
      <x>790</x>
@@ -392,8 +411,8 @@
    <slot>doComparEmpai(bool)</slot>
    <hints>
     <hint type="sourcelabel">
-     <x>492</x>
-     <y>295</y>
+     <x>642</x>
+     <y>360</y>
     </hint>
     <hint type="destinationlabel">
      <x>793</x>
@@ -401,6 +420,22 @@
     </hint>
    </hints>
   </connection>
+  <connection>
+   <sender>ptmislands_checkbox</sender>
+   <signal>clicked(bool)</signal>
+   <receiver>ExportSpreadsheetDialog</receiver>
+   <slot>doPtmIslands(bool)</slot>
+   <hints>
+    <hint type="sourcelabel">
+     <x>79</x>
+     <y>427</y>
+    </hint>
+    <hint type="destinationlabel">
+     <x>765</x>
+     <y>477</y>
+    </hint>
+   </hints>
+  </connection>
  </connections>
  <slots>
   <slot>reject()</slot>
@@ -418,5 +453,6 @@
   <slot>doComparSpecificUniqueSequence(bool)</slot>
   <slot>doComparPai(bool)</slot>
   <slot>doComparEmpai(bool)</slot>
+  <slot>doPtmIslands(bool)</slot>
  </slots>
 </ui>
diff --git a/src/gui/export_spreadsheet_dialog/exportspreadsheetdialog.cpp b/src/gui/export_spreadsheet_dialog/exportspreadsheetdialog.cpp
index fc8a8f12..d8c14fb6 100644
--- a/src/gui/export_spreadsheet_dialog/exportspreadsheetdialog.cpp
+++ b/src/gui/export_spreadsheet_dialog/exportspreadsheetdialog.cpp
@@ -91,6 +91,10 @@ ExportSpreadsheetDialog::ExportSpreadsheetDialog(QWidget * parent):
     if (settings.value("export_ods/samples", "true").toBool()) {
         ui->samples_checkbox->setCheckState(Qt::Checked);
     }
+    ui->ptmislands_checkbox->setCheckState(Qt::Unchecked);
+    if (settings.value("export_ods/ptmislands", "true").toBool()) {
+        ui->ptmislands_checkbox->setCheckState(Qt::Checked);
+    }
     //param.setFilterCrossSamplePeptideNumber(settings.value("automatic_filter/cross_sample", "true").toBool());
 
 #if QT_VERSION >= 0x050000
@@ -188,3 +192,14 @@ void ExportSpreadsheetDialog::doProteinList(bool simple) {
     QSettings settings;
     settings.setValue("export_ods/proteins", QString("%1").arg(simple));
 }
+void ExportSpreadsheetDialog::doPtmIslands(bool simple) {
+    QSettings settings;
+    settings.setValue("export_ods/ptmislands", QString("%1").arg(simple));
+}
+
+void ExportSpreadsheetDialog::disablePtm() {
+    ui->ptm_groupbox->setDisabled(true);
+}
+void ExportSpreadsheetDialog::enablePtm() {
+    ui->ptm_groupbox->setEnabled(true);
+}
diff --git a/src/gui/export_spreadsheet_dialog/exportspreadsheetdialog.h b/src/gui/export_spreadsheet_dialog/exportspreadsheetdialog.h
index 42a72d60..0c11f1bf 100644
--- a/src/gui/export_spreadsheet_dialog/exportspreadsheetdialog.h
+++ b/src/gui/export_spreadsheet_dialog/exportspreadsheetdialog.h
@@ -43,6 +43,8 @@ public:
     explicit ExportSpreadsheetDialog(QWidget * parent);
     ~ExportSpreadsheetDialog();
 
+    void disablePtm();
+    void enablePtm();
 
 public slots:
     void doSimpleProteinPeptideList(bool simple);
@@ -59,6 +61,7 @@ public slots:
     void doSpectra(bool simple);
     void doPeptides(bool simple);
     void doProteins(bool simple);
+    void doPtmIslands(bool simple);
     
 signals:
 
diff --git a/src/gui/mainwindow.cpp b/src/gui/mainwindow.cpp
index 1b8ab60b..c39f42a8 100644
--- a/src/gui/mainwindow.cpp
+++ b/src/gui/mainwindow.cpp
@@ -274,6 +274,12 @@ void MainWindow::doActionSpreadsheet() {
     qDebug() << "MainWindow::doActionSpreadsheet begin";
     try {
 
+        _p_export_spreadsheet_dialog->disablePtm();
+        if (_project_sp.get() != nullptr) {
+            if (_project_sp.get()->hasPtmExperiment()) {
+                _p_export_spreadsheet_dialog->enablePtm();
+            }
+        }
         _p_export_spreadsheet_dialog->show();
         _p_export_spreadsheet_dialog->raise();
         _p_export_spreadsheet_dialog->activateWindow();
-- 
GitLab