@jbrowse/plugin-sequence 1.5.8 → 1.6.2

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jbrowse/plugin-sequence",
3
- "version": "1.5.8",
3
+ "version": "1.6.2",
4
4
  "description": "JBrowse 2 sequence adapters, tracks, etc.",
5
5
  "keywords": [
6
6
  "jbrowse",
@@ -55,5 +55,5 @@
55
55
  "publishConfig": {
56
56
  "access": "public"
57
57
  },
58
- "gitHead": "f16afc382629a4a830f9040410a9ff1a3a328918"
58
+ "gitHead": "92455c6021abd69548496a450983d89f8837860d"
59
59
  }
@@ -1,11 +1,11 @@
1
1
  /* eslint-disable @typescript-eslint/no-explicit-any */
2
+ import React from 'react'
2
3
  import { AnyConfigurationModel } from '@jbrowse/core/configuration/configurationSchema'
3
4
  import { contrastingTextColor } from '@jbrowse/core/util/color'
4
5
  import { Feature } from '@jbrowse/core/util/simpleFeature'
5
6
  import { Region } from '@jbrowse/core/util/types'
6
7
  import { createJBrowseTheme } from '@jbrowse/core/ui'
7
8
  import { observer } from 'mobx-react'
8
- import React from 'react'
9
9
  import {
10
10
  bpSpanPx,
11
11
  revcom,
@@ -273,6 +273,7 @@ const Wrapper = ({ exportSVG, width, totalHeight, children }: any) => {
273
273
  <>{children}</>
274
274
  ) : (
275
275
  <svg
276
+ data-testid="sequence_track"
276
277
  width={width}
277
278
  height={totalHeight}
278
279
  style={{ width, height: totalHeight }}
@@ -3,6 +3,7 @@
3
3
  exports[`<DivSequenceRendering /> renders with no features 1`] = `
4
4
  <div>
5
5
  <svg
6
+ data-testid="sequence_track"
6
7
  height="200"
7
8
  style="width: 100px; height: 200px;"
8
9
  width="100"
@@ -13,6 +14,7 @@ exports[`<DivSequenceRendering /> renders with no features 1`] = `
13
14
  exports[`<DivSequenceRendering /> renders with one feature reversed with a correct seq, zoomed in, should render nicely 1`] = `
14
15
  <div>
15
16
  <svg
17
+ data-testid="sequence_track"
16
18
  height="200"
17
19
  style="width: 20000px; height: 200px;"
18
20
  width="20000"
@@ -23,6 +25,7 @@ exports[`<DivSequenceRendering /> renders with one feature reversed with a corre
23
25
  exports[`<DivSequenceRendering /> renders with one feature with a correct seq, zoomed in, should render nicely 1`] = `
24
26
  <div>
25
27
  <svg
28
+ data-testid="sequence_track"
26
29
  height="200"
27
30
  style="width: 20000px; height: 200px;"
28
31
  width="20000"
@@ -33,6 +36,7 @@ exports[`<DivSequenceRendering /> renders with one feature with a correct seq, z
33
36
  exports[`<DivSequenceRendering /> renders with one feature with an incorrect seq, zoomed in, should throw 1`] = `
34
37
  <div>
35
38
  <svg
39
+ data-testid="sequence_track"
36
40
  height="200"
37
41
  style="width: 20000px; height: 200px;"
38
42
  width="20000"
@@ -43,6 +47,7 @@ exports[`<DivSequenceRendering /> renders with one feature with an incorrect seq
43
47
  exports[`<DivSequenceRendering /> renders with one feature with no seq, zoomed in, should throw 1`] = `
44
48
  <div>
45
49
  <svg
50
+ data-testid="sequence_track"
46
51
  height="200"
47
52
  style="width: 20000px; height: 200px;"
48
53
  width="20000"
@@ -53,6 +58,7 @@ exports[`<DivSequenceRendering /> renders with one feature with no seq, zoomed i
53
58
  exports[`<DivSequenceRendering /> renders with one, zoomed way out 1`] = `
54
59
  <div>
55
60
  <svg
61
+ data-testid="sequence_track"
56
62
  height="200"
57
63
  style="width: 333.3333333333333px; height: 200px;"
58
64
  width="333.3333333333333"
@@ -56,12 +56,13 @@ export default class extends BaseFeatureDataAdapter {
56
56
  return
57
57
  }
58
58
 
59
- const ret = sequenceAdapter.getFeatures(
60
- { ...query, start: queryStart, end: queryEnd },
61
- opts,
62
- )
63
- const [feat] = await ret.pipe(toArray()).toPromise()
64
- const residues = feat.get('seq')
59
+ const ret = sequenceAdapter.getFeatures({
60
+ ...query,
61
+ start: queryStart,
62
+ end: queryEnd,
63
+ })
64
+ const feats = await ret.pipe(toArray()).toPromise()
65
+ const residues = feats[0]?.get('seq') || ''
65
66
 
66
67
  for (let i = hw; i < residues.length - hw; i += this.windowDelta) {
67
68
  const r = f ? residues[i] : residues.slice(i - hw, i + hw)
@@ -86,7 +87,6 @@ export default class extends BaseFeatureDataAdapter {
86
87
  score = (ng - nc) / (ng + nc || 1)
87
88
  }
88
89
 
89
- // if (r[Math.floor(r.length / 2)] !== 'N') {
90
90
  observer.next(
91
91
  new SimpleFeature({
92
92
  uniqueId: `${this.id}_${pos + i}`,
@@ -95,7 +95,6 @@ export default class extends BaseFeatureDataAdapter {
95
95
  score,
96
96
  }),
97
97
  )
98
- // }
99
98
  }
100
99
  observer.complete()
101
100
  })
@@ -1,7 +1,6 @@
1
1
  import { IndexedFasta } from '@gmod/indexedfasta'
2
2
  import {
3
- BaseFeatureDataAdapter,
4
- SequenceAdapter,
3
+ BaseSequenceAdapter,
5
4
  BaseOptions,
6
5
  } from '@jbrowse/core/data_adapters/BaseAdapter'
7
6
  import { FileLocation, NoAssemblyRegion } from '@jbrowse/core/util/types'
@@ -15,7 +14,7 @@ import LRU from '@jbrowse/core/util/QuickLRU'
15
14
  import PluginManager from '@jbrowse/core/PluginManager'
16
15
  import { getSubAdapterType } from '@jbrowse/core/data_adapters/dataAdapterCache'
17
16
 
18
- export default class extends BaseFeatureDataAdapter implements SequenceAdapter {
17
+ export default class extends BaseSequenceAdapter {
19
18
  protected fasta: IndexedFasta
20
19
 
21
20
  private seqCache = new AbortablePromiseCache({
@@ -1,7 +1,4 @@
1
- import {
2
- BaseFeatureDataAdapter,
3
- SequenceAdapter,
4
- } from '@jbrowse/core/data_adapters/BaseAdapter'
1
+ import { BaseSequenceAdapter } from '@jbrowse/core/data_adapters/BaseAdapter'
5
2
  import { NoAssemblyRegion } from '@jbrowse/core/util/types'
6
3
  import { openLocation } from '@jbrowse/core/util/io'
7
4
  import { ObservableCreate } from '@jbrowse/core/util/rxjs'
@@ -12,10 +9,7 @@ import { AnyConfigurationModel } from '@jbrowse/core/configuration/configuration
12
9
  import PluginManager from '@jbrowse/core/PluginManager'
13
10
  import { getSubAdapterType } from '@jbrowse/core/data_adapters/dataAdapterCache'
14
11
 
15
- export default class TwoBitAdapter
16
- extends BaseFeatureDataAdapter
17
- implements SequenceAdapter
18
- {
12
+ export default class TwoBitAdapter extends BaseSequenceAdapter {
19
13
  private twobit: TwoBitFile
20
14
 
21
15
  // the chromSizesData can be used to speed up loading since TwoBit has to do
package/src/index.ts CHANGED
@@ -71,11 +71,14 @@ export default class SequencePlugin extends Plugin {
71
71
  const regexGuess = /\.2bit$/i
72
72
  const adapterName = 'TwoBitAdapter'
73
73
  const fileName = getFileName(file)
74
- if (regexGuess.test(fileName) || adapterHint === adapterName) {
75
- return {
76
- type: adapterName,
77
- twoBitLocation: file,
78
- }
74
+ const obj = {
75
+ type: adapterName,
76
+ twoBitLocation: file,
77
+ }
78
+ if (regexGuess.test(fileName) && !adapterHint) {
79
+ return obj
80
+ } else if (adapterHint === adapterName) {
81
+ return obj
79
82
  }
80
83
  return adapterGuesser(file, index, adapterHint)
81
84
  }
@@ -139,12 +142,16 @@ export default class SequencePlugin extends Plugin {
139
142
  const regexGuess = /\.(fa|fasta|fas|fna|mfa)$/i
140
143
  const adapterName = 'IndexedFastaAdapter'
141
144
  const fileName = getFileName(file)
142
- if (regexGuess.test(fileName) || adapterHint === adapterName) {
143
- return {
144
- type: adapterName,
145
- fastaLocation: file,
146
- faiLocation: index || makeIndex(file, '.fai'),
147
- }
145
+ const obj = {
146
+ type: adapterName,
147
+ fastaLocation: file,
148
+ faiLocation: index || makeIndex(file, '.fai'),
149
+ }
150
+
151
+ if (regexGuess.test(fileName) && !adapterHint) {
152
+ return obj
153
+ } else if (adapterHint === adapterName) {
154
+ return obj
148
155
  }
149
156
  return adapterGuesser(file, index, adapterHint)
150
157
  }
@@ -191,12 +198,16 @@ export default class SequencePlugin extends Plugin {
191
198
  const regexGuess = /\.(fa|fasta|fas|fna|mfa)\.b?gz$/i
192
199
  const adapterName = 'BgzipFastaAdapter'
193
200
  const fileName = getFileName(file)
194
- if (regexGuess.test(fileName) || adapterHint === adapterName) {
195
- return {
196
- type: adapterName,
197
- faiLocation: makeIndex(file, '.fai'),
198
- gziLocation: makeIndex(file, '.gzi'),
199
- }
201
+ const obj = {
202
+ type: adapterName,
203
+ faiLocation: makeIndex(file, '.fai'),
204
+ gziLocation: makeIndex(file, '.gzi'),
205
+ }
206
+
207
+ if (regexGuess.test(fileName) && !adapterHint) {
208
+ return obj
209
+ } else if (adapterHint === adapterName) {
210
+ return obj
200
211
  }
201
212
  return adapterGuesser(file, index, adapterHint)
202
213
  }