@jbrowse/plugin-gff3 2.15.1 → 2.15.3

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.
@@ -1,2 +1,16 @@
1
1
  import { GFF3FeatureLineWithRefs } from 'gff-nostream';
2
- export declare function featureData(data: GFF3FeatureLineWithRefs): Record<string, unknown>;
2
+ interface GFF3Feature {
3
+ start: number;
4
+ end: number;
5
+ strand?: number;
6
+ type: string | null;
7
+ source: string | null;
8
+ refName: string;
9
+ derived_features: unknown[] | null;
10
+ phase?: number;
11
+ score?: number;
12
+ subfeatures: GFF3Feature[] | undefined;
13
+ [key: string]: unknown;
14
+ }
15
+ export declare function featureData(data: GFF3FeatureLineWithRefs): GFF3Feature;
16
+ export {};
@@ -2,24 +2,16 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.featureData = featureData;
4
4
  function featureData(data) {
5
- const f = { ...data };
6
- f.start -= 1; // convert to interbase
7
- if (data.strand === '+') {
8
- f.strand = 1;
5
+ const { end, start, child_features, derived_features, attributes, type, source, phase, seq_id, score, strand, } = data;
6
+ let strand2;
7
+ if (strand === '+') {
8
+ strand2 = 1;
9
9
  }
10
- else if (data.strand === '-') {
11
- f.strand = -1;
10
+ else if (strand === '-') {
11
+ strand2 = -1;
12
12
  }
13
- else if (data.strand === '.') {
14
- f.strand = 0;
15
- }
16
- else {
17
- f.strand = undefined;
18
- }
19
- f.phase = data.phase === null ? undefined : Number(data.phase);
20
- f.refName = data.seq_id;
21
- if (data.score === null) {
22
- f.score = undefined;
13
+ else if (strand === '.') {
14
+ strand2 = 0;
23
15
  }
24
16
  const defaultFields = new Set([
25
17
  'start',
@@ -31,7 +23,8 @@ function featureData(data) {
31
23
  'phase',
32
24
  'strand',
33
25
  ]);
34
- const dataAttributes = data.attributes || {};
26
+ const dataAttributes = attributes || {};
27
+ const resultAttributes = {};
35
28
  for (const a of Object.keys(dataAttributes)) {
36
29
  let b = a.toLowerCase();
37
30
  if (defaultFields.has(b)) {
@@ -39,26 +32,26 @@ function featureData(data) {
39
32
  // reproduces behavior of NCList
40
33
  b += '2';
41
34
  }
42
- if (dataAttributes[a]) {
35
+ if (dataAttributes[a] && a !== '_lineHash') {
43
36
  let attr = dataAttributes[a];
44
37
  if (Array.isArray(attr) && attr.length === 1) {
45
38
  ;
46
39
  [attr] = attr;
47
40
  }
48
- f[b] = attr;
41
+ resultAttributes[b] = attr;
49
42
  }
50
43
  }
51
- f.refName = f.seq_id;
52
- // the SimpleFeature constructor takes care of recursively inflating
53
- // subfeatures
54
- // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
55
- if (data.child_features && data.child_features.length > 0) {
56
- f.subfeatures = data.child_features.flatMap(childLocs => childLocs.map(childLoc => featureData(childLoc)));
57
- }
58
- f.child_features = undefined;
59
- f.data = undefined;
60
- // delete f.derived_features
61
- f.attributes = undefined;
62
- f.seq_id = undefined;
63
- return f;
44
+ return {
45
+ ...resultAttributes,
46
+ start: start - 1,
47
+ end: end,
48
+ strand: strand2,
49
+ type,
50
+ source,
51
+ refName: seq_id,
52
+ derived_features,
53
+ phase: phase === null ? undefined : Number(phase),
54
+ score: score === null ? undefined : score,
55
+ subfeatures: child_features.flatMap(childLocs => childLocs.map(childLoc => featureData(childLoc))),
56
+ };
64
57
  }
@@ -1,2 +1,16 @@
1
1
  import { GFF3FeatureLineWithRefs } from 'gff-nostream';
2
- export declare function featureData(data: GFF3FeatureLineWithRefs): Record<string, unknown>;
2
+ interface GFF3Feature {
3
+ start: number;
4
+ end: number;
5
+ strand?: number;
6
+ type: string | null;
7
+ source: string | null;
8
+ refName: string;
9
+ derived_features: unknown[] | null;
10
+ phase?: number;
11
+ score?: number;
12
+ subfeatures: GFF3Feature[] | undefined;
13
+ [key: string]: unknown;
14
+ }
15
+ export declare function featureData(data: GFF3FeatureLineWithRefs): GFF3Feature;
16
+ export {};
@@ -1,22 +1,14 @@
1
1
  export function featureData(data) {
2
- const f = { ...data };
3
- f.start -= 1; // convert to interbase
4
- if (data.strand === '+') {
5
- f.strand = 1;
2
+ const { end, start, child_features, derived_features, attributes, type, source, phase, seq_id, score, strand, } = data;
3
+ let strand2;
4
+ if (strand === '+') {
5
+ strand2 = 1;
6
6
  }
7
- else if (data.strand === '-') {
8
- f.strand = -1;
7
+ else if (strand === '-') {
8
+ strand2 = -1;
9
9
  }
10
- else if (data.strand === '.') {
11
- f.strand = 0;
12
- }
13
- else {
14
- f.strand = undefined;
15
- }
16
- f.phase = data.phase === null ? undefined : Number(data.phase);
17
- f.refName = data.seq_id;
18
- if (data.score === null) {
19
- f.score = undefined;
10
+ else if (strand === '.') {
11
+ strand2 = 0;
20
12
  }
21
13
  const defaultFields = new Set([
22
14
  'start',
@@ -28,7 +20,8 @@ export function featureData(data) {
28
20
  'phase',
29
21
  'strand',
30
22
  ]);
31
- const dataAttributes = data.attributes || {};
23
+ const dataAttributes = attributes || {};
24
+ const resultAttributes = {};
32
25
  for (const a of Object.keys(dataAttributes)) {
33
26
  let b = a.toLowerCase();
34
27
  if (defaultFields.has(b)) {
@@ -36,26 +29,26 @@ export function featureData(data) {
36
29
  // reproduces behavior of NCList
37
30
  b += '2';
38
31
  }
39
- if (dataAttributes[a]) {
32
+ if (dataAttributes[a] && a !== '_lineHash') {
40
33
  let attr = dataAttributes[a];
41
34
  if (Array.isArray(attr) && attr.length === 1) {
42
35
  ;
43
36
  [attr] = attr;
44
37
  }
45
- f[b] = attr;
38
+ resultAttributes[b] = attr;
46
39
  }
47
40
  }
48
- f.refName = f.seq_id;
49
- // the SimpleFeature constructor takes care of recursively inflating
50
- // subfeatures
51
- // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
52
- if (data.child_features && data.child_features.length > 0) {
53
- f.subfeatures = data.child_features.flatMap(childLocs => childLocs.map(childLoc => featureData(childLoc)));
54
- }
55
- f.child_features = undefined;
56
- f.data = undefined;
57
- // delete f.derived_features
58
- f.attributes = undefined;
59
- f.seq_id = undefined;
60
- return f;
41
+ return {
42
+ ...resultAttributes,
43
+ start: start - 1,
44
+ end: end,
45
+ strand: strand2,
46
+ type,
47
+ source,
48
+ refName: seq_id,
49
+ derived_features,
50
+ phase: phase === null ? undefined : Number(phase),
51
+ score: score === null ? undefined : score,
52
+ subfeatures: child_features.flatMap(childLocs => childLocs.map(childLoc => featureData(childLoc))),
53
+ };
61
54
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jbrowse/plugin-gff3",
3
- "version": "2.15.1",
3
+ "version": "2.15.3",
4
4
  "description": "JBrowse 2 gff3.",
5
5
  "keywords": [
6
6
  "jbrowse",
@@ -55,5 +55,5 @@
55
55
  "distModule": "esm/index.js",
56
56
  "srcModule": "src/index.ts",
57
57
  "module": "esm/index.js",
58
- "gitHead": "86ed70124fc5a0b1161266659d1ca9f8796bf3fe"
58
+ "gitHead": "c0f82fe7b210622dd462e702641cc6da01109c6e"
59
59
  }