~ubuntu-branches/ubuntu/wily/openms/wily

« back to all changes in this revision

Viewing changes to source/VISUAL/VISUALIZER/ProteinIdentificationVisualizer.C

  • Committer: Package Import Robot
  • Author(s): Filippo Rusconi
  • Date: 2013-12-20 11:30:16 UTC
  • mfrom: (5.1.2 sid)
  • Revision ID: package-import@ubuntu.com-20131220113016-wre5g9bteeheq6he
Tags: 1.11.1-3
* remove version number from libbost development package names;
* ensure that AUTHORS is correctly shipped in all packages.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
// -*- mode: C++; tab-width: 2; -*-
2
 
// vi: set ts=2:
3
 
//
4
 
// --------------------------------------------------------------------------
5
 
//                   OpenMS Mass Spectrometry Framework
6
 
// --------------------------------------------------------------------------
7
 
//  Copyright (C) 2003-2011 -- Oliver Kohlbacher, Knut Reinert
8
 
//
9
 
//  This library is free software you can redistribute it and/or
10
 
//  modify it under the terms of the GNU Lesser General Public
11
 
//  License as published by the Free Software Foundation; either
12
 
//  version 2.1 of the License, or (at your option) any later version.
13
 
//
14
 
//  this library is distributed in the hope that it will be useful,
15
 
//  but WITHOUT ANY WARRANTY; without even the implied warranty of
16
 
//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
17
 
//  Lesser General Public License for more details.
18
 
//
19
 
//  You should have received a copy of the GNU Lesser General Public
20
 
//  License along with this library; if not, write to the Free Software
21
 
//  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 
1
// --------------------------------------------------------------------------
 
2
//                   OpenMS -- Open-Source Mass Spectrometry
 
3
// --------------------------------------------------------------------------
 
4
// Copyright The OpenMS Team -- Eberhard Karls University Tuebingen,
 
5
// ETH Zurich, and Freie Universitaet Berlin 2002-2013.
 
6
//
 
7
// This software is released under a three-clause BSD license:
 
8
//  * Redistributions of source code must retain the above copyright
 
9
//    notice, this list of conditions and the following disclaimer.
 
10
//  * Redistributions in binary form must reproduce the above copyright
 
11
//    notice, this list of conditions and the following disclaimer in the
 
12
//    documentation and/or other materials provided with the distribution.
 
13
//  * Neither the name of any author or any participating institution
 
14
//    may be used to endorse or promote products derived from this software
 
15
//    without specific prior written permission.
 
16
// For a full list of authors, refer to the file AUTHORS.
 
17
// --------------------------------------------------------------------------
 
18
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
 
19
// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
 
20
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
 
21
// ARE DISCLAIMED. IN NO EVENT SHALL ANY OF THE AUTHORS OR THE CONTRIBUTING
 
22
// INSTITUTIONS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
 
23
// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
 
24
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
 
25
// OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
 
26
// WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
 
27
// OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
 
28
// ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
22
29
//
23
30
// --------------------------------------------------------------------------
24
31
// $Maintainer:Timo Sachsenberg $
25
32
// $Authors: Marc Sturm $
26
 
// --------------------------------------------------------------------------s
 
33
// --------------------------------------------------------------------------
27
34
 
28
35
 
29
36
#include <OpenMS/VISUAL/VISUALIZER/ProteinIdentificationVisualizer.h>
43
50
 
44
51
namespace OpenMS
45
52
{
46
 
        ProteinIdentificationVisualizer::ProteinIdentificationVisualizer(bool editable, QWidget* parent, MetaDataBrowser* caller)
47
 
                : BaseVisualizerGUI(editable, parent),
48
 
                        BaseVisualizer<ProteinIdentification>()
49
 
        {
50
 
                pidv_caller_= caller;
51
 
             
52
 
                addLineEdit_(identifier_, "Identifier<br>(of corresponding PeptideIdentifications)" );
53
 
                
54
 
                addSeparator_();
55
 
                addLineEdit_(engine_, "Search engine" );
56
 
                addLineEdit_(engine_version_, "Search engine version" );
57
 
                addLineEdit_(identification_date_, "Date of search" );
58
 
                addLineEdit_(score_type_, "Score type" );
59
 
                addBooleanComboBox_(higher_better_,"Higher score is better"); 
60
 
                addDoubleLineEdit_(identification_threshold_, "Protein significance threshold" );       
61
 
                
62
 
                addSeparator_();
63
 
                addLabel_("Search Parameters:");
64
 
                addLineEdit_(db_, "Database name" );
65
 
                addLineEdit_(db_version_, "Database version" );
66
 
                addLineEdit_(taxonomy_, "Taxonomy restriction" );
67
 
                addLineEdit_(charges_, "Allowed charges" );
68
 
                addIntLineEdit_(missed_cleavages_, "Missed Cleavages" );
69
 
                addDoubleLineEdit_(peak_tolerance_, "Fragment ion mass tolerance" );
70
 
                addDoubleLineEdit_(precursor_tolerance_, "Precursor ion mass tolerance" );
71
 
                addComboBox_(mass_type_, "Mass type" );
72
 
                addComboBox_(enzyme_, "Digestion enzyme" );
73
 
                
74
 
                addSeparator_();       
75
 
                addLabel_("Show protein hits with score equal or better than a threshold.");
76
 
                QPushButton* button;
77
 
                addLineEditButton_("Score threshold", filter_threshold_, button, "Filter");
78
 
                connect(button, SIGNAL(clicked()), this, SLOT(updateTree_()) );
79
 
        
80
 
                finishAdding_();
81
 
        }
82
 
 
83
 
        void ProteinIdentificationVisualizer::load(ProteinIdentification& s, int tree_item_id)
84
 
        {
85
 
                ptr_ = &s;
86
 
                temp_=s;
87
 
                
88
 
                // id of the item in the tree
89
 
                tree_id_ = tree_item_id;
90
 
                
91
 
                identification_date_->setText(temp_.getDateTime().get().toQString()); 
92
 
                identification_threshold_->setText(QString::number(temp_.getSignificanceThreshold()));                  
93
 
                identifier_->setText(temp_.getIdentifier().toQString());
94
 
                engine_->setText(temp_.getSearchEngine().toQString());
95
 
                engine_version_->setText(temp_.getSearchEngineVersion().toQString());
96
 
                score_type_->setText(temp_.getScoreType().toQString());
97
 
                higher_better_->setCurrentIndex(temp_.isHigherScoreBetter());
98
 
                
99
 
                db_->setText(temp_.getSearchParameters().db.toQString());
100
 
                db_version_->setText(temp_.getSearchParameters().db_version.toQString());
101
 
                taxonomy_->setText(temp_.getSearchParameters().taxonomy.toQString());
102
 
                charges_->setText(temp_.getSearchParameters().charges.toQString());
103
 
                missed_cleavages_->setText(QString::number(temp_.getSearchParameters().missed_cleavages));
104
 
                peak_tolerance_->setText(QString::number(temp_.getSearchParameters().peak_mass_tolerance));
105
 
                precursor_tolerance_->setText(QString::number(temp_.getSearchParameters().precursor_tolerance));
106
 
 
107
 
                if(! isEditable())
108
 
                {
109
 
                        fillComboBox_(mass_type_,& ProteinIdentification::NamesOfPeakMassType[temp_.getSearchParameters().mass_type], 1);
110
 
                        fillComboBox_(enzyme_,& ProteinIdentification::NamesOfDigestionEnzyme[temp_.getSearchParameters().enzyme], 1);
111
 
                }
112
 
                else
113
 
                {
114
 
                        fillComboBox_(mass_type_, ProteinIdentification::NamesOfPeakMassType, ProteinIdentification::SIZE_OF_PEAKMASSTYPE);
115
 
                        fillComboBox_(enzyme_, ProteinIdentification::NamesOfDigestionEnzyme, ProteinIdentification::SIZE_OF_DIGESTIONENZYME);
116
 
                        
117
 
                        enzyme_->setCurrentIndex(temp_.getSearchParameters().enzyme); 
118
 
                        mass_type_->setCurrentIndex(temp_.getSearchParameters().mass_type); 
119
 
                }
120
 
        }
121
 
        
122
 
        void ProteinIdentificationVisualizer::updateTree_()
123
 
        {
124
 
                if (filter_threshold_->text()!="")
125
 
                {
126
 
                        pidv_caller_->filterHits_(filter_threshold_->text().toDouble(),temp_.isHigherScoreBetter(),tree_id_ );
127
 
                }
128
 
                else
129
 
                {
130
 
                        pidv_caller_->showAllHits_(tree_id_);
131
 
                }
132
 
        }
133
 
        
134
 
        void ProteinIdentificationVisualizer::store()
135
 
        {
136
 
                ptr_->setSearchEngine(engine_->text());
137
 
                ptr_->setSearchEngineVersion(engine_version_->text());
138
 
                ptr_->setIdentifier(identifier_->text());
139
 
                ptr_->setSignificanceThreshold(identification_threshold_->text().toFloat());
140
 
                ptr_->setScoreType(score_type_->text());
141
 
                ptr_->setHigherScoreBetter(higher_better_->currentIndex());
142
 
                //date
143
 
                DateTime date;
144
 
                try
145
 
                {
146
 
                        date.set(identification_date_->text());
147
 
                        ptr_->setDateTime(date);
148
 
                }
149
 
                catch(exception& /*e*/)
150
 
                {
151
 
                        if(date.isNull())
152
 
                        {
153
 
                                std::string status= "Format of date in PROTEINIDENTIFICATION is not correct.";
154
 
                                emit sendStatus(status);
155
 
                        }
156
 
                }
157
 
                
158
 
                //search parameters
159
 
                ProteinIdentification::SearchParameters tmp = ptr_->getSearchParameters();
160
 
                tmp.db = db_->text();
161
 
                tmp.db_version = db_version_->text();
162
 
                tmp.taxonomy = taxonomy_->text();
163
 
                tmp.charges = charges_->text();
164
 
                tmp.missed_cleavages = missed_cleavages_->text().toInt();
165
 
                tmp.peak_mass_tolerance = peak_tolerance_->text().toFloat();
166
 
                tmp.precursor_tolerance = precursor_tolerance_->text().toFloat();
167
 
                tmp.enzyme = (ProteinIdentification::DigestionEnzyme)(enzyme_->currentIndex());
168
 
                tmp.mass_type = (ProteinIdentification::PeakMassType)(mass_type_->currentIndex());
169
 
                ptr_->setSearchParameters(tmp);
170
 
                
171
 
                temp_=(*ptr_);          
172
 
        }
173
 
        
174
 
        void ProteinIdentificationVisualizer::undo_()
175
 
        {
176
 
                load(*ptr_, tree_id_);
177
 
        }
 
53
  ProteinIdentificationVisualizer::ProteinIdentificationVisualizer(bool editable, QWidget * parent, MetaDataBrowser * caller) :
 
54
    BaseVisualizerGUI(editable, parent),
 
55
    BaseVisualizer<ProteinIdentification>()
 
56
  {
 
57
    pidv_caller_ = caller;
 
58
 
 
59
    addLineEdit_(identifier_, "Identifier<br>(of corresponding PeptideIdentifications)");
 
60
 
 
61
    addSeparator_();
 
62
    addLineEdit_(engine_, "Search engine");
 
63
    addLineEdit_(engine_version_, "Search engine version");
 
64
    addLineEdit_(identification_date_, "Date of search");
 
65
    addLineEdit_(score_type_, "Score type");
 
66
    addBooleanComboBox_(higher_better_, "Higher score is better");
 
67
    addDoubleLineEdit_(identification_threshold_, "Protein significance threshold");
 
68
 
 
69
    addSeparator_();
 
70
    addLabel_("Search Parameters:");
 
71
    addLineEdit_(db_, "Database name");
 
72
    addLineEdit_(db_version_, "Database version");
 
73
    addLineEdit_(taxonomy_, "Taxonomy restriction");
 
74
    addLineEdit_(charges_, "Allowed charges");
 
75
    addIntLineEdit_(missed_cleavages_, "Missed Cleavages");
 
76
    addDoubleLineEdit_(peak_tolerance_, "Fragment ion mass tolerance");
 
77
    addDoubleLineEdit_(precursor_tolerance_, "Precursor ion mass tolerance");
 
78
    addComboBox_(mass_type_, "Mass type");
 
79
    addComboBox_(enzyme_, "Digestion enzyme");
 
80
 
 
81
    addSeparator_();
 
82
    addLabel_("Show protein hits with score equal or better than a threshold.");
 
83
    QPushButton * button;
 
84
    addLineEditButton_("Score threshold", filter_threshold_, button, "Filter");
 
85
    connect(button, SIGNAL(clicked()), this, SLOT(updateTree_()));
 
86
 
 
87
    finishAdding_();
 
88
  }
 
89
 
 
90
  void ProteinIdentificationVisualizer::load(ProteinIdentification & s, int tree_item_id)
 
91
  {
 
92
    ptr_ = &s;
 
93
    temp_ = s;
 
94
 
 
95
    // id of the item in the tree
 
96
    tree_id_ = tree_item_id;
 
97
 
 
98
    identification_date_->setText(temp_.getDateTime().get().toQString());
 
99
    identification_threshold_->setText(QString::number(temp_.getSignificanceThreshold()));
 
100
    identifier_->setText(temp_.getIdentifier().toQString());
 
101
    engine_->setText(temp_.getSearchEngine().toQString());
 
102
    engine_version_->setText(temp_.getSearchEngineVersion().toQString());
 
103
    score_type_->setText(temp_.getScoreType().toQString());
 
104
    higher_better_->setCurrentIndex(temp_.isHigherScoreBetter());
 
105
 
 
106
    db_->setText(temp_.getSearchParameters().db.toQString());
 
107
    db_version_->setText(temp_.getSearchParameters().db_version.toQString());
 
108
    taxonomy_->setText(temp_.getSearchParameters().taxonomy.toQString());
 
109
    charges_->setText(temp_.getSearchParameters().charges.toQString());
 
110
    missed_cleavages_->setText(QString::number(temp_.getSearchParameters().missed_cleavages));
 
111
    peak_tolerance_->setText(QString::number(temp_.getSearchParameters().peak_mass_tolerance));
 
112
    precursor_tolerance_->setText(QString::number(temp_.getSearchParameters().precursor_tolerance));
 
113
 
 
114
    if (!isEditable())
 
115
    {
 
116
      fillComboBox_(mass_type_, &ProteinIdentification::NamesOfPeakMassType[temp_.getSearchParameters().mass_type], 1);
 
117
      fillComboBox_(enzyme_, &ProteinIdentification::NamesOfDigestionEnzyme[temp_.getSearchParameters().enzyme], 1);
 
118
    }
 
119
    else
 
120
    {
 
121
      fillComboBox_(mass_type_, ProteinIdentification::NamesOfPeakMassType, ProteinIdentification::SIZE_OF_PEAKMASSTYPE);
 
122
      fillComboBox_(enzyme_, ProteinIdentification::NamesOfDigestionEnzyme, ProteinIdentification::SIZE_OF_DIGESTIONENZYME);
 
123
 
 
124
      enzyme_->setCurrentIndex(temp_.getSearchParameters().enzyme);
 
125
      mass_type_->setCurrentIndex(temp_.getSearchParameters().mass_type);
 
126
    }
 
127
  }
 
128
 
 
129
  void ProteinIdentificationVisualizer::updateTree_()
 
130
  {
 
131
    if (filter_threshold_->text() != "")
 
132
    {
 
133
      pidv_caller_->filterHits_(filter_threshold_->text().toDouble(), temp_.isHigherScoreBetter(), tree_id_);
 
134
    }
 
135
    else
 
136
    {
 
137
      pidv_caller_->showAllHits_(tree_id_);
 
138
    }
 
139
  }
 
140
 
 
141
  void ProteinIdentificationVisualizer::store()
 
142
  {
 
143
    ptr_->setSearchEngine(engine_->text());
 
144
    ptr_->setSearchEngineVersion(engine_version_->text());
 
145
    ptr_->setIdentifier(identifier_->text());
 
146
    ptr_->setSignificanceThreshold(identification_threshold_->text().toFloat());
 
147
    ptr_->setScoreType(score_type_->text());
 
148
    ptr_->setHigherScoreBetter(higher_better_->currentIndex());
 
149
    //date
 
150
    DateTime date;
 
151
    try
 
152
    {
 
153
      date.set(identification_date_->text());
 
154
      ptr_->setDateTime(date);
 
155
    }
 
156
    catch (exception & /*e*/)
 
157
    {
 
158
      if (date.isNull())
 
159
      {
 
160
        std::string status = "Format of date in PROTEINIDENTIFICATION is not correct.";
 
161
        emit sendStatus(status);
 
162
      }
 
163
    }
 
164
 
 
165
    //search parameters
 
166
    ProteinIdentification::SearchParameters tmp = ptr_->getSearchParameters();
 
167
    tmp.db = db_->text();
 
168
    tmp.db_version = db_version_->text();
 
169
    tmp.taxonomy = taxonomy_->text();
 
170
    tmp.charges = charges_->text();
 
171
    tmp.missed_cleavages = missed_cleavages_->text().toInt();
 
172
    tmp.peak_mass_tolerance = peak_tolerance_->text().toFloat();
 
173
    tmp.precursor_tolerance = precursor_tolerance_->text().toFloat();
 
174
    tmp.enzyme = (ProteinIdentification::DigestionEnzyme)(enzyme_->currentIndex());
 
175
    tmp.mass_type = (ProteinIdentification::PeakMassType)(mass_type_->currentIndex());
 
176
    ptr_->setSearchParameters(tmp);
 
177
 
 
178
    temp_ = (*ptr_);
 
179
  }
 
180
 
 
181
  void ProteinIdentificationVisualizer::undo_()
 
182
  {
 
183
    load(*ptr_, tree_id_);
 
184
  }
178
185
 
179
186
}