Commit d9b66395 authored by Daniel's avatar Daniel
Browse files

adding mongo queries samples

parents
#Run the query
```
./runquery.sh app.js
```
var result = [];
db.samples.find().forEach(function(sample) {
addIfNotPresent(result, sample.CITY);
});
prettyPrint(result);
function getGeneNames (object) {
if (object.geneNames) return object.geneNames;
else if (object.geneName) return object.geneName;
else {
var geneNames = new Array();
if (object.bioObjects) {
object.bioObjects.forEach(function(bioObject) {
var subObject = getObjectFromRef(bioObject);
if (subObject) {
var geneNames2 = getGeneNames(subObject);
if (geneNames2) {
geneNames.push(geneNames2);
}
}
});
return geneNames;
}
else {
return object.uniqueName;
}
}
}
function addIfNotPresent(array, object) {
for(var i=0; i<array.length; i++){
if(array[i].object === object){
array[i].count = array[i].count + 1;
return;
}
}
array.push({"object" : object, "count" : 1});
}
function getObjectFromRef(refObject) {
var dbObject;
if (refObject.$ref == "protein") {
dbObject = db.protein.findOne({_id:refObject.$id});
}
else if (refObject.$ref == "nonHumanProtein") {
dbObject = db.nonHumanProtein.findOne({_id:refObject.$id});
}
else if (refObject.$ref == "complex") {
dbObject = db.complex.findOne({_id:refObject.$id});
}
else if (refObject.$ref == "fusionProtein") {
dbObject = db.fusionProtein.findOne({_id:refObject.$id});
}
else if (refObject.$ref == "proteinGroup") {
dbObject = db.proteinGroup.findOne({_id:refObject.$id});
}
else if (refObject.$ref == "chemical") {
dbObject = db.chemical.findOne({_id:refObject.$id});
}
if (!dbObject) {
print ("POUET "+refObject.$ref);
}
return dbObject;
}
function prettyPrint(object){
print(JSON.stringify(object, null, 2));
}
var CAVIAR_ENTRIES = ["APC","BRCA1","BRCA2","BRIP1","EPCAM","IDH1","PALB2","MLH1","MSH2","MSH6","MUTYH"];
var NAVMULTPREDICT_ENTRIES = ["SCN1A","SCN2A","SCN3A","SCN4A","SCN5A","SCN8A","SCN9A","SCN10A","SCN11A"];
mongo arraymap vendor/underscore.js arraymap-commons.js $1
This diff is collapsed.
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