Skip to content

Commit

Permalink
Merge pull request #550 from NBISweden/feature/beacon-requests
Browse files Browse the repository at this point in the history
Make the frontend beacon use the elixir beacon
  • Loading branch information
viklund authored Apr 29, 2019
2 parents a834839 + 3b898de commit 7ef2c91
Show file tree
Hide file tree
Showing 6 changed files with 138 additions and 225 deletions.
135 changes: 0 additions & 135 deletions backend/beacon.py

This file was deleted.

13 changes: 2 additions & 11 deletions backend/route.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@
import handlers
import auth
import settings as swefreq_settings
import beacon
#import template

from modules.browser.route import routes as browser_routes

Expand Down Expand Up @@ -43,7 +41,7 @@ def __init__(self, settings):
{"path": "static/"}),
(r'/(favicon.ico)', tornado.web.StaticFileHandler,
{"path": "static/img/"}),
(r"/release/(?P<dataset>[^\/]+)/(?P<hash_value>[^\/]+)/(?P<file>[^\/]+)",handlers.TemporaryStaticNginxFileHandler,
(r"/release/(?P<dataset>[^\/]+)/(?P<hash_value>[^\/]+)/(?P<file>[^\/]+)", handlers.TemporaryStaticNginxFileHandler,
{"path": "/release-files/"}),
(r"/release/(?P<dataset>[^\/]+)/versions/(?P<ds_version>[^/]+)/(?P<file>[^\/]+)", handlers.AuthorizedStaticNginxFileHandler,
{"path": "/release-files/"}),
Expand All @@ -66,7 +64,7 @@ def __init__(self, settings):
(r"/api/dataset/(?P<dataset>[^\/]+)/log/(?P<event>[^\/]+)/(?P<target>[^\/]+)", application.LogEvent),
(r"/api/dataset/(?P<dataset>[^\/]+)/logo", application.ServeLogo),
(r"/api/dataset/(?P<dataset>[^\/]+)/(?:versions/(?P<ds_version>[^/]+)/)?files", application.DatasetFiles),
(r"/api/dataset/(?P<dataset>[^\/]+)/(?:versions/(?P<ds_version>[^/]+)/)?collection", application.Collection),
(r"/api/dataset/(?P<dataset>[^\/]+)/(?:versions/(?P<ds_version>[^/]+)/)?collection", application.Collection),
(r"/api/dataset/(?P<dataset>[^\/]+)/users_current", application.DatasetUsersCurrent),
(r"/api/dataset/(?P<dataset>[^\/]+)/users_pending", application.DatasetUsersPending),
(r"/api/dataset/(?P<dataset>[^\/]+)/(?:versions/(?P<ds_version>[^/]+)/)?temporary_link", application.GenerateTemporaryLink),
Expand All @@ -77,13 +75,6 @@ def __init__(self, settings):
(r"/api/dataset/(?P<dataset>[^\/]+)/versions/(?P<version>[^\/]+)", application.GetDataset),
(r"/api/dataset/(?P<dataset>[^\/]+)/versions/(?P<version>[^\/]+)/files", application.DatasetFiles),
(r"/api/dataset/(?P<dataset>[^\/]+)/versions/(?P<version>[^\/]+)/temporary_link", application.GenerateTemporaryLink),
### Beacon API
(r"/api/beacon/query", beacon.Query),
(r"/api/beacon/info", beacon.Info),
# # # # # Legacy beacon URIs # # # # #
(r"/query", beacon.Query),
(r"/info", tornado.web.RedirectHandler,
{"url": "/api/beacon/info"}),
]

## Adding module handlers
Expand Down
8 changes: 8 additions & 0 deletions frontend/src/css/main.scss
Original file line number Diff line number Diff line change
Expand Up @@ -295,6 +295,14 @@ table.variant-table {
}
}

/* text for search button */
.alert-text {
color: #900;
}
.left-margin {
margin-left: 5px;
}

#annotationPanel {
position: absolute;
visibility: hidden;
Expand Down
40 changes: 30 additions & 10 deletions frontend/src/js/controller.datasetBeaconController.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,13 @@

activate();


function activate() {
Beacon.getBeaconReferences($routeParams.dataset).then(
function(data) {
localThis.references = data;
}
);
Beacon.getBeaconReferences($routeParams.dataset, $routeParams.version)
.then(function(data) {
if (data) {
localThis.references = data;
}
});

User.getUser().then(function(data) {
localThis.user = data;
Expand All @@ -33,10 +33,30 @@
function search() {
Beacon.queryBeacon(localThis)
.then(function(response) {
var d = response.data;
d.query.position += 1; // Beacon is 0-based
d.response.state = d.response.exists ? "Present" : "Absent";
localThis.queryResponses.push(d);
if (!response.data.datasetAlleleResponses[0]) {
localThis.queryResponses.push({
"response": { "state": "Absent" },
"query": {
"chromosome": localThis.chromosome,
"position": localThis.position,
"allele": localThis.allele,
"referenceAllele": localThis.referenceAllele,
"reference": localThis.reference
}
});
}
else {
localThis.queryResponses.push({
"response": { "state": "Present" },
"query": {
"chromosome": response.data.datasetAlleleResponses[0].referenceName,
"position": response.data.datasetAlleleResponses[0].start + 1, // Beacon is 0-based
"allele": response.data.datasetAlleleResponses[0].alternateBases,
"referenceAllele": response.data.datasetAlleleResponses[0].referenceBases,
"reference": response.data.datasetAlleleResponses[0].datasetId.substring(0, 6),
}
});
}
},
function() {
localThis.queryResponses.push({
Expand Down
52 changes: 36 additions & 16 deletions frontend/src/js/factory.beacon.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,30 +6,50 @@
queryBeacon: queryBeacon
};

function getBeaconReferences(name) {
return $http.get("/api/beacon/info").then(function(data) {
var references = [];
function getBeaconReferences(name, version) {
return $http.get("/api/beacon-elixir/").then(function(data) {
var d = data.data.datasets;

for (var i = 0; i < d.length; i++) {
var dataset = d[i];
if (dataset.id === name) {
references.push(dataset.reference);
if (version) {
for (var i = 0; i < d.length; i++) {
var dataset = d[i].id;
if (dataset.indexOf(name) != -1 && dataset.indexOf(version) != -1) {
return [dataset.split(":")[0].substring(0, 6)];
}
}
}
return references;
}
else {
var references = [];
for (var i = 0; i < d.length; i++) {
var dataset = d[i].id;
if (dataset.indexOf(name) != -1) {
references.push(dataset);
}
}
var highest_ver = 0;
var reference = "";
for (var i = 0; i < references.length; i++) {
var ver = parseInt(dataset.split(":")[2]);
if (ver > highest_ver) {
highest_ver = ver;
reference = dataset.split(":")[0].substring(0, 6);
}
}
return [reference]
}
});
}

function queryBeacon(query) {
return $http.get("/api/beacon/query", {
return $http.get("/api/beacon-elixir/query", {
"params": {
"chrom": query.chromosome,
"pos": query.position - 1, // Beacon is 0-based
"allele": query.allele,
"referenceAllele": query.referenceAllele,
"dataset": query.dataset.shortName,
"ref": query.reference
"referenceName": query.chromosome,
"start": query.position - 1, // Beacon is 0-based
"alternateBases": query.allele,
"referenceBases": query.referenceAllele,
"datasetIds": query.dataset.shortName,
"assemblyId": query.reference,
"includeDatasetResponses": "HIT"
}
}
);
Expand Down
Loading

0 comments on commit 7ef2c91

Please sign in to comment.