jbrowse-plugin-mafviewer 1.1.1 → 1.1.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.
package/package.json CHANGED
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "1.1.1",
2
+ "version": "1.1.3",
3
3
  "license": "MIT",
4
4
  "name": "jbrowse-plugin-mafviewer",
5
5
  "keywords": [
@@ -197,17 +197,25 @@ export default class BgzipTaffyAdapter extends BaseFeatureDataAdapter {
197
197
  if (records) {
198
198
  let firstEntry = records[0]
199
199
  let nextEntry
200
+ // two pass:
201
+ // first pass: find first block greater than query start, then -1 from
202
+ // that
200
203
  for (let i = 0; i < records.length; i++) {
201
204
  if (records[i]!.chrStart >= query.start) {
202
- // we use i-1 for firstEntry because the current record is "greater
203
- // than the query start", we go backwards one record to make sure to
204
- // cover up until the query start. we use i+1 to ensure we get at
205
- // least one block in the case that i=0
206
205
  firstEntry = records[Math.max(i - 1, 0)]
206
+ break
207
+ }
208
+ }
209
+ // second pass: find first block where query end less than record start,
210
+ // and +1 from that
211
+ for (let i = 0; i < records.length; i++) {
212
+ if (query.end <= records[i]!.chrStart) {
207
213
  nextEntry = records[i + 1]
208
214
  break
209
215
  }
210
216
  }
217
+
218
+ nextEntry = nextEntry ?? records.at(-1)
211
219
  if (firstEntry && nextEntry) {
212
220
  const response = await file.read(
213
221
  nextEntry.virtualOffset.blockPosition -
@@ -1,9 +1,13 @@
1
1
  import { BaseFeatureDataAdapter } from '@jbrowse/core/data_adapters/BaseAdapter'
2
2
  import { Feature, Region, SimpleFeature } from '@jbrowse/core/util'
3
+ import { openLocation } from '@jbrowse/core/util/io'
3
4
  import { ObservableCreate } from '@jbrowse/core/util/rxjs'
4
5
  import { getSnapshot } from 'mobx-state-tree'
5
6
  import { firstValueFrom, toArray } from 'rxjs'
6
7
 
8
+ import parseNewick from '../parseNewick'
9
+ import { normalize } from '../util'
10
+
7
11
  interface OrganismRecord {
8
12
  chr: string
9
13
  start: number
@@ -105,5 +109,21 @@ export default class BigMafAdapter extends BaseFeatureDataAdapter {
105
109
  observer.complete()
106
110
  })
107
111
  }
112
+
113
+ async getSamples(_query: Region) {
114
+ const nhLoc = this.getConf('nhLocation')
115
+ const nh =
116
+ nhLoc.uri === '/path/to/my.nh'
117
+ ? undefined
118
+ : await openLocation(nhLoc).readFile('utf8')
119
+
120
+ // TODO: we may need to resolve the exact set of rows in the visible region
121
+ // here
122
+ return {
123
+ samples: normalize(this.getConf('samples')),
124
+ tree: nh ? parseNewick(nh) : undefined,
125
+ }
126
+ }
127
+
108
128
  freeResources(): void {}
109
129
  }
@@ -3,7 +3,15 @@ import React from 'react'
3
3
  import { observer } from 'mobx-react'
4
4
 
5
5
  const Tree = observer(function ({ model }: { model: any }) {
6
- const { hierarchy, showBranchLen } = model
6
+ const {
7
+ // this is needed for redrawing after zoom change, similar to react-msaview
8
+ // renderTreeCanvas
9
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
10
+ rowHeight: _rowHeight,
11
+
12
+ hierarchy,
13
+ showBranchLen,
14
+ } = model
7
15
 
8
16
  return (
9
17
  <>
@@ -213,8 +213,9 @@ export default function stateModelFactory(
213
213
  }))
214
214
  .views(self => {
215
215
  const {
216
+ // eslint-disable-next-line @typescript-eslint/unbound-method
216
217
  trackMenuItems: superTrackMenuItems,
217
-
218
+ // eslint-disable-next-line @typescript-eslint/unbound-method
218
219
  renderProps: superRenderProps,
219
220
  } = self
220
221
  return {
@@ -316,6 +317,7 @@ export default function stateModelFactory(
316
317
  },
317
318
  }))
318
319
  .actions(self => {
320
+ // eslint-disable-next-line @typescript-eslint/unbound-method
319
321
  const { renderSvg: superRenderSvg } = self
320
322
  return {
321
323
  /**
@@ -71,6 +71,7 @@ export default function MultiMAFWidget({ model }: { model: AddTrackModel }) {
71
71
  {['BigMafAdapter', 'MafTabixAdapter', 'BgzipTaffyAdapter'].map(
72
72
  r => (
73
73
  <FormControlLabel
74
+ key={r}
74
75
  value={r}
75
76
  control={<Radio />}
76
77
  checked={fileTypeChoice === r}
@@ -101,9 +102,10 @@ export default function MultiMAFWidget({ model }: { model: AddTrackModel }) {
101
102
  >
102
103
  {['TBI', 'CSI'].map(r => (
103
104
  <FormControlLabel
105
+ key={r}
104
106
  value={r}
105
107
  control={<Radio />}
106
- checked={fileTypeChoice === r}
108
+ checked={indexTypeChoice === r}
107
109
  label={r}
108
110
  />
109
111
  ))}