From 1fe1d82b069c82377e8e0b4c86060a9218c1b131 Mon Sep 17 00:00:00 2001 From: Marc Sturm Date: Mon, 4 Dec 2023 14:06:24 +0100 Subject: [PATCH] GSvar: added search box to disease/phenotype data in gene tab. --- src/GSvar/GeneWidget.cpp | 41 ++++++++++--- src/GSvar/GeneWidget.h | 4 ++ src/GSvar/GeneWidget.ui | 126 ++++++++++++++++++++++++++------------- src/GSvar/MainWindow.cpp | 7 +++ 4 files changed, 129 insertions(+), 49 deletions(-) diff --git a/src/GSvar/GeneWidget.cpp b/src/GSvar/GeneWidget.cpp index d9915a314..54ba29b58 100644 --- a/src/GSvar/GeneWidget.cpp +++ b/src/GSvar/GeneWidget.cpp @@ -23,6 +23,7 @@ GeneWidget::GeneWidget(QWidget* parent, QByteArray symbol) connect(ui_.variation_btn, SIGNAL(clicked(bool)), this, SLOT(showGeneVariationDialog())); connect(ui_.pseudogenes, SIGNAL(linkActivated(QString)), this, SLOT(parseLink(QString))); connect(ui_.type, SIGNAL(linkActivated(QString)), this, SLOT(openGeneTab(QString))); + connect(ui_.pheno_search, SIGNAL(editingFinished()), this, SLOT(updatePhenotypeSearch())); //edit button QMenu* menu = new QMenu(); @@ -148,7 +149,7 @@ void GeneWidget::updateGUI() ui_.hgnc_synonymous->setText(db.synonymousSymbols(gene_id).join(", ")); //show phenotypes/diseases from HPO - QStringList hpo_links; + hpo_lines.clear(); PhenotypeList pheno_list = db.phenotypes(symbol_); foreach(const Phenotype& pheno, pheno_list) { @@ -165,12 +166,12 @@ void GeneWidget::updateGUI() } } - hpo_links << "" + pheno.accession() + " " + pheno.name() + " (sources: " + sources.toList().join(", ") + ")"; + hpo_lines << "" + pheno.accession() + " " + pheno.name() + " (sources: " + sources.toList().join(", ") + ")"; } - ui_.hpo->setText(hpo_links.join("
")); + ui_.hpo->setText(hpo_lines.join("
")); //show OMIM info - QStringList omim_lines; + omim_lines.clear(); QList omim_infos = db.omimInfo(symbol_); foreach(const OmimInfo& omim, omim_infos) { @@ -184,7 +185,7 @@ void GeneWidget::updateGUI() ui_.omim->setText(omim_lines.join("
")); //show OrphaNet info - QByteArrayList orpha_links; + orpha_lines.clear(); SqlQuery query = db.getQuery(); query.exec("SELECT dt.* FROM disease_term dt, disease_gene dg WHERE dg.disease_term_id=dt.id AND dt.source='OrphaNet' AND dg.gene='" + symbol_ + "'"); while (query.next()) @@ -192,9 +193,9 @@ void GeneWidget::updateGUI() QByteArray identifier = query.value("identifier").toByteArray(); QByteArray number = identifier.mid(6); QByteArray name = query.value("name").toByteArray(); - orpha_links << ("" + identifier + " " + name); + orpha_lines << ("" + identifier + " " + name); } - ui_.diseases->setText(orpha_links.join(orpha_links.count()>20 ? " " : "
")); + ui_.diseases->setText(orpha_lines.join("
")); updateTranscriptsTable(db); } @@ -264,6 +265,32 @@ void GeneWidget::openGeneTab(QString symbol) GlobalServiceProvider::openGeneTab(symbol); } +void GeneWidget::updatePhenotypeSearch() +{ + QString search_text = ui_.pheno_search->text().trimmed(); + + QStringList tmp; + foreach(const QString& line, omim_lines) + { + if (line.contains(search_text, Qt::CaseInsensitive)) tmp << line; + } + ui_.omim->setText(tmp.join("
")); + + tmp.clear(); + foreach(const QString& line, orpha_lines) + { + if (line.contains(search_text, Qt::CaseInsensitive)) tmp << line; + } + ui_.diseases->setText(tmp.join("
")); + + tmp.clear(); + foreach(const QString& line, hpo_lines) + { + if (line.contains(search_text, Qt::CaseInsensitive)) tmp << line; + } + ui_.hpo->setText(tmp.join("
")); +} + void GeneWidget::updateTranscriptsTable(NGSD& db) { //clear diff --git a/src/GSvar/GeneWidget.h b/src/GSvar/GeneWidget.h index 820fe4748..82e21ab85 100644 --- a/src/GSvar/GeneWidget.h +++ b/src/GSvar/GeneWidget.h @@ -21,10 +21,14 @@ private slots: void openGeneDatabase(); void parseLink(QString link); void openGeneTab(QString symbol); + void updatePhenotypeSearch(); private: Ui::GeneWidget ui_; QByteArray symbol_; + QStringList omim_lines; + QStringList orpha_lines; + QStringList hpo_lines; void updateTranscriptsTable(NGSD& db); }; diff --git a/src/GSvar/GeneWidget.ui b/src/GSvar/GeneWidget.ui index 4dd8ba00d..c068e1851 100644 --- a/src/GSvar/GeneWidget.ui +++ b/src/GSvar/GeneWidget.ui @@ -19,7 +19,7 @@ Dialog - + 3 @@ -607,13 +607,7 @@ true - - - 3 - - - 3 - + 3 @@ -626,7 +620,23 @@ 3 - + + 3 + + + + + Qt::Vertical + + + + 5 + 5 + + + + + @@ -648,38 +658,53 @@ - - + + - HPO phenotypes: + OMIM phenotypes: Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop - - + + + + + 0 + 0 + + - OMIM phenotypes: + - - Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop + + true + + + Qt::LinksAccessibleByMouse|Qt::TextSelectableByMouse - - + + - OrphaNet diseases: + HPO phenotypes: Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop - + + + + 0 + 0 + + @@ -694,35 +719,52 @@ - - + + - - - - true + OrphaNet diseases: - - Qt::LinksAccessibleByMouse|Qt::TextSelectableByMouse + + Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop + + + + 3 + + + + + Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter + + + Search + + + true + + + + + + + Qt::Vertical + + + + 20 + 40 + + + + + + - - - - Qt::Vertical - - - - 5 - 5 - - - - diff --git a/src/GSvar/MainWindow.cpp b/src/GSvar/MainWindow.cpp index 2cb1ba19b..8e3fdd5ec 100644 --- a/src/GSvar/MainWindow.cpp +++ b/src/GSvar/MainWindow.cpp @@ -225,6 +225,9 @@ MainWindow::MainWindow(QWidget *parent) debug_btn->menu()->addAction("variant: chr1:948519-948519 T>G", this, SLOT(openDebugTab())); debug_btn->menu()->addSeparator(); debug_btn->menu()->addAction("gene: BRCA2", this, SLOT(openDebugTab())); + debug_btn->menu()->addSeparator(); + debug_btn->menu()->addAction("processed sample: NA12878_58", this, SLOT(openDebugTab())); + debug_btn->menu()->addAction("processed sample: NA12878_45", this, SLOT(openDebugTab())); ui_.tools->addWidget(debug_btn); } ui_.actionEncrypt->setVisible(Settings::boolean("debug_mode_enabled", true)); @@ -1601,6 +1604,10 @@ void MainWindow::openDebugTab() { openGeneTab(text.mid(5).trimmed()); } + else if (text.startsWith("processed sample:")) + { + openProcessedSampleTab(text.mid(17).trimmed()); + } else { THROW(ProgrammingException, "Unprocessed debug action: " + text);