forked from molgenis/molgenis-app-genenetwork
-
Notifications
You must be signed in to change notification settings - Fork 0
/
get.js
65 lines (46 loc) · 1.42 KB
/
get.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
var level = require('level');
var fs = require('fs');
if (process.argv.length != 4){
console.log('Usage: node get.js db gene')
process.exit(1)
}
var db = level(process.argv[2], {valueEncoding: 'binary'});
var key = process.argv[3]
// function getData(key) {
// db.get(key, function(err, data) {
// if (err) console.log(err)
// else console.log(data)
// })
// }
// getData('!RNASEQ!' + gene)
var a = []
db.createReadStream({
start: key,
end: key
})
.on('data', function(buffer) {
for (var i = 0; i < buffer.value.length; i+=2){
a.push((buffer.value.readUInt16BE(i) - 32768) / 1000)
}
})
.on('end', function(){
console.log(a.join('\n'))
// fs.writeFile('/data/genenetwork/level/tissuedb.txt', a.join('\n'))
})
// db2.get('RNASEQ!' + gene, [{valueEncoding: 'binary'}], function(err, buffer) {
// if (err) console.log(err)
// else {
// for (var i = 0; i < buffer.length; i+=2){
// a.push((buffer.readUInt16BE(i) - 32768) / 1000)
// }
// }
// })
// db.get('!RNASEQ!TISSUES', [{valueEncoding: 'json'}], function(err, data) {
// if (err) sails.log.error(err)
// else {
// console.log(data)
// // for (var i = 0; i < data.length; i++){
// // console.log(data[i])
// // }
// }
// })