gff-nostream 3.0.9 → 3.0.11
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.js +49 -32
- package/dist/api.js.map +1 -1
- package/esm/api.js +49 -32
- package/esm/api.js.map +1 -1
- package/package.json +5 -5
- package/src/api.ts +51 -31
package/dist/api.js
CHANGED
|
@@ -13,6 +13,31 @@ function extractType(line) {
|
|
|
13
13
|
const t3 = line.indexOf('\t', t2 + 1);
|
|
14
14
|
return line.slice(t2 + 1, t3);
|
|
15
15
|
}
|
|
16
|
+
/** Append a value to the array stored under key, creating the array if absent. */
|
|
17
|
+
function appendOrphan(orphans, key, value) {
|
|
18
|
+
const arr = orphans.get(key);
|
|
19
|
+
if (arr) {
|
|
20
|
+
arr.push(value);
|
|
21
|
+
}
|
|
22
|
+
else {
|
|
23
|
+
orphans.set(key, [value]);
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* The JBrowse parser collapses single-element attribute arrays to scalars, so a
|
|
28
|
+
* raw ID/Parent value can be a string, a string array, or absent. These coerce
|
|
29
|
+
* those `unknown` values without typecasts.
|
|
30
|
+
*/
|
|
31
|
+
function firstString(value) {
|
|
32
|
+
const v = Array.isArray(value) ? value[0] : value;
|
|
33
|
+
return typeof v === 'string' ? v : undefined;
|
|
34
|
+
}
|
|
35
|
+
function toStringArray(value) {
|
|
36
|
+
if (Array.isArray(value)) {
|
|
37
|
+
return value.filter((v) => typeof v === 'string');
|
|
38
|
+
}
|
|
39
|
+
return typeof value === 'string' ? [value] : [];
|
|
40
|
+
}
|
|
16
41
|
/**
|
|
17
42
|
* Synchronously parse a string containing GFF3 and return an array of the
|
|
18
43
|
* parsed items.
|
|
@@ -120,12 +145,7 @@ function parseRecords(records) {
|
|
|
120
145
|
parent[0].child_features.push(feature);
|
|
121
146
|
}
|
|
122
147
|
else {
|
|
123
|
-
|
|
124
|
-
if (!arr) {
|
|
125
|
-
arr = [];
|
|
126
|
-
orphans.set(parentId, arr);
|
|
127
|
-
}
|
|
128
|
-
arr.push(feature);
|
|
148
|
+
appendOrphan(orphans, parentId, feature);
|
|
129
149
|
}
|
|
130
150
|
}
|
|
131
151
|
}
|
|
@@ -151,19 +171,24 @@ function parseRecordsJBrowse(records) {
|
|
|
151
171
|
if (record.lineHash !== undefined) {
|
|
152
172
|
feature._lineHash = String(record.lineHash);
|
|
153
173
|
}
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
const id = Array.isArray(rawId) ? rawId[0] : rawId;
|
|
158
|
-
const parent = feature.parent;
|
|
159
|
-
if (!id && !parent) {
|
|
174
|
+
const id = firstString(feature.id);
|
|
175
|
+
const parents = toStringArray(feature.parent);
|
|
176
|
+
if (!id && parents.length === 0) {
|
|
160
177
|
items.push(feature);
|
|
161
178
|
}
|
|
162
|
-
else
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
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)) {
|
|
167
192
|
byId.set(id, feature);
|
|
168
193
|
const waiting = orphans.get(id);
|
|
169
194
|
if (waiting) {
|
|
@@ -173,21 +198,13 @@ function parseRecordsJBrowse(records) {
|
|
|
173
198
|
orphans.delete(id);
|
|
174
199
|
}
|
|
175
200
|
}
|
|
176
|
-
|
|
177
|
-
const
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
else {
|
|
184
|
-
let arr = orphans.get(parentId);
|
|
185
|
-
if (!arr) {
|
|
186
|
-
arr = [];
|
|
187
|
-
orphans.set(parentId, arr);
|
|
188
|
-
}
|
|
189
|
-
arr.push(feature);
|
|
190
|
-
}
|
|
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);
|
|
191
208
|
}
|
|
192
209
|
}
|
|
193
210
|
}
|
package/dist/api.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"api.js","sourceRoot":"","sources":["../src/api.ts"],"names":[],"mappings":";;AA6BA,kCAKC;
|
|
1
|
+
{"version":3,"file":"api.js","sourceRoot":"","sources":["../src/api.ts"],"names":[],"mappings":";;AA6BA,kCAKC;AAoCD,0CAEC;AAQD,wDAEC;AA2BD,oCAyEC;AASD,kDAuDC;AAtPD,uCAKkB;AAuBlB,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,CAA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6
|
const t3 = line.indexOf('\t', t2 + 1);
|
|
7
7
|
return line.slice(t2 + 1, t3);
|
|
8
8
|
}
|
|
9
|
+
/** Append a value to the array stored under key, creating the array if absent. */
|
|
10
|
+
function appendOrphan(orphans, key, value) {
|
|
11
|
+
const arr = orphans.get(key);
|
|
12
|
+
if (arr) {
|
|
13
|
+
arr.push(value);
|
|
14
|
+
}
|
|
15
|
+
else {
|
|
16
|
+
orphans.set(key, [value]);
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* The JBrowse parser collapses single-element attribute arrays to scalars, so a
|
|
21
|
+
* raw ID/Parent value can be a string, a string array, or absent. These coerce
|
|
22
|
+
* those `unknown` values without typecasts.
|
|
23
|
+
*/
|
|
24
|
+
function firstString(value) {
|
|
25
|
+
const v = Array.isArray(value) ? value[0] : value;
|
|
26
|
+
return typeof v === 'string' ? v : undefined;
|
|
27
|
+
}
|
|
28
|
+
function toStringArray(value) {
|
|
29
|
+
if (Array.isArray(value)) {
|
|
30
|
+
return value.filter((v) => typeof v === 'string');
|
|
31
|
+
}
|
|
32
|
+
return typeof value === 'string' ? [value] : [];
|
|
33
|
+
}
|
|
9
34
|
/**
|
|
10
35
|
* Synchronously parse a string containing GFF3 and return an array of the
|
|
11
36
|
* parsed items.
|
|
@@ -113,12 +138,7 @@ export function parseRecords(records) {
|
|
|
113
138
|
parent[0].child_features.push(feature);
|
|
114
139
|
}
|
|
115
140
|
else {
|
|
116
|
-
|
|
117
|
-
if (!arr) {
|
|
118
|
-
arr = [];
|
|
119
|
-
orphans.set(parentId, arr);
|
|
120
|
-
}
|
|
121
|
-
arr.push(feature);
|
|
141
|
+
appendOrphan(orphans, parentId, feature);
|
|
122
142
|
}
|
|
123
143
|
}
|
|
124
144
|
}
|
|
@@ -144,19 +164,24 @@ export function parseRecordsJBrowse(records) {
|
|
|
144
164
|
if (record.lineHash !== undefined) {
|
|
145
165
|
feature._lineHash = String(record.lineHash);
|
|
146
166
|
}
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
const id = Array.isArray(rawId) ? rawId[0] : rawId;
|
|
151
|
-
const parent = feature.parent;
|
|
152
|
-
if (!id && !parent) {
|
|
167
|
+
const id = firstString(feature.id);
|
|
168
|
+
const parents = toStringArray(feature.parent);
|
|
169
|
+
if (!id && parents.length === 0) {
|
|
153
170
|
items.push(feature);
|
|
154
171
|
}
|
|
155
|
-
else
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
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)) {
|
|
160
185
|
byId.set(id, feature);
|
|
161
186
|
const waiting = orphans.get(id);
|
|
162
187
|
if (waiting) {
|
|
@@ -166,21 +191,13 @@ export function parseRecordsJBrowse(records) {
|
|
|
166
191
|
orphans.delete(id);
|
|
167
192
|
}
|
|
168
193
|
}
|
|
169
|
-
|
|
170
|
-
const
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
else {
|
|
177
|
-
let arr = orphans.get(parentId);
|
|
178
|
-
if (!arr) {
|
|
179
|
-
arr = [];
|
|
180
|
-
orphans.set(parentId, arr);
|
|
181
|
-
}
|
|
182
|
-
arr.push(feature);
|
|
183
|
-
}
|
|
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);
|
|
184
201
|
}
|
|
185
202
|
}
|
|
186
203
|
}
|
package/esm/api.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"api.js","sourceRoot":"","sources":["../src/api.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,YAAY,EACZ,mBAAmB,EACnB,6BAA6B,EAC7B,sBAAsB,GACvB,MAAM,WAAW,CAAA;AAuBlB,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;;;;;;GAMG;AACH,MAAM,UAAU,eAAe,CAAC,GAAW;IACzC,OAAO,YAAY,CAAC,eAAe,CAAC,GAAG,CAAC,CAAC,CAAA;AAC3C,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,sBAAsB,CAAC,GAAW;IAChD,OAAO,mBAAmB,CAAC,eAAe,CAAC,GAAG,CAAC,CAAC,CAAA;AAClD,CAAC;AAED,SAAS,eAAe,CAAC,GAAW;IAClC,MAAM,KAAK,GAAG,GAAG,CAAC,KAAK,CAAC,OAAO,CAAC,CAAA;IAChC,MAAM,OAAO,GAAiB,EAAE,CAAA;IAChC,KAAK,MAAM,IAAI,IAAI,KAAK,EAAE,CAAC;QACzB,IAAI,IAAI,CAAC,UAAU,CAAC,SAAS,CAA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zB,KAAK,CAAC,IAAI,CAAC,OAAO,CAAC,CAAA;YACrB,CAAC;YAED,qEAAqE;YACrE,yEAAyE;YACzE,uEAAuE;YACvE,qEAAqE;YACrE,IAAI,EAAE,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,EAAE,CAAC;gBACxB,IAAI,CAAC,GAAG,CAAC,EAAE,EAAE,OAAO,CAAC,CAAA;gBACrB,MAAM,OAAO,GAAG,OAAO,CAAC,GAAG,CAAC,EAAE,CAAC,CAAA;gBAC/B,IAAI,OAAO,EAAE,CAAC;oBACZ,KAAK,MAAM,CAAC,IAAI,OAAO,EAAE,CAAC;wBACxB,OAAO,CAAC,WAAW,CAAC,IAAI,CAAC,CAAC,CAAC,CAAA;oBAC7B,CAAC;oBACD,OAAO,CAAC,MAAM,CAAC,EAAE,CAAC,CAAA;gBACpB,CAAC;YACH,CAAC;YAED,KAAK,MAAM,QAAQ,IAAI,OAAO,EAAE,CAAC;gBAC/B,MAAM,aAAa,GAAG,IAAI,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAA;gBACxC,IAAI,aAAa,EAAE,CAAC;oBAClB,aAAa,CAAC,WAAW,CAAC,IAAI,CAAC,OAAO,CAAC,CAAA;gBACzC,CAAC;qBAAM,CAAC;oBACN,YAAY,CAAC,OAAO,EAAE,QAAQ,EAAE,OAAO,CAAC,CAAA;gBAC1C,CAAC;YACH,CAAC;QACH,CAAC;IACH,CAAC;IAED,OAAO,KAAK,CAAA;AACd,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "gff-nostream",
|
|
3
|
-
"version": "3.0.
|
|
3
|
+
"version": "3.0.11",
|
|
4
4
|
"description": "utilities to read GFF3 data",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
@@ -48,13 +48,13 @@
|
|
|
48
48
|
],
|
|
49
49
|
"devDependencies": {
|
|
50
50
|
"@eslint/js": "^10.0.1",
|
|
51
|
-
"@types/node": "^25.
|
|
52
|
-
"eslint": "^10.4.
|
|
51
|
+
"@types/node": "^25.9.1",
|
|
52
|
+
"eslint": "^10.4.1",
|
|
53
53
|
"eslint-plugin-import-x": "^4.16.2",
|
|
54
54
|
"prettier": "^3.8.3",
|
|
55
55
|
"rimraf": "^6.1.3",
|
|
56
56
|
"typescript": "^6.0.3",
|
|
57
|
-
"typescript-eslint": "^8.
|
|
58
|
-
"vitest": "^4.1.
|
|
57
|
+
"typescript-eslint": "^8.60.0",
|
|
58
|
+
"vitest": "^4.1.7"
|
|
59
59
|
}
|
|
60
60
|
}
|
package/src/api.ts
CHANGED
|
@@ -34,6 +34,33 @@ export function extractType(line: string): string {
|
|
|
34
34
|
return line.slice(t2 + 1, t3)
|
|
35
35
|
}
|
|
36
36
|
|
|
37
|
+
/** Append a value to the array stored under key, creating the array if absent. */
|
|
38
|
+
function appendOrphan<T>(orphans: Map<string, T[]>, key: string, value: T) {
|
|
39
|
+
const arr = orphans.get(key)
|
|
40
|
+
if (arr) {
|
|
41
|
+
arr.push(value)
|
|
42
|
+
} else {
|
|
43
|
+
orphans.set(key, [value])
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
/**
|
|
48
|
+
* The JBrowse parser collapses single-element attribute arrays to scalars, so a
|
|
49
|
+
* raw ID/Parent value can be a string, a string array, or absent. These coerce
|
|
50
|
+
* those `unknown` values without typecasts.
|
|
51
|
+
*/
|
|
52
|
+
function firstString(value: unknown): string | undefined {
|
|
53
|
+
const v: unknown = Array.isArray(value) ? value[0] : value
|
|
54
|
+
return typeof v === 'string' ? v : undefined
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
function toStringArray(value: unknown): string[] {
|
|
58
|
+
if (Array.isArray(value)) {
|
|
59
|
+
return value.filter((v): v is string => typeof v === 'string')
|
|
60
|
+
}
|
|
61
|
+
return typeof value === 'string' ? [value] : []
|
|
62
|
+
}
|
|
63
|
+
|
|
37
64
|
/**
|
|
38
65
|
* Synchronously parse a string containing GFF3 and return an array of the
|
|
39
66
|
* parsed items.
|
|
@@ -145,12 +172,7 @@ export function parseRecords(records: ParseInput[]): GFF3Feature[] {
|
|
|
145
172
|
// so push once via the first line.
|
|
146
173
|
parent[0]!.child_features.push(feature)
|
|
147
174
|
} else {
|
|
148
|
-
|
|
149
|
-
if (!arr) {
|
|
150
|
-
arr = []
|
|
151
|
-
orphans.set(parentId, arr)
|
|
152
|
-
}
|
|
153
|
-
arr.push(feature)
|
|
175
|
+
appendOrphan(orphans, parentId, feature)
|
|
154
176
|
}
|
|
155
177
|
}
|
|
156
178
|
}
|
|
@@ -181,19 +203,25 @@ export function parseRecordsJBrowse(records: ParseInput[]): JBrowseFeature[] {
|
|
|
181
203
|
feature._lineHash = String(record.lineHash)
|
|
182
204
|
}
|
|
183
205
|
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
const rawId = feature.id as string | string[] | undefined
|
|
187
|
-
const id = Array.isArray(rawId) ? rawId[0] : rawId
|
|
188
|
-
const parent = feature.parent as string | string[] | undefined
|
|
206
|
+
const id = firstString(feature.id)
|
|
207
|
+
const parents = toStringArray(feature.parent)
|
|
189
208
|
|
|
190
|
-
if (!id &&
|
|
209
|
+
if (!id && parents.length === 0) {
|
|
191
210
|
items.push(feature)
|
|
192
|
-
} else
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
211
|
+
} else {
|
|
212
|
+
// A parentless line is a top-level item. Every line of a top-level
|
|
213
|
+
// discontinuous feature (e.g. cDNA_match/EST_match spanning several
|
|
214
|
+
// segments under one shared ID, with no Parent) is its own top-level
|
|
215
|
+
// item, so push here regardless of whether the id is already registered.
|
|
216
|
+
if (parents.length === 0) {
|
|
217
|
+
items.push(feature)
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
// Register the id only the first time it is seen. Continuation lines
|
|
221
|
+
// (multi-location features such as a CDS spanning several segments share
|
|
222
|
+
// one ID across lines) skip registration but must still be attached to
|
|
223
|
+
// their parent below, so this is independent of the parent handling.
|
|
224
|
+
if (id && !byId.has(id)) {
|
|
197
225
|
byId.set(id, feature)
|
|
198
226
|
const waiting = orphans.get(id)
|
|
199
227
|
if (waiting) {
|
|
@@ -204,20 +232,12 @@ export function parseRecordsJBrowse(records: ParseInput[]): JBrowseFeature[] {
|
|
|
204
232
|
}
|
|
205
233
|
}
|
|
206
234
|
|
|
207
|
-
|
|
208
|
-
const
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
} else {
|
|
214
|
-
let arr = orphans.get(parentId)
|
|
215
|
-
if (!arr) {
|
|
216
|
-
arr = []
|
|
217
|
-
orphans.set(parentId, arr)
|
|
218
|
-
}
|
|
219
|
-
arr.push(feature)
|
|
220
|
-
}
|
|
235
|
+
for (const parentId of parents) {
|
|
236
|
+
const parentFeature = byId.get(parentId)
|
|
237
|
+
if (parentFeature) {
|
|
238
|
+
parentFeature.subfeatures.push(feature)
|
|
239
|
+
} else {
|
|
240
|
+
appendOrphan(orphans, parentId, feature)
|
|
221
241
|
}
|
|
222
242
|
}
|
|
223
243
|
}
|