gff-nostream 3.0.10 → 4.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 +33 -89
- package/dist/api.d.ts +6 -21
- package/dist/api.js +29 -122
- 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 +20 -120
- package/dist/util.js +29 -179
- package/dist/util.js.map +1 -1
- package/esm/api.d.ts +6 -21
- package/esm/api.js +30 -121
- 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 +20 -120
- package/esm/util.js +29 -172
- package/esm/util.js.map +1 -1
- package/package.json +5 -5
- package/src/api.ts +39 -150
- package/src/index.ts +2 -18
- package/src/util.ts +39 -308
package/README.md
CHANGED
|
@@ -19,92 +19,26 @@ import fs from 'fs'
|
|
|
19
19
|
const features = parseStringSync(fs.readFileSync('my_annotations.gff3', 'utf8'))
|
|
20
20
|
```
|
|
21
21
|
|
|
22
|
-
|
|
23
|
-
example from `fetch`:
|
|
22
|
+
In the browser or other non-Node environments, pass any GFF3 string directly —
|
|
23
|
+
for example from `fetch`:
|
|
24
24
|
|
|
25
25
|
```js
|
|
26
|
-
import {
|
|
26
|
+
import { parseStringSync } from 'gff-nostream'
|
|
27
27
|
|
|
28
28
|
const text = await fetch('my_annotations.gff3').then(r => r.text())
|
|
29
|
-
const features =
|
|
29
|
+
const features = parseStringSync(text)
|
|
30
30
|
```
|
|
31
31
|
|
|
32
32
|
## Object format
|
|
33
33
|
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
Features are returned as arrays of all lines sharing the same ID (to represent
|
|
37
|
-
multi-location features). Values that are `.` in GFF3 are `null` in the output.
|
|
38
|
-
|
|
39
|
-
A simple feature located in one place:
|
|
40
|
-
|
|
41
|
-
```json
|
|
42
|
-
[
|
|
43
|
-
{
|
|
44
|
-
"seq_id": "ctg123",
|
|
45
|
-
"source": null,
|
|
46
|
-
"type": "gene",
|
|
47
|
-
"start": 1000,
|
|
48
|
-
"end": 9000,
|
|
49
|
-
"score": null,
|
|
50
|
-
"strand": "+",
|
|
51
|
-
"phase": null,
|
|
52
|
-
"attributes": {
|
|
53
|
-
"ID": ["gene00001"],
|
|
54
|
-
"Name": ["EDEN"]
|
|
55
|
-
},
|
|
56
|
-
"child_features": [],
|
|
57
|
-
"derived_features": []
|
|
58
|
-
}
|
|
59
|
-
]
|
|
60
|
-
```
|
|
61
|
-
|
|
62
|
-
A CDS called `cds00001` located in two places:
|
|
63
|
-
|
|
64
|
-
```json
|
|
65
|
-
[
|
|
66
|
-
{
|
|
67
|
-
"seq_id": "ctg123",
|
|
68
|
-
"source": null,
|
|
69
|
-
"type": "CDS",
|
|
70
|
-
"start": 1201,
|
|
71
|
-
"end": 1500,
|
|
72
|
-
"score": null,
|
|
73
|
-
"strand": "+",
|
|
74
|
-
"phase": "0",
|
|
75
|
-
"attributes": {
|
|
76
|
-
"ID": ["cds00001"],
|
|
77
|
-
"Parent": ["mRNA00001"]
|
|
78
|
-
},
|
|
79
|
-
"child_features": [],
|
|
80
|
-
"derived_features": []
|
|
81
|
-
},
|
|
82
|
-
{
|
|
83
|
-
"seq_id": "ctg123",
|
|
84
|
-
"source": null,
|
|
85
|
-
"type": "CDS",
|
|
86
|
-
"start": 3000,
|
|
87
|
-
"end": 3902,
|
|
88
|
-
"score": null,
|
|
89
|
-
"strand": "+",
|
|
90
|
-
"phase": "0",
|
|
91
|
-
"attributes": {
|
|
92
|
-
"ID": ["cds00001"],
|
|
93
|
-
"Parent": ["mRNA00001"]
|
|
94
|
-
},
|
|
95
|
-
"child_features": [],
|
|
96
|
-
"derived_features": []
|
|
97
|
-
}
|
|
98
|
-
]
|
|
99
|
-
```
|
|
100
|
-
|
|
101
|
-
### JBrowse format
|
|
102
|
-
|
|
103
|
-
The `JBrowse` variants return flat objects with coordinates converted to 0-based
|
|
34
|
+
Features are returned as flat objects with coordinates converted to 0-based
|
|
104
35
|
half-open, `strand` as a number (`1`/`-1`/`0`), attributes spread as lowercase
|
|
105
|
-
top-level keys,
|
|
36
|
+
top-level keys, single-valued attributes unwrapped from their array, and child
|
|
37
|
+
features nested under `subfeatures`. An attribute whose lowercased name collides
|
|
38
|
+
with a built-in field (e.g. `Start`, `Type`) is suffixed with `2` (`start2`,
|
|
39
|
+
`type2`).
|
|
106
40
|
|
|
107
|
-
|
|
41
|
+
A gene with an mRNA child:
|
|
108
42
|
|
|
109
43
|
```json
|
|
110
44
|
{
|
|
@@ -114,34 +48,44 @@ The same gene feature in JBrowse format:
|
|
|
114
48
|
"start": 999,
|
|
115
49
|
"end": 9000,
|
|
116
50
|
"strand": 1,
|
|
117
|
-
"subfeatures": [],
|
|
118
51
|
"id": "gene00001",
|
|
119
|
-
"name": "EDEN"
|
|
52
|
+
"name": "EDEN",
|
|
53
|
+
"subfeatures": [
|
|
54
|
+
{
|
|
55
|
+
"refName": "ctg123",
|
|
56
|
+
"source": null,
|
|
57
|
+
"type": "mRNA",
|
|
58
|
+
"start": 1049,
|
|
59
|
+
"end": 9000,
|
|
60
|
+
"strand": 1,
|
|
61
|
+
"id": "mRNA00001",
|
|
62
|
+
"parent": "gene00001",
|
|
63
|
+
"subfeatures": []
|
|
64
|
+
}
|
|
65
|
+
]
|
|
120
66
|
}
|
|
121
67
|
```
|
|
122
68
|
|
|
123
|
-
|
|
124
|
-
|
|
69
|
+
Multi-location features (the same ID on multiple lines, such as a CDS spanning
|
|
70
|
+
several segments) are not merged — each line is its own flat feature, attached
|
|
71
|
+
to its parent (or kept as a top-level item) independently.
|
|
125
72
|
|
|
126
73
|
## API
|
|
127
74
|
|
|
128
|
-
### `parseStringSync(str: string):
|
|
75
|
+
### `parseStringSync(str: string): GffFeature[]`
|
|
129
76
|
|
|
130
77
|
Synchronously parse a GFF3 string and return an array of features. Comments,
|
|
131
78
|
directives, and `##FASTA` sections are ignored.
|
|
132
79
|
|
|
133
|
-
### `
|
|
134
|
-
|
|
135
|
-
Synchronously parse a GFF3 string and return features in JBrowse format.
|
|
136
|
-
|
|
137
|
-
### `parseRecords(records: LineRecord[]): GFF3Feature[]`
|
|
80
|
+
### `parseRecords(records: LineRecord[]): GffFeature[]`
|
|
138
81
|
|
|
139
82
|
Parse an array of `LineRecord` objects. Useful when managing raw line data
|
|
140
83
|
directly (e.g. from a tabix-indexed file with byte offsets).
|
|
141
84
|
|
|
142
|
-
### `
|
|
85
|
+
### `extractType(line: string): string`
|
|
143
86
|
|
|
144
|
-
|
|
87
|
+
Extract the feature type (GFF3 column 3) from a raw line without fully splitting
|
|
88
|
+
it.
|
|
145
89
|
|
|
146
90
|
### `LineRecord`
|
|
147
91
|
|
|
@@ -149,7 +93,7 @@ Same as `parseRecords` but returns JBrowse-format features.
|
|
|
149
93
|
interface LineRecord {
|
|
150
94
|
line: string
|
|
151
95
|
hasEscapes: boolean // set true when line contains '%' to enable URL-decoding
|
|
152
|
-
lineHash?: string | number // propagated to
|
|
96
|
+
lineHash?: string | number // propagated to the feature's _lineHash field
|
|
153
97
|
start?: number // byte offset passthrough (not used by the parser)
|
|
154
98
|
end?: number // byte offset passthrough (not used by the parser)
|
|
155
99
|
}
|
package/dist/api.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { GffFeature } from './util.ts';
|
|
2
2
|
interface ParseInput {
|
|
3
3
|
line: string;
|
|
4
4
|
lineHash?: string | number;
|
|
@@ -16,33 +16,18 @@ export interface LineRecord extends ParseInput {
|
|
|
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
|
|
19
|
+
* parsed features. Comments, directives, and `##FASTA` sections are ignored.
|
|
20
20
|
*
|
|
21
21
|
* @param str - GFF3 string
|
|
22
22
|
* @returns array of parsed features
|
|
23
23
|
*/
|
|
24
|
-
export declare function parseStringSync(str: string):
|
|
25
|
-
/**
|
|
26
|
-
* Synchronously parse a string containing GFF3 directly into JBrowse format.
|
|
27
|
-
*
|
|
28
|
-
* @param str - GFF3 string
|
|
29
|
-
* @returns array of JBrowse-format features
|
|
30
|
-
*/
|
|
31
|
-
export declare function parseStringSyncJBrowse(str: string): JBrowseFeature[];
|
|
24
|
+
export declare function parseStringSync(str: string): GffFeature[];
|
|
32
25
|
/**
|
|
33
26
|
* 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
|
-
* @returns array of parsed features
|
|
38
|
-
*/
|
|
39
|
-
export declare function parseRecords(records: ParseInput[]): GFF3Feature[];
|
|
40
|
-
/**
|
|
41
|
-
* Parse an array of LineRecord objects directly into JBrowse feature format.
|
|
42
27
|
* Supports parent/child relationships via subfeatures.
|
|
43
28
|
*
|
|
44
29
|
* @param records - Array of LineRecord objects with raw line and metadata
|
|
45
|
-
* @returns array of
|
|
30
|
+
* @returns array of parsed features
|
|
46
31
|
*/
|
|
47
|
-
export declare function
|
|
48
|
-
export type {
|
|
32
|
+
export declare function parseRecords(records: ParseInput[]): GffFeature[];
|
|
33
|
+
export type { GffFeature } from './util.ts';
|
package/dist/api.js
CHANGED
|
@@ -2,9 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.extractType = extractType;
|
|
4
4
|
exports.parseStringSync = parseStringSync;
|
|
5
|
-
exports.parseStringSyncJBrowse = parseStringSyncJBrowse;
|
|
6
5
|
exports.parseRecords = parseRecords;
|
|
7
|
-
exports.parseRecordsJBrowse = parseRecordsJBrowse;
|
|
8
6
|
const util_ts_1 = require("./util.js");
|
|
9
7
|
/** Extract the GFF3 feature type (column 3) from a raw line without a full split. */
|
|
10
8
|
function extractType(line) {
|
|
@@ -24,8 +22,8 @@ function appendOrphan(orphans, key, value) {
|
|
|
24
22
|
}
|
|
25
23
|
}
|
|
26
24
|
/**
|
|
27
|
-
* The
|
|
28
|
-
*
|
|
25
|
+
* The parser collapses single-element attribute arrays to scalars, so a raw
|
|
26
|
+
* ID/Parent value can be a string, a string array, or absent. These coerce
|
|
29
27
|
* those `unknown` values without typecasts.
|
|
30
28
|
*/
|
|
31
29
|
function firstString(value) {
|
|
@@ -40,7 +38,7 @@ function toStringArray(value) {
|
|
|
40
38
|
}
|
|
41
39
|
/**
|
|
42
40
|
* Synchronously parse a string containing GFF3 and return an array of the
|
|
43
|
-
* parsed
|
|
41
|
+
* parsed features. Comments, directives, and `##FASTA` sections are ignored.
|
|
44
42
|
*
|
|
45
43
|
* @param str - GFF3 string
|
|
46
44
|
* @returns array of parsed features
|
|
@@ -48,15 +46,6 @@ function toStringArray(value) {
|
|
|
48
46
|
function parseStringSync(str) {
|
|
49
47
|
return parseRecords(stringToRecords(str));
|
|
50
48
|
}
|
|
51
|
-
/**
|
|
52
|
-
* Synchronously parse a string containing GFF3 directly into JBrowse format.
|
|
53
|
-
*
|
|
54
|
-
* @param str - GFF3 string
|
|
55
|
-
* @returns array of JBrowse-format features
|
|
56
|
-
*/
|
|
57
|
-
function parseStringSyncJBrowse(str) {
|
|
58
|
-
return parseRecordsJBrowse(stringToRecords(str));
|
|
59
|
-
}
|
|
60
49
|
function stringToRecords(str) {
|
|
61
50
|
const lines = str.split(/\r?\n/);
|
|
62
51
|
const records = [];
|
|
@@ -76,7 +65,7 @@ function stringToRecords(str) {
|
|
|
76
65
|
}
|
|
77
66
|
/**
|
|
78
67
|
* Parse an array of LineRecord objects containing raw GFF3 lines.
|
|
79
|
-
* Supports parent/child relationships.
|
|
68
|
+
* Supports parent/child relationships via subfeatures.
|
|
80
69
|
*
|
|
81
70
|
* @param records - Array of LineRecord objects with raw line and metadata
|
|
82
71
|
* @returns array of parsed features
|
|
@@ -86,122 +75,40 @@ function parseRecords(records) {
|
|
|
86
75
|
const byId = new Map();
|
|
87
76
|
const orphans = new Map();
|
|
88
77
|
for (const record of records) {
|
|
89
|
-
const
|
|
90
|
-
? (0, util_ts_1.parseFeature)(record.line)
|
|
91
|
-
: (0, util_ts_1.parseFeatureNoUnescape)(record.line);
|
|
92
|
-
const featureLine = {
|
|
93
|
-
...parsed,
|
|
94
|
-
child_features: [],
|
|
95
|
-
derived_features: [],
|
|
96
|
-
};
|
|
97
|
-
if (record.lineHash !== undefined) {
|
|
98
|
-
featureLine.attributes ??= {};
|
|
99
|
-
featureLine.attributes._lineHash = [String(record.lineHash)];
|
|
100
|
-
}
|
|
101
|
-
const attrs = featureLine.attributes;
|
|
102
|
-
const ids = attrs?.ID;
|
|
103
|
-
const parents = attrs?.Parent;
|
|
104
|
-
if (!ids && !parents) {
|
|
105
|
-
items.push([featureLine]);
|
|
106
|
-
}
|
|
107
|
-
else {
|
|
108
|
-
let feature;
|
|
109
|
-
if (ids) {
|
|
110
|
-
const id = ids[0];
|
|
111
|
-
const existing = byId.get(id);
|
|
112
|
-
if (existing) {
|
|
113
|
-
// Multi-location continuation: share child_features/derived_features
|
|
114
|
-
// with the first line so children remain visible across all lines
|
|
115
|
-
// regardless of arrival order.
|
|
116
|
-
featureLine.child_features = existing[0].child_features;
|
|
117
|
-
featureLine.derived_features = existing[0].derived_features;
|
|
118
|
-
existing.push(featureLine);
|
|
119
|
-
feature = existing;
|
|
120
|
-
}
|
|
121
|
-
else {
|
|
122
|
-
feature = [featureLine];
|
|
123
|
-
if (!parents) {
|
|
124
|
-
items.push(feature);
|
|
125
|
-
}
|
|
126
|
-
byId.set(id, feature);
|
|
127
|
-
const waiting = orphans.get(id);
|
|
128
|
-
if (waiting) {
|
|
129
|
-
for (const w of waiting) {
|
|
130
|
-
featureLine.child_features.push(w);
|
|
131
|
-
}
|
|
132
|
-
orphans.delete(id);
|
|
133
|
-
}
|
|
134
|
-
}
|
|
135
|
-
}
|
|
136
|
-
else {
|
|
137
|
-
feature = [featureLine];
|
|
138
|
-
}
|
|
139
|
-
if (parents) {
|
|
140
|
-
for (const parentId of parents) {
|
|
141
|
-
const parent = byId.get(parentId);
|
|
142
|
-
if (parent) {
|
|
143
|
-
// child_features is shared across all parent feature lines,
|
|
144
|
-
// so push once via the first line.
|
|
145
|
-
parent[0].child_features.push(feature);
|
|
146
|
-
}
|
|
147
|
-
else {
|
|
148
|
-
appendOrphan(orphans, parentId, feature);
|
|
149
|
-
}
|
|
150
|
-
}
|
|
151
|
-
}
|
|
152
|
-
}
|
|
153
|
-
}
|
|
154
|
-
return items;
|
|
155
|
-
}
|
|
156
|
-
/**
|
|
157
|
-
* Parse an array of LineRecord objects directly into JBrowse feature format.
|
|
158
|
-
* Supports parent/child relationships via subfeatures.
|
|
159
|
-
*
|
|
160
|
-
* @param records - Array of LineRecord objects with raw line and metadata
|
|
161
|
-
* @returns array of JBrowse-format features
|
|
162
|
-
*/
|
|
163
|
-
function parseRecordsJBrowse(records) {
|
|
164
|
-
const items = [];
|
|
165
|
-
const byId = new Map();
|
|
166
|
-
const orphans = new Map();
|
|
167
|
-
for (const record of records) {
|
|
168
|
-
const feature = record.hasEscapes
|
|
169
|
-
? (0, util_ts_1.parseFeatureJBrowse)(record.line)
|
|
170
|
-
: (0, util_ts_1.parseFeatureJBrowseNoUnescape)(record.line);
|
|
78
|
+
const feature = (0, util_ts_1.parseFeature)(record.line, record.hasEscapes);
|
|
171
79
|
if (record.lineHash !== undefined) {
|
|
172
80
|
feature._lineHash = String(record.lineHash);
|
|
173
81
|
}
|
|
174
82
|
const id = firstString(feature.id);
|
|
175
83
|
const parents = toStringArray(feature.parent);
|
|
176
|
-
|
|
84
|
+
// A parentless line is a top-level item. Every line of a top-level
|
|
85
|
+
// discontinuous feature (e.g. cDNA_match/EST_match spanning several
|
|
86
|
+
// segments under one shared ID, with no Parent) is its own top-level
|
|
87
|
+
// item, so push regardless of whether the id is already registered.
|
|
88
|
+
if (parents.length === 0) {
|
|
177
89
|
items.push(feature);
|
|
178
90
|
}
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
const waiting = orphans.get(id);
|
|
190
|
-
if (waiting) {
|
|
191
|
-
for (const w of waiting) {
|
|
192
|
-
feature.subfeatures.push(w);
|
|
193
|
-
}
|
|
194
|
-
orphans.delete(id);
|
|
91
|
+
// Register the id only the first time it is seen. Continuation lines
|
|
92
|
+
// (multi-location features such as a CDS spanning several segments share
|
|
93
|
+
// one ID across lines) skip registration but must still be attached to
|
|
94
|
+
// their parent below, so this is independent of the parent handling.
|
|
95
|
+
if (id && !byId.has(id)) {
|
|
96
|
+
byId.set(id, feature);
|
|
97
|
+
const waiting = orphans.get(id);
|
|
98
|
+
if (waiting) {
|
|
99
|
+
for (const w of waiting) {
|
|
100
|
+
feature.subfeatures.push(w);
|
|
195
101
|
}
|
|
102
|
+
orphans.delete(id);
|
|
196
103
|
}
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
104
|
+
}
|
|
105
|
+
for (const parentId of parents) {
|
|
106
|
+
const parentFeature = byId.get(parentId);
|
|
107
|
+
if (parentFeature) {
|
|
108
|
+
parentFeature.subfeatures.push(feature);
|
|
109
|
+
}
|
|
110
|
+
else {
|
|
111
|
+
appendOrphan(orphans, parentId, feature);
|
|
205
112
|
}
|
|
206
113
|
}
|
|
207
114
|
}
|
package/dist/api.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"api.js","sourceRoot":"","sources":["../src/api.ts"],"names":[],"mappings":";;
|
|
1
|
+
{"version":3,"file":"api.js","sourceRoot":"","sources":["../src/api.ts"],"names":[],"mappings":";;AAoBA,kCAKC;AAoCD,0CAEC;AA2BD,oCAiDC;AA3ID,uCAAwC;AAmBxC,qFAAqF;AACrF,SAAgB,WAAW,C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seRecords,
|
|
2
|
-
export type {
|
|
1
|
+
export { extractType, parseRecords, parseStringSync } from './api.ts';
|
|
2
|
+
export type { GffFeature, LineRecord } from './api.ts';
|
package/dist/index.js
CHANGED
|
@@ -1,10 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.parseStringSync = exports.parseRecords = exports.extractType = void 0;
|
|
4
4
|
var api_ts_1 = require("./api.js");
|
|
5
5
|
Object.defineProperty(exports, "extractType", { enumerable: true, get: function () { return api_ts_1.extractType; } });
|
|
6
6
|
Object.defineProperty(exports, "parseRecords", { enumerable: true, get: function () { return api_ts_1.parseRecords; } });
|
|
7
|
-
Object.defineProperty(exports, "parseRecordsJBrowse", { enumerable: true, get: function () { return api_ts_1.parseRecordsJBrowse; } });
|
|
8
7
|
Object.defineProperty(exports, "parseStringSync", { enumerable: true, get: function () { return api_ts_1.parseStringSync; } });
|
|
9
|
-
Object.defineProperty(exports, "parseStringSyncJBrowse", { enumerable: true, get: function () { return api_ts_1.parseStringSyncJBrowse; } });
|
|
10
8
|
//# 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,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;AAAA,mCAAqE;AAA5D,qGAAA,WAAW,OAAA;AAAE,sGAAA,YAAY,OAAA;AAAE,yGAAA,eAAe,OAAA"}
|
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,21 @@ 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. Pass shouldUnescape=false as a fast path for data
|
|
33
|
+
* known to contain no escaped characters.
|
|
34
|
+
*
|
|
35
|
+
* @param line - GFF3 feature line
|
|
36
|
+
* @param shouldUnescape - whether to unescape percent-encoded values
|
|
37
|
+
* @returns The parsed feature
|
|
38
|
+
*/
|
|
39
|
+
export declare function parseFeature(line: string, shouldUnescape: boolean): GffFeature;
|