-
Notifications
You must be signed in to change notification settings - Fork 1
/
dock-stats.js
51 lines (41 loc) · 1.39 KB
/
dock-stats.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
#!/usr/bin/env node
const fs = require('fs-extra')
const dockedPath = process.argv[2] ? process.argv[2] : 'docked.mol2'
var dockedString = false
if(fs.existsSync(dockedPath)){
dockedString = fs.readFileSync(dockedPath).toString()
} else {
console.log(`No mol2 file found at ${dockedPath}`)
process.exit()
}
const props = {
Grid_Score:[],
Grid_vdw_energy:[],
Grid_es_energy:[],
Internal_energy_repulsive:[]
}
const max = {}
const min = {}
const regex = /[#]+[ \t]+(Grid_Score|Grid_vdw_energy|Grid_es_energy|Internal_energy_repulsive):[ \t]+([\d-.]+)/g
var matches, prop, val
while (matches = regex.exec(dockedString)) {
prop = matches[1]
val = Number(matches[2])
props[prop].push(val)
if(!max.hasOwnProperty(prop) || max[prop] < val) max[prop] = val
if(!min.hasOwnProperty(prop) || min[prop] > val) min[prop] = val
}
const stats = require('stats-lite')
var outputStats = dockedPath+"\n\n"
outputStats += "PROPERTY,MIN,MAX,MEAN,MEDIAN,STANDARD DEVIATION,SAMPLE STANDARD DEVIATION"
for(prop in props){
outputStats += "\n" + prop
outputStats += "," + min[prop]
outputStats += "," + max[prop]
outputStats += "," + stats.mean(props[prop])
outputStats += "," + stats.median(props[prop])
outputStats += "," + stats.stdev(props[prop])
outputStats += "," + stats.sampleStdev(props[prop])
}
outputStats += "\n\n----------------------------------\n\n\n"
fs.appendFileSync(`dock-stats.txt`, outputStats)