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/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,44 +48,65 @@ 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.
|
|
80
|
+
### `parseRecords<R>(records: readonly R[]): ParsedRecord<R>[]`
|
|
136
81
|
|
|
137
|
-
|
|
82
|
+
Parse an array of records wrapping raw GFF3 lines. Useful when managing raw line
|
|
83
|
+
data directly (e.g. from a tabix-indexed file). Each top-level feature is
|
|
84
|
+
returned paired with the record it came from, so a caller can attach its own
|
|
85
|
+
stable id (a byte offset, a hash, …) without the parser stamping anything onto
|
|
86
|
+
the feature. Records may carry extra fields (`R` is inferred), which pass
|
|
87
|
+
through untouched on `record`.
|
|
138
88
|
|
|
139
|
-
|
|
140
|
-
|
|
89
|
+
```ts
|
|
90
|
+
const features = parseRecords(
|
|
91
|
+
lines.map(line => ({ line, offset })),
|
|
92
|
+
).map(({ feature, record }) => ({ ...feature, id: record.offset }))
|
|
93
|
+
```
|
|
141
94
|
|
|
142
|
-
### `
|
|
95
|
+
### `extractType(line: string): string`
|
|
143
96
|
|
|
144
|
-
|
|
97
|
+
Extract the feature type (GFF3 column 3) from a raw line without fully splitting
|
|
98
|
+
it.
|
|
145
99
|
|
|
146
|
-
### `LineRecord`
|
|
100
|
+
### `LineRecord` / `ParsedRecord`
|
|
147
101
|
|
|
148
102
|
```ts
|
|
149
103
|
interface LineRecord {
|
|
150
104
|
line: string
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
interface ParsedRecord<R extends LineRecord = LineRecord> {
|
|
108
|
+
feature: GffFeature
|
|
109
|
+
record: R // the input record this top-level feature was parsed from
|
|
155
110
|
}
|
|
156
111
|
```
|
|
157
112
|
|
package/dist/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';
|
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) {
|
|
@@ -39,174 +37,82 @@ function toStringArray(value) {
|
|
|
39
37
|
return typeof value === 'string' ? [value] : [];
|
|
40
38
|
}
|
|
41
39
|
/**
|
|
42
|
-
*
|
|
43
|
-
*
|
|
44
|
-
*
|
|
45
|
-
* @param str - GFF3 string
|
|
46
|
-
* @returns array of parsed features
|
|
47
|
-
*/
|
|
48
|
-
function parseStringSync(str) {
|
|
49
|
-
return parseRecords(stringToRecords(str));
|
|
50
|
-
}
|
|
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
|
|
40
|
+
* Register a feature's ID and attach it to its parent(s), building the
|
|
41
|
+
* subfeature tree in `byId`/`orphans`. Returns true when the feature is
|
|
42
|
+
* top-level (has no Parent) and the caller should collect it.
|
|
56
43
|
*/
|
|
57
|
-
function
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
44
|
+
function linkFeature(feature, byId, orphans) {
|
|
45
|
+
const id = firstString(feature.id);
|
|
46
|
+
const parents = toStringArray(feature.parent);
|
|
47
|
+
// Register the id only the first time it is seen. Continuation lines
|
|
48
|
+
// (multi-location features such as a CDS spanning several segments share one
|
|
49
|
+
// ID across lines) skip registration but must still be attached to their
|
|
50
|
+
// parent below, so this is independent of the parent handling.
|
|
51
|
+
if (id && !byId.has(id)) {
|
|
52
|
+
byId.set(id, feature);
|
|
53
|
+
const waiting = orphans.get(id);
|
|
54
|
+
if (waiting) {
|
|
55
|
+
for (const w of waiting) {
|
|
56
|
+
feature.subfeatures.push(w);
|
|
57
|
+
}
|
|
58
|
+
orphans.delete(id);
|
|
66
59
|
}
|
|
67
|
-
|
|
68
|
-
|
|
60
|
+
}
|
|
61
|
+
for (const parentId of parents) {
|
|
62
|
+
const parentFeature = byId.get(parentId);
|
|
63
|
+
if (parentFeature) {
|
|
64
|
+
parentFeature.subfeatures.push(feature);
|
|
65
|
+
}
|
|
66
|
+
else {
|
|
67
|
+
appendOrphan(orphans, parentId, feature);
|
|
69
68
|
}
|
|
70
|
-
records.push({
|
|
71
|
-
line,
|
|
72
|
-
hasEscapes: line.includes('%'),
|
|
73
|
-
});
|
|
74
69
|
}
|
|
75
|
-
|
|
70
|
+
// Every line of a top-level discontinuous feature (e.g. cDNA_match spanning
|
|
71
|
+
// several segments under one shared ID, with no Parent) is its own top-level
|
|
72
|
+
// item, so this is independent of whether the id was just registered.
|
|
73
|
+
return parents.length === 0;
|
|
76
74
|
}
|
|
77
75
|
/**
|
|
78
|
-
*
|
|
79
|
-
*
|
|
76
|
+
* Synchronously parse a string containing GFF3 and return an array of the
|
|
77
|
+
* parsed features. Comments, directives, and `##FASTA` sections are ignored.
|
|
80
78
|
*
|
|
81
|
-
* @param
|
|
79
|
+
* @param str - GFF3 string
|
|
82
80
|
* @returns array of parsed features
|
|
83
81
|
*/
|
|
84
|
-
function
|
|
82
|
+
function parseStringSync(str) {
|
|
85
83
|
const items = [];
|
|
86
84
|
const byId = new Map();
|
|
87
85
|
const orphans = new Map();
|
|
88
|
-
for (const
|
|
89
|
-
|
|
90
|
-
|
|
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]);
|
|
86
|
+
for (const line of str.split(/\r?\n/)) {
|
|
87
|
+
if (line.startsWith('##FASTA') || line.startsWith('>')) {
|
|
88
|
+
break;
|
|
106
89
|
}
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
if (
|
|
110
|
-
|
|
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
|
-
}
|
|
90
|
+
if (line.length !== 0 && !line.startsWith('#')) {
|
|
91
|
+
const feature = (0, util_ts_1.parseFeature)(line);
|
|
92
|
+
if (linkFeature(feature, byId, orphans)) {
|
|
93
|
+
items.push(feature);
|
|
151
94
|
}
|
|
152
95
|
}
|
|
153
96
|
}
|
|
154
97
|
return items;
|
|
155
98
|
}
|
|
156
99
|
/**
|
|
157
|
-
* Parse an array of
|
|
158
|
-
*
|
|
100
|
+
* Parse an array of records wrapping raw GFF3 lines, resolving parent/child
|
|
101
|
+
* relationships into `subfeatures`. Returns each top-level feature paired with
|
|
102
|
+
* the record it came from, so callers can attach their own identity (e.g. a
|
|
103
|
+
* byte offset) without the parser stamping anything onto the feature.
|
|
159
104
|
*
|
|
160
|
-
* @param records - Array of
|
|
161
|
-
* @returns
|
|
105
|
+
* @param records - Array of records, each carrying a raw GFF3 `line`
|
|
106
|
+
* @returns top-level features, each paired with its originating record
|
|
162
107
|
*/
|
|
163
|
-
function
|
|
108
|
+
function parseRecords(records) {
|
|
164
109
|
const items = [];
|
|
165
110
|
const byId = new Map();
|
|
166
111
|
const orphans = new Map();
|
|
167
112
|
for (const record of records) {
|
|
168
|
-
const feature = record.
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
if (record.lineHash !== undefined) {
|
|
172
|
-
feature._lineHash = String(record.lineHash);
|
|
173
|
-
}
|
|
174
|
-
const id = firstString(feature.id);
|
|
175
|
-
const parents = toStringArray(feature.parent);
|
|
176
|
-
if (!id && parents.length === 0) {
|
|
177
|
-
items.push(feature);
|
|
178
|
-
}
|
|
179
|
-
else {
|
|
180
|
-
// A parentless line is a top-level item. Every line of a top-level
|
|
181
|
-
// discontinuous feature (e.g. cDNA_match/EST_match spanning several
|
|
182
|
-
// segments under one shared ID, with no Parent) is its own top-level
|
|
183
|
-
// item, so push here regardless of whether the id is already registered.
|
|
184
|
-
if (parents.length === 0) {
|
|
185
|
-
items.push(feature);
|
|
186
|
-
}
|
|
187
|
-
// Register the id only the first time it is seen. Continuation lines
|
|
188
|
-
// (multi-location features such as a CDS spanning several segments share
|
|
189
|
-
// one ID across lines) skip registration but must still be attached to
|
|
190
|
-
// their parent below, so this is independent of the parent handling.
|
|
191
|
-
if (id && !byId.has(id)) {
|
|
192
|
-
byId.set(id, feature);
|
|
193
|
-
const waiting = orphans.get(id);
|
|
194
|
-
if (waiting) {
|
|
195
|
-
for (const w of waiting) {
|
|
196
|
-
feature.subfeatures.push(w);
|
|
197
|
-
}
|
|
198
|
-
orphans.delete(id);
|
|
199
|
-
}
|
|
200
|
-
}
|
|
201
|
-
for (const parentId of parents) {
|
|
202
|
-
const parentFeature = byId.get(parentId);
|
|
203
|
-
if (parentFeature) {
|
|
204
|
-
parentFeature.subfeatures.push(feature);
|
|
205
|
-
}
|
|
206
|
-
else {
|
|
207
|
-
appendOrphan(orphans, parentId, feature);
|
|
208
|
-
}
|
|
209
|
-
}
|
|
113
|
+
const feature = (0, util_ts_1.parseFeature)(record.line);
|
|
114
|
+
if (linkFeature(feature, byId, orphans)) {
|
|
115
|
+
items.push({ feature, record });
|
|
210
116
|
}
|
|
211
117
|
}
|
|
212
118
|
return items;
|
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;AA+ED,0CAkBC;AAWD,oCAeC;AApJD,uCAAwC;AAmBxC,qFAAqF;AACrF,SAAgB,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,CAA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AAC;gBACxC,KAAK,CAAC,IAAI,CAAC,OAAO,CAAC,CAAA;YACrB,CAAC;QACH,CAAC;IACH,CAAC;IAED,OAAO,KAAK,CAAA;AACd,CAAC;AAED;;;;;;;;GAQG;AACH,SAAgB,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,IAAA,sBAAY,EAAC,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/dist/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/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"}
|