Skip to content
Snippets Groups Projects
Commit 443b2412 authored by Severine Duvaud's avatar Severine Duvaud
Browse files

Beacon v0.3 compliance: Length for DEL only

parent 50c64d18
Branches
No related tags found
No related merge requests found
......@@ -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,6 +105,17 @@ function buildMongoQuery(params) {
var convertedReference = referenceMap[params.assemblyId || defaultReference];
var cond = {};
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,
......@@ -116,6 +128,7 @@ function buildMongoQuery(params) {
}
}
}
}
andConditions.push(cond);
if (orConditions.length > 0) {
andConditions.push({$or: orConditions});
......@@ -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 = {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment