Skip to content

Commit

Permalink
GSvar: replaced context menu link to gnomAD 2.1 by link to gnomAD 4.0
Browse files Browse the repository at this point in the history
  • Loading branch information
marc-sturm committed Nov 7, 2023
1 parent 57284e7 commit a8a3461
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 19 deletions.
14 changes: 3 additions & 11 deletions src/GSvar/GSvarHelper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -288,7 +288,7 @@ Variant GSvarHelper::liftOverVariant(const Variant& v, bool hg19_to_hg38)
return v2;
}

QString GSvarHelper::gnomADLink(const Variant& v, GenomeBuild build)
QString GSvarHelper::gnomADLink(const Variant& v, bool open_in_v4)
{
QString url = "https://gnomad.broadinstitute.org/variant/" + v.chr().strNormalized(false) + "-";

Expand All @@ -298,12 +298,7 @@ QString GSvarHelper::gnomADLink(const Variant& v, GenomeBuild build)
}
else
{
QString genome_key = "reference_genome";
if (GSvarHelper::build()==GenomeBuild::HG38 && build==GenomeBuild::HG19) //GSvar for HG38, but link for HG19 > use special genome key
{
genome_key = "reference_genome_hg19";
}
FastaFileIndex idx(Settings::string(genome_key));
FastaFileIndex idx(Settings::string("reference_genome"));

if (v.obs()=="-") //deletion
{
Expand All @@ -319,10 +314,7 @@ QString GSvarHelper::gnomADLink(const Variant& v, GenomeBuild build)
}
}

//genome build
if (build==GenomeBuild::HG38) url += "?dataset=gnomad_r3";

return url;
return url + "?dataset=" + (open_in_v4 ? "gnomad_r4" : "gnomad_r3");
}

QString GSvarHelper::clinVarSearchLink(const Variant& v, GenomeBuild build)
Expand Down
2 changes: 1 addition & 1 deletion src/GSvar/GSvarHelper.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ class GSvarHelper
static Variant liftOverVariant(const Variant& v, bool hg19_to_hg38);

//Returns gnomAD link for a variant
static QString gnomADLink(const Variant& v, GenomeBuild build);
static QString gnomADLink(const Variant& v, bool open_in_v4);
//Returns ClinVar search link for a variant
static QString clinVarSearchLink(const Variant& v, GenomeBuild build);

Expand Down
10 changes: 4 additions & 6 deletions src/GSvar/VariantDetailsDockWidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -882,7 +882,7 @@ QString VariantDetailsDockWidget::nobr()
void VariantDetailsDockWidget::gnomadClicked(QString variant_string)
{
Variant v = Variant::fromString(variant_string);
QString link = GSvarHelper::gnomADLink(v, GSvarHelper::build());
QString link = GSvarHelper::gnomADLink(v, false);
QDesktopServices::openUrl(QUrl(link));
}

Expand Down Expand Up @@ -1031,16 +1031,14 @@ void VariantDetailsDockWidget::gnomadContextMenu(QPoint pos)
if (GSvarHelper::build()!=GenomeBuild::HG38) return;

QMenu menu;
QAction* a_v2 = menu.addAction("Lift-over to gnomAD 2.1");
QAction* a_v4 = menu.addAction("Open in gnomAD 4.0");

QAction* action = menu.exec(ui->gnomad->mapToGlobal(pos));
if (action==nullptr) return;

if (action==a_v2)
if (action==a_v4)
{
Variant v = Variant::fromString(variant_str);
Variant v2 = GSvarHelper::liftOverVariant(v, false);
QString link = GSvarHelper::gnomADLink(v2, GenomeBuild::HG19);
QString link = GSvarHelper::gnomADLink(v, true);
QDesktopServices::openUrl(QUrl(link));
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/GSvar/VariantWidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -394,7 +394,7 @@ void VariantWidget::gnomadClicked(QString var_id)
{
NGSD db;
Variant v = db.variant(var_id);
QString link = GSvarHelper::gnomADLink(v, GSvarHelper::build());
QString link = GSvarHelper::gnomADLink(v, false);
QDesktopServices::openUrl(QUrl(link));
}

Expand Down

0 comments on commit a8a3461

Please sign in to comment.