gff-nostream 2.0.0 → 3.0.0

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/dist/api.d.ts CHANGED
@@ -1,32 +1,25 @@
1
1
  import type { GFF3Feature } from './util.ts';
2
2
  export interface LineRecord {
3
- fields: string[];
3
+ line: string;
4
4
  lineHash?: string | number;
5
+ start: number;
6
+ end: number;
7
+ hasEscapes: boolean;
5
8
  }
6
9
  /**
7
10
  * Synchronously parse a string containing GFF3 and return an array of the
8
11
  * parsed items.
9
12
  *
10
13
  * @param str - GFF3 string
11
- * @param inputOptions - Parsing options
12
- * @returns array of parsed features, directives, comments and/or sequences
14
+ * @returns array of parsed features
13
15
  */
14
16
  export declare function parseStringSync(str: string): GFF3Feature[];
15
17
  /**
16
- * Synchronously parse an array of strings containing GFF3 and return an array of the
17
- * parsed items.
18
- *
19
- * @param arr - GFF3 array of strings
20
- * @param inputOptions - Parsing options
21
- * @returns array of parsed features, directives, comments and/or sequences
22
- */
23
- export declare function parseArraySync(arr: string[]): GFF3Feature[];
24
- /**
25
- * Synchronously parse an array of LineRecord objects containing pre-split GFF3
26
- * fields and return an array of the parsed items.
18
+ * Parse an array of LineRecord objects containing raw GFF3 lines.
19
+ * Supports parent/child relationships.
27
20
  *
28
- * @param records - Array of LineRecord objects with fields array and optional lineHash
21
+ * @param records - Array of LineRecord objects with raw line and metadata
29
22
  * @returns array of parsed features
30
23
  */
31
- export declare function parseRecordsSync(records: LineRecord[]): GFF3Feature[];
24
+ export declare function parseRecords(records: LineRecord[]): GFF3Feature[];
32
25
  export type { GFF3Comment, GFF3Directive, GFF3Feature, GFF3FeatureLine, GFF3FeatureLineWithRefs, GFF3Item, GFF3Sequence, } from './util.ts';
package/dist/api.js CHANGED
@@ -1,86 +1,115 @@
1
1
  "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
2
  Object.defineProperty(exports, "__esModule", { value: true });
6
3
  exports.parseStringSync = parseStringSync;
7
- exports.parseArraySync = parseArraySync;
8
- exports.parseRecordsSync = parseRecordsSync;
9
- const parse_ts_1 = __importDefault(require("./parse.js"));
4
+ exports.parseRecords = parseRecords;
10
5
  const util_ts_1 = require("./util.js");
11
6
  /**
12
7
  * Synchronously parse a string containing GFF3 and return an array of the
13
8
  * parsed items.
14
9
  *
15
10
  * @param str - GFF3 string
16
- * @param inputOptions - Parsing options
17
- * @returns array of parsed features, directives, comments and/or sequences
11
+ * @returns array of parsed features
18
12
  */
19
13
  function parseStringSync(str) {
20
- const items = [];
21
- const parser = new parse_ts_1.default({
22
- featureCallback: arg => items.push(arg),
23
- disableDerivesFromReferences: true,
24
- errorCallback: err => {
25
- throw new Error(err);
26
- },
27
- });
28
- for (const line of str.split(/\r?\n/)) {
29
- parser.addLine(line);
30
- }
31
- parser.finish();
32
- return items;
33
- }
34
- /**
35
- * Synchronously parse an array of strings containing GFF3 and return an array of the
36
- * parsed items.
37
- *
38
- * @param arr - GFF3 array of strings
39
- * @param inputOptions - Parsing options
40
- * @returns array of parsed features, directives, comments and/or sequences
41
- */
42
- function parseArraySync(arr) {
43
- const items = [];
44
- const parser = new parse_ts_1.default({
45
- featureCallback: arg => items.push(arg),
46
- disableDerivesFromReferences: true,
47
- errorCallback: err => {
48
- throw new Error(err);
49
- },
50
- });
51
- for (const line of arr) {
52
- parser.addLine(line);
14
+ const lines = str.split(/\r?\n/);
15
+ const records = [];
16
+ for (let i = 0; i < lines.length; i++) {
17
+ const line = lines[i];
18
+ if (line.length === 0 || line[0] === '#') {
19
+ if (line.startsWith('##FASTA')) {
20
+ break;
21
+ }
22
+ continue;
23
+ }
24
+ if (line[0] === '>') {
25
+ break;
26
+ }
27
+ records.push({
28
+ line,
29
+ start: 0,
30
+ end: 0,
31
+ hasEscapes: line.includes('%'),
32
+ });
53
33
  }
54
- parser.finish();
55
- return items;
34
+ return parseRecords(records);
56
35
  }
57
36
  /**
58
- * Synchronously parse an array of LineRecord objects containing pre-split GFF3
59
- * fields and return an array of the parsed items.
37
+ * Parse an array of LineRecord objects containing raw GFF3 lines.
38
+ * Supports parent/child relationships.
60
39
  *
61
- * @param records - Array of LineRecord objects with fields array and optional lineHash
40
+ * @param records - Array of LineRecord objects with raw line and metadata
62
41
  * @returns array of parsed features
63
42
  */
64
- function parseRecordsSync(records) {
43
+ function parseRecords(records) {
65
44
  const items = [];
66
- const parser = new parse_ts_1.default({
67
- featureCallback: arg => items.push(arg),
68
- disableDerivesFromReferences: true,
69
- errorCallback: err => {
70
- throw new Error(err);
71
- },
72
- });
73
- for (const record of records) {
74
- const featureLine = (0, util_ts_1.parseFieldsArray)(record.fields);
45
+ const byId = new Map();
46
+ const orphans = new Map();
47
+ for (let i = 0; i < records.length; i++) {
48
+ const record = records[i];
49
+ const featureLine = (record.hasEscapes
50
+ ? (0, util_ts_1.parseFeature)(record.line)
51
+ : (0, util_ts_1.parseFeatureNoUnescape)(record.line));
52
+ featureLine.child_features = [];
53
+ featureLine.derived_features = [];
75
54
  if (record.lineHash !== undefined) {
76
55
  if (!featureLine.attributes) {
77
56
  featureLine.attributes = {};
78
57
  }
79
58
  featureLine.attributes._lineHash = [String(record.lineHash)];
80
59
  }
81
- parser.addParsedFeatureLine(featureLine);
60
+ const attrs = featureLine.attributes;
61
+ const ids = attrs?.ID;
62
+ const parents = attrs?.Parent;
63
+ if (!ids && !parents) {
64
+ items.push([featureLine]);
65
+ continue;
66
+ }
67
+ let feature;
68
+ if (ids) {
69
+ const id = ids[0];
70
+ const existing = byId.get(id);
71
+ if (existing) {
72
+ existing.push(featureLine);
73
+ feature = existing;
74
+ }
75
+ else {
76
+ feature = [featureLine];
77
+ if (!parents) {
78
+ items.push(feature);
79
+ }
80
+ byId.set(id, feature);
81
+ const waiting = orphans.get(id);
82
+ if (waiting) {
83
+ for (let j = 0; j < waiting.length; j++) {
84
+ featureLine.child_features.push(waiting[j]);
85
+ }
86
+ orphans.delete(id);
87
+ }
88
+ }
89
+ }
90
+ else {
91
+ feature = [featureLine];
92
+ }
93
+ if (parents) {
94
+ for (let j = 0; j < parents.length; j++) {
95
+ const parentId = parents[j];
96
+ const parent = byId.get(parentId);
97
+ if (parent) {
98
+ for (let k = 0; k < parent.length; k++) {
99
+ parent[k].child_features.push(feature);
100
+ }
101
+ }
102
+ else {
103
+ let arr = orphans.get(parentId);
104
+ if (!arr) {
105
+ arr = [];
106
+ orphans.set(parentId, arr);
107
+ }
108
+ arr.push(feature);
109
+ }
110
+ }
111
+ }
82
112
  }
83
- parser.finish();
84
113
  return items;
85
114
  }
86
115
  //# sourceMappingURL=api.js.map
package/dist/api.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"api.js","sourceRoot":"","sources":["../src/api.ts"],"names":[],"mappings":";;;;;AAkBA,0CAgBC;AAUD,wCAgBC;AASD,4CAuBC;AA5FD,0DAA+B;AAC/B,uCAA4C;AAS5C;;;;;;;GAOG;AACH,SAAgB,eAAe,CAAC,GAAW;IACzC,MAAM,KAAK,GAAkB,EAAE,CAAA;IAC/B,MAAM,MAAM,GAAG,IAAI,kBAAM,CAAC;QACxB,eAAe,EAAE,GAAG,CAAC,EAAE,CAAC,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC;QACvC,4BAA4B,EAAE,IAAI;QAClC,aAAa,EAAE,GAAG,CAAC,EAAE;YACnB,MAAM,IAAI,KAAK,CAAC,GAAG,CAAC,CAAA;QACtB,CAAC;KACF,CAAC,CAAA;IAEF,KAAK,MAAM,IAAI,IAAI,GAAG,CAAC,KAAK,CAAC,OAAO,CAAC,EAAE,CAAC;QACtC,MAAM,CAAC,OAAO,CAAC,IAAI,CAAC,CAAA;IACtB,CAAC;IACD,MAAM,CAAC,MAAM,EAAE,CAAA;IAEf,OAAO,KAAK,CAAA;AACd,CAAC;AAED;;;;;;;GAOG;AACH,SAAgB,cAAc,CAAC,GAAa;IAC1C,MAAM,KAAK,GAAkB,EAAE,CAAA;IAC/B,MAA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,QAAQ,CAAC,CAAA;oBAC/B,IAAI,CAAC,GAAG,EAAE,CAAC;wBACT,GAAG,GAAG,EAAE,CAAA;wBACR,OAAO,CAAC,GAAG,CAAC,QAAQ,EAAE,GAAG,CAAC,CAAA;oBAC5B,CAAC;oBACD,GAAG,CAAC,IAAI,CAAC,OAAO,CAAC,CAAA;gBACnB,CAAC;YACH,CAAC;QACH,CAAC;IACH,CAAC;IAED,OAAO,KAAK,CAAA;AACd,CAAC"}
package/dist/index.d.ts CHANGED
@@ -1,3 +1,2 @@
1
- import { parseArraySync, parseRecordsSync, parseStringSync } from './api.ts';
2
- export { parseArraySync, parseRecordsSync, parseStringSync };
1
+ export { parseRecords, parseStringSync } from './api.ts';
3
2
  export type { GFF3Comment, GFF3Directive, GFF3Feature, GFF3FeatureLine, GFF3FeatureLineWithRefs, GFF3Item, GFF3Sequence, LineRecord, } from './api.ts';
package/dist/index.js CHANGED
@@ -1,8 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.parseStringSync = exports.parseRecordsSync = exports.parseArraySync = void 0;
4
- const api_ts_1 = require("./api.js");
5
- Object.defineProperty(exports, "parseArraySync", { enumerable: true, get: function () { return api_ts_1.parseArraySync; } });
6
- Object.defineProperty(exports, "parseRecordsSync", { enumerable: true, get: function () { return api_ts_1.parseRecordsSync; } });
3
+ exports.parseStringSync = exports.parseRecords = void 0;
4
+ var api_ts_1 = require("./api.js");
5
+ Object.defineProperty(exports, "parseRecords", { enumerable: true, get: function () { return api_ts_1.parseRecords; } });
7
6
  Object.defineProperty(exports, "parseStringSync", { enumerable: true, get: function () { return api_ts_1.parseStringSync; } });
8
7
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;AAAA,qCAA4E;AACnE,+FADA,uBAAc,OACA;AAAE,iGADA,yBAAgB,OACA;AAAE,gGADA,wBAAe,OACA"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;AAAA,mCAAwD;AAA/C,sGAAA,YAAY,OAAA;AAAE,yGAAA,eAAe,OAAA"}
package/dist/util.d.ts CHANGED
@@ -4,28 +4,22 @@
4
4
  * @param stringVal - Escaped GFF3 string value
5
5
  * @returns An unescaped string value
6
6
  */
7
- export declare function unescape(stringVal: string): string;
7
+ export declare function unescape(s: string): string;
8
8
  /**
9
- * Escape a value for use in a GFF3 attribute value.
10
- *
11
- * @param rawVal - Raw GFF3 attribute value
12
- * @returns An escaped string value
13
- */
14
- export declare function escape(rawVal: string | number): string;
15
- /**
16
- * Escape a value for use in a GFF3 column value.
9
+ * Parse the 9th column (attributes) of a GFF3 feature line.
17
10
  *
18
- * @param rawVal - Raw GFF3 column value
19
- * @returns An escaped column value
11
+ * @param attrString - String of GFF3 9th column
12
+ * @returns Parsed attributes
20
13
  */
21
- export declare function escapeColumn(rawVal: string | number): string;
14
+ export declare function parseAttributes(attrString: string): GFF3Attributes;
22
15
  /**
23
- * Parse the 9th column (attributes) of a GFF3 feature line.
16
+ * Parse the 9th column (attributes) of a GFF3 feature line without unescaping.
17
+ * Fast path for data known to contain no escaped characters.
24
18
  *
25
19
  * @param attrString - String of GFF3 9th column
26
20
  * @returns Parsed attributes
27
21
  */
28
- export declare function parseAttributes(attrString: string): GFF3Attributes;
22
+ export declare function parseAttributesNoUnescape(attrString: string): GFF3Attributes;
29
23
  /**
30
24
  * Parse a GFF3 feature line
31
25
  *
@@ -33,59 +27,36 @@ export declare function parseAttributes(attrString: string): GFF3Attributes;
33
27
  * @returns The parsed feature
34
28
  */
35
29
  export declare function parseFeature(line: string): GFF3FeatureLine;
36
- export declare function parseFieldsArray(f: (string | null | undefined)[]): GFF3FeatureLine;
37
- /**
38
- * Parse a GFF3 directive line.
39
- *
40
- * @param line - GFF3 directive line
41
- * @returns The parsed directive
42
- */
43
- export declare function parseDirective(line: string): GFF3Directive | GFF3SequenceRegionDirective | GFF3GenomeBuildDirective | null;
44
- /**
45
- * Format an attributes object into a string suitable for the 9th column of GFF3.
46
- *
47
- * @param attrs - Attributes
48
- * @returns GFF3 9th column string
49
- */
50
- export declare function formatAttributes(attrs: GFF3Attributes): string;
51
30
  /**
52
- * Format a feature object or array of feature objects into one or more lines of
53
- * GFF3.
31
+ * Parse a GFF3 feature line without unescaping.
32
+ * Fast path for data known to contain no escaped characters.
54
33
  *
55
- * @param featureOrFeatures - A feature object or array of feature objects
56
- * @returns A string of one or more GFF3 lines
57
- */
58
- export declare function formatFeature(featureOrFeatures: GFF3FeatureLine | GFF3FeatureLineWithRefs | (GFF3FeatureLine | GFF3FeatureLineWithRefs)[]): string;
59
- /**
60
- * Format a directive into a line of GFF3.
61
- *
62
- * @param directive - A directive object
63
- * @returns A directive line string
34
+ * @param line - GFF3 feature line
35
+ * @returns The parsed feature
64
36
  */
65
- export declare function formatDirective(directive: GFF3Directive): string;
37
+ export declare function parseFeatureNoUnescape(line: string): GFF3FeatureLine;
66
38
  /**
67
- * Format a comment into a GFF3 comment.
68
- * Yes I know this is just adding a # and a newline.
39
+ * Parse a GFF3 feature from a pre-split fields array
69
40
  *
70
- * @param comment - A comment object
71
- * @returns A comment line string
41
+ * @param f - Array of 9 GFF3 column values (use null or '.' for empty values)
42
+ * @returns The parsed feature
72
43
  */
73
- export declare function formatComment(comment: GFF3Comment): string;
44
+ export declare function parseFieldsArray(f: (string | null | undefined)[]): GFF3FeatureLine;
74
45
  /**
75
- * Format a sequence object as FASTA
46
+ * Parse a GFF3 feature from a pre-split fields array without unescaping.
47
+ * Fast path for data known to contain no escaped characters.
76
48
  *
77
- * @param seq - A sequence object
78
- * @returns Formatted single FASTA sequence string
49
+ * @param f - Array of 9 GFF3 column values (use null or '.' for empty values)
50
+ * @returns The parsed feature
79
51
  */
80
- export declare function formatSequence(seq: GFF3Sequence): string;
52
+ export declare function parseFieldsArrayNoUnescape(f: (string | null | undefined)[]): GFF3FeatureLine;
81
53
  /**
82
- * Format a directive, comment, sequence, or feature, or array of such items,
83
- * into one or more lines of GFF3.
54
+ * Parse a GFF3 directive line.
84
55
  *
85
- * @param itemOrItems - A comment, sequence, or feature, or array of such items
86
- * @returns A formatted string or array of strings
56
+ * @param line - GFF3 directive line
57
+ * @returns The parsed directive
87
58
  */
88
- export declare function formatItem(itemOrItems: GFF3FeatureLineWithRefs | GFF3Directive | GFF3Comment | GFF3Sequence | (GFF3FeatureLineWithRefs | GFF3Directive | GFF3Comment | GFF3Sequence)[]): string | string[];
59
+ export declare function parseDirective(line: string): GFF3Directive | GFF3SequenceRegionDirective | GFF3GenomeBuildDirective | null;
89
60
  /** A record of GFF3 attribute identifiers and the values of those identifiers */
90
61
  export type GFF3Attributes = Record<string, string[] | undefined>;
91
62
  /** A representation of a single line of a GFF3 file */