Commit 576aa549 authored by Severine Duvaud's avatar Severine Duvaud
Browse files

Beacon version 0.3: Handling of datasetIds

parent 4817ee85
......@@ -56,6 +56,13 @@ function checkPreconditions(params) {
};
}
if (!params.datasetIds) {
return {
hasError: true,
msg: "No dataset provided"
};
}
console.log(Boolean(variantClassMap[params.variantClass]));
if (!params.variantClass) {
......@@ -78,20 +85,21 @@ function checkPreconditions(params) {
}
function buildMongoQuery(params) {
var position = parseInt(params.start);
var conditions = [];
//add constraint on dataset if it exsits
if (params.dataset) conditions.push({
ICDMORPHOLOGYCODE: params.dataset
});
var andConditions = [];
var orConditions = [];
//add constraint on datasets if required
if (params.datasetIds){
var identifiers = params.datasetIds.split(','); // comma separated list of datasets
identifiers.forEach(function(id) {
orConditions.push({ICDMORPHOLOGYCODE: id});
});
}
var segType = variantClassMap[params.variantClass]
var convertedReference = referenceMap[params.assemblyId || defaultReference];
var cond = {};
......@@ -107,10 +115,11 @@ function buildMongoQuery(params) {
}
}
}
andConditions.push(cond);
andConditions.push({$or: orConditions});
conditions.push(cond);
return {
$and: conditions
$and: andConditions
};
}
......@@ -142,7 +151,7 @@ function checkResultAndGetResponse(params, samples, countTotal) {
"referenceName": params.referenceName,
"start": params.start,
"assemblyId": params.assemblyId,
"datasetid": params.dataset
"datasetIds": params.datasetIds
};
......@@ -156,15 +165,13 @@ function checkResultAndGetResponse(params, samples, countTotal) {
function checkResult(params, sample) {
var convertedReference = referenceMap[params.reference || defaultReference];
var convertedReference = referenceMap[params.assemblyId || defaultReference];
var expectedSegType = variantClassMap[params.variantClass]
var position = parseInt(params.start);
//TODO should check for dataset and genomre reference as well
//TODO should check for datasets and genome reference as well
var foundSegment;
sample[convertedReference].forEach(function (segment) {
if (segment.CHRO === params.referenceName) {
......@@ -179,7 +186,6 @@ function checkResult(params, sample) {
}
})
var result = {
matchedSampleUID: sample.UID,
matchedDataSet: sample.ICDMORPHOLOGYCODE,
......@@ -188,7 +194,6 @@ function checkResult(params, sample) {
return result;
}
module.exports.checkPreconditions = checkPreconditions;
module.exports.buildMongoQuery = buildMongoQuery;
module.exports.checkResultAndGetResponse = checkResultAndGetResponse;
\ No newline at end of file
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