Commit 7047dc4f authored by Daniel Teixeira's avatar Daniel Teixeira
Browse files

adding back genome HG 36

parent 51d2cd77
var info = require('./beacon-info.js').info
//check https://genome.ucsc.edu/FAQ/FAQreleases.html
var referenceMap = {
'GRCh38': 'SEGMENTS_HG38',
'GRCh37': 'SEGMENTS_HG19'
};
/*var referenceMap = {
'GRCh38': 'SEGMENTS_HG38',
'GRCh37': 'SEGMENTS_HG19'
};*/
/*var referenceMap = {
var referenceMap = {
'GRCh38': 'SEGMENTS_HG38',
'GRCh37': 'SEGMENTS_HG19',
'GRCh36': 'SEGMENTS_HG18'
};
*/
//correspondence to arraymap class
var alternateBasesMap = {
"DEL": -1,
......@@ -24,7 +24,7 @@ var alternateBasesMap = {
var defaultReference = 'GRCh38';
function checkPreconditions(params) {
if (!params.referenceName) {
return {
hasError: true,
......@@ -101,21 +101,15 @@ function buildMongoQuery(params) {
var position = parseInt(params.start);
var length = 0;
var maxLength = 0;
if(params.alternateBases == 'DEL') {
if (typeof params.length != undefined && params.length != null && params.length != '') // min. length is provided
{
length = (params.length.length == 0 ? 0 : parseInt(params.length));
}
if (typeof params.maxLength != undefined && params.maxLength != null && params.maxLength != '') // max length is provided
{
maxLength = (params.maxLength.length == 0 ? 0 : parseInt(params.maxLength));
if (length == 0) {
length++; // force min. length in case none is given
}
var minLength = params.minlength ? parseInt(params.minlength) : 0;
var maxLength = params.maxlength ? parseInt(params.maxlength) : 0;
if(!minLength && (maxLength > 0)){
minLength = 1;
}
}
var andConditions = [];
......@@ -136,49 +130,32 @@ function buildMongoQuery(params) {
var segType = alternateBasesMap[params.alternateBases]
var convertedReference = referenceMap[params.assemblyId || defaultReference];
var cond = {};
if (length > 0) {
if (maxLength > 0) {
cond[convertedReference] = {
'$elemMatch': {
'CHRO': params.referenceName,
'SEGTYPE': segType,
'SEGSIZE': {
$gte: length,
$lte: maxLength
}, // min. and max lengths
'SEGSTART': position // exact position
}
}
var condition = {};
condition[convertedReference] = {
'$elemMatch': {
'CHRO': params.referenceName,
'SEGTYPE': segType
}
else {
cond[convertedReference] = {
'$elemMatch': {
'CHRO': params.referenceName,
'SEGTYPE': segType,
'SEGSIZE': {
$gte: length
}, // min. length
'SEGSTART': position // exact position
}
}
}
}
else {
cond[convertedReference] = {
'$elemMatch': {
'CHRO': params.referenceName,
'SEGTYPE': segType,
'SEGSTOP': {
$gte: position
},
'SEGSTART': {
$lte: position
}
}
};
//elem match element
var condElemMatch = condition[convertedReference]['$elemMatch'];
if (minLength > 0) { //There is a minLength
if (maxLength > 0) { //There is always a minLenght, if there is a max length specified (see code above)
condElemMatch.SEGSIZE = { $gte: minLength,$lte: maxLength } // min. and max lengths
condElemMatch.SEGSTART = position // exact position
}else { //If there is no max length specified
condElemMatch.SEGSIZE = { $gte: minLength }; // min. length
condElemMatch.SEGSTART = position; // exact position
}
}else { //If there is a position specifiec
condElemMatch.SEGSTOP = { $gte: position };
condElemMatch.SEGSTART = { $lte: position };
}
andConditions.push(cond);
andConditions.push(condition);
if (orConditions.length > 0) {
andConditions.push({$or: orConditions});
}
......
......@@ -15,17 +15,16 @@ arrayMap.config(['$routeProvider', '$locationProvider',
arrayMap.controller('BeaconController', ['$scope', '$location', function ($scope, $location) {
//$scope.references = ['GRCh38','GRCh37','GRCh36'];
$scope.references = ['GRCh38','GRCh37'];
$scope.references = ['GRCh38','GRCh37','GRCh36'];
$scope.config = {
"chromosome": "",
"position": '',
"reference": "GRCh38",
"dataset": "all",
"referenceName": "11",
"start": 34439881,
"assemblyId": "GRCh38",
"datasetIds": "8070/3",
"alternateBases": "DEL",
"length": '',
"maxLength": ''
"minlength": '',
"maxlength": ''
}
$scope.getNewApiUrl = function () {
......@@ -33,13 +32,13 @@ arrayMap.controller('BeaconController', ['$scope', '$location', function ($scope
var conf = $scope.config;
return $location.absUrl() + "v0.3/query?" +
"referenceName=" + conf.chromosome +
"&start=" + conf.position +
"&assemblyId=" + conf.reference +
"&datasetIds=" + conf.dataset +
"referenceName=" + conf.referenceName +
"&start=" + conf.start +
"&assemblyId=" + conf.assemblyId +
"&datasetIds=" + conf.datasetIds +
((conf.alternateBases === "") ? "all" : "&alternateBases=" + conf.alternateBases) +
"&length=" + conf.length +
((conf.maxLength === '') ? "" : "&maxLength=" + conf.maxLength);
((conf.minlength === '') ? "" : "&minlength=" + conf.minlength) +
((conf.maxlength === '') ? "" : "&maxlength=" + conf.maxlength);
};
$scope.getInfoUrl = function () {
......
......@@ -7,29 +7,29 @@
</div>
<form class="form-horizontal">
<div class="form-group">
<label for="chromosome" class="col-sm-2 control-label">Reference name</label>
<label for="referenceName" class="col-sm-2 control-label">Reference name</label>
<div class="col-sm-4">
<input type="text" class="form-control" id="chromosome" ng-model="config.chromosome" placeholder="Chromosome">
<input type="text" class="form-control" id="referenceName" ng-model="config.referenceName" placeholder="corresponds to chromosome name, ex: 11">
</div>
</div>
<div class="form-group">
<label for="position" class="col-sm-2 control-label">Start</label>
<label for="start" class="col-sm-2 control-label">Start</label>
<div class="col-sm-4">
<input type="text" class="form-control" id="position" ng-model="config.position" placeholder="Position">
<input type="text" class="form-control" id="start" ng-model="config.start" placeholder="start position, ex: 34439881">
</div>
</div>
<div class="form-group">
<label for="referenceSelect" class="col-sm-2 control-label">Assembly ID</label>
<div class="col-sm-4">
<select id="referenceSelect" ng-model="config.reference" class="form-control">
<select id="referenceSelect" ng-model="config.assemblyId" class="form-control">
<option ng-repeat="ref in references" value="{{ref}}" >{{ref}}</option>
</select>
</div>
</div>
<div class="form-group">
<label for="datasetSelect" class="col-sm-2 control-label">Dataset</label>
<label for="datasetSelect" class="col-sm-2 control-label">Dataset Ids</label>
<div class="col-sm-4">
<select id="datasetSelect" ng-model="config.dataset" class="form-control">
<select id="datasetSelect" ng-model="config.datasetIds" class="form-control">
<option ng-repeat="ds in datasets" value="{{ds.code}}" >({{ds.code}}) {{ds.description}}</option>
</select>
</div>
......@@ -49,22 +49,16 @@
</div>
</div>
<div class="form-group">
<label for="position" class="col-sm-2 control-label">Minimal length</label>
<label for="minlength" class="col-sm-2 control-label">Minimal length</label>
<div class="col-sm-4">
<input type="text" class="form-control" id="length" ng-model="config.length" placeholder="1">
<input type="text" class="form-control" id="minlength" ng-model="config.minlength" placeholder="1">
</div>
</div>
<div class="form-group">
<label for="position" class="col-sm-2 control-label">Maximal length</label>
<label for="maxlength" class="col-sm-2 control-label">Maximal length</label>
<div class="col-sm-4">
<input type="text" class="form-control" id="maxLength" ng-model="config.maxLength" placeholder="Max bases for the selected chromosome">
</div>
</div>
<div class="form-group">
<div class="col-sm-offset-2 col-sm-8">
<a target="beacon" ng-href="/v0.3/query?referenceName=11&start=34439881&assemblyId=GRCh38&datasetIds=8070/3&alternateBases=DEL">Example query</a>
<input type="text" class="form-control" id="maxlength" ng-model="config.maxlength" placeholder="Max bases for the selected chromosome">
</div>
</div>
......@@ -86,15 +80,11 @@
</div>
</div>
<!--
<div class="form-group">
<div class="col-sm-offset-2 col-sm-8">
<a target="beacon" ng-href="{{getApiUrl()}}">{{getApiUrl()}}</a>
</div>
<div class="col-sm-2">
<a target="beacon" ng-href="{{getApiUrl()}}" class="btn btn-info">Beacon v0.2</a>
<a target="beacon" href="/samples?limit=10">Get 10 samples</a>
</div>
</div>
-->
</form>
</div>
\ No newline at end of file
This can easily be achieved by using the implementation of Maximilen
https://github.com/maximilianh/ucscBeacon
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment