sdf-parser 5.0.1 → 5.0.2
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
|
@@ -23,8 +23,13 @@ function getEntriesBoundaries(string, substring, eol) {
|
|
|
23
23
|
next = string.indexOf(substring, previous);
|
|
24
24
|
if (next !== -1) {
|
|
25
25
|
res.push([previous, next]);
|
|
26
|
-
|
|
27
|
-
|
|
26
|
+
const nextMatch = string.indexOf(eol, next + substring.length);
|
|
27
|
+
if (nextMatch === -1) {
|
|
28
|
+
next = -1;
|
|
29
|
+
} else {
|
|
30
|
+
previous = nextMatch + eol.length;
|
|
31
|
+
next = previous;
|
|
32
|
+
}
|
|
28
33
|
} else {
|
|
29
34
|
res.push([previous, string.length]);
|
|
30
35
|
}
|
|
@@ -184,9 +189,9 @@ function parse(sdf, options = {}) {
|
|
|
184
189
|
|
|
185
190
|
return {
|
|
186
191
|
time: Date.now() - start,
|
|
187
|
-
molecules
|
|
192
|
+
molecules,
|
|
188
193
|
labels: Object.keys(labels),
|
|
189
|
-
statistics
|
|
194
|
+
statistics,
|
|
190
195
|
};
|
|
191
196
|
}
|
|
192
197
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "sdf-parser",
|
|
3
|
-
"version": "5.0.
|
|
3
|
+
"version": "5.0.2",
|
|
4
4
|
"description": "SDF parser",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"module": "src/index.js",
|
|
@@ -43,18 +43,18 @@
|
|
|
43
43
|
},
|
|
44
44
|
"homepage": "https://github.com/cheminfo/sdf-parser",
|
|
45
45
|
"devDependencies": {
|
|
46
|
-
"@babel/plugin-transform-modules-commonjs": "^7.
|
|
46
|
+
"@babel/plugin-transform-modules-commonjs": "^7.18.6",
|
|
47
47
|
"babel-eslint": "^10.1.0",
|
|
48
48
|
"callback-stream": "^1.1.0",
|
|
49
49
|
"cheminfo-build": "^1.1.11",
|
|
50
|
-
"eslint": "^8.
|
|
51
|
-
"eslint-config-cheminfo": "^
|
|
52
|
-
"jest": "^
|
|
53
|
-
"openchemlib": "^
|
|
54
|
-
"prettier": "^2.
|
|
50
|
+
"eslint": "^8.22.0",
|
|
51
|
+
"eslint-config-cheminfo": "^8.0.2",
|
|
52
|
+
"jest": "^28.1.3",
|
|
53
|
+
"openchemlib": "^8.0.1",
|
|
54
|
+
"prettier": "^2.7.1"
|
|
55
55
|
},
|
|
56
56
|
"dependencies": {
|
|
57
|
-
"ensure-string": "^1.
|
|
57
|
+
"ensure-string": "^1.2.0",
|
|
58
58
|
"pumpify": "^2.0.1",
|
|
59
59
|
"split2": "^4.1.0",
|
|
60
60
|
"through2": "^4.0.2",
|
|
@@ -24,3 +24,10 @@ let sdf2 = fs.readFileSync(`${__dirname}/test2.sdf`, 'utf-8');
|
|
|
24
24
|
);
|
|
25
25
|
});
|
|
26
26
|
});
|
|
27
|
+
|
|
28
|
+
test('should parse sdf files without EOL in the EOF', () => {
|
|
29
|
+
const eol = '\n';
|
|
30
|
+
const sdf = fs.readFileSync(`${__dirname}/test4.sdf`, 'utf-8');
|
|
31
|
+
|
|
32
|
+
expect(getEntriesBoundaries(sdf, `${eol}$$$$`, eol)).toMatchSnapshot();
|
|
33
|
+
});
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
|
|
2
|
+
-ISIS- 04231216572D
|
|
3
|
+
|
|
4
|
+
15 16 0 0 0 0 0 0 0 0999 V2000
|
|
5
|
+
2.4792 1.7000 0.0000 N 0 0 0 0 0 0 0 0 0 0 0 0
|
|
6
|
+
2.4292 0.3500 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0
|
|
7
|
+
0.4042 1.1208 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0
|
|
8
|
+
1.2167 2.1833 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0
|
|
9
|
+
1.1542 -0.0000 0.0000 S 0 0 0 0 0 0 0 0 0 0 0 0
|
|
10
|
+
-0.9208 1.1208 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0
|
|
11
|
+
3.4792 -0.4500 0.0000 O 0 0 0 0 0 0 0 0 0 0 0 0
|
|
12
|
+
0.8792 3.4458 0.0000 O 0 0 0 0 0 0 0 0 0 0 0 0
|
|
13
|
+
-1.6000 -0.0292 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0
|
|
14
|
+
-0.9625 -1.1792 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0
|
|
15
|
+
-1.6208 -2.3292 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0
|
|
16
|
+
-0.9125 -3.4375 0.0000 Br 0 0 0 0 0 0 0 0 0 0 0 0
|
|
17
|
+
-3.5958 -1.1792 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0
|
|
18
|
+
-2.9208 -0.0292 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0
|
|
19
|
+
-3.0333 -2.3292 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0
|
|
20
|
+
2 1 1 0 0 0 0
|
|
21
|
+
3 4 1 0 0 0 0
|
|
22
|
+
4 1 1 0 0 0 0
|
|
23
|
+
5 2 1 0 0 0 0
|
|
24
|
+
6 3 2 0 0 0 0
|
|
25
|
+
7 2 2 0 0 0 0
|
|
26
|
+
8 4 2 0 0 0 0
|
|
27
|
+
9 6 1 0 0 0 0
|
|
28
|
+
10 9 2 0 0 0 0
|
|
29
|
+
11 10 1 0 0 0 0
|
|
30
|
+
12 11 1 0 0 0 0
|
|
31
|
+
13 14 2 0 0 0 0
|
|
32
|
+
14 9 1 0 0 0 0
|
|
33
|
+
15 13 1 0 0 0 0
|
|
34
|
+
3 5 1 0 0 0 0
|
|
35
|
+
15 11 2 0 0 0 0
|
|
36
|
+
M END
|
|
37
|
+
$$$$
|
|
@@ -6,8 +6,13 @@ export function getEntriesBoundaries(string, substring, eol) {
|
|
|
6
6
|
next = string.indexOf(substring, previous);
|
|
7
7
|
if (next !== -1) {
|
|
8
8
|
res.push([previous, next]);
|
|
9
|
-
|
|
10
|
-
|
|
9
|
+
const nextMatch = string.indexOf(eol, next + substring.length);
|
|
10
|
+
if (nextMatch === -1) {
|
|
11
|
+
next = -1;
|
|
12
|
+
} else {
|
|
13
|
+
previous = nextMatch + eol.length;
|
|
14
|
+
next = previous;
|
|
15
|
+
}
|
|
11
16
|
} else {
|
|
12
17
|
res.push([previous, string.length]);
|
|
13
18
|
}
|
package/src/parse.js
CHANGED