-
Notifications
You must be signed in to change notification settings - Fork 0
/
collections.js
executable file
·104 lines (95 loc) · 2.34 KB
/
collections.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
'use strict';
var _ = require('lodash');
var Q = require('q');
var MongoClient = require('mongodb').MongoClient;
var host = 'localhost'
, port = 27017
, dbName = 'oryza'
, dbVersion = '7'
, rootMongoUrl = 'mongodb://' + host + ':' + port + '/' + dbName + dbVersion
, databasePromise = Q.ninvoke(MongoClient, "connect", rootMongoUrl);
function Collections(collections) {
// copy all the properties to this object
_.assign(this, collections);
// add mongoCollection function to each.
_.forOwn(collections, function (collection) {
collection.mongoCollection = function() {
return databasePromise.then(function (db) {
return db.collection(collection.collectionName);
}).catch(function(err) {
console.log(err);
});
}.bind(this)
}.bind(this));
}
Collections.prototype.closeMongoDatabase = function () {
databasePromise.then(function (db) {
db.close();
});
};
Collections.prototype.getVersion = function () {
return dbVersion;
};
Collections.prototype.getMongoConfig = function () {
return {
host: host,
port: port,
version: dbVersion,
db: dbName + dbVersion
};
};
var collections = new Collections({
genes: {
collectionName: 'genes',
description: 'gramene genes'
},
genetrees: {
collectionName: 'genetree',
description: 'compara gene trees'
},
GO: {
collectionName: 'GO',
description: 'gene ontology terms'
},
PO: {
collectionName: 'PO',
description: 'plant ontology terms'
},
TO: {
collectionName: 'TO',
description: 'trait ontology terms'
},
qtls: {
collectionName: 'qtls',
description: 'qtls'
},
taxonomy: {
collectionName: 'taxonomy',
description: 'NCBI taxonomy (pruned to cover gramene species)'
},
domains: {
collectionName: 'domains',
description: 'intepro domains'
},
pathways: {
collectionName: 'pathways',
description: 'plant reactome pathways and reactions'
},
maps: {
collectionName: 'maps',
description: 'maps genomes, genetic maps, and physical maps'
},
experiments: {
collectionName: 'experiments',
description: 'EBI Atlas experiments'
},
assays: {
collectionName: 'assays',
description: 'EBI Atlas assays'
},
expression: {
collectionName: 'expression',
description: 'EBI Atlas expression data'
}
});
module.exports = collections;