@jbrowse/plugin-gff3 1.5.1 → 1.5.5
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/plugin-gff3.cjs.development.js +54 -50
- package/dist/plugin-gff3.cjs.development.js.map +1 -1
- package/dist/plugin-gff3.cjs.production.min.js +1 -1
- package/dist/plugin-gff3.cjs.production.min.js.map +1 -1
- package/dist/plugin-gff3.esm.js +54 -50
- package/dist/plugin-gff3.esm.js.map +1 -1
- package/package.json +7 -7
- package/src/Gff3Adapter/Gff3Adapter.ts +17 -10
- package/src/Gff3TabixAdapter/Gff3TabixAdapter.ts +19 -14
- package/dist/util.d.ts +0 -14
- package/src/declare.d.ts +0 -2
- package/src/util.ts +0 -12
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@jbrowse/plugin-gff3",
|
|
3
|
-
"version": "1.5.
|
|
3
|
+
"version": "1.5.5",
|
|
4
4
|
"description": "JBrowse 2 gff3.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"jbrowse",
|
|
@@ -35,11 +35,11 @@
|
|
|
35
35
|
"useSrc": "node ../../scripts/useSrc.js"
|
|
36
36
|
},
|
|
37
37
|
"dependencies": {
|
|
38
|
-
"@flatten-js/interval-tree": "^1.0.
|
|
39
|
-
"@gmod/bgzf-filehandle": "^1.
|
|
40
|
-
"@gmod/gff": "^1.
|
|
41
|
-
"@gmod/tabix": "^1.5.
|
|
42
|
-
"generic-filehandle": "^2.2.
|
|
38
|
+
"@flatten-js/interval-tree": "^1.0.15",
|
|
39
|
+
"@gmod/bgzf-filehandle": "^1.4.2",
|
|
40
|
+
"@gmod/gff": "^1.2.0",
|
|
41
|
+
"@gmod/tabix": "^1.5.2",
|
|
42
|
+
"generic-filehandle": "^2.2.2"
|
|
43
43
|
},
|
|
44
44
|
"peerDependencies": {
|
|
45
45
|
"@jbrowse/core": "^1.0.0",
|
|
@@ -54,5 +54,5 @@
|
|
|
54
54
|
"publishConfig": {
|
|
55
55
|
"access": "public"
|
|
56
56
|
},
|
|
57
|
-
"gitHead": "
|
|
57
|
+
"gitHead": "214a3bed2d2722f0971c0d0eed37c8d801f086d7"
|
|
58
58
|
}
|
|
@@ -10,9 +10,7 @@ import IntervalTree from '@flatten-js/interval-tree'
|
|
|
10
10
|
import SimpleFeature, { Feature } from '@jbrowse/core/util/simpleFeature'
|
|
11
11
|
import { unzip } from '@gmod/bgzf-filehandle'
|
|
12
12
|
|
|
13
|
-
import gff from '@gmod/gff'
|
|
14
|
-
|
|
15
|
-
import { FeatureLoc } from '../util'
|
|
13
|
+
import gff, { GFF3FeatureLineWithRefs } from '@gmod/gff'
|
|
16
14
|
|
|
17
15
|
function isGzip(buf: Buffer) {
|
|
18
16
|
return buf[0] === 31 && buf[1] === 139 && buf[2] === 8
|
|
@@ -29,7 +27,7 @@ export default class extends BaseFeatureDataAdapter {
|
|
|
29
27
|
readConfObject(this.config, 'gffLocation'),
|
|
30
28
|
this.pluginManager,
|
|
31
29
|
).readFile()
|
|
32
|
-
const buf = isGzip(buffer
|
|
30
|
+
const buf = isGzip(buffer) ? await unzip(buffer) : buffer
|
|
33
31
|
// 512MB max chrome string length is 512MB
|
|
34
32
|
if (buf.length > 536_870_888) {
|
|
35
33
|
throw new Error('Data exceeds maximum string length (512MB)')
|
|
@@ -47,7 +45,7 @@ export default class extends BaseFeatureDataAdapter {
|
|
|
47
45
|
parseComments: false,
|
|
48
46
|
parseDirectives: false,
|
|
49
47
|
parseSequences: false,
|
|
50
|
-
})
|
|
48
|
+
})
|
|
51
49
|
|
|
52
50
|
const intervalTree = feats
|
|
53
51
|
.flat()
|
|
@@ -106,10 +104,18 @@ export default class extends BaseFeatureDataAdapter {
|
|
|
106
104
|
}, opts.signal)
|
|
107
105
|
}
|
|
108
106
|
|
|
109
|
-
private featureData(data:
|
|
107
|
+
private featureData(data: GFF3FeatureLineWithRefs) {
|
|
110
108
|
const f: Record<string, unknown> = { ...data }
|
|
111
109
|
;(f.start as number) -= 1 // convert to interbase
|
|
112
|
-
|
|
110
|
+
if (data.strand === '+') {
|
|
111
|
+
f.strand = 1
|
|
112
|
+
} else if (data.strand === '-') {
|
|
113
|
+
f.strand = -1
|
|
114
|
+
} else if (data.strand === '.') {
|
|
115
|
+
f.strand = 0
|
|
116
|
+
} else {
|
|
117
|
+
f.strand = undefined
|
|
118
|
+
}
|
|
113
119
|
f.phase = Number(data.phase)
|
|
114
120
|
f.refName = data.seq_id
|
|
115
121
|
if (data.score === null) {
|
|
@@ -128,15 +134,16 @@ export default class extends BaseFeatureDataAdapter {
|
|
|
128
134
|
'phase',
|
|
129
135
|
'strand',
|
|
130
136
|
]
|
|
131
|
-
|
|
137
|
+
const dataAttributes = data.attributes || {}
|
|
138
|
+
Object.keys(dataAttributes).forEach(a => {
|
|
132
139
|
let b = a.toLowerCase()
|
|
133
140
|
if (defaultFields.includes(b)) {
|
|
134
141
|
// add "suffix" to tag name if it already exists
|
|
135
142
|
// reproduces behavior of NCList
|
|
136
143
|
b += '2'
|
|
137
144
|
}
|
|
138
|
-
if (
|
|
139
|
-
let attr =
|
|
145
|
+
if (dataAttributes[a] !== null) {
|
|
146
|
+
let attr: string | string[] | undefined = dataAttributes[a]
|
|
140
147
|
if (Array.isArray(attr) && attr.length === 1) {
|
|
141
148
|
;[attr] = attr
|
|
142
149
|
}
|
|
@@ -9,7 +9,7 @@ import { openLocation } from '@jbrowse/core/util/io'
|
|
|
9
9
|
import { ObservableCreate } from '@jbrowse/core/util/rxjs'
|
|
10
10
|
import SimpleFeature, { Feature } from '@jbrowse/core/util/simpleFeature'
|
|
11
11
|
import { TabixIndexedFile } from '@gmod/tabix'
|
|
12
|
-
import gff from '@gmod/gff'
|
|
12
|
+
import gff, { GFF3Feature, GFF3FeatureLineWithRefs } from '@gmod/gff'
|
|
13
13
|
import { Observer } from 'rxjs'
|
|
14
14
|
|
|
15
15
|
import { Instance } from 'mobx-state-tree'
|
|
@@ -17,7 +17,6 @@ import { readConfObject } from '@jbrowse/core/configuration'
|
|
|
17
17
|
import MyConfigSchema from './configSchema'
|
|
18
18
|
import PluginManager from '@jbrowse/core/PluginManager'
|
|
19
19
|
import { getSubAdapterType } from '@jbrowse/core/data_adapters/dataAdapterCache'
|
|
20
|
-
import { FeatureLoc } from '../util'
|
|
21
20
|
|
|
22
21
|
interface LineFeature {
|
|
23
22
|
start: number
|
|
@@ -110,12 +109,8 @@ export default class extends BaseFeatureDataAdapter {
|
|
|
110
109
|
}
|
|
111
110
|
})
|
|
112
111
|
if (maxEnd > query.end || minStart < query.start) {
|
|
113
|
-
// console.log(
|
|
114
|
-
// `redispatching ${query.start}-${query.end} => ${minStart}-${maxEnd}`,
|
|
115
|
-
// )
|
|
116
112
|
// make a new feature callback to only return top-level features
|
|
117
113
|
// in the original query range
|
|
118
|
-
|
|
119
114
|
this.getFeaturesHelper(
|
|
120
115
|
{ ...query, start: minStart, end: maxEnd },
|
|
121
116
|
opts,
|
|
@@ -146,7 +141,7 @@ export default class extends BaseFeatureDataAdapter {
|
|
|
146
141
|
parseComments: false,
|
|
147
142
|
parseDirectives: false,
|
|
148
143
|
parseSequences: false,
|
|
149
|
-
})
|
|
144
|
+
})
|
|
150
145
|
|
|
151
146
|
features.forEach(featureLocs =>
|
|
152
147
|
this.formatFeatures(featureLocs).forEach(f => {
|
|
@@ -184,20 +179,29 @@ export default class extends BaseFeatureDataAdapter {
|
|
|
184
179
|
}
|
|
185
180
|
}
|
|
186
181
|
|
|
187
|
-
private formatFeatures(featureLocs:
|
|
182
|
+
private formatFeatures(featureLocs: GFF3Feature) {
|
|
188
183
|
return featureLocs.map(
|
|
189
184
|
featureLoc =>
|
|
190
185
|
new SimpleFeature({
|
|
191
186
|
data: this.featureData(featureLoc),
|
|
192
|
-
|
|
187
|
+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
188
|
+
id: `${this.id}-offset-${featureLoc.attributes!._lineHash![0]}`,
|
|
193
189
|
}),
|
|
194
190
|
)
|
|
195
191
|
}
|
|
196
192
|
|
|
197
|
-
private featureData(data:
|
|
193
|
+
private featureData(data: GFF3FeatureLineWithRefs) {
|
|
198
194
|
const f: Record<string, unknown> = { ...data }
|
|
199
195
|
;(f.start as number) -= 1 // convert to interbase
|
|
200
|
-
|
|
196
|
+
if (data.strand === '+') {
|
|
197
|
+
f.strand = 1
|
|
198
|
+
} else if (data.strand === '-') {
|
|
199
|
+
f.strand = -1
|
|
200
|
+
} else if (data.strand === '.') {
|
|
201
|
+
f.strand = 0
|
|
202
|
+
} else {
|
|
203
|
+
f.strand = undefined
|
|
204
|
+
}
|
|
201
205
|
f.phase = Number(data.phase)
|
|
202
206
|
f.refName = data.seq_id
|
|
203
207
|
if (data.score === null) {
|
|
@@ -216,15 +220,16 @@ export default class extends BaseFeatureDataAdapter {
|
|
|
216
220
|
'phase',
|
|
217
221
|
'strand',
|
|
218
222
|
]
|
|
219
|
-
|
|
223
|
+
const dataAttributes = data.attributes || {}
|
|
224
|
+
Object.keys(dataAttributes).forEach(a => {
|
|
220
225
|
let b = a.toLowerCase()
|
|
221
226
|
if (defaultFields.includes(b)) {
|
|
222
227
|
// add "suffix" to tag name if it already exists
|
|
223
228
|
// reproduces behavior of NCList
|
|
224
229
|
b += '2'
|
|
225
230
|
}
|
|
226
|
-
if (
|
|
227
|
-
let attr =
|
|
231
|
+
if (dataAttributes[a] !== null) {
|
|
232
|
+
let attr: string | string[] | undefined = dataAttributes[a]
|
|
228
233
|
if (Array.isArray(attr) && attr.length === 1) {
|
|
229
234
|
;[attr] = attr
|
|
230
235
|
}
|
package/dist/util.d.ts
DELETED
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
export declare type Strand = '+' | '-' | '.' | '?';
|
|
2
|
-
export interface FeatureLoc {
|
|
3
|
-
[key: string]: unknown;
|
|
4
|
-
start: number;
|
|
5
|
-
end: number;
|
|
6
|
-
strand: Strand;
|
|
7
|
-
seq_id: string;
|
|
8
|
-
child_features: FeatureLoc[][];
|
|
9
|
-
data: unknown;
|
|
10
|
-
derived_features: unknown;
|
|
11
|
-
attributes: {
|
|
12
|
-
[key: string]: unknown[];
|
|
13
|
-
};
|
|
14
|
-
}
|
package/src/declare.d.ts
DELETED
package/src/util.ts
DELETED
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
export type Strand = '+' | '-' | '.' | '?'
|
|
2
|
-
export interface FeatureLoc {
|
|
3
|
-
[key: string]: unknown
|
|
4
|
-
start: number
|
|
5
|
-
end: number
|
|
6
|
-
strand: Strand
|
|
7
|
-
seq_id: string
|
|
8
|
-
child_features: FeatureLoc[][]
|
|
9
|
-
data: unknown
|
|
10
|
-
derived_features: unknown
|
|
11
|
-
attributes: { [key: string]: unknown[] }
|
|
12
|
-
}
|