jbrowse-plugin-msaview 2.7.1 → 2.7.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.
Files changed (59) hide show
  1. package/dist/AddHighlightModel/MsaToGenomeHighlight.js +6 -5
  2. package/dist/LaunchMsaView/components/NCBIBlastQuery/CachedBlastResults.js +1 -1
  3. package/dist/LaunchMsaView/components/NCBIBlastQuery/NCBIBlastPanel.js +1 -1
  4. package/dist/LaunchMsaView/components/NCBIBlastQuery/useCachedBlastResults.d.ts +1 -1
  5. package/dist/LaunchMsaView/components/NCBIBlastQuery/useCachedBlastResults.js +5 -2
  6. package/dist/LaunchMsaView/components/calculateProteinSequence.d.ts +3 -2
  7. package/dist/LaunchMsaView/components/calculateProteinSequence.js +31 -15
  8. package/dist/LaunchMsaView/components/geneticCodes.d.ts +15 -0
  9. package/dist/LaunchMsaView/components/geneticCodes.js +227 -0
  10. package/dist/LaunchMsaView/components/types.d.ts +1 -0
  11. package/dist/LaunchMsaView/index.js +32 -26
  12. package/dist/MsaViewPanel/doLaunchBlast.js +10 -22
  13. package/dist/MsaViewPanel/genomeToMSA.js +13 -6
  14. package/dist/MsaViewPanel/genomeToMSA.test.js +35 -6
  15. package/dist/MsaViewPanel/model.d.ts +68 -66
  16. package/dist/MsaViewPanel/model.js +14 -12
  17. package/dist/MsaViewPanel/msaCoordToGenomeCoord.d.ts +32 -13
  18. package/dist/MsaViewPanel/msaCoordToGenomeCoord.js +43 -14
  19. package/dist/MsaViewPanel/msaCoordToGenomeCoord.test.js +108 -18
  20. package/dist/MsaViewPanel/msaDataStore.js +8 -17
  21. package/dist/MsaViewPanel/syncGenomeHoverToMsaColumn.test.js +8 -6
  22. package/dist/jbrowse-plugin-msaview.umd.production.min.js +31 -31
  23. package/dist/jbrowse-plugin-msaview.umd.production.min.js.map +4 -4
  24. package/dist/utils/blastCache.d.ts +1 -2
  25. package/dist/utils/blastCache.js +9 -22
  26. package/dist/utils/domainCache.js +6 -15
  27. package/dist/utils/idb.d.ts +12 -0
  28. package/dist/utils/idb.js +21 -0
  29. package/dist/utils/taxonomyNames.js +13 -18
  30. package/dist/utils/useLocalStorage.d.ts +1 -0
  31. package/dist/utils/useLocalStorage.js +29 -0
  32. package/dist/version.d.ts +1 -1
  33. package/dist/version.js +1 -1
  34. package/package.json +5 -3
  35. package/src/AddHighlightModel/MsaToGenomeHighlight.tsx +6 -8
  36. package/src/LaunchMsaView/components/NCBIBlastQuery/CachedBlastResults.tsx +1 -1
  37. package/src/LaunchMsaView/components/NCBIBlastQuery/NCBIBlastPanel.tsx +1 -1
  38. package/src/LaunchMsaView/components/NCBIBlastQuery/useCachedBlastResults.ts +4 -2
  39. package/src/LaunchMsaView/components/calculateProteinSequence.ts +35 -20
  40. package/src/LaunchMsaView/components/geneticCodes.ts +298 -0
  41. package/src/LaunchMsaView/components/types.ts +3 -0
  42. package/src/LaunchMsaView/index.ts +44 -35
  43. package/src/MsaViewPanel/doLaunchBlast.ts +20 -29
  44. package/src/MsaViewPanel/genomeToMSA.test.ts +38 -6
  45. package/src/MsaViewPanel/genomeToMSA.ts +14 -6
  46. package/src/MsaViewPanel/model.ts +17 -12
  47. package/src/MsaViewPanel/msaCoordToGenomeCoord.test.ts +117 -18
  48. package/src/MsaViewPanel/msaCoordToGenomeCoord.ts +70 -26
  49. package/src/MsaViewPanel/msaDataStore.ts +17 -17
  50. package/src/MsaViewPanel/syncGenomeHoverToMsaColumn.test.ts +8 -6
  51. package/src/utils/blastCache.ts +20 -23
  52. package/src/utils/domainCache.ts +14 -18
  53. package/src/utils/idb.ts +28 -0
  54. package/src/utils/taxonomyNames.ts +22 -24
  55. package/src/utils/useLocalStorage.ts +31 -0
  56. package/src/version.ts +1 -1
  57. package/dist/MsaViewPanel/blosum62.d.ts +0 -2
  58. package/dist/MsaViewPanel/blosum62.js +0 -627
  59. package/src/MsaViewPanel/blosum62.ts +0 -628
@@ -1,22 +1,13 @@
1
- import { openDB } from 'idb';
1
+ import { createDbOpener } from '../utils/idb';
2
2
  const DB_NAME = 'jbrowse-msaview-data';
3
3
  const DB_VERSION = 1;
4
4
  const STORE_NAME = 'msa-data';
5
- let dbPromise;
6
- function getDB() {
7
- dbPromise ??= openDB(DB_NAME, DB_VERSION, {
8
- upgrade(db) {
9
- if (!db.objectStoreNames.contains(STORE_NAME)) {
10
- const store = db.createObjectStore(STORE_NAME, { keyPath: 'id' });
11
- store.createIndex('timestamp', 'timestamp', { unique: false });
12
- }
13
- },
14
- }).catch((e) => {
15
- dbPromise = undefined;
16
- throw e;
17
- });
18
- return dbPromise;
19
- }
5
+ const getDB = createDbOpener(DB_NAME, DB_VERSION, db => {
6
+ if (!db.objectStoreNames.contains(STORE_NAME)) {
7
+ const store = db.createObjectStore(STORE_NAME, { keyPath: 'id' });
8
+ store.createIndex('timestamp', 'timestamp', { unique: false });
9
+ }
10
+ });
20
11
  export function generateDataStoreId() {
21
12
  return `msa-${Date.now()}-${Math.random().toString(36).slice(2, 11)}`;
22
13
  }
@@ -41,7 +32,7 @@ export async function storeMsaData(id, data) {
41
32
  export async function retrieveMsaData(id) {
42
33
  try {
43
34
  const db = await getDB();
44
- const result = (await db.get(STORE_NAME, id));
35
+ const result = await db.get(STORE_NAME, id);
45
36
  if (result) {
46
37
  return {
47
38
  msa: result.msa,
@@ -45,12 +45,14 @@ describe('syncGenomeHoverToMsaColumn (real genomeToMSA mapping)', () => {
45
45
  beforeEach(() => {
46
46
  vi.clearAllMocks();
47
47
  });
48
- test('genome hover at coord 1005 highlights MSA column 5', () => {
48
+ test('genome hover at coord 1005 highlights MSA column 4', () => {
49
49
  const { model, calls } = makeModel();
50
50
  const run = syncGenomeHoverToMsaColumn(model);
51
- hoverGenome(1005); // 1005 - mafRegion.start(1000) = ungapped 5
51
+ // the hover coord is 1-based, so 1005 is the 0-based base 1004, i.e.
52
+ // ungapped offset 4 into a region starting at 1000
53
+ hoverGenome(1005);
52
54
  run();
53
- expect(calls).toEqual([5]);
55
+ expect(calls).toEqual([4]);
54
56
  });
55
57
  test('moving the genome hover moves the highlighted column', () => {
56
58
  const { model, calls } = makeModel();
@@ -59,7 +61,7 @@ describe('syncGenomeHoverToMsaColumn (real genomeToMSA mapping)', () => {
59
61
  run();
60
62
  hoverGenome(1007);
61
63
  run();
62
- expect(calls).toEqual([2, 7]);
64
+ expect(calls).toEqual([1, 6]);
63
65
  });
64
66
  test('leaving the genome clears the column it set', () => {
65
67
  const { model, calls } = makeModel();
@@ -68,7 +70,7 @@ describe('syncGenomeHoverToMsaColumn (real genomeToMSA mapping)', () => {
68
70
  run();
69
71
  clearGenomeHover();
70
72
  run();
71
- expect(calls).toEqual([4, undefined]);
73
+ expect(calls).toEqual([3, undefined]);
72
74
  });
73
75
  test('a hover outside the maf region clears a previously-set column once', () => {
74
76
  const { model, calls } = makeModel();
@@ -78,7 +80,7 @@ describe('syncGenomeHoverToMsaColumn (real genomeToMSA mapping)', () => {
78
80
  hoverGenome(5000); // outside [1000,1010) -> genomeToMSA returns undefined
79
81
  run();
80
82
  run();
81
- expect(calls).toEqual([4, undefined]);
83
+ expect(calls).toEqual([3, undefined]);
82
84
  });
83
85
  test('never touches mouseCol when the genome never provides a column, so a direct MSA hover survives unrelated session hovers', () => {
84
86
  const { model, calls } = makeModel();