jbrowse-plugin-msaview 2.3.8 → 2.4.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.
Files changed (128) hide show
  1. package/dist/AddHighlightModel/GenomeMouseoverHighlight.js +4 -15
  2. package/dist/AddHighlightModel/GenomeMouseoverHighlight.js.map +1 -1
  3. package/dist/AddHighlightModel/MsaToGenomeHighlight.js +11 -13
  4. package/dist/AddHighlightModel/MsaToGenomeHighlight.js.map +1 -1
  5. package/dist/AddHighlightModel/util.d.ts +6 -0
  6. package/dist/AddHighlightModel/util.js +6 -0
  7. package/dist/AddHighlightModel/util.js.map +1 -1
  8. package/dist/BgzipFastaMsaAdapter/BgzipFastaMsaAdapter.d.ts +2 -0
  9. package/dist/BgzipFastaMsaAdapter/BgzipFastaMsaAdapter.js +8 -4
  10. package/dist/BgzipFastaMsaAdapter/BgzipFastaMsaAdapter.js.map +1 -1
  11. package/dist/LaunchMsaView/components/LaunchMsaViewDialog.js +3 -8
  12. package/dist/LaunchMsaView/components/LaunchMsaViewDialog.js.map +1 -1
  13. package/dist/LaunchMsaView/components/ManualMSALoader/ManualMSALoader.js +7 -10
  14. package/dist/LaunchMsaView/components/ManualMSALoader/ManualMSALoader.js.map +1 -1
  15. package/dist/LaunchMsaView/components/NCBIBlastQuery/NCBIBlastAutomaticPanel.js +2 -5
  16. package/dist/LaunchMsaView/components/NCBIBlastQuery/NCBIBlastAutomaticPanel.js.map +1 -1
  17. package/dist/LaunchMsaView/components/NCBIBlastQuery/NCBIBlastManualPanel.js +0 -3
  18. package/dist/LaunchMsaView/components/NCBIBlastQuery/NCBIBlastManualPanel.js.map +1 -1
  19. package/dist/LaunchMsaView/components/NCBIBlastQuery/blastLaunchView.d.ts +4 -4
  20. package/dist/LaunchMsaView/components/NCBIBlastQuery/blastLaunchView.js +2 -2
  21. package/dist/LaunchMsaView/components/NCBIBlastQuery/blastLaunchView.js.map +1 -1
  22. package/dist/LaunchMsaView/components/NCBIBlastQuery/consts.d.ts +4 -0
  23. package/dist/LaunchMsaView/components/NCBIBlastQuery/consts.js +2 -0
  24. package/dist/LaunchMsaView/components/NCBIBlastQuery/consts.js.map +1 -1
  25. package/dist/LaunchMsaView/components/PreLoadedMSA/PreLoadedMSADataPanel.js +10 -21
  26. package/dist/LaunchMsaView/components/PreLoadedMSA/PreLoadedMSADataPanel.js.map +1 -1
  27. package/dist/LaunchMsaView/components/PreLoadedMSA/types.d.ts +1 -0
  28. package/dist/LaunchMsaView/components/PreLoadedMSA/types.js +4 -1
  29. package/dist/LaunchMsaView/components/PreLoadedMSA/types.js.map +1 -1
  30. package/dist/LaunchMsaView/components/types.d.ts +0 -3
  31. package/dist/LaunchMsaView/components/useFeatureSequence.d.ts +4 -4
  32. package/dist/LaunchMsaView/components/useFeatureSequence.js +2 -4
  33. package/dist/LaunchMsaView/components/useFeatureSequence.js.map +1 -1
  34. package/dist/LaunchMsaView/components/useSWRFeatureSequence.d.ts +4 -5
  35. package/dist/LaunchMsaView/components/useSWRFeatureSequence.js +11 -30
  36. package/dist/LaunchMsaView/components/useSWRFeatureSequence.js.map +1 -1
  37. package/dist/MsaViewPanel/afterCreateAutoruns.js +13 -17
  38. package/dist/MsaViewPanel/afterCreateAutoruns.js.map +1 -1
  39. package/dist/MsaViewPanel/components/ConnectStructureDialog.js +2 -2
  40. package/dist/MsaViewPanel/components/ConnectStructureDialog.js.map +1 -1
  41. package/dist/MsaViewPanel/components/LoadingBLAST.js +2 -3
  42. package/dist/MsaViewPanel/components/LoadingBLAST.js.map +1 -1
  43. package/dist/MsaViewPanel/model.d.ts +9 -11
  44. package/dist/MsaViewPanel/model.js +22 -23
  45. package/dist/MsaViewPanel/model.js.map +1 -1
  46. package/dist/MsaViewPanel/msaDataStore.d.ts +0 -1
  47. package/dist/MsaViewPanel/msaDataStore.js +0 -9
  48. package/dist/MsaViewPanel/msaDataStore.js.map +1 -1
  49. package/dist/MsaViewPanel/structureConnection.d.ts +6 -4
  50. package/dist/MsaViewPanel/structureConnection.js +6 -6
  51. package/dist/MsaViewPanel/structureConnection.js.map +1 -1
  52. package/dist/MsaViewPanel/structureConnection.test.js +1 -19
  53. package/dist/MsaViewPanel/structureConnection.test.js.map +1 -1
  54. package/dist/MsaViewPanel/util.d.ts +11 -0
  55. package/dist/MsaViewPanel/util.js +11 -3
  56. package/dist/MsaViewPanel/util.js.map +1 -1
  57. package/dist/jbrowse-plugin-msaview.umd.production.min.js +25 -27
  58. package/dist/jbrowse-plugin-msaview.umd.production.min.js.map +4 -4
  59. package/dist/utils/blastCache.d.ts +7 -13
  60. package/dist/utils/blastCache.js +0 -12
  61. package/dist/utils/blastCache.js.map +1 -1
  62. package/dist/utils/msa.d.ts +2 -1
  63. package/dist/utils/msa.js +0 -3
  64. package/dist/utils/msa.js.map +1 -1
  65. package/dist/utils/ncbiBlast.d.ts +3 -2
  66. package/dist/utils/ncbiBlast.js +7 -7
  67. package/dist/utils/ncbiBlast.js.map +1 -1
  68. package/dist/utils/taxonomyNames.js +9 -7
  69. package/dist/utils/taxonomyNames.js.map +1 -1
  70. package/dist/version.d.ts +1 -1
  71. package/dist/version.js +1 -1
  72. package/package.json +22 -20
  73. package/src/AddHighlightModel/GenomeMouseoverHighlight.tsx +8 -25
  74. package/src/AddHighlightModel/MsaToGenomeHighlight.tsx +16 -16
  75. package/src/AddHighlightModel/util.ts +11 -0
  76. package/src/BgzipFastaMsaAdapter/BgzipFastaMsaAdapter.ts +10 -4
  77. package/src/LaunchMsaView/components/LaunchMsaViewDialog.tsx +3 -16
  78. package/src/LaunchMsaView/components/ManualMSALoader/ManualMSALoader.tsx +8 -12
  79. package/src/LaunchMsaView/components/NCBIBlastQuery/NCBIBlastAutomaticPanel.tsx +6 -15
  80. package/src/LaunchMsaView/components/NCBIBlastQuery/NCBIBlastManualPanel.tsx +0 -9
  81. package/src/LaunchMsaView/components/NCBIBlastQuery/blastLaunchView.ts +6 -6
  82. package/src/LaunchMsaView/components/NCBIBlastQuery/consts.ts +7 -0
  83. package/src/LaunchMsaView/components/PreLoadedMSA/PreLoadedMSADataPanel.tsx +12 -27
  84. package/src/LaunchMsaView/components/PreLoadedMSA/types.ts +6 -0
  85. package/src/LaunchMsaView/components/types.ts +0 -3
  86. package/src/LaunchMsaView/components/useFeatureSequence.ts +1 -7
  87. package/src/LaunchMsaView/components/useSWRFeatureSequence.ts +10 -37
  88. package/src/MsaViewPanel/afterCreateAutoruns.ts +15 -17
  89. package/src/MsaViewPanel/components/ConnectStructureDialog.tsx +2 -2
  90. package/src/MsaViewPanel/components/LoadingBLAST.tsx +4 -3
  91. package/src/MsaViewPanel/model.ts +33 -33
  92. package/src/MsaViewPanel/msaDataStore.ts +0 -9
  93. package/src/MsaViewPanel/structureConnection.test.ts +0 -21
  94. package/src/MsaViewPanel/structureConnection.ts +7 -7
  95. package/src/MsaViewPanel/util.ts +27 -2
  96. package/src/utils/blastCache.ts +14 -37
  97. package/src/utils/msa.ts +5 -6
  98. package/src/utils/ncbiBlast.ts +18 -11
  99. package/src/utils/taxonomyNames.ts +13 -6
  100. package/src/version.ts +1 -1
  101. package/dist/LaunchMsaView/components/EnsemblGeneTree/EnsemblGeneTree.d.ts +0 -8
  102. package/dist/LaunchMsaView/components/EnsemblGeneTree/EnsemblGeneTree.js +0 -70
  103. package/dist/LaunchMsaView/components/EnsemblGeneTree/EnsemblGeneTree.js.map +0 -1
  104. package/dist/LaunchMsaView/components/EnsemblGeneTree/ensemblGeneTreeLaunchView.d.ts +0 -13
  105. package/dist/LaunchMsaView/components/EnsemblGeneTree/ensemblGeneTreeLaunchView.js +0 -12
  106. package/dist/LaunchMsaView/components/EnsemblGeneTree/ensemblGeneTreeLaunchView.js.map +0 -1
  107. package/dist/LaunchMsaView/components/EnsemblGeneTree/ensemblGeneTreeUtils.d.ts +0 -6
  108. package/dist/LaunchMsaView/components/EnsemblGeneTree/ensemblGeneTreeUtils.js +0 -25
  109. package/dist/LaunchMsaView/components/EnsemblGeneTree/ensemblGeneTreeUtils.js.map +0 -1
  110. package/dist/LaunchMsaView/components/EnsemblGeneTree/gatherSequencesFromTree.d.ts +0 -2
  111. package/dist/LaunchMsaView/components/EnsemblGeneTree/gatherSequencesFromTree.js +0 -20
  112. package/dist/LaunchMsaView/components/EnsemblGeneTree/gatherSequencesFromTree.js.map +0 -1
  113. package/dist/LaunchMsaView/components/EnsemblGeneTree/types.d.ts +0 -24
  114. package/dist/LaunchMsaView/components/EnsemblGeneTree/types.js +0 -2
  115. package/dist/LaunchMsaView/components/EnsemblGeneTree/types.js.map +0 -1
  116. package/dist/LaunchMsaView/components/EnsemblGeneTree/useGeneTree.d.ts +0 -10
  117. package/dist/LaunchMsaView/components/EnsemblGeneTree/useGeneTree.js +0 -11
  118. package/dist/LaunchMsaView/components/EnsemblGeneTree/useGeneTree.js.map +0 -1
  119. package/dist/LaunchMsaView/components/EnsemblGeneTree/util.d.ts +0 -1
  120. package/dist/LaunchMsaView/components/EnsemblGeneTree/util.js +0 -2
  121. package/dist/LaunchMsaView/components/EnsemblGeneTree/util.js.map +0 -1
  122. package/src/LaunchMsaView/components/EnsemblGeneTree/EnsemblGeneTree.tsx +0 -123
  123. package/src/LaunchMsaView/components/EnsemblGeneTree/ensemblGeneTreeLaunchView.ts +0 -30
  124. package/src/LaunchMsaView/components/EnsemblGeneTree/ensemblGeneTreeUtils.ts +0 -47
  125. package/src/LaunchMsaView/components/EnsemblGeneTree/gatherSequencesFromTree.ts +0 -22
  126. package/src/LaunchMsaView/components/EnsemblGeneTree/types.ts +0 -28
  127. package/src/LaunchMsaView/components/EnsemblGeneTree/useGeneTree.ts +0 -17
  128. package/src/LaunchMsaView/components/EnsemblGeneTree/util.ts +0 -6
@@ -21,6 +21,13 @@ export function isProteinView(view: unknown): view is ProteinView {
21
21
  return v.type === 'ProteinView' && Array.isArray(v.structures)
22
22
  }
23
23
 
24
+ /**
25
+ * Extract all ProteinView instances from a session's views array.
26
+ */
27
+ export function getProteinViews(views: { type: string }[]): ProteinView[] {
28
+ return (views as unknown[]).filter(isProteinView)
29
+ }
30
+
24
31
  /**
25
32
  * Represents a connection between the MSA view and a protein structure
26
33
  */
@@ -82,10 +89,3 @@ export function ungappedToGappedPosition(
82
89
  }
83
90
  return undefined
84
91
  }
85
-
86
- /**
87
- * Convert Map to plain object for MST frozen storage
88
- */
89
- export function mapToRecord(map: Map<number, number>): Record<number, number> {
90
- return Object.fromEntries(map)
91
- }
@@ -5,13 +5,38 @@ export function checkHovered(hovered: unknown): hovered is {
5
5
  hoverPosition: { coord: number; refName: string }
6
6
  } {
7
7
  return (
8
+ !!hovered &&
8
9
  typeof hovered === 'object' &&
9
- hovered !== null &&
10
10
  'hoverFeature' in hovered &&
11
- 'hoverPosition' in hovered
11
+ 'hoverPosition' in hovered &&
12
+ !!hovered.hoverPosition
12
13
  )
13
14
  }
14
15
 
16
+ interface AssemblyManagerLike {
17
+ get: (name: string) =>
18
+ | { getCanonicalRefName: (r: string) => string | undefined }
19
+ | undefined
20
+ }
21
+
22
+ export function getCanonicalRefName({
23
+ assemblyManager,
24
+ assemblyNames,
25
+ refName,
26
+ }: {
27
+ assemblyManager: AssemblyManagerLike
28
+ assemblyNames: string[] | undefined
29
+ refName: string
30
+ }) {
31
+ const assemblyName = assemblyNames?.[0]
32
+ if (assemblyName) {
33
+ return (
34
+ assemblyManager.get(assemblyName)?.getCanonicalRefName(refName) ?? refName
35
+ )
36
+ }
37
+ return refName
38
+ }
39
+
15
40
  /**
16
41
  * Extracts UniProt ID from an AlphaFold URL
17
42
  * Examples:
@@ -1,5 +1,11 @@
1
1
  import { openDB } from 'idb'
2
2
 
3
+ import type {
4
+ BlastDatabase,
5
+ BlastProgram,
6
+ MsaAlgorithm,
7
+ } from '../LaunchMsaView/components/NCBIBlastQuery/consts'
8
+
3
9
  const DB_NAME = 'jbrowse-msaview-blast-cache'
4
10
  const STORE_NAME = 'blast-results'
5
11
  const DB_VERSION = 2
@@ -7,9 +13,9 @@ const DB_VERSION = 2
7
13
  export interface CachedBlastResult {
8
14
  id: string
9
15
  proteinSequence: string
10
- blastDatabase: string
11
- blastProgram: string
12
- msaAlgorithm: string
16
+ blastDatabase: BlastDatabase
17
+ blastProgram: BlastProgram
18
+ msaAlgorithm: MsaAlgorithm
13
19
  msa: string
14
20
  tree: string
15
21
  treeMetadata: string
@@ -36,8 +42,8 @@ async function getDB() {
36
42
 
37
43
  function createCacheKey(
38
44
  proteinSequence: string,
39
- blastDatabase: string,
40
- blastProgram: string,
45
+ blastDatabase: BlastDatabase,
46
+ blastProgram: BlastProgram,
41
47
  transcriptId?: string,
42
48
  ) {
43
49
  if (transcriptId) {
@@ -46,27 +52,6 @@ function createCacheKey(
46
52
  return `${blastDatabase}:${blastProgram}:${proteinSequence}`
47
53
  }
48
54
 
49
- export async function getCachedBlastResult({
50
- proteinSequence,
51
- blastDatabase,
52
- blastProgram,
53
- transcriptId,
54
- }: {
55
- proteinSequence: string
56
- blastDatabase: string
57
- blastProgram: string
58
- transcriptId?: string
59
- }) {
60
- const db = await getDB()
61
- const id = createCacheKey(
62
- proteinSequence,
63
- blastDatabase,
64
- blastProgram,
65
- transcriptId,
66
- )
67
- return db.get(STORE_NAME, id)
68
- }
69
-
70
55
  export async function saveBlastResult({
71
56
  proteinSequence,
72
57
  blastDatabase,
@@ -82,9 +67,9 @@ export async function saveBlastResult({
82
67
  geneName,
83
68
  }: {
84
69
  proteinSequence: string
85
- blastDatabase: string
86
- blastProgram: string
87
- msaAlgorithm: string
70
+ blastDatabase: BlastDatabase
71
+ blastProgram: BlastProgram
72
+ msaAlgorithm: MsaAlgorithm
88
73
  msa: string
89
74
  tree: string
90
75
  treeMetadata: string
@@ -127,14 +112,6 @@ export async function getAllCachedResults() {
127
112
  return results.toSorted((a, b) => b.timestamp - a.timestamp)
128
113
  }
129
114
 
130
- export async function getCachedResultsByGeneId(geneId: string) {
131
- const db = await getDB()
132
- const results = await db.getAll(STORE_NAME)
133
- return results
134
- .filter(r => r.geneId === geneId)
135
- .toSorted((a, b) => b.timestamp - a.timestamp)
136
- }
137
-
138
115
  export async function deleteCachedResult(id: string) {
139
116
  const db = await getDB()
140
117
  await db.delete(STORE_NAME, id)
package/src/utils/msa.ts CHANGED
@@ -1,9 +1,11 @@
1
1
  import { textfetch, timeout } from './fetch'
2
2
 
3
+ import type { MsaAlgorithm } from '../LaunchMsaView/components/NCBIBlastQuery/consts'
4
+
3
5
  const base = `https://www.ebi.ac.uk/Tools/services/rest`
4
6
 
5
7
  const algorithms: Record<
6
- string,
8
+ MsaAlgorithm,
7
9
  {
8
10
  params: Record<string, string>
9
11
  msaResult: string
@@ -38,7 +40,7 @@ async function wait({
38
40
  algorithm,
39
41
  }: {
40
42
  jobId: string
41
- algorithm: string
43
+ algorithm: MsaAlgorithm
42
44
  onProgress: (arg: string) => void
43
45
  }) {
44
46
  // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
@@ -62,14 +64,11 @@ export async function launchMSA({
62
64
  sequence,
63
65
  onProgress,
64
66
  }: {
65
- algorithm: string
67
+ algorithm: MsaAlgorithm
66
68
  sequence: string
67
69
  onProgress: (arg: string) => void
68
70
  }) {
69
71
  const config = algorithms[algorithm]
70
- if (!config) {
71
- throw new Error(`unknown algorithm: ${algorithm}`)
72
- }
73
72
 
74
73
  onProgress(`Launching ${algorithm} MSA...`)
75
74
 
@@ -1,6 +1,10 @@
1
1
  import { jsonfetch, textfetch, timeout } from './fetch'
2
2
 
3
3
  import type { BlastResults } from './types'
4
+ import type {
5
+ BlastDatabase,
6
+ BlastProgram,
7
+ } from '../LaunchMsaView/components/NCBIBlastQuery/consts'
4
8
 
5
9
  export async function queryBlastFromRid({
6
10
  rid,
@@ -35,8 +39,8 @@ export async function queryBlast({
35
39
  onRid,
36
40
  }: {
37
41
  query: string
38
- blastDatabase: string
39
- blastProgram: string
42
+ blastDatabase: BlastDatabase
43
+ blastProgram: BlastProgram
40
44
  baseUrl: string
41
45
  onProgress: (arg: string) => void
42
46
  onRid: (arg: string) => void
@@ -59,8 +63,8 @@ async function initialQuery({
59
63
  baseUrl,
60
64
  }: {
61
65
  query: string
62
- blastProgram: string
63
- blastDatabase: string
66
+ blastProgram: BlastProgram
67
+ blastDatabase: BlastDatabase
64
68
  baseUrl: string
65
69
  }) {
66
70
  const res = await textfetch(baseUrl, {
@@ -70,7 +74,7 @@ async function initialQuery({
70
74
  PROGRAM: blastProgram === 'quick-blastp' ? 'blastp' : blastProgram,
71
75
  DATABASE: blastDatabase,
72
76
  QUERY: query,
73
- ...(blastDatabase === 'nr_clustered_seq'
77
+ ...(blastDatabase === 'nr_cluster_seq'
74
78
  ? {
75
79
  CLUSTERED_DB: 'on',
76
80
  DB_TYPE: 'Experimental Databases',
@@ -117,25 +121,28 @@ async function waitForRid({
117
121
  const res = await textfetch(
118
122
  `${baseUrl}?CMD=Get&FORMAT_OBJECT=SearchInfo&RID=${rid}`,
119
123
  )
120
- const isWaiting = /\s+Status=WAITING/m.test(res)
121
- const isFailed = /\s+Status=FAILED/m.test(res)
122
- const isReady = /\s+Status=READY/m.test(res)
124
+ const statusMatch = /\s+Status=(\S+)/m.exec(res)
125
+ const status = statusMatch?.[1]
123
126
  const hasHits = /\s+ThereAreHits=yes/m.test(res)
124
127
 
125
- if (isWaiting) {
128
+ if (status === 'WAITING') {
126
129
  continue
127
130
  }
128
131
 
129
- if (isFailed) {
132
+ if (status === 'FAILED') {
130
133
  throw new Error(`BLAST ${rid} failed`)
131
134
  }
132
135
 
133
- if (isReady) {
136
+ if (status === 'READY') {
134
137
  if (hasHits) {
135
138
  return true
136
139
  } else {
137
140
  throw new Error('No hits found')
138
141
  }
139
142
  }
143
+
144
+ throw new Error(
145
+ `BLAST ${rid} returned unexpected status: ${status ?? 'unknown'}`,
146
+ )
140
147
  }
141
148
  }
@@ -21,9 +21,16 @@ async function getDB() {
21
21
  })
22
22
  }
23
23
 
24
- async function getCachedCommonName(taxid: number) {
24
+ async function getCachedTaxonomies(taxids: number[]) {
25
25
  const db = await getDB()
26
- return db.get(STORE_NAME, taxid) as Promise<CachedTaxonomy | undefined>
26
+ const tx = db.transaction(STORE_NAME, 'readonly')
27
+ const results = await Promise.all(
28
+ taxids.map(
29
+ taxid => tx.store.get(taxid) as Promise<CachedTaxonomy | undefined>,
30
+ ),
31
+ )
32
+ await tx.done
33
+ return results
27
34
  }
28
35
 
29
36
  async function saveTaxonomyCache(entries: CachedTaxonomy[]) {
@@ -45,9 +52,11 @@ export async function fetchTaxonomyInfo(
45
52
  ): Promise<Map<number, TaxonomyInfo>> {
46
53
  const result = new Map<number, TaxonomyInfo>()
47
54
  const uncachedTaxids: number[] = []
55
+ const cachedResults = await getCachedTaxonomies(taxids)
48
56
 
49
- for (const taxid of taxids) {
50
- const cached = await getCachedCommonName(taxid)
57
+ for (let i = 0; i < taxids.length; i++) {
58
+ const taxid = taxids[i]!
59
+ const cached = cachedResults[i]
51
60
  if (cached) {
52
61
  result.set(taxid, {
53
62
  sciname: cached.sciname,
@@ -126,8 +135,6 @@ export async function fetchTaxonomyInfo(
126
135
  const sci = sciName?.[1] ?? ''
127
136
  result.set(taxid, { sciname: sci, commonName: name })
128
137
  toCache.push({ taxid, sciname: sci, commonName: name })
129
- } else {
130
- toCache.push({ taxid, sciname: '', commonName: undefined })
131
138
  }
132
139
  }
133
140
  } catch (error) {
package/src/version.ts CHANGED
@@ -1 +1 @@
1
- export const version = '2.3.8'
1
+ export const version = '2.4.1'
@@ -1,8 +0,0 @@
1
- import React from 'react';
2
- import type { AbstractTrackModel, Feature } from '@jbrowse/core/util';
3
- declare const EnsemblGeneTree: ({ model, feature, handleClose, }: {
4
- model: AbstractTrackModel;
5
- feature: Feature;
6
- handleClose: () => void;
7
- }) => React.JSX.Element;
8
- export default EnsemblGeneTree;
@@ -1,70 +0,0 @@
1
- import React, { useState } from 'react';
2
- import { ErrorMessage, LoadingEllipses } from '@jbrowse/core/ui';
3
- import { getContainingView, getSession } from '@jbrowse/core/util';
4
- import { Button, DialogActions, DialogContent, Link } from '@mui/material';
5
- import { observer } from 'mobx-react';
6
- import { makeStyles } from 'tss-react/mui';
7
- import { ensemblGeneTreeLaunchView } from './ensemblGeneTreeLaunchView';
8
- import { useGeneTree } from './useGeneTree';
9
- import { getGeneDisplayName } from '../../util';
10
- import TranscriptSelector from '../TranscriptSelector';
11
- import { useTranscriptSelection } from '../useTranscriptSelection';
12
- const useStyles = makeStyles()({
13
- dialogContent: {
14
- width: '80em',
15
- display: 'flex',
16
- flexDirection: 'column',
17
- gap: 16,
18
- },
19
- });
20
- const EnsemblGeneTree = observer(function ({ model, feature, handleClose, }) {
21
- const session = getSession(model);
22
- const view = getContainingView(model);
23
- const { classes } = useStyles();
24
- const [launchViewError, setLaunchViewError] = useState();
25
- const { options, selectedId, setSelectedId, selectedTranscript, proteinSequence, error: featureSequenceError, } = useTranscriptSelection({ feature, view });
26
- const { treeData, isTreeLoading, treeError } = useGeneTree(selectedId);
27
- const loadingMessage = isTreeLoading
28
- ? 'Loading tree data from Ensembl GeneTree'
29
- : undefined;
30
- const e = treeError ?? launchViewError ?? featureSequenceError;
31
- return (React.createElement(React.Fragment, null,
32
- React.createElement(DialogContent, { className: classes.dialogContent },
33
- e ? React.createElement(ErrorMessage, { error: e }) : null,
34
- loadingMessage ? React.createElement(LoadingEllipses, { message: loadingMessage }) : null,
35
- treeData ? (React.createElement("div", null,
36
- React.createElement("div", null,
37
- "Found Ensembl Compara GeneTree: ",
38
- treeData.geneTreeId),
39
- React.createElement(Link, { target: "_blank", href: `https://useast.ensembl.org/Multi/GeneTree/Image?gt=${treeData.geneTreeId}` },
40
- "See ",
41
- treeData.geneTreeId,
42
- " at Ensembl"))) : null,
43
- React.createElement(TranscriptSelector, { feature: feature, options: options, selectedId: selectedId, selectedTranscript: selectedTranscript, onTranscriptChange: setSelectedId, proteinSequence: proteinSequence })),
44
- React.createElement(DialogActions, null,
45
- React.createElement(Button, { color: "primary", variant: "contained", onClick: () => {
46
- try {
47
- if (!treeData) {
48
- return;
49
- }
50
- setLaunchViewError(undefined);
51
- ensemblGeneTreeLaunchView({
52
- feature,
53
- view,
54
- session,
55
- newViewTitle: getGeneDisplayName(feature),
56
- data: treeData,
57
- });
58
- handleClose();
59
- }
60
- catch (e) {
61
- console.error(e);
62
- setLaunchViewError(e);
63
- }
64
- } }, "Submit"),
65
- React.createElement(Button, { color: "secondary", variant: "contained", onClick: () => {
66
- handleClose();
67
- } }, "Cancel"))));
68
- });
69
- export default EnsemblGeneTree;
70
- //# sourceMappingURL=EnsemblGeneTree.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"EnsemblGeneTree.js","sourceRoot":"","sources":["../../../../src/LaunchMsaView/components/EnsemblGeneTree/EnsemblGeneTree.tsx"],"names":[],"mappings":"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"}
@@ -1,13 +0,0 @@
1
- import type { AbstractSessionModel, Feature } from '@jbrowse/core/util';
2
- import type { LinearGenomeViewModel } from '@jbrowse/plugin-linear-genome-view';
3
- export declare function ensemblGeneTreeLaunchView({ session, newViewTitle, view, feature, data, }: {
4
- session: AbstractSessionModel;
5
- newViewTitle: string;
6
- view: LinearGenomeViewModel;
7
- feature: Feature;
8
- data: {
9
- tree: string;
10
- msa: string;
11
- treeMetadata: string;
12
- };
13
- }): void;
@@ -1,12 +0,0 @@
1
- export function ensemblGeneTreeLaunchView({ session, newViewTitle, view, feature, data, }) {
2
- session.addView('MsaView', {
3
- type: 'MsaView',
4
- displayName: newViewTitle,
5
- colWidth: 10,
6
- rowHeight: 12,
7
- data,
8
- connectedViewId: view.id,
9
- connectedFeature: feature.toJSON(),
10
- });
11
- }
12
- //# sourceMappingURL=ensemblGeneTreeLaunchView.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"ensemblGeneTreeLaunchView.js","sourceRoot":"","sources":["../../../../src/LaunchMsaView/components/EnsemblGeneTree/ensemblGeneTreeLaunchView.ts"],"names":[],"mappings":"AAGA,MAAM,UAAU,yBAAyB,CAAC,EACxC,OAAO,EACP,YAAY,EACZ,IAAI,EACJ,OAAO,EACP,IAAI,GAWL;IACC,OAAO,CAAC,OAAO,CAAC,SAAS,EAAE;QACzB,IAAI,EAAE,SAAS;QACf,WAAW,EAAE,YAAY;QACzB,QAAQ,EAAE,EAAE;QACZ,SAAS,EAAE,EAAE;QACb,IAAI;QACJ,eAAe,EAAE,IAAI,CAAC,EAAE;QACxB,gBAAgB,EAAE,OAAO,CAAC,MAAM,EAAE;KACnC,CAAC,CAAA;AACJ,CAAC"}
@@ -1,6 +0,0 @@
1
- export declare function geneTreeFetcher(id2: string): Promise<{
2
- geneTreeId: string;
3
- tree: string;
4
- msa: string;
5
- treeMetadata: string;
6
- }>;
@@ -1,25 +0,0 @@
1
- import { gatherSequencesFromTree } from './gatherSequencesFromTree';
2
- import { fetchWithLocalStorageCache, jsonfetch, textfetch } from './util';
3
- const base = 'https://rest.ensembl.org';
4
- export async function geneTreeFetcher(id2) {
5
- const id = id2.replace(/\..*/, '');
6
- const { species } = await fetchWithLocalStorageCache(`${id}-ensembl`, () => jsonfetch(`${base}/lookup/id/${id}?content-type=application/json`));
7
- const treeBase = `${base}/genetree/member/id/${species}/${id}`;
8
- const geneTreeResult = await fetchWithLocalStorageCache(`${id}-msa`, () => jsonfetch(`${treeBase}?content-type=application/json;aligned=1;sequence=pep`));
9
- // we query again to get newick format tree. could probably extract from json
10
- // as alternative
11
- const tree = await fetchWithLocalStorageCache(`${id}-tree`, () => textfetch(`${treeBase}?nh_format=simple;content-type=text/x-nh`));
12
- const res = gatherSequencesFromTree(geneTreeResult.tree);
13
- return {
14
- geneTreeId: geneTreeResult.id,
15
- tree,
16
- msa: res.map(r => `>${r.id}\n${r.seq}`).join('\n'),
17
- treeMetadata: JSON.stringify(Object.fromEntries(res.map(r => [
18
- r.id,
19
- {
20
- genome: r.species,
21
- },
22
- ]))),
23
- };
24
- }
25
- //# sourceMappingURL=ensemblGeneTreeUtils.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"ensemblGeneTreeUtils.js","sourceRoot":"","sources":["../../../../src/LaunchMsaView/components/EnsemblGeneTree/ensemblGeneTreeUtils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,uBAAuB,EAAE,MAAM,2BAA2B,CAAA;AACnE,OAAO,EAAE,0BAA0B,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM,QAAQ,CAAA;AAIzE,MAAM,IAAI,GAAG,0BAA0B,CAAA;AAEvC,MAAM,CAAC,KAAK,UAAU,eAAe,CAAC,GAAW;IAC/C,MAAM,EAAE,GAAG,GAAG,CAAC,OAAO,CAAC,MAAM,EAAE,EAAE,CAAC,CAAA;IAClC,MAAM,EAAE,OAAO,EAAE,GAAG,MAAM,0BAA0B,CAAC,GAAG,EAAE,UAAU,EAAE,GAAG,EAAE,CACzE,SAAS,CACP,GAAG,IAAI,cAAc,EAAE,gCAAgC,CACxD,CACF,CAAA;IACD,MAAM,QAAQ,GAAG,GAAG,IAAI,uBAAuB,OAAO,IAAI,EAAE,EAAE,CAAA;IAC9D,MAAM,cAAc,GAAG,MAAM,0BAA0B,CAAC,GAAG,EAAE,MAAM,EAAE,GAAG,EAAE,CACxE,SAAS,CACP,GAAG,QAAQ,uDAAuD,CACnE,CACF,CAAA;IAED,6EAA6E;IAC7E,iBAAiB;IACjB,MAAM,IAAI,GAAG,MAAM,0BAA0B,CAAS,GAAG,EAAE,OAAO,EAAE,GAAG,EAAE,CACvE,SAAS,CAAC,GAAG,QAAQ,0CAA0C,CAAC,CACjE,CAAA;IAED,MAAM,GAAG,GAAG,uBAAuB,CAAC,cAAc,CAAC,IAAI,CAAC,CAAA;IACxD,OAAO;QACL,UAAU,EAAE,cAAc,CAAC,EAAE;QAC7B,IAAI;QACJ,GAAG,EAAE,GAAG,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,IAAI,CAAC,CAAC,EAAE,KAAK,CAAC,CAAC,GAAG,EAAE,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC;QAClD,YAAY,EAAE,IAAI,CAAC,SAAS,CAC1B,MAAM,CAAC,WAAW,CAChB,GAAG,CAAC,GAAG,CACL,CAAC,CAAC,EAAE,CACF;YACE,CAAC,CAAC,EAAE;YACJ;gBACE,MAAM,EAAE,CAAC,CAAC,OAAO;aAClB;SACO,CACb,CACF,CACF;KACF,CAAA;AACH,CAAC"}
@@ -1,2 +0,0 @@
1
- import type { TreeNode, TreeRow } from './types';
2
- export declare function gatherSequencesFromTree(tree: TreeNode, arr?: TreeRow[]): TreeRow[];
@@ -1,20 +0,0 @@
1
- export function gatherSequencesFromTree(tree, arr = []) {
2
- if (tree.children) {
3
- for (const child of tree.children) {
4
- if (child.sequence) {
5
- const id = child.sequence.id[0]?.accession;
6
- if (id) {
7
- arr.push({
8
- id,
9
- seq: child.sequence.mol_seq.seq,
10
- species: child.taxonomy.common_name || child.taxonomy.scientific_name,
11
- genomicLocString: child.sequence.mol_seq.location,
12
- });
13
- }
14
- }
15
- gatherSequencesFromTree(child, arr);
16
- }
17
- }
18
- return arr;
19
- }
20
- //# sourceMappingURL=gatherSequencesFromTree.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"gatherSequencesFromTree.js","sourceRoot":"","sources":["../../../../src/LaunchMsaView/components/EnsemblGeneTree/gatherSequencesFromTree.ts"],"names":[],"mappings":"AAEA,MAAM,UAAU,uBAAuB,CAAC,IAAc,EAAE,MAAiB,EAAE;IACzE,IAAI,IAAI,CAAC,QAAQ,EAAE,CAAC;QAClB,KAAK,MAAM,KAAK,IAAI,IAAI,CAAC,QAAQ,EAAE,CAAC;YAClC,IAAI,KAAK,CAAC,QAAQ,EAAE,CAAC;gBACnB,MAAM,EAAE,GAAG,KAAK,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,SAAS,CAAA;gBAC1C,IAAI,EAAE,EAAE,CAAC;oBACP,GAAG,CAAC,IAAI,CAAC;wBACP,EAAE;wBACF,GAAG,EAAE,KAAK,CAAC,QAAQ,CAAC,OAAO,CAAC,GAAG;wBAC/B,OAAO,EACL,KAAK,CAAC,QAAQ,CAAC,WAAW,IAAI,KAAK,CAAC,QAAQ,CAAC,eAAe;wBAC9D,gBAAgB,EAAE,KAAK,CAAC,QAAQ,CAAC,OAAO,CAAC,QAAQ;qBAClD,CAAC,CAAA;gBACJ,CAAC;YACH,CAAC;YACD,uBAAuB,CAAC,KAAK,EAAE,GAAG,CAAC,CAAA;QACrC,CAAC;IACH,CAAC;IACD,OAAO,GAAG,CAAA;AACZ,CAAC"}
@@ -1,24 +0,0 @@
1
- export interface TreeNodeSequence {
2
- mol_seq: {
3
- seq: string;
4
- location?: string;
5
- };
6
- id: {
7
- accession: string;
8
- }[];
9
- }
10
- export interface TreeNodeTaxonomy {
11
- common_name: string;
12
- scientific_name: string;
13
- }
14
- export interface TreeNode {
15
- children?: TreeNode[];
16
- sequence?: TreeNodeSequence;
17
- taxonomy: TreeNodeTaxonomy;
18
- }
19
- export interface TreeRow {
20
- id: string;
21
- seq: string;
22
- species: string;
23
- genomicLocString?: string;
24
- }
@@ -1,2 +0,0 @@
1
- export {};
2
- //# sourceMappingURL=types.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"types.js","sourceRoot":"","sources":["../../../../src/LaunchMsaView/components/EnsemblGeneTree/types.ts"],"names":[],"mappings":""}
@@ -1,10 +0,0 @@
1
- export declare function useGeneTree(geneId: string): {
2
- treeData: {
3
- geneTreeId: string;
4
- tree: string;
5
- msa: string;
6
- treeMetadata: string;
7
- } | undefined;
8
- isTreeLoading: boolean;
9
- treeError: any;
10
- };
@@ -1,11 +0,0 @@
1
- import useSWR from 'swr';
2
- import { geneTreeFetcher } from './ensemblGeneTreeUtils';
3
- export function useGeneTree(geneId) {
4
- const { data, error, isLoading } = useSWR(() => (geneId ? ['geneTree', geneId] : null), ([, geneId]) => geneTreeFetcher(geneId), {
5
- revalidateOnFocus: false,
6
- revalidateOnReconnect: false,
7
- revalidateIfStale: false,
8
- });
9
- return { treeData: data, isTreeLoading: isLoading, treeError: error };
10
- }
11
- //# sourceMappingURL=useGeneTree.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"useGeneTree.js","sourceRoot":"","sources":["../../../../src/LaunchMsaView/components/EnsemblGeneTree/useGeneTree.ts"],"names":[],"mappings":"AAAA,OAAO,MAAM,MAAM,KAAK,CAAA;AAExB,OAAO,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAA;AAExD,MAAM,UAAU,WAAW,CAAC,MAAc;IACxC,MAAM,EAAE,IAAI,EAAE,KAAK,EAAE,SAAS,EAAE,GAAG,MAAM,CACvC,GAAG,EAAE,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,UAAU,EAAE,MAAM,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,EAC5C,CAAC,CAAC,EAAE,MAAM,CAAC,EAAE,EAAE,CAAC,eAAe,CAAC,MAAM,CAAC,EACvC;QACE,iBAAiB,EAAE,KAAK;QACxB,qBAAqB,EAAE,KAAK;QAC5B,iBAAiB,EAAE,KAAK;KACzB,CACF,CAAA;IAED,OAAO,EAAE,QAAQ,EAAE,IAAI,EAAE,aAAa,EAAE,SAAS,EAAE,SAAS,EAAE,KAAK,EAAE,CAAA;AACvE,CAAC"}
@@ -1 +0,0 @@
1
- export { fetchWithLocalStorageCache, jsonfetch, textfetch, unzipfetch, } from '../../../utils/fetch';
@@ -1,2 +0,0 @@
1
- export { fetchWithLocalStorageCache, jsonfetch, textfetch, unzipfetch, } from '../../../utils/fetch';
2
- //# sourceMappingURL=util.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"util.js","sourceRoot":"","sources":["../../../../src/LaunchMsaView/components/EnsemblGeneTree/util.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,0BAA0B,EAC1B,SAAS,EACT,SAAS,EACT,UAAU,GACX,MAAM,sBAAsB,CAAA"}