Commit 37b166f9 authored by Severine Duvaud's avatar Severine Duvaud
Browse files

Moved the check of Alternate bases to the checkPreconditions function

parent 6579bbf6
......@@ -72,7 +72,14 @@ function checkPreconditions(params) {
if (!params.alternateBases) {
return {
hasError: true,
msg: "variant class is not defined, arrayMap supports be DUP or DEL"
msg: "Alternate bases not defined, arrayMap supports DUP or DEL"
};
}
if (!alternateBasesMap[params.alternateBases]) {
return {
hasError: true,
msg: "Alternate bases not supported, arrayMap supports DUP or DEL"
};
}
......@@ -115,50 +122,47 @@ function buildMongoQuery(params) {
var andConditions = [];
var orConditions = [];
if (alternateBasesMap[params.alternateBases]) {
//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});
});
}
//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 segType = alternateBasesMap[params.alternateBases]
var convertedReference = referenceMap[params.assemblyId || defaultReference];
var segType = alternateBasesMap[params.alternateBases]
var convertedReference = referenceMap[params.assemblyId || defaultReference];
var condition = {};
condition[convertedReference] = {
'$elemMatch': {
'CHRO': params.referenceName,
'SEGTYPE': segType
}
};
var condition = {};
condition[convertedReference] = {
'$elemMatch': {
'CHRO': params.referenceName,
'SEGTYPE': segType
}
};
//elem match element
var condElemMatch = condition[convertedReference]['$elemMatch'];
//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 };
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(condition);
if (orConditions.length > 0) {
andConditions.push({$or: orConditions});
}
andConditions.push(condition);
if (orConditions.length > 0) {
andConditions.push({$or: orConditions});
}
return {
......
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