Skip to content

Commit ac65701

Browse files
authored
Merge pull request #2 from jpfeuffer/gui/proteintable
Fixes, cleanups and todos
2 parents 232f491 + a066019 commit ac65701

13 files changed

Lines changed: 206 additions & 116 deletions

src/openms_gui/include/OpenMS/VISUAL/DataSelectionTabs.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ namespace OpenMS
9393
/// Tabs which have data to show are automatically enabled. Others are disabled.
9494
/// If the currently visible tab would have to data to show, we pick the highest (rightmost) tab
9595
/// which has data and show that instead
96-
void update();
96+
void callUpdateEntries();
9797

9898
/// invoked when user changes the active tab to @p tab_index
9999
void currentTabChanged(int tab_index);

src/openms_gui/include/OpenMS/VISUAL/SequenceVisualizer.h

Lines changed: 40 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,38 @@
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-2021.
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.
29+
//
30+
// --------------------------------------------------------------------------
31+
// $Maintainer: Julianus Pfeuffer $
32+
// $Authors: Dhanmoni Nath, Julianus Pfeuffer $
33+
// --------------------------------------------------------------------------
34+
35+
#ifdef QT_WEBENGINEWIDGETS_LIB
136
#pragma once
237

338
// OpenMS_GUI config
@@ -6,9 +41,6 @@
641
#include <QWidget>
742
#include <QJsonObject>
843

9-
#include <unordered_map>
10-
#include <vector>
11-
1244
namespace Ui
1345
{
1446
class SequenceVisualizer;
@@ -23,15 +55,16 @@ namespace OpenMS
2355
Q_PROPERTY(QJsonObject json_data_obj MEMBER m_json_data_obj)
2456

2557
public:
26-
SequenceVisualizer(QWidget* parent = nullptr);
27-
~SequenceVisualizer();
58+
explicit SequenceVisualizer(QWidget* parent = nullptr);
59+
~SequenceVisualizer() override;
2860

2961
public slots:
3062

31-
void setProteinPeptideDataToJsonObj(QString accession_num, QString pro_seq, QJsonArray peptides_data, QJsonArray pep_mod_data);
63+
void setProteinPeptideDataToJsonObj(const QString& accession_num, const QString& pro_seq, const QJsonArray& peptides_data, const QJsonArray& pep_mod_data);
3264

3365
private:
3466
Ui::SequenceVisualizer* ui;
3567
QJsonObject m_json_data_obj;
3668
};
37-
}// namespace OpenMS
69+
}// namespace OpenMS
70+
#endif

src/openms_gui/include/OpenMS/VISUAL/SpectraIDViewTab.h

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -98,23 +98,20 @@ namespace OpenMS
9898

9999
private:
100100
/// partially fill the bottom-most row
101-
void fillRow_(const MSSpectrum& spectrum, const int spec_index, const QColor background_color);
101+
void fillRow_(const MSSpectrum& spectrum, const int spec_index, const QColor& background_color);
102102
// extract the required part of the accession
103-
QString extractNumFromAccession_(QString listItem);
103+
static static QString extractNumFromAccession_(const QString& listItem);
104104
//open browser to navigate to uniport site with accession
105-
void openUniProtSiteWithAccession_(QString accession);
105+
void openUniProtSiteWithAccession_(const QString& accession);
106106

107107
LayerData* layer_ = nullptr;
108108
QCheckBox* hide_no_identification_ = nullptr;
109109
QCheckBox* create_rows_for_commmon_metavalue_ = nullptr;
110110
TableView* table_widget_ = nullptr;
111111
TableView* protein_table_widget_ = nullptr;
112112
QTableWidget* fragment_window_ = nullptr;
113-
QWidget* protein_window_ = nullptr;
114-
QWidget* accession_window_ = nullptr;
115-
bool is_ms1_shown_ = false;
116113
bool is_first_time_loading = true;
117-
std::unordered_map<String, std::vector<PeptideIdentification>> protein_to_peptide_id_map;
114+
std::unordered_map<String, std::vector<const PeptideIdentification*>> protein_to_peptide_id_map;
118115
private slots:
119116
/// Saves the (potentially filtered) IDs as an idXML or mzIdentML file
120117
void saveIDs_();

src/openms_gui/include/OpenMS/VISUAL/SpectraTreeTab.h

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,9 @@ namespace OpenMS
8080
/// @param current_type Either DT_PEAK or DT_CHROMATOGRAM, depending on what is currently shown
8181
bool getSelectedScan(MSExperiment& exp, LayerData::DataType& current_type) const;
8282

83+
/// received focus e.g. through tabswitching
84+
void updateIndexFromCurrentLayer();
85+
8386
signals:
8487
void spectrumSelected(int);
8588
void chromsSelected(std::vector<int> indices);
@@ -92,13 +95,15 @@ namespace OpenMS
9295
QLineEdit* spectra_search_box_ = nullptr;
9396
QComboBox* spectra_combo_box_ = nullptr;
9497
TreeView* spectra_treewidget_ = nullptr;
98+
LayerData* layer_ = nullptr;
9599
/// cache to store mapping of chromatogram precursors to chromatogram indices
96100
std::map<size_t, std::map<Precursor, std::vector<Size>, Precursor::MZLess> > map_precursor_to_chrom_idx_cache_;
97101
/// remember the last PeakMap that we used to fill the spectra list (and avoid rebuilding it)
98102
const PeakMap* last_peakmap_ = nullptr;
99103

100104
private slots:
101-
/// fill the search-combo-box with current column header names
105+
106+
/// fill the search-combo-box with current column header names
102107
void populateSearchBox_();
103108
/// searches for rows containing a search text (from spectra_search_box_); called when text search box is used
104109
void spectrumSearchText_();

src/openms_gui/source/VISUAL/APPLICATIONS/TOPPViewBase.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2022,7 +2022,8 @@ namespace OpenMS
20222022
{
20232023
return;
20242024
}
2025-
selection_view_->currentTabChanged(1); //switch to ID view
2025+
selection_view_->setCurrentIndex(DataSelectionTabs::IDENT_IDX); //switch to ID view
2026+
selection_view_->currentTabChanged(DataSelectionTabs::IDENT_IDX);
20262027
}
20272028

20282029
void TOPPViewBase::annotateWithOSW()

src/openms_gui/source/VISUAL/DataSelectionTabs.cpp

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ namespace OpenMS
113113

114114
// called externally
115115
// and internally by signals
116-
void DataSelectionTabs::update()
116+
void DataSelectionTabs::callUpdateEntries()
117117
{
118118
// prevent infinite loop when calling 'setTabEnabled' -> currentTabChanged() -> update()
119119
this->blockSignals(true);
@@ -151,7 +151,6 @@ namespace OpenMS
151151
Size current_index = currentIndex();
152152
// update the currently visible tab (might be disabled if no data is shown)
153153
tab_ptrs_[current_index]->updateEntries(layer_ptr);
154-
this->update(); // not sure if necessary. Should update itself if changes occurred.
155154
}
156155

157156
void DataSelectionTabs::currentTabChanged(int tab_index)
@@ -167,9 +166,13 @@ namespace OpenMS
167166
case IDENT_IDX:
168167
spectraview_controller_->deactivateBehavior();
169168
diatab_controller_->deactivateBehavior();
170-
if (tv_->getActive2DWidget()) // currently 2D window is open
169+
std::cout << "trying to switch to Ident tab" << std::endl;
170+
if (tv_->getActive2DWidget()) // currently, 2D window is open
171171
{
172+
std::cout << "2D was open" << std::endl;
172173
idview_controller_->showSpectrumAsNew1D(0);
174+
} else {
175+
std::cout << "2D was NOT open" << std::endl;
173176
}
174177
idview_controller_->activateBehavior();
175178
break;
@@ -182,7 +185,12 @@ namespace OpenMS
182185
std::cerr << "Error: tab_index " << tab_index << " is invalid\n";
183186
throw Exception::NotImplemented(__FILE__, __LINE__, OPENMS_PRETTY_FUNCTION);
184187
}
185-
update();
188+
callUpdateEntries(); //TODO actually this is overkill. Why would you load the entire table again
189+
// when you only switched tabs? The TabView should get notified when the layer data changes, so it only
190+
// updates when necessary...
191+
// The only thing that maybe needs to happen when switching tabs is to sync the index across the tables in the different tabs.
192+
// which is the only reason why we need to actually use callUpdateEntries here.
193+
// At least we reduced it to only updateEntries during tab switch, not EVERY update() [e.g. when resizing, refocussing...]
186194
}
187195

188196
void DataSelectionTabs::showSpectrumAsNew1D(int index)

src/openms_gui/source/VISUAL/ICONS/sequence_viz.html

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,7 @@
117117
length="${protlen}"
118118
displaystart="1"
119119
displayend="${protlen}"
120+
numberofticks="0"
120121
use-ctrl-to-zoom="true"
121122
highlight-event="onmouseover"
122123
/>
@@ -132,7 +133,7 @@
132133
let modProtTrack = `
133134
<protvista-track id="mod_track"
134135
length="${protlen}"
135-
displaystart="0"
136+
displaystart="1"
136137
displayend="${protlen}"
137138
use-ctrl-to-zoom="true"
138139
tooltip-event="mouseover"

src/openms_gui/source/VISUAL/Plot1DCanvas.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -823,7 +823,7 @@ namespace OpenMS
823823
}
824824

825825
// Warn if non-empty peak color array present but size doesn't match number of peaks
826-
// This indicates a bug but we gracefuly just issue a warning
826+
// This indicates a bug but we gracefully just issue a warning
827827
if (!layer.peak_colors_1d.empty() &&
828828
layer.peak_colors_1d.size() < spectrum.size())
829829
{
@@ -996,7 +996,7 @@ namespace OpenMS
996996
if (peak.peak >= spec.size())
997997
{
998998
// somehow the peak is invalid. This happens from time to time and should be tracked down elsewhere
999-
// but its hard to reproduce (changing spectra in 1D view using arrow keys while hovering over the spectrum with the mouse?).
999+
// but it's hard to reproduce (changing spectra in 1D view using arrow keys while hovering over the spectrum with the mouse?).
10001000
return;
10011001
}
10021002
const ExperimentType::PeakType& sel = spec[peak.peak];
@@ -2096,6 +2096,7 @@ namespace OpenMS
20962096
// be an in-memory representation in the peak data structure. Using
20972097
// setCurrentSpectrumIndex will select the appropriate spectrum and load it
20982098
// into memory.
2099+
std::cout << "Current nr. spec: " << getCurrentLayer().getPeakData()->size() << std::endl;
20992100
if (index < getCurrentLayer().getPeakData()->size())
21002101
{
21012102
getCurrentLayer().setCurrentSpectrumIndex(index);
Lines changed: 43 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,42 @@
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-2021.
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.
29+
//
30+
// --------------------------------------------------------------------------
31+
// $Maintainer: Julianus Pfeuffer $
32+
// $Authors: Dhanmoni Nath, Julianus Pfeuffer $
33+
// --------------------------------------------------------------------------
34+
35+
#ifdef QT_WEBENGINEWIDGETS_LIB
136
#include <OpenMS/VISUAL/SequenceVisualizer.h>
237
#include <ui_SequenceVisualizer.h>
338

4-
#include <QLabel>
5-
#include <QDebug>
639
#include <QWebChannel>
7-
#include <QPushButton>
8-
#include <QMessageBox>
9-
#include <QJsonArray>
1040
#include <QString>
1141

1242
#include <QtWebEngineWidgets/QWebEngineView>
@@ -18,8 +48,8 @@ namespace OpenMS
1848
QWidget(parent), ui(new Ui::SequenceVisualizer)
1949
{
2050
ui->setupUi(this);
21-
QWebEngineView* view = new QWebEngineView(parent);
22-
QWebChannel* channel = new QWebChannel(this);
51+
auto* view = new QWebEngineView(parent);
52+
auto* channel = new QWebChannel(this);
2353
view->page()->setWebChannel(channel);
2454
channel->registerObject(QString("SequenceVisualizer"), this);
2555
view->load(QUrl("qrc:/new/sequence_viz.html"));
@@ -31,14 +61,15 @@ namespace OpenMS
3161
delete ui;
3262
}
3363

34-
void SequenceVisualizer::setProteinPeptideDataToJsonObj(QString accession_num,
35-
QString pro_seq,
36-
QJsonArray pep_data,
37-
QJsonArray pep_mod_data)
64+
void SequenceVisualizer::setProteinPeptideDataToJsonObj(const QString& accession_num,
65+
const QString& pro_seq,
66+
const QJsonArray& pep_data,
67+
const QJsonArray& pep_mod_data)
3868
{
3969
m_json_data_obj["accession_num"] = accession_num;
4070
m_json_data_obj["protein_sequence_data"] = pro_seq;
4171
m_json_data_obj["peptides_data"] = pep_data;
4272
m_json_data_obj["peptides_mod_data"] = pep_mod_data;
4373
}
44-
}// namespace OpenMS
74+
}// namespace OpenMS
75+
#endif

0 commit comments

Comments
 (0)