-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindigo_inchi.js
94 lines (82 loc) · 2.98 KB
/
indigo_inchi.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
/* start of file ->*/
ls = __filename.lastIndexOf('/');
rs = __filename.lastIndexOf('\\');
__filename = __filename.substring((((ls >= 0)? ls + 1: 0) | ((rs >= 0)? rs + 1: 0)), __filename.length);
console.log('[' + __filename + ']' + ": starting");
exports.done = false;
/* start of file <- */
/* ----------------------------------------- */
var ffi = require('ffi');
function IndigoInchi(indigo) {
if (!(this instanceof IndigoInchi)) {
return new IndigoInchi(indigo);
}
if (indigo.done == true) {
/* module*/
this.indigo = indigo.indigo();
}
else {
/* function */
if (indigo.name == "Indigo") {
this.indigo = indigo();
} else {
/* object */
if (indigo instanceof Object) {
this.indigo = indigo;
}
}
}
var libpath = './indigo-libs/shared/' + process.platform + '/' + process.arch + '/indigo-inchi';
this._lib = ffi.Library(libpath, {
"indigoInchiVersion": ["string", []],
"indigoInchiResetOptions": ["int", []],
"indigoInchiLoadMolecule": ["int", ["string"]],
"indigoInchiGetInchi": ["string", ["int"]],
"indigoInchiGetInchiKey": ["string", ["string"]],
"indigoInchiGetWarning": ["string", []],
"indigoInchiGetLog": ["string", []],
"indigoInchiGetAuxInfo": [" string", []]
});
/* function indigo.vesrion() gets node +indigo versions*/
this.version = function () {
this.indigo._setSessionId();
return this._lib.indigoInchiVersion();
}
this.resetOptions = function () {
this.indigo._setSessionId();
this.indigo._checkResult(this._lib.indigoInchiResetOptions());
}
this.loadMolecule = function (inchi) {
this.indigo._setSessionId();
res = this.indigo._checkResult(this._lib.indigoInchiLoadMolecule(inchi));
if (res == 0)
return null;
return this.indigo.IndigoObject(this.indigo, res)
}
this.getInchi = function (molecule) {
this.indigo._setSessionId();
return this.indigo._checkResultString(this._lib.indigoInchiGetInchi(molecule.id));
}
this.getInchiKey = function (inchi) {
this.indigo._setSessionId()
return this.indigo._checkResultString(this._lib.indigoInchiGetInchiKey(inchi));
}
this.getWarning = function () {
this.indigo._setSessionId();
return this.indigo._checkResultString(this._lib.indigoInchiGetWarning());
}
this.getLog = function () {
this.indigo._setSessionId();
return this.indigo._checkResultString(this._lib.indigoInchiGetLog());
}
this.getAuxInfo = function () {
this.indigo._setSessionId();
return this.indigo._checkResultString(this._lib.indigoInchiGetAuxInfo());
}
}
exports.inchi = IndigoInchi;
/* ----------------------------------------- */
/*end of file ->*/
exports.done = true;
console.log('[' + __filename + ']' + ": done.");
/*end of file <-*/