gff-nostream 3.0.11 → 5.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/README.md +49 -94
- package/dist/api.d.ts +21 -34
- package/dist/api.js +53 -147
- package/dist/api.js.map +1 -1
- package/dist/index.d.ts +2 -2
- package/dist/index.js +1 -3
- package/dist/index.js.map +1 -1
- package/dist/util.d.ts +19 -120
- package/dist/util.js +29 -179
- package/dist/util.js.map +1 -1
- package/esm/api.d.ts +21 -34
- package/esm/api.js +54 -146
- package/esm/api.js.map +1 -1
- package/esm/index.d.ts +2 -2
- package/esm/index.js +1 -1
- package/esm/index.js.map +1 -1
- package/esm/util.d.ts +19 -120
- package/esm/util.js +29 -172
- package/esm/util.js.map +1 -1
- package/package.json +1 -1
- package/src/api.ts +80 -187
- package/src/index.ts +2 -18
- package/src/util.ts +39 -308
package/esm/api.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { parseFeature
|
|
1
|
+
import { parseFeature } from "./util.js";
|
|
2
2
|
/** Extract the GFF3 feature type (column 3) from a raw line without a full split. */
|
|
3
3
|
export function extractType(line) {
|
|
4
4
|
const t1 = line.indexOf('\t');
|
|
@@ -17,8 +17,8 @@ function appendOrphan(orphans, key, value) {
|
|
|
17
17
|
}
|
|
18
18
|
}
|
|
19
19
|
/**
|
|
20
|
-
* The
|
|
21
|
-
*
|
|
20
|
+
* The parser collapses single-element attribute arrays to scalars, so a raw
|
|
21
|
+
* ID/Parent value can be a string, a string array, or absent. These coerce
|
|
22
22
|
* those `unknown` values without typecasts.
|
|
23
23
|
*/
|
|
24
24
|
function firstString(value) {
|
|
@@ -32,174 +32,82 @@ function toStringArray(value) {
|
|
|
32
32
|
return typeof value === 'string' ? [value] : [];
|
|
33
33
|
}
|
|
34
34
|
/**
|
|
35
|
-
*
|
|
36
|
-
*
|
|
37
|
-
*
|
|
38
|
-
* @param str - GFF3 string
|
|
39
|
-
* @returns array of parsed features
|
|
40
|
-
*/
|
|
41
|
-
export function parseStringSync(str) {
|
|
42
|
-
return parseRecords(stringToRecords(str));
|
|
43
|
-
}
|
|
44
|
-
/**
|
|
45
|
-
* Synchronously parse a string containing GFF3 directly into JBrowse format.
|
|
46
|
-
*
|
|
47
|
-
* @param str - GFF3 string
|
|
48
|
-
* @returns array of JBrowse-format features
|
|
35
|
+
* Register a feature's ID and attach it to its parent(s), building the
|
|
36
|
+
* subfeature tree in `byId`/`orphans`. Returns true when the feature is
|
|
37
|
+
* top-level (has no Parent) and the caller should collect it.
|
|
49
38
|
*/
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
39
|
+
function linkFeature(feature, byId, orphans) {
|
|
40
|
+
const id = firstString(feature.id);
|
|
41
|
+
const parents = toStringArray(feature.parent);
|
|
42
|
+
// Register the id only the first time it is seen. Continuation lines
|
|
43
|
+
// (multi-location features such as a CDS spanning several segments share one
|
|
44
|
+
// ID across lines) skip registration but must still be attached to their
|
|
45
|
+
// parent below, so this is independent of the parent handling.
|
|
46
|
+
if (id && !byId.has(id)) {
|
|
47
|
+
byId.set(id, feature);
|
|
48
|
+
const waiting = orphans.get(id);
|
|
49
|
+
if (waiting) {
|
|
50
|
+
for (const w of waiting) {
|
|
51
|
+
feature.subfeatures.push(w);
|
|
52
|
+
}
|
|
53
|
+
orphans.delete(id);
|
|
59
54
|
}
|
|
60
|
-
|
|
61
|
-
|
|
55
|
+
}
|
|
56
|
+
for (const parentId of parents) {
|
|
57
|
+
const parentFeature = byId.get(parentId);
|
|
58
|
+
if (parentFeature) {
|
|
59
|
+
parentFeature.subfeatures.push(feature);
|
|
60
|
+
}
|
|
61
|
+
else {
|
|
62
|
+
appendOrphan(orphans, parentId, feature);
|
|
62
63
|
}
|
|
63
|
-
records.push({
|
|
64
|
-
line,
|
|
65
|
-
hasEscapes: line.includes('%'),
|
|
66
|
-
});
|
|
67
64
|
}
|
|
68
|
-
|
|
65
|
+
// Every line of a top-level discontinuous feature (e.g. cDNA_match spanning
|
|
66
|
+
// several segments under one shared ID, with no Parent) is its own top-level
|
|
67
|
+
// item, so this is independent of whether the id was just registered.
|
|
68
|
+
return parents.length === 0;
|
|
69
69
|
}
|
|
70
70
|
/**
|
|
71
|
-
*
|
|
72
|
-
*
|
|
71
|
+
* Synchronously parse a string containing GFF3 and return an array of the
|
|
72
|
+
* parsed features. Comments, directives, and `##FASTA` sections are ignored.
|
|
73
73
|
*
|
|
74
|
-
* @param
|
|
74
|
+
* @param str - GFF3 string
|
|
75
75
|
* @returns array of parsed features
|
|
76
76
|
*/
|
|
77
|
-
export function
|
|
77
|
+
export function parseStringSync(str) {
|
|
78
78
|
const items = [];
|
|
79
79
|
const byId = new Map();
|
|
80
80
|
const orphans = new Map();
|
|
81
|
-
for (const
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
: parseFeatureNoUnescape(record.line);
|
|
85
|
-
const featureLine = {
|
|
86
|
-
...parsed,
|
|
87
|
-
child_features: [],
|
|
88
|
-
derived_features: [],
|
|
89
|
-
};
|
|
90
|
-
if (record.lineHash !== undefined) {
|
|
91
|
-
featureLine.attributes ??= {};
|
|
92
|
-
featureLine.attributes._lineHash = [String(record.lineHash)];
|
|
93
|
-
}
|
|
94
|
-
const attrs = featureLine.attributes;
|
|
95
|
-
const ids = attrs?.ID;
|
|
96
|
-
const parents = attrs?.Parent;
|
|
97
|
-
if (!ids && !parents) {
|
|
98
|
-
items.push([featureLine]);
|
|
81
|
+
for (const line of str.split(/\r?\n/)) {
|
|
82
|
+
if (line.startsWith('##FASTA') || line.startsWith('>')) {
|
|
83
|
+
break;
|
|
99
84
|
}
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
if (
|
|
103
|
-
|
|
104
|
-
const existing = byId.get(id);
|
|
105
|
-
if (existing) {
|
|
106
|
-
// Multi-location continuation: share child_features/derived_features
|
|
107
|
-
// with the first line so children remain visible across all lines
|
|
108
|
-
// regardless of arrival order.
|
|
109
|
-
featureLine.child_features = existing[0].child_features;
|
|
110
|
-
featureLine.derived_features = existing[0].derived_features;
|
|
111
|
-
existing.push(featureLine);
|
|
112
|
-
feature = existing;
|
|
113
|
-
}
|
|
114
|
-
else {
|
|
115
|
-
feature = [featureLine];
|
|
116
|
-
if (!parents) {
|
|
117
|
-
items.push(feature);
|
|
118
|
-
}
|
|
119
|
-
byId.set(id, feature);
|
|
120
|
-
const waiting = orphans.get(id);
|
|
121
|
-
if (waiting) {
|
|
122
|
-
for (const w of waiting) {
|
|
123
|
-
featureLine.child_features.push(w);
|
|
124
|
-
}
|
|
125
|
-
orphans.delete(id);
|
|
126
|
-
}
|
|
127
|
-
}
|
|
128
|
-
}
|
|
129
|
-
else {
|
|
130
|
-
feature = [featureLine];
|
|
131
|
-
}
|
|
132
|
-
if (parents) {
|
|
133
|
-
for (const parentId of parents) {
|
|
134
|
-
const parent = byId.get(parentId);
|
|
135
|
-
if (parent) {
|
|
136
|
-
// child_features is shared across all parent feature lines,
|
|
137
|
-
// so push once via the first line.
|
|
138
|
-
parent[0].child_features.push(feature);
|
|
139
|
-
}
|
|
140
|
-
else {
|
|
141
|
-
appendOrphan(orphans, parentId, feature);
|
|
142
|
-
}
|
|
143
|
-
}
|
|
85
|
+
if (line.length !== 0 && !line.startsWith('#')) {
|
|
86
|
+
const feature = parseFeature(line);
|
|
87
|
+
if (linkFeature(feature, byId, orphans)) {
|
|
88
|
+
items.push(feature);
|
|
144
89
|
}
|
|
145
90
|
}
|
|
146
91
|
}
|
|
147
92
|
return items;
|
|
148
93
|
}
|
|
149
94
|
/**
|
|
150
|
-
* Parse an array of
|
|
151
|
-
*
|
|
95
|
+
* Parse an array of records wrapping raw GFF3 lines, resolving parent/child
|
|
96
|
+
* relationships into `subfeatures`. Returns each top-level feature paired with
|
|
97
|
+
* the record it came from, so callers can attach their own identity (e.g. a
|
|
98
|
+
* byte offset) without the parser stamping anything onto the feature.
|
|
152
99
|
*
|
|
153
|
-
* @param records - Array of
|
|
154
|
-
* @returns
|
|
100
|
+
* @param records - Array of records, each carrying a raw GFF3 `line`
|
|
101
|
+
* @returns top-level features, each paired with its originating record
|
|
155
102
|
*/
|
|
156
|
-
export function
|
|
103
|
+
export function parseRecords(records) {
|
|
157
104
|
const items = [];
|
|
158
105
|
const byId = new Map();
|
|
159
106
|
const orphans = new Map();
|
|
160
107
|
for (const record of records) {
|
|
161
|
-
const feature = record.
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
if (record.lineHash !== undefined) {
|
|
165
|
-
feature._lineHash = String(record.lineHash);
|
|
166
|
-
}
|
|
167
|
-
const id = firstString(feature.id);
|
|
168
|
-
const parents = toStringArray(feature.parent);
|
|
169
|
-
if (!id && parents.length === 0) {
|
|
170
|
-
items.push(feature);
|
|
171
|
-
}
|
|
172
|
-
else {
|
|
173
|
-
// A parentless line is a top-level item. Every line of a top-level
|
|
174
|
-
// discontinuous feature (e.g. cDNA_match/EST_match spanning several
|
|
175
|
-
// segments under one shared ID, with no Parent) is its own top-level
|
|
176
|
-
// item, so push here regardless of whether the id is already registered.
|
|
177
|
-
if (parents.length === 0) {
|
|
178
|
-
items.push(feature);
|
|
179
|
-
}
|
|
180
|
-
// Register the id only the first time it is seen. Continuation lines
|
|
181
|
-
// (multi-location features such as a CDS spanning several segments share
|
|
182
|
-
// one ID across lines) skip registration but must still be attached to
|
|
183
|
-
// their parent below, so this is independent of the parent handling.
|
|
184
|
-
if (id && !byId.has(id)) {
|
|
185
|
-
byId.set(id, feature);
|
|
186
|
-
const waiting = orphans.get(id);
|
|
187
|
-
if (waiting) {
|
|
188
|
-
for (const w of waiting) {
|
|
189
|
-
feature.subfeatures.push(w);
|
|
190
|
-
}
|
|
191
|
-
orphans.delete(id);
|
|
192
|
-
}
|
|
193
|
-
}
|
|
194
|
-
for (const parentId of parents) {
|
|
195
|
-
const parentFeature = byId.get(parentId);
|
|
196
|
-
if (parentFeature) {
|
|
197
|
-
parentFeature.subfeatures.push(feature);
|
|
198
|
-
}
|
|
199
|
-
else {
|
|
200
|
-
appendOrphan(orphans, parentId, feature);
|
|
201
|
-
}
|
|
202
|
-
}
|
|
108
|
+
const feature = parseFeature(record.line);
|
|
109
|
+
if (linkFeature(feature, byId, orphans)) {
|
|
110
|
+
items.push({ feature, record });
|
|
203
111
|
}
|
|
204
112
|
}
|
|
205
113
|
return items;
|
package/esm/api.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"api.js","sourceRoot":"","sources":["../src/api.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"api.js","sourceRoot":"","sources":["../src/api.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,WAAW,CAAA;AAmBxC,qFAAqF;AACrF,MAAM,UAAU,WAAW,CAAC,IAAY;IACtC,MAAM,EAAE,GAAG,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,CAAA;IAC7B,MAAM,EAAE,GAAG,IAAI,CAAC,OAAO,CAAC,IAAI,EAAE,EAAE,GAAG,CAAC,CAAC,CAAA;IACrC,MAAM,EAAE,GAAG,IAAI,CAAC,OAAO,CAAC,IAAI,EAAE,EAAE,GAAG,CAAC,CAAC,CAAA;IACrC,OAAO,IAAI,CAAC,KAAK,CAAC,EAAE,GAAG,CAAC,EAAE,EAAE,CAAC,CAAA;AAC/B,CAAC;AAED,kFAAkF;AAClF,SAAS,YAAY,CAAI,OAAyB,EAAE,GAAW,EAAE,KAAQ;IACvE,MAAM,GAAG,GAAG,OAAO,CAAC,GAAG,CAAC,GAAG,CAAC,CAAA;IAC5B,IAAI,GAAG,EAAE,CAAC;QACR,GAAG,CAAC,IAAI,CAAC,KAAK,CAAC,CAAA;IACjB,CAAC;SAAM,CAAC;QACN,OAAO,CAAC,GAAG,CAAC,GAAG,EAAE,CAAC,KAAK,CAAC,CAAC,CAAA;IAC3B,CAAC;AACH,CAAC;AAED;;;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QG;AACH,MAAM,UAAU,YAAY,CAC1B,OAAqB;IAErB,MAAM,KAAK,GAAsB,EAAE,CAAA;IACnC,MAAM,IAAI,GAAG,IAAI,GAAG,EAAsB,CAAA;IAC1C,MAAM,OAAO,GAAG,IAAI,GAAG,EAAwB,CAAA;IAE/C,KAAK,MAAM,MAAM,IAAI,OAAO,EAAE,CAAC;QAC7B,MAAM,OAAO,GAAG,YAAY,CAAC,MAAM,CAAC,IAAI,CAAC,CAAA;QACzC,IAAI,WAAW,CAAC,OAAO,EAAE,IAAI,EAAE,OAAO,CAAC,EAAE,CAAC;YACxC,KAAK,CAAC,IAAI,CAAC,EAAE,OAAO,EAAE,MAAM,EAAE,CAAC,CAAA;QACjC,CAAC;IACH,CAAC;IAED,OAAO,KAAK,CAAA;AACd,CAAC"}
|
package/esm/index.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export { extractType, parseRecords,
|
|
2
|
-
export type {
|
|
1
|
+
export { extractType, parseRecords, parseStringSync } from './api.ts';
|
|
2
|
+
export type { GffFeature, LineRecord, ParsedRecord } from './api.ts';
|
package/esm/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export { extractType, parseRecords,
|
|
1
|
+
export { extractType, parseRecords, parseStringSync } from "./api.js";
|
|
2
2
|
//# sourceMappingURL=index.js.map
|
package/esm/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,YAAY,EAAE,eAAe,EAAE,MAAM,UAAU,CAAA"}
|
package/esm/util.d.ts
CHANGED
|
@@ -6,122 +6,11 @@
|
|
|
6
6
|
*/
|
|
7
7
|
export declare function unescape(stringVal: string): string;
|
|
8
8
|
/**
|
|
9
|
-
*
|
|
10
|
-
*
|
|
11
|
-
*
|
|
12
|
-
* @returns Parsed attributes
|
|
13
|
-
*/
|
|
14
|
-
export declare function parseAttributes(attrString: string): GFF3Attributes;
|
|
15
|
-
/**
|
|
16
|
-
* Parse the 9th column (attributes) of a GFF3 feature line without unescaping.
|
|
17
|
-
* Fast path for data known to contain no escaped characters.
|
|
18
|
-
*
|
|
19
|
-
* @param attrString - String of GFF3 9th column
|
|
20
|
-
* @returns Parsed attributes
|
|
21
|
-
*/
|
|
22
|
-
export declare function parseAttributesNoUnescape(attrString: string): GFF3Attributes;
|
|
23
|
-
/**
|
|
24
|
-
* Parse a GFF3 feature line
|
|
25
|
-
*
|
|
26
|
-
* @param line - GFF3 feature line
|
|
27
|
-
* @returns The parsed feature
|
|
9
|
+
* A parsed GFF3 feature: a flat object with 0-based half-open coordinates,
|
|
10
|
+
* numeric strand (`1`/`-1`/`0`), attributes spread as lowercase top-level keys,
|
|
11
|
+
* and child features nested under `subfeatures`.
|
|
28
12
|
*/
|
|
29
|
-
export
|
|
30
|
-
/**
|
|
31
|
-
* Parse a GFF3 feature line without unescaping.
|
|
32
|
-
* Fast path for data known to contain no escaped characters.
|
|
33
|
-
*
|
|
34
|
-
* @param line - GFF3 feature line
|
|
35
|
-
* @returns The parsed feature
|
|
36
|
-
*/
|
|
37
|
-
export declare function parseFeatureNoUnescape(line: string): GFF3FeatureLine;
|
|
38
|
-
/**
|
|
39
|
-
* Parse a GFF3 directive line.
|
|
40
|
-
*
|
|
41
|
-
* @param line - GFF3 directive line
|
|
42
|
-
* @returns The parsed directive
|
|
43
|
-
*/
|
|
44
|
-
export declare function parseDirective(line: string): GFF3Directive | GFF3SequenceRegionDirective | GFF3GenomeBuildDirective | null;
|
|
45
|
-
/** A record of GFF3 attribute identifiers and the values of those identifiers */
|
|
46
|
-
export type GFF3Attributes = Record<string, string[] | undefined>;
|
|
47
|
-
/** A representation of a single line of a GFF3 file */
|
|
48
|
-
export interface GFF3FeatureLine {
|
|
49
|
-
/** The ID of the landmark used to establish the coordinate system for the current feature */
|
|
50
|
-
seq_id: string | null;
|
|
51
|
-
/** A free text qualifier intended to describe the algorithm or operating procedure that generated this feature */
|
|
52
|
-
source: string | null;
|
|
53
|
-
/** The type of the feature */
|
|
54
|
-
type: string | null;
|
|
55
|
-
/** The start coordinates of the feature */
|
|
56
|
-
start: number | null;
|
|
57
|
-
/** The end coordinates of the feature */
|
|
58
|
-
end: number | null;
|
|
59
|
-
/** The score of the feature */
|
|
60
|
-
score: number | null;
|
|
61
|
-
/** The strand of the feature */
|
|
62
|
-
strand: string | null;
|
|
63
|
-
/** For features of type "CDS", the phase indicates where the next codon begins relative to the 5' end of the current CDS feature */
|
|
64
|
-
phase: string | null;
|
|
65
|
-
/** Feature attributes */
|
|
66
|
-
attributes: GFF3Attributes | null;
|
|
67
|
-
}
|
|
68
|
-
/**
|
|
69
|
-
* A GFF3 Feature line that includes references to other features defined in
|
|
70
|
-
* their "Parent" or "Derives_from" attributes
|
|
71
|
-
*/
|
|
72
|
-
export interface GFF3FeatureLineWithRefs extends GFF3FeatureLine {
|
|
73
|
-
/** An array of child features */
|
|
74
|
-
child_features: GFF3Feature[];
|
|
75
|
-
/** An array of features derived from this feature */
|
|
76
|
-
derived_features: GFF3Feature[];
|
|
77
|
-
}
|
|
78
|
-
/**
|
|
79
|
-
* A GFF3 feature, which may include multiple individual feature lines
|
|
80
|
-
*/
|
|
81
|
-
export type GFF3Feature = GFF3FeatureLineWithRefs[];
|
|
82
|
-
/** A GFF3 directive */
|
|
83
|
-
export interface GFF3Directive {
|
|
84
|
-
/** The name of the directive */
|
|
85
|
-
directive: string;
|
|
86
|
-
/** The string value of the directive */
|
|
87
|
-
value?: string;
|
|
88
|
-
}
|
|
89
|
-
/** A GFF3 sequence-region directive */
|
|
90
|
-
export interface GFF3SequenceRegionDirective extends GFF3Directive {
|
|
91
|
-
/** The string value of the directive */
|
|
92
|
-
value: string;
|
|
93
|
-
/** The sequence ID parsed from the directive */
|
|
94
|
-
seq_id: string;
|
|
95
|
-
/** The sequence start parsed from the directive */
|
|
96
|
-
start: string;
|
|
97
|
-
/** The sequence end parsed from the directive */
|
|
98
|
-
end: string;
|
|
99
|
-
}
|
|
100
|
-
/** A GFF3 genome-build directive */
|
|
101
|
-
export interface GFF3GenomeBuildDirective extends GFF3Directive {
|
|
102
|
-
/** The string value of the directive */
|
|
103
|
-
value: string;
|
|
104
|
-
/** The genome build source parsed from the directive */
|
|
105
|
-
source: string;
|
|
106
|
-
/** The genome build name parsed from the directive */
|
|
107
|
-
buildName: string;
|
|
108
|
-
}
|
|
109
|
-
/** A GFF3 comment */
|
|
110
|
-
export interface GFF3Comment {
|
|
111
|
-
/** The text of the comment */
|
|
112
|
-
comment: string;
|
|
113
|
-
}
|
|
114
|
-
/** A GFF3 FASTA single sequence */
|
|
115
|
-
export interface GFF3Sequence {
|
|
116
|
-
/** The ID of the sequence */
|
|
117
|
-
id: string;
|
|
118
|
-
/** The description of the sequence */
|
|
119
|
-
description?: string;
|
|
120
|
-
/** The sequence */
|
|
121
|
-
sequence: string;
|
|
122
|
-
}
|
|
123
|
-
export type GFF3Item = GFF3Feature | GFF3Directive | GFF3Comment | GFF3Sequence;
|
|
124
|
-
export interface JBrowseFeature {
|
|
13
|
+
export interface GffFeature {
|
|
125
14
|
start: number;
|
|
126
15
|
end: number;
|
|
127
16
|
strand?: number;
|
|
@@ -130,10 +19,20 @@ export interface JBrowseFeature {
|
|
|
130
19
|
refName: string;
|
|
131
20
|
phase?: number;
|
|
132
21
|
score?: number;
|
|
133
|
-
subfeatures:
|
|
22
|
+
subfeatures: GffFeature[];
|
|
134
23
|
[key: string]: unknown;
|
|
135
24
|
}
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
25
|
+
/**
|
|
26
|
+
* Parse the 9th column (attributes) of a GFF3 feature line into `result`,
|
|
27
|
+
* lowercasing keys and suffixing any that collide with a default field name.
|
|
28
|
+
* Pass shouldUnescape=false as a fast path for data with no escaped characters.
|
|
29
|
+
*/
|
|
30
|
+
export declare function parseAttributes(attrString: string, result: Record<string, unknown>, shouldUnescape: boolean): void;
|
|
31
|
+
/**
|
|
32
|
+
* Parse a GFF3 feature line. Unescaping is skipped entirely for lines with no
|
|
33
|
+
* '%' character, which is the common case.
|
|
34
|
+
*
|
|
35
|
+
* @param line - GFF3 feature line
|
|
36
|
+
* @returns The parsed feature
|
|
37
|
+
*/
|
|
38
|
+
export declare function parseFeature(line: string): GffFeature;
|