Commit 443b2412 authored by Severine Duvaud's avatar Severine Duvaud
Browse files

Beacon v0.3 compliance: Length for DEL only

parent 50c64d18
......@@ -63,8 +63,6 @@ function checkPreconditions(params) {
};
}
console.log(Boolean(alternateBasesMap[params.alternateBases]));
if (!params.alternateBases) {
return {
hasError: true,
......@@ -82,8 +80,11 @@ 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 length = 0;
if(params.alternateBases == 'DEL') {
length = (params.length.length == 0 ? 0 : parseInt(params.length));
}
var andConditions = [];
var orConditions = [];
......@@ -104,15 +105,27 @@ function buildMongoQuery(params) {
var convertedReference = referenceMap[params.assemblyId || defaultReference];
var cond = {};
cond[convertedReference] = {
'$elemMatch': {
'CHRO': params.referenceName,
'SEGTYPE': segType,
'SEGSTOP': {
$gte: position
},
'SEGSTART': {
$lte: position
if (length > 0) {
cond[convertedReference] = {
'$elemMatch': {
'CHRO': params.referenceName,
'SEGTYPE': segType,
'SEGSTOP': position + length, // exact position
'SEGSTART': position // exact position
}
}
}
else {
cond[convertedReference] = {
'$elemMatch': {
'CHRO': params.referenceName,
'SEGTYPE': segType,
'SEGSTOP': {
$gte: position
},
'SEGSTART': {
$lte: position
}
}
}
}
......@@ -159,6 +172,9 @@ function checkResultAndGetResponse(params, samples, countTotal) {
if (typeof params.length != undefined && params.length != null && params.length != '')
{
length = parseInt(params.length);
if (params.alternateBases == 'DUP') {
responseResource.note = "Length provided but not considered when querying DUP";
}
}
var queryResource = {
......
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