Commit b9fb0cc0 authored by Severine Duvaud's avatar Severine Duvaud
Browse files

Added an optinal length field (not handled for now) + Response in case of not...

Added an optinal length field (not handled for now) + Response in case of not supported variant class (exists: false, note: 'Not supported' instead of an error)
parent 1782a632
......@@ -72,12 +72,7 @@ function checkPreconditions(params) {
};
}
if (!alternateBasesMap[params.alternateBases]) {
return {
hasError: true,
msg: params.alternateBases + " variant class is not supported by arrayMap , only supports DUP or DEL"
};
} //TODO add additional checks
//TODO add additional checks
return {
hasError: false
......@@ -87,38 +82,44 @@ function checkPreconditions(params) {
function buildMongoQuery(params) {
var position = parseInt(params.start);
// not handled for now...
var length = (params.length.length == 0 ? 0 : parseInt(params.length));
var andConditions = [];
var orConditions = [];
//add constraint on datasets if required
if (params.datasetIds){
if (params.datasetIds != 'all') {
var identifiers = params.datasetIds.split(','); // comma separated list of datasets
identifiers.forEach(function (id) {
orConditions.push({ICDMORPHOLOGYCODE: id});
});
}
}
if (alternateBasesMap[params.alternateBases]) {
var segType = alternateBasesMap[params.alternateBases]
var convertedReference = referenceMap[params.assemblyId || defaultReference];
//add constraint on datasets if required
if (params.datasetIds) {
if (params.datasetIds != 'all') {
var identifiers = params.datasetIds.split(','); // comma separated list of datasets
identifiers.forEach(function (id) {
orConditions.push({ICDMORPHOLOGYCODE: id});
});
}
}
var cond = {};
cond[convertedReference] = {
'$elemMatch': {
'CHRO': params.referenceName,
'SEGTYPE': segType,
'SEGSTOP': {
$gte: position
},
'SEGSTART': {
$lte: position
var segType = alternateBasesMap[params.alternateBases]
var convertedReference = referenceMap[params.assemblyId || defaultReference];
var cond = {};
cond[convertedReference] = {
'$elemMatch': {
'CHRO': params.referenceName,
'SEGTYPE': segType,
'SEGSTOP': {
$gte: position
},
'SEGSTART': {
$lte: position
}
}
}
}
andConditions.push(cond);
if (orConditions.length > 0) {
andConditions.push({$or: orConditions});
andConditions.push(cond);
if (orConditions.length > 0) {
andConditions.push({$or: orConditions});
}
}
return {
......@@ -130,8 +131,8 @@ function checkResultAndGetResponse(params, samples, countTotal) {
var responseResource = {
"exists": null,
"info": "ok",
"error": null
"error": null,
"note": null
}
if (samples && samples.length > 0) { // a value was found by mongodb
......@@ -143,16 +144,26 @@ function checkResultAndGetResponse(params, samples, countTotal) {
responseResource.exists = null;
responseResource.error = "Internal error, DB returned a value but post check is not valid."
} else {
responseResource.exists = "overlap";
responseResource.exists = true;
responseResource.NOT_BEACON_ARRAYMAP_DEBUG_INFO = {"matchedSegments" : matchedSegments};
}
}
else {
if (!alternateBasesMap[params.alternateBases]) {
responseResource.exists = false;
responseResource.note = "Type of variant not supported by arrayMap.";
}
}
var length = (params.length == '' ? 0 : parseInt(params.length));
var queryResource = {
"referenceName": params.referenceName,
"start": params.start,
"assemblyId": params.assemblyId,
"datasetIds": params.datasetIds
"datasetIds": params.datasetIds,
"alternateBases": params.alternateBases,
"length": length
};
return {
......
......@@ -22,7 +22,8 @@ arrayMap.controller('BeaconController', ['$scope', '$location', function ($scope
"position": '',
"reference": "GRCh38",
"dataset": "all",
"alternateBases": "DEL"
"alternateBases": "DEL",
"length": ''
}
$scope.getNewApiUrl = function () {
......@@ -34,7 +35,8 @@ arrayMap.controller('BeaconController', ['$scope', '$location', function ($scope
"&start=" + conf.position +
"&assemblyId=" + conf.reference +
"&datasetIds=" + conf.dataset +
((conf.alternateBases === "") ? "all" : "&alternateBases=" + conf.alternateBases);
((conf.alternateBases === "") ? "all" : "&alternateBases=" + conf.alternateBases) +
"&length=" + conf.length;
};
$scope.getInfoUrl = function () {
......
......@@ -38,17 +38,22 @@
<label style="color:green" for="alternateBases" class="col-sm-2 control-label">Alternate bases</label>
<div class="col-sm-4">
<select id="alternateBases" ng-model="config.alternateBases" class="form-control">
<option value="">Substitution (For precise variants)</option>
<!--<option value="">Substitution (For precise variants)</option>-->
<option value="DEL">DEL (Deletion)</option>
<option value="INS">INS (Insertion)</option>
<!--<option value="INS">INS (Insertion)</option>-->
<option value="DUP">DUP (Duplication)</option>
<option value="INV">INV (Inversion)</option>
<!--<option value="INV">INV (Inversion)</option>
<option value="CNV">CNV (Copy Number Variation)</option>
<option value="BND">BND (Breakend???)</option>
<option value="BND">BND (Breakend???)</option>-->
</select>
</div>
</div>
<div class="form-group">
<label for="position" class="col-sm-2 control-label">Length</label>
<div class="col-sm-4">
<input type="text" class="form-control" id="length" ng-model="config.length" placeholder="Length">
</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>
......
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