Commit 9c2df180 authored by Severine Duvaud's avatar Severine Duvaud
Browse files

Beacon v0.4

parent bcc8bcb5
......@@ -83,27 +83,33 @@ function checkPreconditions(params) {
if (!params.alternateBases) {
return {
hasError: true,
msg: "Alternate bases not defined, arrayMap supports DUP or DEL followed by optional length"
msg: "Alternate bases not defined, arrayMap supports DUP or DEL"
};
}
// Beacon 0.4
// alternate bases: DEL[0-9]* AND DUP[0-9]*
var alternate = params.alternateBases.replace(/\d+/, "");
if (!alternateBasesMap[alternate]) {
if (!alternateBasesMap[params.alternateBases]) {
return {
hasError: true,
msg: "Alternate bases not supported, arrayMap supports DUP or DEL followed by optional length"
msg: "Alternate bases not supported, arrayMap supports DUP or DEL"
};
}
if (params.length && !Number(params.length)) {
// Do not allow minLength and maxLength to be compliant with 0.3
/*
if (params.minlength && !Number(params.minlength)) {
return {
hasError: true,
msg: "Length not a number"
msg: "min. length not a number"
};
}
if (params.maxlength && !Number(params.maxlength)) {
return {
hasError: true,
msg: "max length not a number"
};
}*/
//TODO add additional checks
return {
......@@ -137,7 +143,19 @@ function checkPreconditions(params) {
function buildMongoQuery(params) {
var position = parseInt(params.start);
var length = params.alternateBases.replace(/(DUP|DEL)/, "") ? parseInt(params.alternateBases.replace(/(DUP|DEL)/, "")) : 0;
// Do not allow minLength and maxLength to be compliant with 0.3
/*
if(params.alternateBases == 'DEL') {
var minLength = params.minlength ? parseInt(params.minlength) : 0;
var maxLength = params.maxlength ? parseInt(params.maxlength) : 0;
if(!minLength && (maxLength > 0)){
minLength = 1;
}
}*/
var andConditions = [];
var orConditions = [];
......@@ -152,9 +170,7 @@ function buildMongoQuery(params) {
}
}
// Beacon 0.4
// alternate bases: DEL[0-9]* AND DUP[0-9]*
var segType = alternateBasesMap[params.alternateBases.replace(/\d+/, "")]
var segType = alternateBasesMap[params.alternateBases]
var convertedReference = referenceMap[params.assemblyId || defaultReference];
var condition = {};
......@@ -167,14 +183,22 @@ function buildMongoQuery(params) {
//elem match element
var condElemMatch = condition[convertedReference]['$elemMatch'];
if (length > 0) {
condElemMatch.SEGSIZE = length;
condElemMatch.SEGSTART = position;
}
else {
condElemMatch.SEGSTOP = {$gte: position};
condElemMatch.SEGSTART = {$lte: position};
}
// Do not allow minLength and maxLength to be compliant with 0.3
/*
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 specific
*/
condElemMatch.SEGSTOP = { $gte: position };
condElemMatch.SEGSTART = { $lte: position };
//}
andConditions.push(condition);
if (orConditions.length > 0) {
......@@ -202,6 +226,23 @@ function buildMongoQuery(params) {
function checkResultAndGetResponse(params, datasets) {
// Do not allow minLength and maxLength to be compliant with 0.3
// var length = 0;
/*
if (typeof params.minlength != undefined && params.minlength != null && params.minlength != '')
{
length = parseInt(params.minlength);
if (params.alternateBases == 'DUP') {
responseResource.note = "Length provided but not considered when querying DUP";
}
}
var maxLength = 0;
if (typeof params.maxlength != undefined && params.maxlength != null && params.maxlength != '')
{
maxLength = parseInt(params.maxlength);
}
*/
var responses = [];
// The query returns only datasets for which there is at least one sample with at least one matching SEGMENT...
......@@ -258,9 +299,7 @@ function checkResultAndGetResponse(params, datasets) {
"error": null,
};
// Beacon 0.4
// alternate bases: DEL[0-9]* AND DUP[0-9]*
if (!alternateBasesMap[params.alternateBases.replace(/\d+/,"")]) {
if (!alternateBasesMap[params.alternateBases]) {
response.note = "Type of variant not supported by arrayMap.";
}
else {
......@@ -275,9 +314,12 @@ function checkResultAndGetResponse(params, datasets) {
"start": params.start,
"assemblyId": params.assemblyId,
"datasetIds": params.datasetIds,
// Beacon 0.4
// alternate bases: DEL[0-9]* AND DUP[0-9]*
"alternateBases": params.alternateBases
// Do not allow minLength and maxLength to be compliant with 0.3
/*
"length": length,
"maxlength": maxLength
*/
};
// BeaconAlleleResponse
......
var beacon = {};
beacon.info = require('./beacon-info.js').info
beacon.checkResultAndGetResponse = require('./beacon-query.js').checkResultAndGetResponse
beacon.checkPreconditions = require('./beacon-query.js').checkPreconditions
beacon.buildMongoQuery = require('./beacon-query.js').buildMongoQuery
beacon.checkDatasetIdentifier = require('./beacon-dataset.js').checkDatasetIdentifier
beacon.buildMongoDatasetQuery = require('./beacon-dataset.js').buildMongoDatasetQuery
beacon.checkDatasetResultAndGetResponse = require('./beacon-dataset.js').checkDatasetResultAndGetResponse
module.exports = beacon;
\ No newline at end of file
/**
* Created by sduvaud on 26/05/16.
*/
var info = require('./beacon-info.js').info;
// store all the dataset identifiers
var allDatasetIds = [];
info['info']['info']['datasets'].forEach(function(dataset){
allDatasetIds.push(dataset.id);
});
function checkDatasetIdentifier(params) {
if (!params.id) {
return {
hasError: true,
msg: "No identifier specified"
};
}
return {
hasError: false
};
}
function buildMongoDatasetQuery(params)
{
console.log("ID=" + params.id);
var groupCondition = {
$group: {
_id: "$ICDMORPHOLOGYCODE",
sampleCount: {$sum: 1},
name: { $first: "$ICDMORPHOLOGY"}
}
};
if (params.id == 'all') {
return [
groupCondition
];
}
else {
var orConditions = [];
var identifiers = params.id.split(','); // comma separated list of datasets
identifiers.forEach(function (id) {
orConditions.push({ICDMORPHOLOGYCODE: id});
});
return [
{
$match: {
$or: orConditions
}
},
groupCondition
];
}
}
function checkDatasetResultAndGetResponse(params, datasets) {
var matchedIdentifiers = [];
datasets.forEach(function(dataset){
matchedIdentifiers.push(dataset._id);
});
var submittedIdentifiers = allDatasetIds;
if (params.id != 'all') {
submittedIdentifiers = params.id.split(',');
}
if (submittedIdentifiers.length != matchedIdentifiers.length) {
var missingIdentifiers = [];
submittedIdentifiers.forEach(function(submitted) {
var found = false;
matchedIdentifiers.forEach(function(matched) {
if (matched == submitted) {
found = true;
}
}
);
if (!found) {
missingIdentifiers.push(submitted);
}
}
);
missingIdentifiers.forEach(function (missing) {
var json = {
"_id": missing,
"sampleCount": 0,
"name": "Dataset not found"
};
datasets.push(json);
}
);
}
return datasets;
}
module.exports.checkDatasetIdentifier = checkDatasetIdentifier;
module.exports.buildMongoDatasetQuery = buildMongoDatasetQuery;
module.exports.checkDatasetResultAndGetResponse = checkDatasetResultAndGetResponse;
\ No newline at end of file
var object = {
info: { "info": {
"id": "arraymap-beacon",
"name": "Beacon ArrayMap",
"organization": "SIB Swiss Institute of Bioinformatics",
"description": "First Prototype of a Beacon v0.3 implementation for ArrayMap.",
"datasets": [
{"id": "9962/3", "description": "Essential thrombocythemia", "reference": "reference genome", "size": { "variants": "-1", "samples": "45"}},
{"id": "9961/3", "description": "Chronic idiopathic myelofibrosis", "reference": "reference genome", "size": { "variants": "-1", "samples": "47"}},
{"id": "9950/3", "description": "Polycythemia vera", "reference": "reference genome", "size": { "variants": "-1", "samples": "44"}},
{"id": "9891/3", "description": "Acute monoblastic leukemia [FAB M5]", "reference": "reference genome", "size": { "variants": "-1", "samples": "9"}},
{"id": "9866/3", "description": "Acute promyelocytic leukemia [FAB type M3]", "reference": "reference genome", "size": { "variants": "-1", "samples": "56"}},
{"id": "9861/3", "description": "Acute myeloid leukemia, NOS", "reference": "reference genome", "size": { "variants": "-1", "samples": "1725"}},
{"id": "9837/3", "description": "Precursor T-cell lymphoblastic leukemia", "reference": "reference genome", "size": { "variants": "-1", "samples": "99"}},
{"id": "9835/3", "description": "Acute lymphoblastic leukemia, NOS", "reference": "reference genome", "size": { "variants": "-1", "samples": "465"}},
{"id": "9823/3", "description": "B-cell chronic lymphocytic leukemia/small lymphocytic lymphoma", "reference": "reference genome", "size": { "variants": "-1", "samples": "342"}},
{"id": "9761/3", "description": "Waldenstrom macroglobulinemia", "reference": "reference genome", "size": { "variants": "-1", "samples": "31"}},
{"id": "9717/3", "description": "Enteropathy type T-cell lymphoma", "reference": "reference genome", "size": { "variants": "-1", "samples": "1"}},
{"id": "9729/3", "description": "Precursor T-cell lymphoblastic lymphoma", "reference": "reference genome", "size": { "variants": "-1", "samples": "9"}},
{"id": "9728/3", "description": "Precursor B-cell lymphoblastic lymphoma", "reference": "reference genome", "size": { "variants": "-1", "samples": "6"}},
{"id": "9705/3", "description": "Peripheral T-cell lymphoma, NOS", "reference": "reference genome", "size": { "variants": "-1", "samples": "45"}},
{"id": "9699/3", "description": "Marginal zone lymphoma, NOS", "reference": "reference genome", "size": { "variants": "-1", "samples": "151"}},
{"id": "9689/3", "description": "Splenic marginal zone lymphoma, NOS", "reference": "reference genome", "size": { "variants": "-1", "samples": "156"}},
{"id": "9680/3", "description": "diffuse large B-cell lymphoma, NOS", "reference": "reference genome", "size": { "variants": "-1", "samples": "241"}},
{"id": "9801/3", "description": "Acute leukemia, NOS", "reference": "reference genome", "size": { "variants": "-1", "samples": "10"}},
{"id": "9673/3", "description": "Mantle cell lymphoma", "reference": "reference genome", "size": { "variants": "-1", "samples": "89"}},
{"id": "9671/3", "description": "Malignant lymphoma, lymphoplasmacytic", "reference": "reference genome", "size": { "variants": "-1", "samples": "10"}},
{"id": "9591/3", "description": "Malignant lymphoma, B-cell NOS", "reference": "reference genome", "size": { "variants": "-1", "samples": "74"}},
{"id": "9071/3", "description": "Yolk sac tumor", "reference": "reference genome", "size": { "variants": "-1", "samples": "9"}},
{"id": "9687/3", "description": "Burkitt lymphoma, NOS", "reference": "reference genome", "size": { "variants": "-1", "samples": "64"}},
{"id": "9100/3", "description": "Choriocarcinoma", "reference": "reference genome", "size": { "variants": "-1", "samples": "1"}},
{"id": "8720/3", "description": "Malignant melanoma, NOS", "reference": "reference genome", "size": { "variants": "-1", "samples": "694"}},
{"id": "9061/3", "description": "Seminoma, NOS", "reference": "reference genome", "size": { "variants": "-1", "samples": "17"}},
{"id": "8522/3", "description": "Infiltrating duct and lobular carcinoma", "reference": "reference genome", "size": { "variants": "-1", "samples": "28"}},
{"id": "9560/0", "description": "Schwannoma, NOS", "reference": "reference genome", "size": { "variants": "-1", "samples": "4"}},
{"id": "9081/3", "description": "Teratocarcinoma", "reference": "reference genome", "size": { "variants": "-1", "samples": "13"}},
{"id": "8501/2", "description": "DCIS, comedo type [C50._]", "reference": "reference genome", "size": { "variants": "-1", "samples": "1"}},
{"id": "9989/3", "description": "Myelodysplastic syndrome, NOS", "reference": "reference genome", "size": { "variants": "-1", "samples": "474"}},
{"id": "8201/3", "description": "Ductal carcinoma, cribriform type [C50._]", "reference": "reference genome", "size": { "variants": "-1", "samples": "6"}},
{"id": "8520/2", "description": "Lobular carcinoma in situ", "reference": "reference genome", "size": { "variants": "-1", "samples": "36"}},
{"id": "8890/3", "description": "Leiomyosarcoma, NOS", "reference": "reference genome", "size": { "variants": "-1", "samples": "58"}},
{"id": "8500/2", "description": "Ductal carcinoma in situ, NOS", "reference": "reference genome", "size": { "variants": "-1", "samples": "76"}},
{"id": "9041/3", "description": "Synovial sarcoma, monophasic", "reference": "reference genome", "size": { "variants": "-1", "samples": "18"}},
{"id": "9945/3", "description": "Chronic myelomonocytic leukemia, NOS", "reference": "reference genome", "size": { "variants": "-1", "samples": "30"}},
{"id": "8810/3", "description": "Fibrosarcoma, NOS", "reference": "reference genome", "size": { "variants": "-1", "samples": "47"}},
{"id": "9471/3", "description": "Medulloblastoma with extensive nodularity", "reference": "reference genome", "size": { "variants": "-1", "samples": "63"}},
{"id": "8312/3", "description": "Renal cell carcinoma", "reference": "reference genome", "size": { "variants": "-1", "samples": "183"}},
{"id": "8980/3", "description": "Carcinosarcoma, NOS", "reference": "reference genome", "size": { "variants": "-1", "samples": "2"}},
{"id": "8800/3", "description": "Sarcoma, NOS", "reference": "reference genome", "size": { "variants": "-1", "samples": "13"}},
{"id": "8020/3", "description": "Carcinoma, undifferentiated type, NOS", "reference": "reference genome", "size": { "variants": "-1", "samples": "2"}},
{"id": "9701/3", "description": "Sezary syndrome", "reference": "reference genome", "size": { "variants": "-1", "samples": "40"}},
{"id": "8317/3", "description": "Renal cell carcinoma, chromophobe", "reference": "reference genome", "size": { "variants": "-1", "samples": "8"}},
{"id": "9500/3", "description": "Neuroblastoma, NOS", "reference": "reference genome", "size": { "variants": "-1", "samples": "649"}},
{"id": "8500/3", "description": "invasive carcinoma of no special type", "reference": "reference genome", "size": { "variants": "-1", "samples": "4431"}},
{"id": "8562/3", "description": "Myoepithelial carcinoma", "reference": "reference genome", "size": { "variants": "-1", "samples": "14"}},
{"id": "9863/3", "description": "Chronic myeloid leukemia, NOS", "reference": "reference genome", "size": { "variants": "-1", "samples": "129"}},
{"id": "8520/3", "description": "Invasive lobular carcinoma", "reference": "reference genome", "size": { "variants": "-1", "samples": "25"}},
{"id": "9510/3", "description": "Retinoblastoma, NOS", "reference": "reference genome", "size": { "variants": "-1", "samples": "7"}},
{"id": "8021/3", "description": "Carcinoma, anaplastic type, NOS", "reference": "reference genome", "size": { "variants": "-1", "samples": "1"}},
{"id": "8441/3", "description": "Serous adenocarcinoma, NOS", "reference": "reference genome", "size": { "variants": "-1", "samples": "104"}},
{"id": "8811/3", "description": "Myxofibrosarcoma", "reference": "reference genome", "size": { "variants": "-1", "samples": "27"}},
{"id": "8041/3", "description": "Small cell carcinoma, NOS", "reference": "reference genome", "size": { "variants": "-1", "samples": "69"}},
{"id": "9690/3", "description": "follicular lymphoma, NOS", "reference": "reference genome", "size": { "variants": "-1", "samples": "337"}},
{"id": "9260/3", "description": "Ewing sarcoma", "reference": "reference genome", "size": { "variants": "-1", "samples": "46"}},
{"id": "8210/3", "description": "Adenocarcinoma in adenomatous polyp", "reference": "reference genome", "size": { "variants": "-1", "samples": "1"}},
{"id": "8805/3", "description": "Undifferentiated sarcoma", "reference": "reference genome", "size": { "variants": "-1", "samples": "29"}},
{"id": "9834/3", "description": "Prolymphocytic leukemia, T-cell type", "reference": "reference genome", "size": { "variants": "-1", "samples": "10"}},
{"id": "8370/3", "description": "Adrenal cortical carcinoma", "reference": "reference genome", "size": { "variants": "-1", "samples": "16"}},
{"id": "8144/3", "description": "Adenocarcinoma, intestinal type", "reference": "reference genome", "size": { "variants": "-1", "samples": "123"}},
{"id": "8170/3", "description": "Hepatocellular carcinoma, NOS", "reference": "reference genome", "size": { "variants": "-1", "samples": "275"}},
{"id": "9876/3", "description": "Atypical chronic myeloid leukemia, BCR/ABL negative", "reference": "reference genome", "size": { "variants": "-1", "samples": "28"}},
{"id": "8070/3", "description": "Squamous cell carcinoma, NOS", "reference": "reference genome", "size": { "variants": "-1", "samples": "593"}},
{"id": "8010/2", "description": "Carcinoma in situ, NOS", "reference": "reference genome", "size": { "variants": "-1", "samples": "6"}},
{"id": "8833/3", "description": "Pigmented dermatofibrosarcoma protuberans", "reference": "reference genome", "size": { "variants": "-1", "samples": "15"}},
{"id": "8033/3", "description": "Sarcomatoid carcinoma", "reference": "reference genome", "size": { "variants": "-1", "samples": "1"}},
{"id": "8120/3", "description": "Transitional cell carcinoma, NOS", "reference": "reference genome", "size": { "variants": "-1", "samples": "158"}},
{"id": "9120/0", "description": "Hemangioma, NOS", "reference": "reference genome", "size": { "variants": "-1", "samples": "2"}},
{"id": "8858/3", "description": "Liposarcoma, dedifferentiated", "reference": "reference genome", "size": { "variants": "-1", "samples": "42"}},
{"id": "8077/2", "description": "Squamous intraepithelial neoplasia, grade III", "reference": "reference genome", "size": { "variants": "-1", "samples": "46"}},
{"id": "9380/3", "description": "Glioma, NOS", "reference": "reference genome", "size": { "variants": "-1", "samples": "113"}},
{"id": "8140/0", "description": "Adenoma, NOS", "reference": "reference genome", "size": { "variants": "-1", "samples": "52"}},
{"id": "8290/0", "description": "Oncocytoma", "reference": "reference genome", "size": { "variants": "-1", "samples": "9"}},
{"id": "9582/0", "description": "Granular cell tumor", "reference": "reference genome", "size": { "variants": "-1", "samples": "2"}},
{"id": "9180/3", "description": "Osteosarcoma, NOS", "reference": "reference genome", "size": { "variants": "-1", "samples": "69"}},
{"id": "8524/3", "description": "Infiltrating lobular mixed with other types of carcinoma", "reference": "reference genome", "size": { "variants": "-1", "samples": "1"}},
{"id": "8140/3", "description": "Adenocarcinoma, NOS", "reference": "reference genome", "size": { "variants": "-1", "samples": "2628"}},
{"id": "8721/3", "description": "Nodular melanoma", "reference": "reference genome", "size": { "variants": "-1", "samples": "4"}},
{"id": "8046/3", "description": "Non-small cell carcinoma", "reference": "reference genome", "size": { "variants": "-1", "samples": "595"}},
{"id": "8272/3", "description": "Pituitary carcinoma, NOS", "reference": "reference genome", "size": { "variants": "-1", "samples": "4"}},
{"id": "8247/3", "description": "Merkel cell carcinoma", "reference": "reference genome", "size": { "variants": "-1", "samples": "25"}},
{"id": "8130/1", "description": "Urothelial papilloma, NOS", "reference": "reference genome", "size": { "variants": "-1", "samples": "34"}},
{"id": "9470/3", "description": "medulloblastoma, NOS", "reference": "reference genome", "size": { "variants": "-1", "samples": "440"}},
{"id": "9181/3", "description": "Chondroblastic osteosarcoma", "reference": "reference genome", "size": { "variants": "-1", "samples": "8"}},
{"id": "9430/3", "description": "Astroblastoma", "reference": "reference genome", "size": { "variants": "-1", "samples": "1"}},
{"id": "8310/3", "description": "Clear cell renal cell carcinoma", "reference": "reference genome", "size": { "variants": "-1", "samples": "175"}},
{"id": "8012/3", "description": "Large cell carcinoma, NOS", "reference": "reference genome", "size": { "variants": "-1", "samples": "7"}},
{"id": "8852/3", "description": "Liposarcoma, myxoid", "reference": "reference genome", "size": { "variants": "-1", "samples": "20"}},
{"id": "8854/3", "description": "Liposarcoma, pleomorphic", "reference": "reference genome", "size": { "variants": "-1", "samples": "10"}},
{"id": "9960/3", "description": "Chronic myeloproliferative disease, NOS", "reference": "reference genome", "size": { "variants": "-1", "samples": "118"}},
{"id": "8900/3", "description": "Rhabdomyosarcoma, NOS", "reference": "reference genome", "size": { "variants": "-1", "samples": "11"}},
{"id": "8910/3", "description": "Embryonal rhabdomyosarcoma", "reference": "reference genome", "size": { "variants": "-1", "samples": "11"}},
{"id": "8743/3", "description": "Superficial spreading melanoma", "reference": "reference genome", "size": { "variants": "-1", "samples": "21"}},
{"id": "9040/3", "description": "Synovial sarcoma, NOS", "reference": "reference genome", "size": { "variants": "-1", "samples": "3"}},
{"id": "8920/3", "description": "Alveolar rhabdomyosarcoma", "reference": "reference genome", "size": { "variants": "-1", "samples": "50"}},
{"id": "8936/3", "description": "Gastrointestinal stromal tumor, malignant", "reference": "reference genome", "size": { "variants": "-1", "samples": "174"}},
{"id": "9540/3", "description": "Malignant peripheral nerve sheath tumor", "reference": "reference genome", "size": { "variants": "-1", "samples": "22"}},
{"id": "8982/0", "description": "Myoepithelioma", "reference": "reference genome", "size": { "variants": "-1", "samples": "19"}},
{"id": "8010/3", "description": "Carcinoma, NOS", "reference": "reference genome", "size": { "variants": "-1", "samples": "568"}},
{"id": "9065/3", "description": "Germ cell tumor, nonseminomatous", "reference": "reference genome", "size": { "variants": "-1", "samples": "3"}},
{"id": "8850/3", "description": "Liposarcoma, NOS", "reference": "reference genome", "size": { "variants": "-1", "samples": "29"}},
{"id": "9064/2", "description": "Intratubular germ cell neoplasia [C62._]", "reference": "reference genome", "size": { "variants": "-1", "samples": "16"}},
{"id": "9043/3", "description": "Synovial sarcoma, biphasic", "reference": "reference genome", "size": { "variants": "-1", "samples": "4"}},
{"id": "9050/3", "description": "Mesothelioma, NOS", "reference": "reference genome", "size": { "variants": "-1", "samples": "48"}},
{"id": "9064/3", "description": "Germinoma", "reference": "reference genome", "size": { "variants": "-1", "samples": "1"}},
{"id": "9070/3", "description": "Embryonal carcinoma, NOS", "reference": "reference genome", "size": { "variants": "-1", "samples": "8"}},
{"id": "9085/3", "description": "Mixed germ cell tumor", "reference": "reference genome", "size": { "variants": "-1", "samples": "34"}},
{"id": "9120/3", "description": "Angiosarcoma", "reference": "reference genome", "size": { "variants": "-1", "samples": "2"}},
{"id": "9826/3", "description": "Acute lymphoblastic leukemia, mature B-cell type", "reference": "reference genome", "size": { "variants": "-1", "samples": "25"}},
{"id": "9700/3", "description": "mycosis fungoides", "reference": "reference genome", "size": { "variants": "-1", "samples": "62"}},
{"id": "9220/3", "description": "Chondrosarcoma, NOS", "reference": "reference genome", "size": { "variants": "-1", "samples": "69"}},
{"id": "9650/3", "description": "Hodgkin lymphoma, NOS", "reference": "reference genome", "size": { "variants": "-1", "samples": "2"}},
{"id": "9370/3", "description": "Chordoma, NOS", "reference": "reference genome", "size": { "variants": "-1", "samples": "42"}},
{"id": "9080/3", "description": "Teratoma, malignant, NOS", "reference": "reference genome", "size": { "variants": "-1", "samples": "20"}},
{"id": "9382/3", "description": "Glioma, mixed", "reference": "reference genome", "size": { "variants": "-1", "samples": "24"}},
{"id": "9391/3", "description": "Ependymoma, NOS", "reference": "reference genome", "size": { "variants": "-1", "samples": "68"}},
{"id": "8575/3", "description": "Metaplastic carcinoma, NOS", "reference": "reference genome", "size": { "variants": "-1", "samples": "2"}},
{"id": "9442/3", "description": "Gliosarcoma", "reference": "reference genome", "size": { "variants": "-1", "samples": "3"}},
{"id": "9400/3", "description": "Astrocytoma, NOS", "reference": "reference genome", "size": { "variants": "-1", "samples": "123"}},
{"id": "9401/3", "description": "Astrocytoma, anaplastic", "reference": "reference genome", "size": { "variants": "-1", "samples": "83"}},
{"id": "9424/3", "description": "Pleomorphic xanthoastrocytoma", "reference": "reference genome", "size": { "variants": "-1", "samples": "2"}},
{"id": "9421/1", "description": "Pilocytic astrocytoma", "reference": "reference genome", "size": { "variants": "-1", "samples": "154"}},
{"id": "9440/3", "description": "Glioblastoma, NOS", "reference": "reference genome", "size": { "variants": "-1", "samples": "985"}},
{"id": "9732/3", "description": "Plasma cell myeloma", "reference": "reference genome", "size": { "variants": "-1", "samples": "323"}},
{"id": "9473/3", "description": "Primitive neuroectodermal tumor, NOS", "reference": "reference genome", "size": { "variants": "-1", "samples": "94"}},
{"id": "8530/3", "description": "Inflammatory carcinoma", "reference": "reference genome", "size": { "variants": "-1", "samples": "1"}},
{"id": "9450/3", "description": "Oligodendroglioma, NOS", "reference": "reference genome", "size": { "variants": "-1", "samples": "110"}},
{"id": "9474/3", "description": "Large cell / Anaplastic medulloblastoma", "reference": "reference genome", "size": { "variants": "-1", "samples": "37"}},
{"id": "9540/0", "description": "Neurofibroma, NOS", "reference": "reference genome", "size": { "variants": "-1", "samples": "2"}},
{"id": "8380/3", "description": "Endometrioid carcinoma, NOS", "reference": "reference genome", "size": { "variants": "-1", "samples": "168"}},
{"id": "9451/3", "description": "Oligodendroglioma, anaplastic", "reference": "reference genome", "size": { "variants": "-1", "samples": "22"}},
{"id": "9530/0", "description": "meningioma, NOS", "reference": "reference genome", "size": { "variants": "-1", "samples": "4"}}
],
"api": "v0.3",
"homepage": "http://beacon-arraymap.vital-it.ch/",
"email": "SIB-Technology@isb-sib.ch"
}
}
}
module.exports.info = object;
var info = require('./beacon-info.js').info;
// store all the dataset identifiers
// not used when a list of datasets is entered
// find a better place for this?
var allDatasetIds = [];
info['info']['info']['datasets'].forEach(function(dataset){
allDatasetIds.push(dataset.id);
});
var referenceMap = {
'GRCh38': 'SEGMENTS_HG38',
'GRCh37': 'SEGMENTS_HG19',
'GRCh36': 'SEGMENTS_HG18'
};
//correspondence to arraymap class
var alternateBasesMap = {
"DEL": -1,
"DUP": 1
};
// By default doe Maximilien takes Reference 37. https://github.com/maximilianh/ucscBeacon/blob/master/help.txt
//TODO Should it be the same as Maximilen? Is it specified by beacon documentaiton?
var defaultReference = 'GRCh38';
function checkPreconditions(params) {
if (!params.referenceName) {
return {
hasError: true,
msg: "reference name is not present"
};
}
var referenceNameInvalid = {
hasError: true,
msg: params.referenceName + " reference name not valid"
};
if (Number(params.referenceName)) {
if (params.referenceName < 1 || params.referenceName > 23) {
return referenceNameInvalid;
}
}
else {
if (params.referenceName.match(/^(X|Y)$/i) == null) {
return referenceNameInvalid;
}
}
if (!params.start) {
return {
hasError: true,
msg: "position not present"
};
}
if (!Number(params.start)) {
return {
hasError: true,
msg: "position not a number"
};
}
if (!params.datasetIds) {
return {
hasError: true,
msg: "No dataset provided"
};
}
if (params.datasetIds != 'all') {
var error = checkDatasetIdentifiers(params.datasetIds, allDatasetIds);
if (error.length > 0) {
return {
hasError: true,
msg: "Incorrect dataset(s): " + error.toString()
};
}
}
if (!params.alterna