@jbrowse/plugin-gtf 1.7.10 → 2.0.1

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/esm/util.js ADDED
@@ -0,0 +1,62 @@
1
+ export function featureData(data) {
2
+ const f = { ...data };
3
+ f.start -= 1; // convert to interbase
4
+ f.strand = { '+': 1, '-': -1, '.': 0, '?': undefined }[data.strand]; // convert strand
5
+ f.phase = Number(data.frame);
6
+ f.refName = data.seq_name;
7
+ if (data.score === null) {
8
+ delete f.score;
9
+ }
10
+ if (data.frame === null) {
11
+ delete f.score;
12
+ }
13
+ const defaultFields = [
14
+ 'start',
15
+ 'end',
16
+ 'seq_name',
17
+ 'score',
18
+ 'featureType',
19
+ 'source',
20
+ 'frame',
21
+ 'strand',
22
+ ];
23
+ Object.keys(data.attributes).forEach(a => {
24
+ let b = a.toLowerCase();
25
+ if (defaultFields.includes(b)) {
26
+ // add "suffix" to tag name if it already exists
27
+ // reproduces behavior of NCList
28
+ b += '2';
29
+ }
30
+ if (data.attributes[a] !== null) {
31
+ let attr = data.attributes[a];
32
+ if (Array.isArray(attr) && attr.length === 1) {
33
+ // gtf uses double quotes for text values in the attributes column, remove them
34
+ const formattedAttr = attr[0].replace(/^"|"$/g, '');
35
+ attr = formattedAttr;
36
+ }
37
+ f[b] = attr;
38
+ }
39
+ });
40
+ f.refName = f.seq_name;
41
+ f.type = f.featureType;
42
+ // the SimpleFeature constructor takes care of recursively inflating subfeatures
43
+ if (data.child_features && data.child_features.length) {
44
+ f.subfeatures = data.child_features
45
+ .map(childLocs => childLocs.map(childLoc => featureData(childLoc)))
46
+ .flat();
47
+ }
48
+ delete f.child_features;
49
+ delete f.data;
50
+ delete f.derived_features;
51
+ // eslint-disable-next-line no-underscore-dangle
52
+ delete f._linehash;
53
+ delete f.attributes;
54
+ delete f.seq_name;
55
+ delete f.featureType;
56
+ delete f.frame;
57
+ if (f.transcript_id) {
58
+ f.name = f.transcript_id;
59
+ }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 -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jbrowse/plugin-gtf",
3
- "version": "1.7.10",
3
+ "version": "2.0.1",
4
4
  "description": "JBrowse 2 gtf feature adapter",
5
5
  "keywords": [
6
6
  "jbrowse",
@@ -20,17 +20,21 @@
20
20
  "main": "dist/index.js",
21
21
  "files": [
22
22
  "dist",
23
- "src"
23
+ "src",
24
+ "esm"
24
25
  ],
25
26
  "scripts": {
26
- "build": "babel src --root-mode upward --out-dir dist --extensions .ts,.js,.tsx,.jsx",
27
+ "build": "npm-run-all build:*",
27
28
  "test": "cd ../..; jest plugins/gtf --passWithNoTests",
28
29
  "prepublishOnly": "yarn test",
29
30
  "prepack": "yarn build; yarn useDist",
30
31
  "postpack": "yarn useSrc",
31
32
  "useDist": "node ../../scripts/useDist.js",
32
33
  "useSrc": "node ../../scripts/useSrc.js",
33
- "postbuild": "tsc --build tsconfig.build.json"
34
+ "prebuild": "npm run clean",
35
+ "build:esm": "tsc --build tsconfig.build.esm.json",
36
+ "build:es5": "tsc --build tsconfig.build.es5.json",
37
+ "clean": "rimraf dist esm *.tsbuildinfo"
34
38
  },
35
39
  "dependencies": {
36
40
  "@babel/runtime": "^7.17.9",
@@ -39,11 +43,12 @@
39
43
  "@gmod/gtf": "^0.0.6"
40
44
  },
41
45
  "peerDependencies": {
42
- "@jbrowse/core": "^1.0.0",
43
- "@jbrowse/plugin-linear-genome-view": "^1.0.0",
44
- "@material-ui/core": "^4.12.2",
45
- "mobx-react": "^6.0.0",
46
- "mobx-state-tree": "3.14.1",
46
+ "@jbrowse/core": "^2.0.0",
47
+ "@jbrowse/plugin-linear-genome-view": "^2.0.0",
48
+ "@mui/material": "^5.0.0",
49
+ "mobx": "^6.0.0",
50
+ "mobx-react": "^7.0.0",
51
+ "mobx-state-tree": "^5.0.0",
47
52
  "prop-types": "^15.0.0",
48
53
  "react": ">=16.8.0",
49
54
  "rxjs": "^6.0.0"
@@ -51,5 +56,8 @@
51
56
  "publishConfig": {
52
57
  "access": "public"
53
58
  },
54
- "gitHead": "02d8c1e88e5603ea5855faed4ccb814e28071b32"
59
+ "distModule": "esm/index.js",
60
+ "srcModule": "src/index.ts",
61
+ "module": "esm/index.js",
62
+ "gitHead": "ed935bf5612af3818abdc8ef52d100d5d81d33a2"
55
63
  }
@@ -23,11 +23,9 @@ export default class extends BaseFeatureDataAdapter {
23
23
  [key: string]: Promise<IntervalTree | undefined> | undefined
24
24
  } = {}
25
25
 
26
- private async loadDataP() {
27
- const buffer = await openLocation(
28
- this.getConf('gtfLocation'),
29
- this.pluginManager,
30
- ).readFile()
26
+ private async loadDataP(opts: BaseOptions = {}) {
27
+ const gtfLoc = this.getConf('gtfLocation')
28
+ const buffer = await openLocation(gtfLoc, this.pluginManager).readFile(opts)
31
29
 
32
30
  const buf = isGzip(buffer) ? await unzip(buffer) : buffer
33
31
  // 512MB max chrome string length is 512MB
@@ -39,7 +37,12 @@ export default class extends BaseFeatureDataAdapter {
39
37
  const lines = data.split('\n').filter(f => !!f && !f.startsWith('#'))
40
38
  const feats = {} as { [key: string]: string[] }
41
39
  for (let i = 0; i < lines.length; i++) {
42
- const refName = lines[i].split('\t')[0]
40
+ const line = lines[i]
41
+ if (line.startsWith('#')) {
42
+ continue
43
+ }
44
+ const tab = line.indexOf('\t')
45
+ const refName = line.slice(0, tab)
43
46
  if (!feats[refName]) {
44
47
  feats[refName] = []
45
48
  }
@@ -49,9 +52,9 @@ export default class extends BaseFeatureDataAdapter {
49
52
  return { feats }
50
53
  }
51
54
 
52
- private async loadData() {
55
+ private async loadData(opts: BaseOptions = {}) {
53
56
  if (!this.gtfFeatures) {
54
- this.gtfFeatures = this.loadDataP().catch(e => {
57
+ this.gtfFeatures = this.loadDataP(opts).catch(e => {
55
58
  this.gtfFeatures = undefined
56
59
  throw e
57
60
  })
@@ -61,7 +64,7 @@ export default class extends BaseFeatureDataAdapter {
61
64
  }
62
65
 
63
66
  public async getRefNames(opts: BaseOptions = {}) {
64
- const { feats } = await this.loadData()
67
+ const { feats } = await this.loadData(opts)
65
68
  return Object.keys(feats)
66
69
  }
67
70
 
@@ -83,7 +86,7 @@ export default class extends BaseFeatureDataAdapter {
83
86
  (f, i) =>
84
87
  new SimpleFeature({
85
88
  data: featureData(f),
86
- id: `${this.id}-offset-${i}`,
89
+ id: `${this.id}-${refName}-${i}`,
87
90
  }),
88
91
  )
89
92