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/dist/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;
|
package/dist/util.js
CHANGED
|
@@ -1,20 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
// Fast, low-level functions for parsing
|
|
2
|
+
// Fast, low-level functions for parsing GFF3.
|
|
3
3
|
// JavaScript port of Robert Buels's Bio::GFF3::LowLevel Perl module.
|
|
4
4
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
5
5
|
exports.unescape = unescape;
|
|
6
6
|
exports.parseAttributes = parseAttributes;
|
|
7
|
-
exports.parseAttributesNoUnescape = parseAttributesNoUnescape;
|
|
8
7
|
exports.parseFeature = parseFeature;
|
|
9
|
-
exports.parseFeatureNoUnescape = parseFeatureNoUnescape;
|
|
10
|
-
exports.parseDirective = parseDirective;
|
|
11
|
-
exports.parseAttributesJBrowse = parseAttributesJBrowse;
|
|
12
|
-
exports.parseAttributesJBrowseNoUnescape = parseAttributesJBrowseNoUnescape;
|
|
13
|
-
exports.parseFeatureJBrowse = parseFeatureJBrowse;
|
|
14
|
-
exports.parseFeatureJBrowseNoUnescape = parseFeatureJBrowseNoUnescape;
|
|
15
|
-
const directiveRegex = /^\s*##\s*(\S+)\s*(.*)/;
|
|
16
|
-
const whitespaceRegex = /\s+/;
|
|
17
|
-
const nonDigitRegex = /\D/g;
|
|
18
8
|
const HEX_LOOKUP = {};
|
|
19
9
|
for (let i = 0; i < 256; i++) {
|
|
20
10
|
const hex = i.toString(16).toUpperCase().padStart(2, '0');
|
|
@@ -36,169 +26,28 @@ function unescape(stringVal) {
|
|
|
36
26
|
let lastIdx = 0;
|
|
37
27
|
let i = idx;
|
|
38
28
|
while (i < stringVal.length) {
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
result += char;
|
|
45
|
-
}
|
|
46
|
-
else {
|
|
47
|
-
result += stringVal.slice(i, i + 3);
|
|
48
|
-
}
|
|
29
|
+
const char = stringVal[i] === '%' && i + 2 < stringVal.length
|
|
30
|
+
? HEX_LOOKUP[stringVal.slice(i + 1, i + 3)]
|
|
31
|
+
: undefined;
|
|
32
|
+
if (char !== undefined) {
|
|
33
|
+
result += stringVal.slice(lastIdx, i) + char;
|
|
49
34
|
i += 3;
|
|
50
35
|
lastIdx = i;
|
|
51
36
|
}
|
|
52
37
|
else {
|
|
38
|
+
// Not a valid escape: advance one char so a '%' that begins a real
|
|
39
|
+
// escape immediately after isn't swallowed (e.g. the %20 in "a%b%20c").
|
|
53
40
|
i++;
|
|
54
41
|
}
|
|
55
42
|
}
|
|
56
43
|
return result + stringVal.slice(lastIdx);
|
|
57
44
|
}
|
|
58
|
-
function parseAttributesImpl(attrString, shouldUnescape) {
|
|
59
|
-
if (attrString.length === 0 || attrString === '.') {
|
|
60
|
-
return {};
|
|
61
|
-
}
|
|
62
|
-
const attrs = {};
|
|
63
|
-
let len = attrString.length;
|
|
64
|
-
if (attrString[len - 1] === '\n') {
|
|
65
|
-
len = attrString[len - 2] === '\r' ? len - 2 : len - 1;
|
|
66
|
-
attrString = attrString.slice(0, len);
|
|
67
|
-
}
|
|
68
|
-
let start = 0;
|
|
69
|
-
while (start < len) {
|
|
70
|
-
let semiIdx = attrString.indexOf(';', start);
|
|
71
|
-
if (semiIdx === -1) {
|
|
72
|
-
semiIdx = len;
|
|
73
|
-
}
|
|
74
|
-
if (semiIdx > start) {
|
|
75
|
-
const eqIdx = attrString.indexOf('=', start);
|
|
76
|
-
if (eqIdx !== -1 && eqIdx < semiIdx && eqIdx + 1 < semiIdx) {
|
|
77
|
-
const tag = attrString.slice(start, eqIdx);
|
|
78
|
-
let arec = attrs[tag];
|
|
79
|
-
if (!arec) {
|
|
80
|
-
arec = [];
|
|
81
|
-
attrs[tag] = arec;
|
|
82
|
-
}
|
|
83
|
-
let valStart = eqIdx + 1;
|
|
84
|
-
while (valStart < semiIdx) {
|
|
85
|
-
let commaIdx = attrString.indexOf(',', valStart);
|
|
86
|
-
if (commaIdx === -1 || commaIdx > semiIdx) {
|
|
87
|
-
commaIdx = semiIdx;
|
|
88
|
-
}
|
|
89
|
-
if (commaIdx > valStart) {
|
|
90
|
-
const val = attrString.slice(valStart, commaIdx);
|
|
91
|
-
arec.push(shouldUnescape ? unescape(val) : val);
|
|
92
|
-
}
|
|
93
|
-
valStart = commaIdx + 1;
|
|
94
|
-
}
|
|
95
|
-
}
|
|
96
|
-
}
|
|
97
|
-
start = semiIdx + 1;
|
|
98
|
-
}
|
|
99
|
-
return attrs;
|
|
100
|
-
}
|
|
101
|
-
/**
|
|
102
|
-
* Parse the 9th column (attributes) of a GFF3 feature line.
|
|
103
|
-
*
|
|
104
|
-
* @param attrString - String of GFF3 9th column
|
|
105
|
-
* @returns Parsed attributes
|
|
106
|
-
*/
|
|
107
|
-
function parseAttributes(attrString) {
|
|
108
|
-
return parseAttributesImpl(attrString, true);
|
|
109
|
-
}
|
|
110
|
-
/**
|
|
111
|
-
* Parse the 9th column (attributes) of a GFF3 feature line without unescaping.
|
|
112
|
-
* Fast path for data known to contain no escaped characters.
|
|
113
|
-
*
|
|
114
|
-
* @param attrString - String of GFF3 9th column
|
|
115
|
-
* @returns Parsed attributes
|
|
116
|
-
*/
|
|
117
|
-
function parseAttributesNoUnescape(attrString) {
|
|
118
|
-
return parseAttributesImpl(attrString, false);
|
|
119
|
-
}
|
|
120
45
|
function isEmpty(s) {
|
|
121
46
|
return s.length === 0 || s === '.';
|
|
122
47
|
}
|
|
123
48
|
function strField(s, shouldUnescape, empty) {
|
|
124
49
|
return isEmpty(s) ? empty : shouldUnescape ? unescape(s) : s;
|
|
125
50
|
}
|
|
126
|
-
function numField(s) {
|
|
127
|
-
return isEmpty(s) ? null : +s;
|
|
128
|
-
}
|
|
129
|
-
function parseFeatureImpl(line, shouldUnescape) {
|
|
130
|
-
const f = line.split('\t');
|
|
131
|
-
const attrString = f[8];
|
|
132
|
-
return {
|
|
133
|
-
seq_id: strField(f[0], shouldUnescape, null),
|
|
134
|
-
source: strField(f[1], shouldUnescape, null),
|
|
135
|
-
type: strField(f[2], shouldUnescape, null),
|
|
136
|
-
start: numField(f[3]),
|
|
137
|
-
end: numField(f[4]),
|
|
138
|
-
score: numField(f[5]),
|
|
139
|
-
strand: strField(f[6], false, null),
|
|
140
|
-
phase: strField(f[7], false, null),
|
|
141
|
-
attributes: isEmpty(attrString)
|
|
142
|
-
? null
|
|
143
|
-
: parseAttributesImpl(attrString, shouldUnescape),
|
|
144
|
-
};
|
|
145
|
-
}
|
|
146
|
-
/**
|
|
147
|
-
* Parse a GFF3 feature line
|
|
148
|
-
*
|
|
149
|
-
* @param line - GFF3 feature line
|
|
150
|
-
* @returns The parsed feature
|
|
151
|
-
*/
|
|
152
|
-
function parseFeature(line) {
|
|
153
|
-
return parseFeatureImpl(line, true);
|
|
154
|
-
}
|
|
155
|
-
/**
|
|
156
|
-
* Parse a GFF3 feature line without unescaping.
|
|
157
|
-
* Fast path for data known to contain no escaped characters.
|
|
158
|
-
*
|
|
159
|
-
* @param line - GFF3 feature line
|
|
160
|
-
* @returns The parsed feature
|
|
161
|
-
*/
|
|
162
|
-
function parseFeatureNoUnescape(line) {
|
|
163
|
-
return parseFeatureImpl(line, false);
|
|
164
|
-
}
|
|
165
|
-
/**
|
|
166
|
-
* Parse a GFF3 directive line.
|
|
167
|
-
*
|
|
168
|
-
* @param line - GFF3 directive line
|
|
169
|
-
* @returns The parsed directive
|
|
170
|
-
*/
|
|
171
|
-
function parseDirective(line) {
|
|
172
|
-
const match = directiveRegex.exec(line);
|
|
173
|
-
if (!match) {
|
|
174
|
-
return null;
|
|
175
|
-
}
|
|
176
|
-
const name = match[1];
|
|
177
|
-
const contents = match[2];
|
|
178
|
-
const parsed = { directive: name };
|
|
179
|
-
if (contents.length) {
|
|
180
|
-
parsed.value = contents.trimEnd();
|
|
181
|
-
}
|
|
182
|
-
if (name === 'sequence-region') {
|
|
183
|
-
const c = contents.split(whitespaceRegex, 3);
|
|
184
|
-
return {
|
|
185
|
-
...parsed,
|
|
186
|
-
seq_id: c[0],
|
|
187
|
-
start: c[1].replaceAll(nonDigitRegex, ''),
|
|
188
|
-
end: c[2].replaceAll(nonDigitRegex, ''),
|
|
189
|
-
};
|
|
190
|
-
}
|
|
191
|
-
else if (name === 'genome-build') {
|
|
192
|
-
const [source, buildName] = contents.split(whitespaceRegex, 2);
|
|
193
|
-
return {
|
|
194
|
-
...parsed,
|
|
195
|
-
source: source,
|
|
196
|
-
buildName: buildName,
|
|
197
|
-
};
|
|
198
|
-
}
|
|
199
|
-
return parsed;
|
|
200
|
-
}
|
|
201
|
-
// JBrowse format types and parsing functions
|
|
202
51
|
const JBROWSE_DEFAULT_FIELDS = new Set([
|
|
203
52
|
'start',
|
|
204
53
|
'end',
|
|
@@ -232,7 +81,17 @@ const COMMON_ATTRS = {
|
|
|
232
81
|
target: 'target',
|
|
233
82
|
gap: 'gap',
|
|
234
83
|
};
|
|
235
|
-
|
|
84
|
+
const STRAND_MAP = {
|
|
85
|
+
'+': 1,
|
|
86
|
+
'-': -1,
|
|
87
|
+
'.': 0,
|
|
88
|
+
};
|
|
89
|
+
/**
|
|
90
|
+
* Parse the 9th column (attributes) of a GFF3 feature line into `result`,
|
|
91
|
+
* lowercasing keys and suffixing any that collide with a default field name.
|
|
92
|
+
* Pass shouldUnescape=false as a fast path for data with no escaped characters.
|
|
93
|
+
*/
|
|
94
|
+
function parseAttributes(attrString, result, shouldUnescape) {
|
|
236
95
|
if (attrString.length === 0 || attrString === '.') {
|
|
237
96
|
return;
|
|
238
97
|
}
|
|
@@ -277,19 +136,16 @@ function parseAttributesJBrowseImpl(attrString, result, shouldUnescape) {
|
|
|
277
136
|
start = semiIdx + 1;
|
|
278
137
|
}
|
|
279
138
|
}
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
'-': -1,
|
|
289
|
-
'.': 0,
|
|
290
|
-
};
|
|
291
|
-
function parseFeatureJBrowseImpl(line, shouldUnescape) {
|
|
139
|
+
/**
|
|
140
|
+
* Parse a GFF3 feature line. Unescaping is skipped entirely for lines with no
|
|
141
|
+
* '%' character, which is the common case.
|
|
142
|
+
*
|
|
143
|
+
* @param line - GFF3 feature line
|
|
144
|
+
* @returns The parsed feature
|
|
145
|
+
*/
|
|
146
|
+
function parseFeature(line) {
|
|
292
147
|
const f = line.split('\t');
|
|
148
|
+
const shouldUnescape = line.includes('%');
|
|
293
149
|
const startStr = f[3];
|
|
294
150
|
const endStr = f[4];
|
|
295
151
|
const scoreStr = f[5];
|
|
@@ -306,13 +162,7 @@ function parseFeatureJBrowseImpl(line, shouldUnescape) {
|
|
|
306
162
|
phase: isEmpty(phase) ? undefined : +phase,
|
|
307
163
|
subfeatures: [],
|
|
308
164
|
};
|
|
309
|
-
|
|
165
|
+
parseAttributes(attrString, result, shouldUnescape);
|
|
310
166
|
return result;
|
|
311
167
|
}
|
|
312
|
-
function parseFeatureJBrowse(line) {
|
|
313
|
-
return parseFeatureJBrowseImpl(line, true);
|
|
314
|
-
}
|
|
315
|
-
function parseFeatureJBrowseNoUnescape(line) {
|
|
316
|
-
return parseFeatureJBrowseImpl(line, false);
|
|
317
|
-
}
|
|
318
168
|
//# sourceMappingURL=util.js.map
|
package/dist/util.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"util.js","sourceRoot":"","sources":["../src/util.ts"],"names":[],"mappings":";AAAA,
|
|
1
|
+
{"version":3,"file":"util.js","sourceRoot":"","sources":["../src/util.ts"],"names":[],"mappings":";AAAA,8CAA8C;AAC9C,qEAAqE;;AAerE,4BA2BC;AA8ED,0CAqDC;AASD,oCAuBC;AA3MD,MAAM,UAAU,GAAuC,EAAE,CAAA;AACzD,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,GAAG,EAAE,CAAC,EAAE,EAAE,CAAC;IAC7B,MAAM,GAAG,GAAG,CAAC,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC,WAAW,EAAE,CAAC,QAAQ,CAAC,CAAC,EAAE,GAAG,CAAC,CAAA;IACzD,UAAU,CAAC,GAAG,CAAC,GAAG,MAAM,CAAC,YAAY,CAAC,CAAC,CAAC,CAAA;IACxC,UAAU,CAAC,GAAG,CAAC,WAAW,EAAE,CAAC,GAAG,MAAM,CAAC,YAAY,CAAC,CAAC,CAAC,CAAA;AACxD,CAAC;AAED;;;;;GAKG;AACH,SAAgB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AAE,IAAI,CAAC;QAC7C,IAAI,EAAE,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAE,EAAE,cAAc,EAAE,IAAI,CAAC;QAC3C,KAAK,EAAE,OAAO,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,QAAQ,GAAG,CAAC;QAC5C,GAAG,EAAE,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,MAAM;QAClC,KAAK,EAAE,OAAO,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,QAAQ;QAChD,MAAM,EAAE,UAAU,CAAC,CAAC,CAAC,CAAC,CAAE,CAAC;QACzB,KAAK,EAAE,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,KAAK;QAC1C,WAAW,EAAE,EAAE;KAChB,CAAA;IAED,eAAe,CAAC,UAAU,EAAE,MAAM,EAAE,cAAc,CAAC,CAAA;IACnD,OAAO,MAAM,CAAA;AACf,CAAC"}
|
package/esm/api.d.ts
CHANGED
|
@@ -1,48 +1,35 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
interface
|
|
1
|
+
import type { GffFeature } from './util.ts';
|
|
2
|
+
export interface LineRecord {
|
|
3
|
+
/** Raw GFF3 feature line */
|
|
3
4
|
line: string;
|
|
4
|
-
lineHash?: string | number;
|
|
5
|
-
hasEscapes: boolean;
|
|
6
5
|
}
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
6
|
+
/**
|
|
7
|
+
* A top-level parsed feature paired with the input record it came from. The
|
|
8
|
+
* parser stamps no identity onto the feature itself; callers that need a stable
|
|
9
|
+
* per-feature id (e.g. from a tabix byte offset) read it off their own `record`.
|
|
10
|
+
*/
|
|
11
|
+
export interface ParsedRecord<R extends LineRecord = LineRecord> {
|
|
12
|
+
feature: GffFeature;
|
|
13
|
+
record: R;
|
|
14
14
|
}
|
|
15
15
|
/** Extract the GFF3 feature type (column 3) from a raw line without a full split. */
|
|
16
16
|
export declare function extractType(line: string): string;
|
|
17
17
|
/**
|
|
18
18
|
* Synchronously parse a string containing GFF3 and return an array of the
|
|
19
|
-
* parsed
|
|
20
|
-
*
|
|
21
|
-
* @param str - GFF3 string
|
|
22
|
-
* @returns array of parsed features
|
|
23
|
-
*/
|
|
24
|
-
export declare function parseStringSync(str: string): GFF3Feature[];
|
|
25
|
-
/**
|
|
26
|
-
* Synchronously parse a string containing GFF3 directly into JBrowse format.
|
|
19
|
+
* parsed features. Comments, directives, and `##FASTA` sections are ignored.
|
|
27
20
|
*
|
|
28
21
|
* @param str - GFF3 string
|
|
29
|
-
* @returns array of JBrowse-format features
|
|
30
|
-
*/
|
|
31
|
-
export declare function parseStringSyncJBrowse(str: string): JBrowseFeature[];
|
|
32
|
-
/**
|
|
33
|
-
* Parse an array of LineRecord objects containing raw GFF3 lines.
|
|
34
|
-
* Supports parent/child relationships.
|
|
35
|
-
*
|
|
36
|
-
* @param records - Array of LineRecord objects with raw line and metadata
|
|
37
22
|
* @returns array of parsed features
|
|
38
23
|
*/
|
|
39
|
-
export declare function
|
|
24
|
+
export declare function parseStringSync(str: string): GffFeature[];
|
|
40
25
|
/**
|
|
41
|
-
* Parse an array of
|
|
42
|
-
*
|
|
26
|
+
* Parse an array of records wrapping raw GFF3 lines, resolving parent/child
|
|
27
|
+
* relationships into `subfeatures`. Returns each top-level feature paired with
|
|
28
|
+
* the record it came from, so callers can attach their own identity (e.g. a
|
|
29
|
+
* byte offset) without the parser stamping anything onto the feature.
|
|
43
30
|
*
|
|
44
|
-
* @param records - Array of
|
|
45
|
-
* @returns
|
|
31
|
+
* @param records - Array of records, each carrying a raw GFF3 `line`
|
|
32
|
+
* @returns top-level features, each paired with its originating record
|
|
46
33
|
*/
|
|
47
|
-
export declare function
|
|
48
|
-
export type {
|
|
34
|
+
export declare function parseRecords<R extends LineRecord>(records: readonly R[]): ParsedRecord<R>[];
|
|
35
|
+
export type { GffFeature } from './util.ts';
|