From 53540ba192e787365351f8b2741ceafe4e66b813 Mon Sep 17 00:00:00 2001
From: Olivier Langella <Olivier.Langella@moulon.inra.fr>
Date: Mon, 10 Apr 2017 14:53:26 +0200
Subject: [PATCH] contaminant regexp

---
 src/gui/project_view/project_view.ui   | 98 +++++++++++++++-----------
 src/gui/project_view/projectwindow.cpp |  2 +
 src/input/xtandemsaxhandler.cpp        | 72 +++++++++++++++++++
 src/utils/proteinstore.cpp             | 17 ++++-
 src/utils/proteinstore.h               |  4 ++
 5 files changed, 150 insertions(+), 43 deletions(-)

diff --git a/src/gui/project_view/project_view.ui b/src/gui/project_view/project_view.ui
index 4e92c6dc..70b513cf 100644
--- a/src/gui/project_view/project_view.ui
+++ b/src/gui/project_view/project_view.ui
@@ -21,7 +21,7 @@
        <bool>true</bool>
       </property>
       <property name="currentIndex">
-       <number>3</number>
+       <number>1</number>
       </property>
       <widget class="QWidget" name="identifications">
        <attribute name="title">
@@ -39,10 +39,26 @@
        </attribute>
        <layout class="QGridLayout" name="gridLayout_3">
         <item row="0" column="0">
-         <layout class="QFormLayout" name="filter_parameter_layout">
-          <property name="fieldGrowthPolicy">
-           <enum>QFormLayout::AllNonFixedFieldsGrow</enum>
-          </property>
+         <layout class="QVBoxLayout" name="filter_parameter_tab_layout">
+          <item>
+           <layout class="QVBoxLayout" name="filter_parameter_layout"/>
+          </item>
+          <item>
+           <widget class="QGroupBox" name="groupBox_4">
+            <property name="title">
+             <string>Contaminants</string>
+            </property>
+            <layout class="QVBoxLayout" name="verticalLayout_6">
+             <item>
+              <widget class="QLineEdit" name="contaminant_protein_regexp_line_edit">
+               <property name="placeholderText">
+                <string>^conta\\|</string>
+               </property>
+              </widget>
+             </item>
+            </layout>
+           </widget>
+          </item>
          </layout>
         </item>
        </layout>
@@ -127,45 +143,45 @@
             </layout>
            </widget>
           </item>
-         </layout>
-        </item>
-        <item row="1" column="0">
-         <widget class="QGroupBox" name="groupBox_2">
-          <property name="title">
-           <string>Decoy protein regular expression</string>
-          </property>
-          <layout class="QVBoxLayout" name="verticalLayout_4">
-           <item>
-            <widget class="QLineEdit" name="decoy_protein_regexp_line_edit">
-             <property name="placeholderText">
-              <string>.*\\|reversed$</string>
-             </property>
-            </widget>
-           </item>
-          </layout>
-         </widget>
-        </item>
-        <item row="3" column="0">
-         <layout class="QHBoxLayout" name="horizontalLayout_2">
           <item>
-           <spacer name="horizontalSpacer_2">
-            <property name="orientation">
-             <enum>Qt::Horizontal</enum>
-            </property>
-            <property name="sizeHint" stdset="0">
-             <size>
-              <width>40</width>
-              <height>20</height>
-             </size>
+           <widget class="QGroupBox" name="groupBox_2">
+            <property name="title">
+             <string>Decoy protein regular expression</string>
             </property>
-           </spacer>
+            <layout class="QVBoxLayout" name="verticalLayout_4">
+             <item>
+              <widget class="QLineEdit" name="decoy_protein_regexp_line_edit">
+               <property name="placeholderText">
+                <string>.*\\|reversed$</string>
+               </property>
+              </widget>
+             </item>
+            </layout>
+           </widget>
           </item>
           <item>
-           <widget class="QPushButton" name="pushButton_2">
-            <property name="text">
-             <string>OK</string>
-            </property>
-           </widget>
+           <layout class="QHBoxLayout" name="horizontalLayout_2">
+            <item>
+             <spacer name="horizontalSpacer_2">
+              <property name="orientation">
+               <enum>Qt::Horizontal</enum>
+              </property>
+              <property name="sizeHint" stdset="0">
+               <size>
+                <width>40</width>
+                <height>20</height>
+               </size>
+              </property>
+             </spacer>
+            </item>
+            <item>
+             <widget class="QPushButton" name="fdr_button">
+              <property name="text">
+               <string>OK</string>
+              </property>
+             </widget>
+            </item>
+           </layout>
           </item>
          </layout>
         </item>
@@ -264,7 +280,7 @@
  <resources/>
  <connections>
   <connection>
-   <sender>pushButton_2</sender>
+   <sender>fdr_button</sender>
    <signal>clicked()</signal>
    <receiver>ProjectView</receiver>
    <slot>doFdrChanged()</slot>
diff --git a/src/gui/project_view/projectwindow.cpp b/src/gui/project_view/projectwindow.cpp
index cffc67cd..ec66c9ca 100644
--- a/src/gui/project_view/projectwindow.cpp
+++ b/src/gui/project_view/projectwindow.cpp
@@ -201,6 +201,7 @@ void ProjectWindow::doFdrChanged() {
 }
 void ProjectWindow::doAutomaticFilterParametersChanged(AutomaticFilterParameters parameters) {
     qDebug() << "ProjectWindow::doAutomaticFilterParametersChanged begin ";
+    _project_sp.get()->getProteinStore().setRegexpDecoyPattern(ui->contaminant_protein_regexp_line_edit->text());
     _project_sp.get()->updateAutomaticFilters(parameters);
 
     //re group
@@ -381,6 +382,7 @@ void ProjectWindow::setProjectSp(ProjectSp project_sp) {
     //_protein_list_window->show();
 
     ui->decoy_protein_regexp_line_edit->setText(_project_sp.get()->getProteinStore().getRegexpDecoy().pattern());
+    ui->contaminant_protein_regexp_line_edit->setText(_project_sp.get()->getProteinStore().getRegexpContaminant().pattern());
     computeFdr(ValidationState::grouped);
 
     computeMassPrecision(ValidationState::validAndChecked);
diff --git a/src/input/xtandemsaxhandler.cpp b/src/input/xtandemsaxhandler.cpp
index 001cb943..5647756b 100644
--- a/src/input/xtandemsaxhandler.cpp
+++ b/src/input/xtandemsaxhandler.cpp
@@ -197,6 +197,78 @@ bool XtandemSaxHandler::startElement_domain(QXmlAttributes attributes) {
     // delta="0.998" hyperscore="32.9" nextscore="12.2" y_score="10.7"
     // y_ions="9" b_score="0.0" b_ions="0"
     // pre="VLGR" post="VEFM" seq="TGSQGQCTQVR" missed_cleavages="10">
+    /*
+     * id
+ – the identifier for t
+his particular identified dom
+ain (s
+pectrum
+ #).(i
+d
+#).(dom
+ain#) 
+start
+ – the first residue
+ of t
+he dom
+ain 
+end
+ – the last residue
+ of t
+he dom
+ain 
+expect
+ – the expe
+ctation va
+lue for t
+he peptide identification 
+mh
+ – the calculated pe
+ptide mass + a prot
+on 
+delta
+ – the spectrum
+ mh m
+inus
+ the calculated m
+h 
+hyperscore
+ – T
+ande
+m’s score for t
+he identification 
+peak_count
+ – the num
+ber of pe
+aks that matched be
+tween the theoretical
+and t
+he test mass spectrum
+pre
+ – the four re
+sidue
+s pre
+ceding t
+he dom
+ain 
+post
+ – the four re
+sidue
+s fol
+lowing t
+he dom
+ain 
+seq
+ – the seque
+nce of t
+he dom
+ain 
+missed_cleavages
+ – the num
+ber of pot
+ential cleavage sites in this
+peptide seque
+nce*/
 
     // valeur généric du scan
     _current_peptide_sp = PeptideXtp(attributes.value("seq").simplified()).makePeptideXtpSp();
diff --git a/src/utils/proteinstore.cpp b/src/utils/proteinstore.cpp
index d2d95dc2..e8619a13 100644
--- a/src/utils/proteinstore.cpp
+++ b/src/utils/proteinstore.cpp
@@ -41,6 +41,16 @@ ProteinStore::ProteinStore()
 ProteinStore::~ProteinStore()
 {
 
+}
+QRegExp ProteinStore::getRegexpContaminant() const {
+    return (_regexp_contaminant);
+}
+void ProteinStore::setRegexpContaminantPattern(const QString & pattern) {
+    _regexp_contaminant.setPattern(pattern);
+    
+    for  (std::pair<const QString, ProteinXtpSp> & acc_protein :_map_accession_protein_list) {
+        setProteinInformations(acc_protein.second);
+    }
 }
 QRegExp ProteinStore::getRegexpDecoy() const {
     return (_regexp_decoy);
@@ -66,12 +76,15 @@ ProteinXtpSp & ProteinStore::getInstance(ProteinXtpSp & peptide_in) {
 
 void ProteinStore::setProteinInformations(ProteinXtpSp & peptide_in) {
     //qDebug() << "ProteinStore::setProteinInformations begin" << peptide_in.get()->getSequence();
+    peptide_in.get()->setIsContaminant(false);
+    peptide_in.get()->setIsDecoy(false);
     QString accession = peptide_in.get()->getAccession();
-    if (_regexp_contaminant.indexIn(accession, 0)>-1) {
+    
+    if ((!_regexp_contaminant.isEmpty()) && (_regexp_contaminant.indexIn(accession, 0)>-1)) {
         //qDebug() << "ProteinStore::setProteinInformations is contaminant " << accession;
         peptide_in.get()->setIsContaminant(true);
     }
-    if (_regexp_decoy.indexIn(accession, 0)>-1) {
+    if ((!_regexp_decoy.isEmpty()) && (_regexp_decoy.indexIn(accession, 0)>-1) ) {
         peptide_in.get()->setIsDecoy(true);
     }
     //qDebug() << "ProteinStore::setProteinInformations end";
diff --git a/src/utils/proteinstore.h b/src/utils/proteinstore.h
index 93c755ce..2208156c 100644
--- a/src/utils/proteinstore.h
+++ b/src/utils/proteinstore.h
@@ -49,6 +49,10 @@ public:
     void setRegexpDecoyPattern(const QString & pattern);
     
     QRegExp getRegexpDecoy() const;
+    
+    void setRegexpContaminantPattern(const QString & pattern);
+    
+    QRegExp getRegexpContaminant() const;
 
 private :
     void setProteinInformations(ProteinXtpSp & protein_in);
-- 
GitLab