Skip to content

Commit

Permalink
Make beacon searches specific to dataset.
Browse files Browse the repository at this point in the history
Also remove reference selection from the frontend as the current frontend only supports the reference used with the dataset.
  • Loading branch information
talavis committed Apr 30, 2019
1 parent 7ef2c91 commit 5be11e0
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 34 deletions.
29 changes: 18 additions & 11 deletions frontend/src/js/controller.datasetBeaconController.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
Beacon.getBeaconReferences($routeParams.dataset, $routeParams.version)
.then(function(data) {
if (data) {
localThis.references = data;
localThis.beaconInfo = data;
}
});

Expand All @@ -33,30 +33,38 @@
function search() {
Beacon.queryBeacon(localThis)
.then(function(response) {
if (!response.data.datasetAlleleResponses[0]) {
if (response.data.exists===false) { // value may be null -> error
localThis.queryResponses.push({
"response": { "state": "Absent" },
"query": {
"chromosome": localThis.chromosome,
"position": localThis.position,
"allele": localThis.allele,
"referenceAllele": localThis.referenceAllele,
"reference": localThis.reference
}
});
}
else {
else if (response.data.exists===true) {
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),
}
"chromosome": localThis.chromosome,
"position": localThis.position,
"allele": localThis.allele,
"referenceAllele": localThis.referenceAllele,
}
});
}
else {
localThis.queryResponses.push({
"response": { "state": "Error" },
"query": {
"chromosome": localThis.chromosome,
"position": localThis.position,
"allele": localThis.allele,
"referenceAllele": localThis.referenceAllele,
}
});
},
function() {
localThis.queryResponses.push({
Expand All @@ -66,7 +74,6 @@
"position": localThis.position,
"allele": localThis.allele,
"referenceAllele": localThis.referenceAllele,
"reference": localThis.reference
}
});
}
Expand Down
22 changes: 14 additions & 8 deletions frontend/src/js/factory.beacon.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,28 +14,35 @@
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 {
"reference": dataset.split(":")[0].substring(0, 6),
"datasetId": dataset,
}
}
}
}
else {
var references = [];
for (var i = 0; i < d.length; i++) {
var dataset = d[i].id;
if (dataset.indexOf(name) != -1) {
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]);
var ver = parseInt(references[i].split(":")[2]);
if (ver > highest_ver) {
highest_ver = ver;
reference = dataset.split(":")[0].substring(0, 6);
reference = references[i].split(":")[0].substring(0, 6);
beaconId = references[i];
}
}
return [reference]
return {
"reference": reference,
"datasetId": beaconId,
}
}
});
}
Expand All @@ -47,9 +54,8 @@
"start": query.position - 1, // Beacon is 0-based
"alternateBases": query.allele,
"referenceBases": query.referenceAllele,
"datasetIds": query.dataset.shortName,
"assemblyId": query.reference,
"includeDatasetResponses": "HIT"
"datasetIds": query.beaconInfo.datasetId,
"assemblyId": query.beaconInfo.reference,
}
}
);
Expand Down
22 changes: 7 additions & 15 deletions frontend/templates/ng-templates/dataset-beacon.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
[% block controller %]datasetBeaconController[% endblock %]
[% block contents %]
<h2>Search</h2>
<div class="alert alert-danger" ng-if="!ctrl.references[0]">
<div class="alert alert-danger" ng-if="!ctrl.beaconInfo.reference">
<h3>Beacon error</h3>
<p>Unable to retrieve the reference set from the Beacon.</p>
<p>Either the dataset version is not available or the service is down.</p>
Expand All @@ -13,37 +13,31 @@ <h3>Beacon error</h3>
<div class="form-group">
<label for="chromosome" class="col-sm-3 control-label">Chromosome</label>
<div class="col-sm-3">
<input type="text" required ng-pattern='/^([1-9]|1[0-9]|2[0-2]|X|Y|x|y)$/' class="form-control" id="chromosome" name="chromosome" ng-model="ctrl.chromosome" placeholder="Chromosome" ng-disabled="!ctrl.references[0]">
<input type="text" required ng-pattern='/^([1-9]|1[0-9]|2[0-2]|X|Y|x|y)$/' class="form-control" id="chromosome" name="chromosome" ng-model="ctrl.chromosome" placeholder="Chromosome" ng-disabled="!ctrl.beaconInfo.reference">
</div>

<label for="position" class="col-sm-3 control-label">Position</label>
<div class="col-sm-3">
<input type="number" required class="form-control" id="position" ng-model="ctrl.position" placeholder="Position" ng-disabled="!ctrl.references[0]">
<input type="number" required class="form-control" id="position" ng-model="ctrl.position" placeholder="Position" ng-disabled="!ctrl.beaconInfo.reference">
</div>
</div>

<div class="form-group">
<label for="referenceAllele" class="col-sm-3 control-label">Reference Allele</label>
<div class="col-sm-3">
<input type="text" required ng-pattern='/^([ATCGatcg]+)$/' class="form-control" id="referenceAllele" ng-model="ctrl.referenceAllele" name='referenceAllele' placeholder="Reference Allele" ng-disabled="!ctrl.references[0]">
<input type="text" required ng-pattern='/^([ATCGatcg]+)$/' class="form-control" id="referenceAllele" ng-model="ctrl.referenceAllele" name='referenceAllele' placeholder="Reference Allele" ng-disabled="!ctrl.beaconInfo.reference">
</div>

<label for="allele" class="col-sm-3 control-label">Alternate Allele</label>
<div class="col-sm-3">
<input type="text" required ng-pattern='/^([ATCGatcg]+)$/' class="form-control" id="allele" ng-model="ctrl.allele" name='allele' placeholder="Alternate Allele" ng-disabled="!ctrl.references[0]">
</div>
</div>

<div class="form-group">
<label for="reference" class="col-sm-3 control-label">Reference</label>
<div class="col-sm-3">
<select required class="form-control" ng-disabled="!ctrl.references[0]" ng-model="ctrl.reference" ng-options="r as r for r in ctrl.references"></select>
<input type="text" required ng-pattern='/^([ATCGatcg]+)$/' class="form-control" id="allele" ng-model="ctrl.allele" name='allele' placeholder="Alternate Allele" ng-disabled="!ctrl.beaconInfo.reference">
</div>
</div>

<div class="form-group">
<div class="col-sm-offset-3 col-sm-7">
<button ng-click="ctrl.search()" class="btn btn-primary" ng-disabled="!(ctrl.chromosome && ctrl.position && ctrl.referenceAllele && ctrl.allele && ctrl.reference)">Search</button><span class="left-margin alert-text" ng-if="!(ctrl.chromosome && ctrl.position && ctrl.referenceAllele && ctrl.allele && ctrl.reference)">Need to fill in all values before searching</span>
<button ng-click="ctrl.search()" class="btn btn-primary" ng-disabled="!(ctrl.chromosome && ctrl.position && ctrl.referenceAllele && ctrl.allele && ctrl.beaconInfo.reference)">Search</button>
<span class="left-margin alert-text" ng-if="!(ctrl.chromosome && ctrl.position && ctrl.referenceAllele && ctrl.allele) && ctrl.beaconInfo.reference">Need to fill in all values before searching</span>
</div>
<div class="col-sm-2">
<a style='cursor: pointer' ng-click="showDetails = ! showDetails" class="pull-right">
Expand Down Expand Up @@ -75,15 +69,13 @@ <h2>Results</h2>
<th>Position</th>
<th>Reference Allele</th>
<th>Alternate Allele</th>
<th>Reference</th>
</tr>
<tr ng-repeat="row in ctrl.queryResponses">
<td>{{row.response.state}}</td>
<td>{{row.query.chromosome}}</td>
<td>{{row.query.position}}</td>
<td>{{row.query.referenceAllele}}</td>
<td>{{row.query.allele}}</td>
<td>{{row.query.reference}}</td>
</tr>
</table>
</div>
Expand Down

0 comments on commit 5be11e0

Please sign in to comment.