sdf-parser 7.0.3 → 7.0.4
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 +6 -4
- package/package.json +1 -1
- package/src/MolfileStream.js +4 -2
- package/src/iterator.js +0 -1
- package/src/parse.js +2 -1
package/lib/index.js
CHANGED
|
@@ -108,6 +108,7 @@ function getMolecule$1(sdfPart, labels, currentLabels, options) {
|
|
|
108
108
|
* @param {object} [options.modifiers] - Object containing callbacks to apply on some specific fields
|
|
109
109
|
* @param {boolean} [options.mixedEOL=false] - Set to true if you know there is a mixture between \r\n and \n
|
|
110
110
|
* @param {string} [options.eol] - Specify the end of line character. Default will be the one found in the file
|
|
111
|
+
* @returns {object} - Object containing the molecules, the labels and the statistics
|
|
111
112
|
*/
|
|
112
113
|
function parse(sdf, options = {}) {
|
|
113
114
|
options = { ...options };
|
|
@@ -148,7 +149,7 @@ function parse(sdf, options = {}) {
|
|
|
148
149
|
|
|
149
150
|
for (let i = 0; i < entriesBoundaries.length; i++) {
|
|
150
151
|
let sdfPart = sdf.slice(...entriesBoundaries[i]);
|
|
151
|
-
|
|
152
|
+
if (sdfPart.length < 40) continue;
|
|
152
153
|
let currentLabels = [];
|
|
153
154
|
const molecule = getMolecule$1(sdfPart, labels, currentLabels, options);
|
|
154
155
|
if (!molecule) continue;
|
|
@@ -224,14 +225,16 @@ class MolfileStream extends TransformStream {
|
|
|
224
225
|
}
|
|
225
226
|
const eolLength = this.#buffer[endOfDelimiter - 1] === '\r' ? 2 : 1;
|
|
226
227
|
// need to remove the last eol because we will split on eol+'>' in getMolecule
|
|
227
|
-
|
|
228
|
+
if (index - eolLength - begin > 40) {
|
|
229
|
+
controller.enqueue(this.#buffer.slice(begin, index - eolLength));
|
|
230
|
+
}
|
|
228
231
|
index = endOfDelimiter + eolLength;
|
|
229
232
|
begin = index;
|
|
230
233
|
}
|
|
231
234
|
this.#buffer = this.#buffer.slice(begin);
|
|
232
235
|
},
|
|
233
236
|
flush: (controller) => {
|
|
234
|
-
if (this.#buffer) {
|
|
237
|
+
if (this.#buffer && this.#buffer.length > 40) {
|
|
235
238
|
controller.enqueue(this.#buffer);
|
|
236
239
|
}
|
|
237
240
|
},
|
|
@@ -253,7 +256,6 @@ async function* iterator(readStream, options = {}) {
|
|
|
253
256
|
|
|
254
257
|
const moleculeStream = readStream.pipeThrough(new MolfileStream({ eol }));
|
|
255
258
|
for await (const entry of moleculeStream) {
|
|
256
|
-
if (entry.length < 20) continue;
|
|
257
259
|
const molecule = getMolecule(entry, {
|
|
258
260
|
eol,
|
|
259
261
|
dynamicTyping,
|
package/package.json
CHANGED
package/src/MolfileStream.js
CHANGED
|
@@ -17,14 +17,16 @@ export class MolfileStream extends TransformStream {
|
|
|
17
17
|
}
|
|
18
18
|
const eolLength = this.#buffer[endOfDelimiter - 1] === '\r' ? 2 : 1;
|
|
19
19
|
// need to remove the last eol because we will split on eol+'>' in getMolecule
|
|
20
|
-
|
|
20
|
+
if (index - eolLength - begin > 40) {
|
|
21
|
+
controller.enqueue(this.#buffer.slice(begin, index - eolLength));
|
|
22
|
+
}
|
|
21
23
|
index = endOfDelimiter + eolLength;
|
|
22
24
|
begin = index;
|
|
23
25
|
}
|
|
24
26
|
this.#buffer = this.#buffer.slice(begin);
|
|
25
27
|
},
|
|
26
28
|
flush: (controller) => {
|
|
27
|
-
if (this.#buffer) {
|
|
29
|
+
if (this.#buffer && this.#buffer.length > 40) {
|
|
28
30
|
controller.enqueue(this.#buffer);
|
|
29
31
|
}
|
|
30
32
|
},
|
package/src/iterator.js
CHANGED
|
@@ -16,7 +16,6 @@ export async function* iterator(readStream, options = {}) {
|
|
|
16
16
|
|
|
17
17
|
const moleculeStream = readStream.pipeThrough(new MolfileStream({ eol }));
|
|
18
18
|
for await (const entry of moleculeStream) {
|
|
19
|
-
if (entry.length < 20) continue;
|
|
20
19
|
const molecule = getMolecule(entry, {
|
|
21
20
|
eol,
|
|
22
21
|
dynamicTyping,
|
package/src/parse.js
CHANGED
|
@@ -13,6 +13,7 @@ import { getMolecule } from './util/getMolecule';
|
|
|
13
13
|
* @param {object} [options.modifiers] - Object containing callbacks to apply on some specific fields
|
|
14
14
|
* @param {boolean} [options.mixedEOL=false] - Set to true if you know there is a mixture between \r\n and \n
|
|
15
15
|
* @param {string} [options.eol] - Specify the end of line character. Default will be the one found in the file
|
|
16
|
+
* @returns {object} - Object containing the molecules, the labels and the statistics
|
|
16
17
|
*/
|
|
17
18
|
export function parse(sdf, options = {}) {
|
|
18
19
|
options = { ...options };
|
|
@@ -53,7 +54,7 @@ export function parse(sdf, options = {}) {
|
|
|
53
54
|
|
|
54
55
|
for (let i = 0; i < entriesBoundaries.length; i++) {
|
|
55
56
|
let sdfPart = sdf.slice(...entriesBoundaries[i]);
|
|
56
|
-
|
|
57
|
+
if (sdfPart.length < 40) continue;
|
|
57
58
|
let currentLabels = [];
|
|
58
59
|
const molecule = getMolecule(sdfPart, labels, currentLabels, options);
|
|
59
60
|
if (!molecule) continue;
|