@jbrowse/plugin-legacy-jbrowse 2.4.0 → 2.4.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.
Files changed (45) hide show
  1. package/dist/JBrowse1Connection/jb1ConfigLoad.js +17 -11
  2. package/dist/JBrowse1Connection/jb1ConfigLoad.js.map +1 -1
  3. package/dist/JBrowse1Connection/jb1ConfigParse.js +16 -22
  4. package/dist/JBrowse1Connection/jb1ConfigParse.js.map +1 -1
  5. package/dist/JBrowse1Connection/jb1ToJb2.js +16 -28
  6. package/dist/JBrowse1Connection/jb1ToJb2.js.map +1 -1
  7. package/dist/JBrowse1Connection/model.js +2 -2
  8. package/dist/JBrowse1Connection/model.js.map +1 -1
  9. package/dist/JBrowse1Connection/util.js +4 -5
  10. package/dist/JBrowse1Connection/util.js.map +1 -1
  11. package/dist/JBrowse1TextSearchAdapter/HttpMap.js +2 -2
  12. package/dist/JBrowse1TextSearchAdapter/HttpMap.js.map +1 -1
  13. package/dist/JBrowse1TextSearchAdapter/JBrowse1TextSearchAdapter.d.ts +4 -4
  14. package/dist/JBrowse1TextSearchAdapter/JBrowse1TextSearchAdapter.js +13 -20
  15. package/dist/JBrowse1TextSearchAdapter/JBrowse1TextSearchAdapter.js.map +1 -1
  16. package/dist/NCListAdapter/NCListFeature.js +2 -2
  17. package/dist/NCListAdapter/NCListFeature.js.map +1 -1
  18. package/esm/JBrowse1Connection/jb1ConfigLoad.js +17 -11
  19. package/esm/JBrowse1Connection/jb1ConfigLoad.js.map +1 -1
  20. package/esm/JBrowse1Connection/jb1ConfigParse.js +16 -22
  21. package/esm/JBrowse1Connection/jb1ConfigParse.js.map +1 -1
  22. package/esm/JBrowse1Connection/jb1ToJb2.js +16 -28
  23. package/esm/JBrowse1Connection/jb1ToJb2.js.map +1 -1
  24. package/esm/JBrowse1Connection/model.js +2 -2
  25. package/esm/JBrowse1Connection/model.js.map +1 -1
  26. package/esm/JBrowse1Connection/util.js +4 -5
  27. package/esm/JBrowse1Connection/util.js.map +1 -1
  28. package/esm/JBrowse1TextSearchAdapter/HttpMap.js +2 -2
  29. package/esm/JBrowse1TextSearchAdapter/HttpMap.js.map +1 -1
  30. package/esm/JBrowse1TextSearchAdapter/JBrowse1TextSearchAdapter.d.ts +4 -4
  31. package/esm/JBrowse1TextSearchAdapter/JBrowse1TextSearchAdapter.js +14 -21
  32. package/esm/JBrowse1TextSearchAdapter/JBrowse1TextSearchAdapter.js.map +1 -1
  33. package/esm/NCListAdapter/NCListFeature.js +2 -2
  34. package/esm/NCListAdapter/NCListFeature.js.map +1 -1
  35. package/package.json +2 -2
  36. package/src/JBrowse1Connection/jb1ConfigLoad.ts +12 -15
  37. package/src/JBrowse1Connection/jb1ConfigParse.ts +8 -14
  38. package/src/JBrowse1Connection/jb1ToJb2.ts +36 -44
  39. package/src/JBrowse1Connection/model.tsx +2 -2
  40. package/src/JBrowse1Connection/util.ts +18 -24
  41. package/src/JBrowse1TextSearchAdapter/HttpMap.ts +2 -2
  42. package/src/JBrowse1TextSearchAdapter/JBrowse1TextSearchAdapter.test.ts +71 -32
  43. package/src/JBrowse1TextSearchAdapter/JBrowse1TextSearchAdapter.ts +24 -25
  44. package/src/NCListAdapter/NCListAdapter.test.ts +2 -2
  45. package/src/NCListAdapter/NCListFeature.ts +2 -2
@@ -14,13 +14,13 @@ export default class NCListFeature {
14
14
  throw new Error('not implemented');
15
15
  }
16
16
  jb2TagToJb1Tag(tag) {
17
- // @ts-ignore
17
+ // @ts-expect-error
18
18
  const mapped = jb2ToJb1[tag] || tag;
19
19
  return mapped.toLowerCase();
20
20
  }
21
21
  jb1TagToJb2Tag(tag) {
22
22
  const t = tag.toLowerCase();
23
- // @ts-ignore
23
+ // @ts-expect-error
24
24
  const mapped = jb1ToJb2[t] || t;
25
25
  return mapped;
26
26
  }
@@ -1 +1 @@
1
- {"version":3,"file":"NCListFeature.js","sourceRoot":"","sources":["../../src/NCListAdapter/NCListFeature.ts"],"names":[],"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C,CAAC,CAAS,EAAE,EAAE,CAAC,IAAI,CAAC,cAAc,CAAC,CAAC,CAAC,CAAC,CAAA;IACzE,CAAC;IAED;;OAEG;IACH,EAAE;QACA,OAAO,IAAI,CAAC,QAAQ,CAAA;IACtB,CAAC;IAED;;OAEG;IACH,MAAM;QACJ,OAAO,IAAI,CAAC,YAAY,CAAA;IAC1B,CAAC;IAED;;OAEG;IACH,QAAQ;QACN,OAAO,IAAI,CAAC,GAAG,CAAC,aAAa,CAAC,CAAA;IAChC,CAAC;IAED,MAAM;QACJ,MAAM,IAAI,GAA4B,EAAE,QAAQ,EAAE,IAAI,CAAC,EAAE,EAAE,EAAE,CAAA;QAC7D,IAAI,CAAC,SAAS,CAAC,IAAI,EAAE,CAAC,OAAO,CAAC,CAAC,GAAW,EAAE,EAAE;YAC5C,MAAM,SAAS,GAAG,IAAI,CAAC,cAAc,CAAC,GAAG,CAAC,CAAA;YAC1C,MAAM,KAAK,GAAG,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,GAAG,CAAC,CAAA;YACrC,IAAI,SAAS,KAAK,aAAa,EAAE;gBAC/B,IAAI,CAAC,WAAW,GAAG,CAAC,KAAK,IAAI,EAAE,CAAC,CAAC,GAAG,CAAC,CAAC,CAAU,EAAE,EAAE;oBAClD,qEAAqE;oBACrE,OAAO,IAAI,aAAa,CAAC,CAAC,EAAE,IAAI,CAAC,CAAC,MAAM,EAAE,CAAA;gBAC5C,CAAC,CAAC,CAAA;aACH;iBAAM;gBACL,IAAI,CAAC,SAAS,CAAC,GAAG,KAAK,CAAA;aACxB;QACH,CAAC,CAAC,CAAA;QACF,OAAO,IAAI,CAAA;IACb,CAAC;CACF"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jbrowse/plugin-legacy-jbrowse",
3
- "version": "2.4.0",
3
+ "version": "2.4.2",
4
4
  "description": "JBrowse 2 plugin for connecting to and reading JBrowse 1 data",
5
5
  "keywords": [
6
6
  "jbrowse",
@@ -56,5 +56,5 @@
56
56
  "distModule": "esm/index.js",
57
57
  "srcModule": "src/index.ts",
58
58
  "module": "esm/index.js",
59
- "gitHead": "78707a2bc3ba8489f26a590ef83f62ede945d048"
59
+ "gitHead": "36e382a70e7d220343b873e7e6aba5c83e5342c8"
60
60
  }
@@ -21,10 +21,13 @@ function isLocalPathLocation(
21
21
  }
22
22
 
23
23
  export async function fetchJb1(
24
+ // eslint-disable-next-line unicorn/no-object-as-default-parameter
24
25
  dataRoot: JBLocation = { uri: '', locationType: 'UriLocation' },
26
+ // eslint-disable-next-line unicorn/no-object-as-default-parameter
25
27
  baseConfig: Config = {
26
28
  include: ['{dataRoot}/trackList.json', '{dataRoot}/tracks.conf'],
27
29
  },
30
+ // eslint-disable-next-line unicorn/no-object-as-default-parameter
28
31
  baseConfigRoot: JBLocation = { uri: '', locationType: 'UriLocation' },
29
32
  ): Promise<Config> {
30
33
  const protocol = 'uri' in dataRoot ? 'uri' : 'localPath'
@@ -37,10 +40,7 @@ export async function fetchJb1(
37
40
  dataRootLocation = dataRoot.localPath
38
41
  }
39
42
  if (dataRootLocation.endsWith('/')) {
40
- dataRootReg[protocol] = dataRootLocation.slice(
41
- 0,
42
- dataRootLocation.length - 1,
43
- )
43
+ dataRootReg[protocol] = dataRootLocation.slice(0, -1)
44
44
  }
45
45
  if (
46
46
  (isUriLocation(baseConfigRoot) && baseConfigRoot.uri) ||
@@ -55,16 +55,13 @@ export async function fetchJb1(
55
55
  baseConfigLocation = baseConfigRoot.localPath
56
56
  }
57
57
  if (baseConfigLocation.endsWith('/')) {
58
- baseConfigLocation = baseConfigLocation.slice(
59
- 0,
60
- baseConfigLocation.length - 1,
61
- )
58
+ baseConfigLocation = baseConfigLocation.slice(0, -1)
62
59
  }
63
60
  let newConfig: Config = {}
64
61
  for (const conf of ['jbrowse.conf', 'jbrowse_conf.json']) {
65
62
  let fetchedConfig = null
66
63
  try {
67
- // @ts-ignore
64
+ // @ts-expect-error
68
65
  fetchedConfig = await fetchConfigFile({
69
66
  [baseProtocol]: `${baseConfigLocation}/${conf}`,
70
67
  })
@@ -143,12 +140,12 @@ function mergeConfigs(a: Config | null, b: Config | null): Config | null {
143
140
  } else if (
144
141
  !noRecursiveMerge(prop) &&
145
142
  prop in a &&
146
- // @ts-ignore
143
+ // @ts-expect-error
147
144
  typeof b[prop] === 'object' &&
148
- // @ts-ignore
145
+ // @ts-expect-error
149
146
  typeof a[prop] === 'object'
150
147
  ) {
151
- // @ts-ignore
148
+ // @ts-expect-error
152
149
  a[prop] = deepUpdate(a[prop], b[prop])
153
150
  } else if (prop === 'dataRoot') {
154
151
  if (
@@ -157,9 +154,9 @@ function mergeConfigs(a: Config | null, b: Config | null): Config | null {
157
154
  ) {
158
155
  a[prop] = b[prop]
159
156
  }
160
- // @ts-ignore
157
+ // @ts-expect-error
161
158
  } else if (a[prop] === undefined || b[prop] !== undefined) {
162
- // @ts-ignore
159
+ // @ts-expect-error
163
160
  a[prop] = b[prop]
164
161
  }
165
162
  }
@@ -284,7 +281,7 @@ function fillTemplates<T extends any>(subconfig: T, config: Config): T {
284
281
  sub[name] = fillTemplates(sub[name], config)
285
282
  }
286
283
  } else if (typeof subconfig === 'string') {
287
- // @ts-ignore
284
+ // @ts-expect-error
288
285
  return fillTemplate(subconfig, config)
289
286
  }
290
287
 
@@ -68,7 +68,7 @@ function parse(text: string, url: string): Config {
68
68
  if (!keyPath) {
69
69
  throw new Error(`Error parsing in section ${section.join(' - ')}`)
70
70
  }
71
- const path = section.concat(keyPath).join('.')
71
+ const path = [...section, ...keyPath].join('.')
72
72
  if (operation === '+=') {
73
73
  let existing = getValue(data, path)
74
74
  if (existing) {
@@ -124,7 +124,7 @@ function parse(text: string, url: string): Config {
124
124
  recordVal()
125
125
  keyPath = match[1].trim().split(/\s*\.\s*/)
126
126
  ;[, , operation] = match
127
- if (isAlwaysArray(section.concat(keyPath).join('.'))) {
127
+ if (isAlwaysArray([...section, ...keyPath].join('.'))) {
128
128
  operation = '+='
129
129
  }
130
130
  value = match[3].trim()
@@ -385,12 +385,9 @@ function synthesizeTrackStoreConfig(
385
385
  // defaults if it is not explicit in the configuration
386
386
  const { urlTemplate = '' } = trackConfig
387
387
 
388
- let storeClass: string
389
- if (trackConfig.storeClass) {
390
- storeClass = regularizeClass('JBrowse/Store', trackConfig.storeClass)
391
- } else {
392
- storeClass = guessStoreClass(trackConfig, urlTemplate)
393
- }
388
+ const storeClass = trackConfig.storeClass
389
+ ? regularizeClass('JBrowse/Store', trackConfig.storeClass)
390
+ : guessStoreClass(trackConfig, urlTemplate)
394
391
 
395
392
  if (!storeClass) {
396
393
  console.warn(
@@ -404,7 +401,7 @@ function synthesizeTrackStoreConfig(
404
401
 
405
402
  // if this is the first sequence store we see, and we have no refseqs store
406
403
  // defined explicitly, make this the refseqs store.
407
- if (
404
+ storeConf.name =
408
405
  (storeClass === 'JBrowse/Store/Sequence/StaticChunked' ||
409
406
  storeClass === 'JBrowse/Store/Sequence/IndexedFasta' ||
410
407
  storeClass === 'JBrowse/Store/SeqFeature/IndexedFasta' ||
@@ -413,11 +410,8 @@ function synthesizeTrackStoreConfig(
413
410
  storeClass === 'JBrowse/Store/Sequence/TwoBit' ||
414
411
  trackConfig.useAsRefSeqStore) &&
415
412
  !(mainConf.stores && mainConf.stores.refseqs)
416
- ) {
417
- storeConf.name = 'refseqs'
418
- } else {
419
- storeConf.name = `store${objectHash(storeConf)}`
420
- }
413
+ ? 'refseqs'
414
+ : `store${objectHash(storeConf)}`
421
415
  // record it
422
416
  if (!mainConf.stores) {
423
417
  mainConf.stores = {}
@@ -139,17 +139,15 @@ export function convertTrackConfig(
139
139
  cramLocation: { uri: urlTemplate, locationType: 'UriLocation' },
140
140
  sequenceAdapter,
141
141
  }
142
- if (jb1TrackConfig.craiUrlTemplate) {
143
- adapter.craiLocation = {
144
- uri: resolveUrlTemplate(jb1TrackConfig.craiUrlTemplate),
145
- locationType: 'UriLocation',
146
- }
147
- } else {
148
- adapter.craiLocation = {
149
- uri: `${urlTemplate}.crai`,
150
- locationType: 'UriLocation',
151
- }
152
- }
142
+ adapter.craiLocation = jb1TrackConfig.craiUrlTemplate
143
+ ? {
144
+ uri: resolveUrlTemplate(jb1TrackConfig.craiUrlTemplate),
145
+ locationType: 'UriLocation',
146
+ }
147
+ : {
148
+ uri: `${urlTemplate}.crai`,
149
+ locationType: 'UriLocation',
150
+ }
153
151
  return {
154
152
  ...jb2TrackConfig,
155
153
  type: 'AlignmentsTrack',
@@ -346,17 +344,15 @@ export function convertTrackConfig(
346
344
  type: 'IndexedFastaAdapter',
347
345
  fastaLocation: { uri: urlTemplate, locationType: 'UriLocation' },
348
346
  }
349
- if (jb1TrackConfig.faiUrlTemplate) {
350
- adapter.faiLocation = {
351
- uri: resolveUrlTemplate(jb1TrackConfig.faiUrlTemplate),
352
- locationType: 'UriLocation',
353
- }
354
- } else {
355
- adapter.faiLocation = {
356
- uri: `${urlTemplate}.fai`,
357
- locationType: 'UriLocation',
358
- }
359
- }
347
+ adapter.faiLocation = jb1TrackConfig.faiUrlTemplate
348
+ ? {
349
+ uri: resolveUrlTemplate(jb1TrackConfig.faiUrlTemplate),
350
+ locationType: 'UriLocation',
351
+ }
352
+ : {
353
+ uri: `${urlTemplate}.fai`,
354
+ locationType: 'UriLocation',
355
+ }
360
356
  return {
361
357
  ...jb2TrackConfig,
362
358
  type: 'SequenceTrack',
@@ -368,28 +364,24 @@ export function convertTrackConfig(
368
364
  type: 'BgzipFastaAdapter',
369
365
  fastaLocation: { uri: urlTemplate, locationType: 'UriLocation' },
370
366
  }
371
- if (jb1TrackConfig.faiUrlTemplate) {
372
- adapter.faiLocation = {
373
- uri: resolveUrlTemplate(jb1TrackConfig.faiUrlTemplate),
374
- locationType: 'UriLocation',
375
- }
376
- } else {
377
- adapter.faiLocation = {
378
- uri: `${urlTemplate}.fai`,
379
- locationType: 'UriLocation',
380
- }
381
- }
382
- if (jb1TrackConfig.gziUrlTemplate) {
383
- adapter.gziLocation = {
384
- uri: resolveUrlTemplate(jb1TrackConfig.gziUrlTemplate),
385
- locationType: 'UriLocation',
386
- }
387
- } else {
388
- adapter.gziLocation = {
389
- uri: `${urlTemplate}.gzi`,
390
- locationType: 'UriLocation',
391
- }
392
- }
367
+ adapter.faiLocation = jb1TrackConfig.faiUrlTemplate
368
+ ? {
369
+ uri: resolveUrlTemplate(jb1TrackConfig.faiUrlTemplate),
370
+ locationType: 'UriLocation',
371
+ }
372
+ : {
373
+ uri: `${urlTemplate}.fai`,
374
+ locationType: 'UriLocation',
375
+ }
376
+ adapter.gziLocation = jb1TrackConfig.gziUrlTemplate
377
+ ? {
378
+ uri: resolveUrlTemplate(jb1TrackConfig.gziUrlTemplate),
379
+ locationType: 'UriLocation',
380
+ }
381
+ : {
382
+ uri: `${urlTemplate}.gzi`,
383
+ locationType: 'UriLocation',
384
+ }
393
385
  return {
394
386
  ...jb2TrackConfig,
395
387
  type: 'ReferenceSequenceTrack',
@@ -49,7 +49,7 @@ export default function (pluginManager: PluginManager) {
49
49
  'adapter',
50
50
  ])
51
51
 
52
- // @ts-ignore
52
+ // @ts-expect-error
53
53
  const jb2Tracks = config.tracks?.map(jb1Track => {
54
54
  const jb2Track = convertTrackConfig(
55
55
  jb1Track,
@@ -57,7 +57,7 @@ export default function (pluginManager: PluginManager) {
57
57
  sequenceAdapter,
58
58
  )
59
59
 
60
- // @ts-ignore
60
+ // @ts-expect-error
61
61
  jb2Track.assemblyNames = [assemblyName]
62
62
  return jb2Track
63
63
  })
@@ -24,10 +24,7 @@ export function deepUpdate(a: Obj, b: Obj): Obj {
24
24
  typeof a[prop] === 'object'
25
25
  ) {
26
26
  deepUpdate(a[prop], b[prop])
27
- } else if (
28
- typeof a[prop] === 'undefined' ||
29
- typeof b[prop] !== 'undefined'
30
- ) {
27
+ } else if (a[prop] === undefined || b[prop] !== undefined) {
31
28
  a[prop] = b[prop]
32
29
  }
33
30
  }
@@ -44,27 +41,24 @@ export function deepUpdate(a: Obj, b: Obj): Obj {
44
41
  * e.g., 'htp://foo/someurl?arg=valueforbaz'
45
42
  */
46
43
  export function fillTemplate(template: string, fillWith: Obj): string {
47
- return template.replace(
48
- /\{([\w\s.]+)\}/g,
49
- (match, varName: string): string => {
50
- varName = varName.replace(/\s+/g, '') // remove all whitespace
51
- const fill = getValue(fillWith, varName)
52
- if (fill !== undefined) {
53
- if (typeof fill === 'function') {
54
- return fill(varName)
55
- }
56
- return fill
44
+ return template.replace(/{([\s\w.]+)}/g, (match, varName: string): string => {
45
+ varName = varName.replace(/\s+/g, '') // remove all whitespace
46
+ const fill = getValue(fillWith, varName)
47
+ if (fill !== undefined) {
48
+ if (typeof fill === 'function') {
49
+ return fill(varName)
57
50
  }
58
- if (fillWith.callback) {
59
- // @ts-ignore
60
- const v = fillWith.callback.call(this, varName)
61
- if (v !== undefined) {
62
- return v
63
- }
51
+ return fill
52
+ }
53
+ if (fillWith.callback) {
54
+ // @ts-expect-error
55
+ const v = fillWith.callback.call(this, varName)
56
+ if (v !== undefined) {
57
+ return v
64
58
  }
65
- return match
66
- },
67
- )
59
+ }
60
+ return match
61
+ })
68
62
  }
69
63
 
70
64
  /**
@@ -146,7 +140,7 @@ function mixin(dest: Obj, source: Obj, copyFunc: Function): Obj {
146
140
  s = source[name]
147
141
  if (
148
142
  !(name in dest) ||
149
- // @ts-ignore
143
+ // @ts-expect-error
150
144
  (dest[name] !== s && (!(name in empty) || empty[name] !== s))
151
145
  ) {
152
146
  dest[name] = copyFunc ? copyFunc(s) : s
@@ -81,10 +81,10 @@ export default class HttpMap {
81
81
  while (hex.length < 8) {
82
82
  hex = `0${hex}`
83
83
  }
84
- hex = hex.substr(8 - hashHexCharacters)
84
+ hex = hex.slice(8 - hashHexCharacters)
85
85
  const dirpath = []
86
86
  for (let i = 0; i < hex.length; i += 3) {
87
- dirpath.push(hex.substring(i, i + 3))
87
+ dirpath.push(hex.slice(i, i + 3))
88
88
  }
89
89
  return `${dirpath.join('/')}.json${compress ? 'z' : ''}`
90
90
  }
@@ -6,50 +6,89 @@ import last from '../../test_data/names/f.json'
6
6
  import Adapter from './JBrowse1TextSearchAdapter'
7
7
  import configSchema from './configSchema'
8
8
 
9
- test('adapter can fetch files from names index', async () => {
10
- function mockFetch(url: string): Promise<Response> {
11
- let response = {}
12
- if (url.includes('names/meta.json')) {
13
- response = meta
14
- }
15
- if (url.includes('names/0.json')) {
16
- response = first
17
- }
18
- if (url.includes('names/f.json')) {
19
- response = last
20
- }
21
- return Promise.resolve(new Response(JSON.stringify(response)))
9
+ function mockFetch(url: string) {
10
+ let response = {}
11
+ if (url.includes('names/meta.json')) {
12
+ response = meta
22
13
  }
14
+ if (url.includes('names/0.json')) {
15
+ response = first
16
+ }
17
+ if (url.includes('names/f.json')) {
18
+ response = last
19
+ }
20
+ return Promise.resolve(new Response(JSON.stringify(response)))
21
+ }
23
22
 
24
- const rootTemplate = path
25
- .join(__dirname, '..', '..', '..', '..', 'test_data', 'names')
26
- .replace(/\\/g, '\\\\')
23
+ const rootTemplate = path
24
+ .join(__dirname, '..', '..', '..', '..', 'test_data', 'names')
25
+ .replace(/\\/g, '\\\\')
27
26
 
27
+ test('search upper case', async () => {
28
28
  const spy = jest.spyOn(global, 'fetch')
29
29
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
30
30
  spy.mockImplementation(mockFetch as any)
31
31
 
32
- const urlPath = decodeURI(new URL(`file://${rootTemplate}`).href)
33
- const args = {
34
- type: 'JBrowse1TextSearchAdapter',
35
- textSearchAdapterId: 'JBrowse1GenerateNamesAdapterTest',
36
- namesIndexLocation: {
37
- uri: urlPath,
38
- locationType: 'UriLocation',
39
- },
40
- }
41
- // create adapter
42
- const adapter = new Adapter(configSchema.create(args))
43
- // prefix search
32
+ const adapter = new Adapter(
33
+ configSchema.create({
34
+ type: 'JBrowse1TextSearchAdapter',
35
+ textSearchAdapterId: 'JBrowse1GenerateNamesAdapterTest',
36
+ namesIndexLocation: {
37
+ uri: decodeURI(new URL(`file://${rootTemplate}`).href),
38
+ locationType: 'UriLocation',
39
+ },
40
+ }),
41
+ )
42
+ const results = await adapter.searchIndex({
43
+ searchType: 'prefix',
44
+ queryString: 'Apple',
45
+ })
46
+ // check results are of type BaseResult for prefix search
47
+ expect(results.length).toBeGreaterThan(0)
48
+ expect(results[0] instanceof BaseResult).toBeTruthy()
49
+ expect(results[0].getLabel()).toEqual('Apple1')
50
+ expect(results[1].getLabel()).toEqual('Apple2')
51
+ expect(results[2].getLabel()).toEqual('Apple3')
52
+
53
+ // exact search
54
+ const results2 = await adapter.searchIndex({
55
+ searchType: 'exact',
56
+ queryString: 'Apple3',
57
+ })
58
+ // check results are of type location for exact search
59
+ expect(results2.length).toEqual(5)
60
+ expect(results2.length).toBeGreaterThan(0)
61
+ expect(results2[0] instanceof BaseResult).toBeTruthy()
62
+ expect(results2[0].getLabel()).toEqual('Apple3')
63
+ expect(results2[0].getLocation()).toEqual('ctgA:17399-23000')
64
+ })
65
+
66
+ test('search lower case', async () => {
67
+ const spy = jest.spyOn(global, 'fetch')
68
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
69
+ spy.mockImplementation(mockFetch as any)
70
+
71
+ const adapter = new Adapter(
72
+ configSchema.create({
73
+ type: 'JBrowse1TextSearchAdapter',
74
+ textSearchAdapterId: 'JBrowse1GenerateNamesAdapterTest',
75
+ namesIndexLocation: {
76
+ uri: decodeURI(new URL(`file://${rootTemplate}`).href),
77
+ locationType: 'UriLocation',
78
+ },
79
+ }),
80
+ )
44
81
  const results = await adapter.searchIndex({
45
82
  searchType: 'prefix',
46
83
  queryString: 'apple',
47
84
  })
48
85
  // check results are of type BaseResult for prefix search
86
+ expect(results.length).toBeGreaterThan(0)
49
87
  expect(results[0] instanceof BaseResult).toBeTruthy()
50
88
  expect(results[0].getLabel()).toEqual('Apple1')
51
89
  expect(results[1].getLabel()).toEqual('Apple2')
52
90
  expect(results[2].getLabel()).toEqual('Apple3')
91
+
53
92
  // exact search
54
93
  const results2 = await adapter.searchIndex({
55
94
  searchType: 'exact',
@@ -57,8 +96,8 @@ test('adapter can fetch files from names index', async () => {
57
96
  })
58
97
  // check results are of type location for exact search
59
98
  expect(results2.length).toEqual(5)
60
- const test2 = results2[0]
61
- expect(test2 instanceof BaseResult).toBeTruthy()
62
- expect(test2.getLabel()).toEqual('Apple3')
63
- expect(test2.getLocation()).toEqual('ctgA:17399-23000')
99
+ expect(results2.length).toBeGreaterThan(0)
100
+ expect(results2[0] instanceof BaseResult).toBeTruthy()
101
+ expect(results2[0].getLabel()).toEqual('Apple3')
102
+ expect(results2[0].getLocation()).toEqual('ctgA:17399-23000')
64
103
  })
@@ -4,9 +4,10 @@ import {
4
4
  BaseAdapter,
5
5
  } from '@jbrowse/core/data_adapters/BaseAdapter'
6
6
  import BaseResult from '@jbrowse/core/TextSearch/BaseResults'
7
- import { Instance } from 'mobx-state-tree'
8
- import { readConfObject } from '@jbrowse/core/configuration'
9
- import MyConfigSchema from './configSchema'
7
+ import {
8
+ AnyConfigurationModel,
9
+ readConfObject,
10
+ } from '@jbrowse/core/configuration'
10
11
  import HttpMap from './HttpMap'
11
12
  import PluginManager from '@jbrowse/core/PluginManager'
12
13
  import { getSubAdapterType } from '@jbrowse/core/data_adapters/dataAdapterCache'
@@ -23,7 +24,8 @@ interface SearchResults {
23
24
 
24
25
  export type NamesIndexRecord = string | Array<string | number>
25
26
 
26
- // Jbrowse1 text search adapter
27
+ type IndexFile = Record<string, SearchResults>
28
+
27
29
  // Uses index built by generate-names.pl
28
30
  export default class JBrowse1TextSearchAdapter
29
31
  extends BaseAdapter
@@ -34,19 +36,15 @@ export default class JBrowse1TextSearchAdapter
34
36
  tracksNames?: string[]
35
37
 
36
38
  constructor(
37
- config: Instance<typeof MyConfigSchema>,
39
+ config: AnyConfigurationModel,
38
40
  getSubAdapter?: getSubAdapterType,
39
41
  pluginManager?: PluginManager,
40
42
  ) {
41
43
  super(config, getSubAdapter, pluginManager)
42
- const namesIndexLocation = readConfObject(config, 'namesIndexLocation')
43
- if (!namesIndexLocation) {
44
- throw new Error('must provide namesIndexLocation')
45
- }
44
+ const namesIndex = readConfObject(config, 'namesIndexLocation')
45
+ const { baseUri, uri } = namesIndex
46
46
  this.httpMap = new HttpMap({
47
- url: namesIndexLocation.baseUri
48
- ? new URL(namesIndexLocation.uri, namesIndexLocation.baseUri).href
49
- : namesIndexLocation.uri,
47
+ url: baseUri ? new URL(uri, baseUri).href : uri,
50
48
  })
51
49
  }
52
50
 
@@ -55,30 +53,31 @@ export default class JBrowse1TextSearchAdapter
55
53
  * else it returns empty
56
54
  * @param query - string query
57
55
  */
58
- async loadIndexFile(query: string): Promise<Record<string, SearchResults>> {
56
+ async loadIndexFile(query: string): Promise<IndexFile> {
59
57
  return this.httpMap.getBucket(query)
60
58
  }
61
59
 
62
60
  async searchIndex(args: BaseArgs) {
63
61
  const { searchType, queryString } = args
64
62
  const tracks = this.tracksNames || (await this.httpMap.getTrackNames())
65
- const entries = await this.loadIndexFile(queryString.toLowerCase())
66
- if (entries[queryString]) {
67
- return this.formatResults(entries[queryString], tracks, searchType)
68
- }
69
- return []
63
+ const str = queryString.toLowerCase()
64
+ const entries = await this.loadIndexFile(str)
65
+ return entries[str]
66
+ ? this.formatResults(entries[str], tracks, searchType)
67
+ : []
70
68
  }
71
69
  formatResults(results: SearchResults, tracks: string[], searchType?: string) {
72
70
  return [
73
71
  ...(searchType === 'exact'
74
72
  ? []
75
- : results.prefix.map(result => {
76
- return new BaseResult({
77
- label: typeof result === 'object' ? result.name : result,
78
- matchedAttribute: 'name',
79
- matchedObject: { result: result },
80
- })
81
- })),
73
+ : results.prefix.map(
74
+ result =>
75
+ new BaseResult({
76
+ label: typeof result === 'object' ? result.name : result,
77
+ matchedAttribute: 'name',
78
+ matchedObject: { result: result },
79
+ }),
80
+ )),
82
81
  ...results.exact.map(result => {
83
82
  const name = result[0]
84
83
  const trackIndex = result[1]
@@ -15,9 +15,9 @@ export function generateReadBuffer(
15
15
  }
16
16
 
17
17
  beforeEach(() => {
18
- // @ts-ignore
18
+ // @ts-expect-error
19
19
  fetch.resetMocks()
20
- // @ts-ignore
20
+ // @ts-expect-error
21
21
  fetch.mockResponse(
22
22
  generateReadBuffer(
23
23
  (url: string) =>
@@ -26,14 +26,14 @@ export default class NCListFeature implements Feature {
26
26
  }
27
27
 
28
28
  jb2TagToJb1Tag(tag: string): string {
29
- // @ts-ignore
29
+ // @ts-expect-error
30
30
  const mapped = jb2ToJb1[tag] || tag
31
31
  return mapped.toLowerCase()
32
32
  }
33
33
 
34
34
  jb1TagToJb2Tag(tag: string): string {
35
35
  const t = tag.toLowerCase()
36
- // @ts-ignore
36
+ // @ts-expect-error
37
37
  const mapped = jb1ToJb2[t] || t
38
38
  return mapped
39
39
  }