sdf-parser 6.0.0 → 6.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/lib/index.js
CHANGED
|
@@ -194,7 +194,7 @@ function parse(sdf, options = {}) {
|
|
|
194
194
|
|
|
195
195
|
/**
|
|
196
196
|
* Parse a SDF file
|
|
197
|
-
* @param {
|
|
197
|
+
* @param {NodeJS.ReadableStream} readStream SDF file to parse
|
|
198
198
|
* @param {object} [options={}]
|
|
199
199
|
* @param {Function} [options.filter] Callback allowing to filter the molecules
|
|
200
200
|
* @param {boolean} [options.dynamicTyping] Dynamically type the data
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "sdf-parser",
|
|
3
|
-
"version": "6.0.
|
|
3
|
+
"version": "6.0.1",
|
|
4
4
|
"description": "SDF parser",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"module": "src/index.js",
|
|
@@ -8,9 +8,12 @@
|
|
|
8
8
|
"lib",
|
|
9
9
|
"src"
|
|
10
10
|
],
|
|
11
|
+
"browser": {
|
|
12
|
+
"./src/iterator.js": "./src/iterator.browser.js"
|
|
13
|
+
},
|
|
11
14
|
"sideEffects": false,
|
|
12
15
|
"scripts": {
|
|
13
|
-
"build": "
|
|
16
|
+
"build": "cheminfo-build --entry src/index.js --root SDFParser",
|
|
14
17
|
"compile": "rollup -c",
|
|
15
18
|
"eslint": "eslint src",
|
|
16
19
|
"eslint-fix": "npm run eslint -- --fix",
|
|
@@ -21,9 +24,6 @@
|
|
|
21
24
|
"test-coverage": "jest --coverage",
|
|
22
25
|
"test-only": "jest"
|
|
23
26
|
},
|
|
24
|
-
"browser": {
|
|
25
|
-
"./src/stream.js": "./src/stream.browser.js"
|
|
26
|
-
},
|
|
27
27
|
"repository": {
|
|
28
28
|
"type": "git",
|
|
29
29
|
"url": "https://github.com/cheminfo/sdf-parser.git"
|
|
@@ -44,13 +44,14 @@
|
|
|
44
44
|
"homepage": "https://github.com/cheminfo/sdf-parser",
|
|
45
45
|
"devDependencies": {
|
|
46
46
|
"@babel/plugin-transform-modules-commonjs": "^7.18.6",
|
|
47
|
+
"@types/jest": "^29.1.2",
|
|
47
48
|
"babel-eslint": "^10.1.0",
|
|
48
49
|
"callback-stream": "^1.1.0",
|
|
49
50
|
"cheminfo-build": "^1.1.11",
|
|
50
|
-
"eslint": "^8.
|
|
51
|
+
"eslint": "^8.25.0",
|
|
51
52
|
"eslint-config-cheminfo": "^8.0.2",
|
|
52
|
-
"filelist-utils": "^0.
|
|
53
|
-
"jest": "^
|
|
53
|
+
"filelist-utils": "^1.0.1",
|
|
54
|
+
"jest": "^29.2.0",
|
|
54
55
|
"openchemlib": "^8.0.1",
|
|
55
56
|
"prettier": "^2.7.1"
|
|
56
57
|
},
|
|
@@ -1,22 +1,24 @@
|
|
|
1
|
-
import { createReadStream } from 'fs';
|
|
1
|
+
import { createReadStream, ReadStream } from 'fs';
|
|
2
2
|
import { join } from 'path';
|
|
3
3
|
import { createGunzip } from 'zlib';
|
|
4
4
|
|
|
5
|
-
import {
|
|
5
|
+
import { fileCollectionFromPath } from 'filelist-utils';
|
|
6
6
|
|
|
7
7
|
import { iterator } from '../iterator';
|
|
8
8
|
|
|
9
9
|
test('iterator', async () => {
|
|
10
|
-
const
|
|
11
|
-
(
|
|
12
|
-
);
|
|
10
|
+
const files = (
|
|
11
|
+
await fileCollectionFromPath(join(__dirname, '.'))
|
|
12
|
+
).files.filter((file) => file.name === 'test.sdf');
|
|
13
13
|
const results = [];
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
14
|
+
|
|
15
|
+
if (parseInt(process.versions.node) >= 18) {
|
|
16
|
+
for await (const entry of iterator(ReadStream.fromWeb(files[0].stream()))) {
|
|
17
|
+
results.push(entry);
|
|
18
|
+
}
|
|
19
|
+
expect(results).toHaveLength(128);
|
|
20
|
+
expect(results[0]).toMatchInlineSnapshot(`
|
|
21
|
+
{
|
|
20
22
|
"CLogP": 2.7,
|
|
21
23
|
"Code": 100380824,
|
|
22
24
|
"Number of H-Acceptors": 3,
|
|
@@ -61,6 +63,7 @@ test('iterator', async () => {
|
|
|
61
63
|
",
|
|
62
64
|
}
|
|
63
65
|
`);
|
|
66
|
+
}
|
|
64
67
|
});
|
|
65
68
|
|
|
66
69
|
test('iterator on stream', async () => {
|
|
@@ -72,7 +75,7 @@ test('iterator on stream', async () => {
|
|
|
72
75
|
}
|
|
73
76
|
expect(results).toHaveLength(128);
|
|
74
77
|
expect(results[0]).toMatchInlineSnapshot(`
|
|
75
|
-
|
|
78
|
+
{
|
|
76
79
|
"CLogP": 2.7,
|
|
77
80
|
"Code": 100380824,
|
|
78
81
|
"Number of H-Acceptors": 3,
|
|
@@ -118,3 +121,63 @@ test('iterator on stream', async () => {
|
|
|
118
121
|
}
|
|
119
122
|
`);
|
|
120
123
|
});
|
|
124
|
+
|
|
125
|
+
test('iterator on fileCollection stream', async () => {
|
|
126
|
+
const file = (await fileCollectionFromPath(join(__dirname, '.'))).filter(
|
|
127
|
+
(file) => file.size === 32233,
|
|
128
|
+
).files[0];
|
|
129
|
+
const results = [];
|
|
130
|
+
|
|
131
|
+
if (parseInt(process.versions.node) >= 18) {
|
|
132
|
+
for await (const entry of iterator(ReadStream.fromWeb(file.stream()))) {
|
|
133
|
+
results.push(entry);
|
|
134
|
+
}
|
|
135
|
+
expect(results).toHaveLength(128);
|
|
136
|
+
expect(results[0]).toMatchInlineSnapshot(`
|
|
137
|
+
{
|
|
138
|
+
"CLogP": 2.7,
|
|
139
|
+
"Code": 100380824,
|
|
140
|
+
"Number of H-Acceptors": 3,
|
|
141
|
+
"Number of H-Donors": 1,
|
|
142
|
+
"Number of Rotatable bonds": 1,
|
|
143
|
+
"molfile": "
|
|
144
|
+
-ISIS- 04231216572D
|
|
145
|
+
|
|
146
|
+
15 16 0 0 0 0 0 0 0 0999 V2000
|
|
147
|
+
2.4792 1.7000 0.0000 N 0 0 0 0 0 0 0 0 0 0 0 0
|
|
148
|
+
2.4292 0.3500 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0
|
|
149
|
+
0.4042 1.1208 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0
|
|
150
|
+
1.2167 2.1833 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0
|
|
151
|
+
1.1542 -0.0000 0.0000 S 0 0 0 0 0 0 0 0 0 0 0 0
|
|
152
|
+
-0.9208 1.1208 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0
|
|
153
|
+
3.4792 -0.4500 0.0000 O 0 0 0 0 0 0 0 0 0 0 0 0
|
|
154
|
+
0.8792 3.4458 0.0000 O 0 0 0 0 0 0 0 0 0 0 0 0
|
|
155
|
+
-1.6000 -0.0292 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0
|
|
156
|
+
-0.9625 -1.1792 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0
|
|
157
|
+
-1.6208 -2.3292 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0
|
|
158
|
+
-0.9125 -3.4375 0.0000 Br 0 0 0 0 0 0 0 0 0 0 0 0
|
|
159
|
+
-3.5958 -1.1792 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0
|
|
160
|
+
-2.9208 -0.0292 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0
|
|
161
|
+
-3.0333 -2.3292 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0
|
|
162
|
+
2 1 1 0 0 0 0
|
|
163
|
+
3 4 1 0 0 0 0
|
|
164
|
+
4 1 1 0 0 0 0
|
|
165
|
+
5 2 1 0 0 0 0
|
|
166
|
+
6 3 2 0 0 0 0
|
|
167
|
+
7 2 2 0 0 0 0
|
|
168
|
+
8 4 2 0 0 0 0
|
|
169
|
+
9 6 1 0 0 0 0
|
|
170
|
+
10 9 2 0 0 0 0
|
|
171
|
+
11 10 1 0 0 0 0
|
|
172
|
+
12 11 1 0 0 0 0
|
|
173
|
+
13 14 2 0 0 0 0
|
|
174
|
+
14 9 1 0 0 0 0
|
|
175
|
+
15 13 1 0 0 0 0
|
|
176
|
+
3 5 1 0 0 0 0
|
|
177
|
+
15 11 2 0 0 0 0
|
|
178
|
+
M END
|
|
179
|
+
",
|
|
180
|
+
}
|
|
181
|
+
`);
|
|
182
|
+
}
|
|
183
|
+
});
|
package/src/iterator.js
CHANGED
|
@@ -3,7 +3,7 @@ import { createInterface } from 'readline';
|
|
|
3
3
|
import { parseString } from 'dynamic-typing';
|
|
4
4
|
/**
|
|
5
5
|
* Parse a SDF file
|
|
6
|
-
* @param {
|
|
6
|
+
* @param {NodeJS.ReadableStream} readStream SDF file to parse
|
|
7
7
|
* @param {object} [options={}]
|
|
8
8
|
* @param {Function} [options.filter] Callback allowing to filter the molecules
|
|
9
9
|
* @param {boolean} [options.dynamicTyping] Dynamically type the data
|