@jbrowse/plugin-alignments 2.2.2 → 2.3.0

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 (308) hide show
  1. package/dist/AlignmentsFeatureDetail/AlignmentsFeatureDetail.js +1 -1
  2. package/dist/AlignmentsFeatureDetail/AlignmentsFeatureDetail.js.map +1 -1
  3. package/dist/AlignmentsTrack/index.js +1 -0
  4. package/dist/AlignmentsTrack/index.js.map +1 -1
  5. package/dist/BamAdapter/BamSlightlyLazyFeature.d.ts +3 -4
  6. package/dist/BamAdapter/BamSlightlyLazyFeature.js +11 -18
  7. package/dist/BamAdapter/BamSlightlyLazyFeature.js.map +1 -1
  8. package/dist/BamAdapter/index.js +1 -0
  9. package/dist/BamAdapter/index.js.map +1 -1
  10. package/dist/CramAdapter/CramSlightlyLazyFeature.d.ts +5 -7
  11. package/dist/CramAdapter/CramSlightlyLazyFeature.js +6 -8
  12. package/dist/CramAdapter/CramSlightlyLazyFeature.js.map +1 -1
  13. package/dist/CramAdapter/index.js +1 -0
  14. package/dist/CramAdapter/index.js.map +1 -1
  15. package/dist/GuessAlignmentsTypes/index.d.ts +3 -0
  16. package/dist/GuessAlignmentsTypes/index.js +56 -0
  17. package/dist/GuessAlignmentsTypes/index.js.map +1 -0
  18. package/dist/HtsgetBamAdapter/index.js +11 -11
  19. package/dist/HtsgetBamAdapter/index.js.map +1 -1
  20. package/dist/LinearAlignmentsDisplay/components/AlignmentsDisplay.js +10 -13
  21. package/dist/LinearAlignmentsDisplay/components/AlignmentsDisplay.js.map +1 -1
  22. package/dist/LinearAlignmentsDisplay/index.js +1 -0
  23. package/dist/LinearAlignmentsDisplay/index.js.map +1 -1
  24. package/dist/LinearAlignmentsDisplay/models/configSchema.d.ts +6 -3
  25. package/dist/LinearAlignmentsDisplay/models/configSchema.js +2 -3
  26. package/dist/LinearAlignmentsDisplay/models/configSchema.js.map +1 -1
  27. package/dist/LinearAlignmentsDisplay/models/model.d.ts +22 -36
  28. package/dist/LinearAlignmentsDisplay/models/model.js +166 -151
  29. package/dist/LinearAlignmentsDisplay/models/model.js.map +1 -1
  30. package/dist/LinearPileupDisplay/components/SetFeatureHeight.d.ts +2 -2
  31. package/dist/LinearPileupDisplay/components/SetFeatureHeight.js +2 -4
  32. package/dist/LinearPileupDisplay/components/SetFeatureHeight.js.map +1 -1
  33. package/dist/LinearPileupDisplay/configSchema.d.ts +0 -3
  34. package/dist/LinearPileupDisplay/configSchema.js.map +1 -1
  35. package/dist/LinearPileupDisplay/index.js +2 -0
  36. package/dist/LinearPileupDisplay/index.js.map +1 -1
  37. package/dist/LinearPileupDisplay/model.d.ts +19 -16
  38. package/dist/LinearPileupDisplay/model.js +28 -13
  39. package/dist/LinearPileupDisplay/model.js.map +1 -1
  40. package/dist/LinearReadArcsDisplay/components/ReactComponent.d.ts +6 -0
  41. package/dist/LinearReadArcsDisplay/components/ReactComponent.js +49 -0
  42. package/dist/LinearReadArcsDisplay/components/ReactComponent.js.map +1 -0
  43. package/dist/LinearReadArcsDisplay/configSchema.d.ts +6 -0
  44. package/dist/LinearReadArcsDisplay/configSchema.js +52 -0
  45. package/dist/LinearReadArcsDisplay/configSchema.js.map +1 -0
  46. package/dist/LinearReadArcsDisplay/drawFeats.d.ts +14 -0
  47. package/dist/LinearReadArcsDisplay/drawFeats.js +162 -0
  48. package/dist/LinearReadArcsDisplay/drawFeats.js.map +1 -0
  49. package/dist/LinearReadArcsDisplay/index.d.ts +2 -0
  50. package/dist/LinearReadArcsDisplay/index.js +27 -0
  51. package/dist/LinearReadArcsDisplay/index.js.map +1 -0
  52. package/dist/LinearReadArcsDisplay/model.d.ts +342 -0
  53. package/dist/LinearReadArcsDisplay/model.js +327 -0
  54. package/dist/LinearReadArcsDisplay/model.js.map +1 -0
  55. package/dist/LinearReadCloudDisplay/components/ReactComponent.d.ts +6 -0
  56. package/dist/LinearReadCloudDisplay/components/ReactComponent.js +49 -0
  57. package/dist/LinearReadCloudDisplay/components/ReactComponent.js.map +1 -0
  58. package/dist/LinearReadCloudDisplay/configSchema.d.ts +6 -0
  59. package/dist/LinearReadCloudDisplay/configSchema.js +51 -0
  60. package/dist/LinearReadCloudDisplay/configSchema.js.map +1 -0
  61. package/dist/LinearReadCloudDisplay/drawFeats.d.ts +10 -0
  62. package/dist/LinearReadCloudDisplay/drawFeats.js +159 -0
  63. package/dist/LinearReadCloudDisplay/drawFeats.js.map +1 -0
  64. package/dist/LinearReadCloudDisplay/index.d.ts +2 -0
  65. package/dist/LinearReadCloudDisplay/index.js +27 -0
  66. package/dist/LinearReadCloudDisplay/index.js.map +1 -0
  67. package/dist/LinearReadCloudDisplay/model.d.ts +320 -0
  68. package/dist/LinearReadCloudDisplay/model.js +252 -0
  69. package/dist/LinearReadCloudDisplay/model.js.map +1 -0
  70. package/dist/LinearSNPCoverageDisplay/index.js +1 -0
  71. package/dist/LinearSNPCoverageDisplay/index.js.map +1 -1
  72. package/dist/LinearSNPCoverageDisplay/models/model.d.ts +19 -20
  73. package/dist/LinearSNPCoverageDisplay/models/model.js +1 -6
  74. package/dist/LinearSNPCoverageDisplay/models/model.js.map +1 -1
  75. package/dist/{BamAdapter/MismatchParser.d.ts → MismatchParser/index.d.ts} +23 -0
  76. package/dist/{BamAdapter/MismatchParser.js → MismatchParser/index.js} +116 -3
  77. package/dist/MismatchParser/index.js.map +1 -0
  78. package/dist/PileupRPC/base.d.ts +8 -0
  79. package/dist/PileupRPC/base.js +22 -0
  80. package/dist/PileupRPC/base.js.map +1 -0
  81. package/dist/PileupRPC/index.d.ts +3 -0
  82. package/dist/PileupRPC/index.js +9 -0
  83. package/dist/PileupRPC/index.js.map +1 -0
  84. package/dist/PileupRPC/methods/GetGlobalValueForTag.d.ts +14 -0
  85. package/dist/PileupRPC/methods/GetGlobalValueForTag.js +29 -0
  86. package/dist/PileupRPC/methods/GetGlobalValueForTag.js.map +1 -0
  87. package/dist/PileupRPC/methods/GetReducedFeatures.d.ts +25 -0
  88. package/dist/PileupRPC/methods/GetReducedFeatures.js +61 -0
  89. package/dist/PileupRPC/methods/GetReducedFeatures.js.map +1 -0
  90. package/dist/PileupRPC/methods/GetVisibleModifications.d.ts +14 -0
  91. package/dist/PileupRPC/methods/GetVisibleModifications.js +32 -0
  92. package/dist/PileupRPC/methods/GetVisibleModifications.js.map +1 -0
  93. package/dist/PileupRPC/rpcMethods.d.ts +4 -34
  94. package/dist/PileupRPC/rpcMethods.js +7 -77
  95. package/dist/PileupRPC/rpcMethods.js.map +1 -1
  96. package/dist/PileupRPC/util.d.ts +8 -0
  97. package/dist/PileupRPC/util.js +20 -0
  98. package/dist/PileupRPC/util.js.map +1 -0
  99. package/dist/PileupRenderer/PileupRenderer.d.ts +1 -1
  100. package/dist/PileupRenderer/PileupRenderer.js +5 -5
  101. package/dist/PileupRenderer/PileupRenderer.js.map +1 -1
  102. package/dist/PileupRenderer/index.js +1 -0
  103. package/dist/PileupRenderer/index.js.map +1 -1
  104. package/dist/PileupRenderer/sortUtil.d.ts +1 -1
  105. package/dist/PileupRenderer/sortUtil.js +2 -2
  106. package/dist/PileupRenderer/sortUtil.js.map +1 -1
  107. package/dist/SNPCoverageAdapter/generateCoverageBins.js +1 -1
  108. package/dist/SNPCoverageAdapter/generateCoverageBins.js.map +1 -1
  109. package/dist/SNPCoverageAdapter/index.js +1 -3
  110. package/dist/SNPCoverageAdapter/index.js.map +1 -1
  111. package/dist/index.d.ts +2 -2
  112. package/dist/index.js +12 -58
  113. package/dist/index.js.map +1 -1
  114. package/dist/{LinearPileupDisplay/components → shared}/FilterByTag.d.ts +0 -0
  115. package/dist/{LinearPileupDisplay/components → shared}/FilterByTag.js +3 -9
  116. package/dist/shared/FilterByTag.js.map +1 -0
  117. package/dist/shared/color.d.ts +17 -0
  118. package/dist/shared/color.js +43 -0
  119. package/dist/shared/color.js.map +1 -0
  120. package/dist/shared/fetchChains.d.ts +27 -0
  121. package/dist/shared/fetchChains.js +30 -0
  122. package/dist/shared/fetchChains.js.map +1 -0
  123. package/dist/shared/index.d.ts +36 -0
  124. package/dist/{shared.js → shared/index.js} +12 -2
  125. package/dist/shared/index.js.map +1 -0
  126. package/esm/AlignmentsFeatureDetail/AlignmentsFeatureDetail.js +1 -1
  127. package/esm/AlignmentsFeatureDetail/AlignmentsFeatureDetail.js.map +1 -1
  128. package/esm/AlignmentsTrack/index.js +1 -0
  129. package/esm/AlignmentsTrack/index.js.map +1 -1
  130. package/esm/BamAdapter/BamSlightlyLazyFeature.d.ts +3 -4
  131. package/esm/BamAdapter/BamSlightlyLazyFeature.js +11 -18
  132. package/esm/BamAdapter/BamSlightlyLazyFeature.js.map +1 -1
  133. package/esm/BamAdapter/index.js +1 -0
  134. package/esm/BamAdapter/index.js.map +1 -1
  135. package/esm/CramAdapter/CramSlightlyLazyFeature.d.ts +5 -7
  136. package/esm/CramAdapter/CramSlightlyLazyFeature.js +6 -8
  137. package/esm/CramAdapter/CramSlightlyLazyFeature.js.map +1 -1
  138. package/esm/CramAdapter/index.js +1 -0
  139. package/esm/CramAdapter/index.js.map +1 -1
  140. package/esm/GuessAlignmentsTypes/index.d.ts +3 -0
  141. package/esm/GuessAlignmentsTypes/index.js +54 -0
  142. package/esm/GuessAlignmentsTypes/index.js.map +1 -0
  143. package/esm/HtsgetBamAdapter/index.js +11 -11
  144. package/esm/HtsgetBamAdapter/index.js.map +1 -1
  145. package/esm/LinearAlignmentsDisplay/components/AlignmentsDisplay.js +10 -13
  146. package/esm/LinearAlignmentsDisplay/components/AlignmentsDisplay.js.map +1 -1
  147. package/esm/LinearAlignmentsDisplay/index.js +1 -0
  148. package/esm/LinearAlignmentsDisplay/index.js.map +1 -1
  149. package/esm/LinearAlignmentsDisplay/models/configSchema.d.ts +6 -3
  150. package/esm/LinearAlignmentsDisplay/models/configSchema.js +2 -4
  151. package/esm/LinearAlignmentsDisplay/models/configSchema.js.map +1 -1
  152. package/esm/LinearAlignmentsDisplay/models/model.d.ts +22 -36
  153. package/esm/LinearAlignmentsDisplay/models/model.js +167 -152
  154. package/esm/LinearAlignmentsDisplay/models/model.js.map +1 -1
  155. package/esm/LinearPileupDisplay/components/SetFeatureHeight.d.ts +2 -2
  156. package/esm/LinearPileupDisplay/components/SetFeatureHeight.js +2 -4
  157. package/esm/LinearPileupDisplay/components/SetFeatureHeight.js.map +1 -1
  158. package/esm/LinearPileupDisplay/configSchema.d.ts +0 -3
  159. package/esm/LinearPileupDisplay/configSchema.js.map +1 -1
  160. package/esm/LinearPileupDisplay/index.js +2 -0
  161. package/esm/LinearPileupDisplay/index.js.map +1 -1
  162. package/esm/LinearPileupDisplay/model.d.ts +19 -16
  163. package/esm/LinearPileupDisplay/model.js +29 -14
  164. package/esm/LinearPileupDisplay/model.js.map +1 -1
  165. package/esm/LinearReadArcsDisplay/components/ReactComponent.d.ts +6 -0
  166. package/esm/LinearReadArcsDisplay/components/ReactComponent.js +44 -0
  167. package/esm/LinearReadArcsDisplay/components/ReactComponent.js.map +1 -0
  168. package/esm/LinearReadArcsDisplay/configSchema.d.ts +6 -0
  169. package/esm/LinearReadArcsDisplay/configSchema.js +50 -0
  170. package/esm/LinearReadArcsDisplay/configSchema.js.map +1 -0
  171. package/esm/LinearReadArcsDisplay/drawFeats.d.ts +14 -0
  172. package/esm/LinearReadArcsDisplay/drawFeats.js +157 -0
  173. package/esm/LinearReadArcsDisplay/drawFeats.js.map +1 -0
  174. package/esm/LinearReadArcsDisplay/index.d.ts +2 -0
  175. package/esm/LinearReadArcsDisplay/index.js +21 -0
  176. package/esm/LinearReadArcsDisplay/index.js.map +1 -0
  177. package/esm/LinearReadArcsDisplay/model.d.ts +342 -0
  178. package/esm/LinearReadArcsDisplay/model.js +299 -0
  179. package/esm/LinearReadArcsDisplay/model.js.map +1 -0
  180. package/esm/LinearReadCloudDisplay/components/ReactComponent.d.ts +6 -0
  181. package/esm/LinearReadCloudDisplay/components/ReactComponent.js +44 -0
  182. package/esm/LinearReadCloudDisplay/components/ReactComponent.js.map +1 -0
  183. package/esm/LinearReadCloudDisplay/configSchema.d.ts +6 -0
  184. package/esm/LinearReadCloudDisplay/configSchema.js +49 -0
  185. package/esm/LinearReadCloudDisplay/configSchema.js.map +1 -0
  186. package/esm/LinearReadCloudDisplay/drawFeats.d.ts +10 -0
  187. package/esm/LinearReadCloudDisplay/drawFeats.js +156 -0
  188. package/esm/LinearReadCloudDisplay/drawFeats.js.map +1 -0
  189. package/esm/LinearReadCloudDisplay/index.d.ts +2 -0
  190. package/esm/LinearReadCloudDisplay/index.js +21 -0
  191. package/esm/LinearReadCloudDisplay/index.js.map +1 -0
  192. package/esm/LinearReadCloudDisplay/model.d.ts +320 -0
  193. package/esm/LinearReadCloudDisplay/model.js +224 -0
  194. package/esm/LinearReadCloudDisplay/model.js.map +1 -0
  195. package/esm/LinearSNPCoverageDisplay/index.js +1 -0
  196. package/esm/LinearSNPCoverageDisplay/index.js.map +1 -1
  197. package/esm/LinearSNPCoverageDisplay/models/model.d.ts +19 -20
  198. package/esm/LinearSNPCoverageDisplay/models/model.js +2 -7
  199. package/esm/LinearSNPCoverageDisplay/models/model.js.map +1 -1
  200. package/esm/{BamAdapter/MismatchParser.d.ts → MismatchParser/index.d.ts} +23 -0
  201. package/esm/{BamAdapter/MismatchParser.js → MismatchParser/index.js} +107 -2
  202. package/esm/MismatchParser/index.js.map +1 -0
  203. package/esm/PileupRPC/base.d.ts +8 -0
  204. package/esm/PileupRPC/base.js +16 -0
  205. package/esm/PileupRPC/base.js.map +1 -0
  206. package/esm/PileupRPC/index.d.ts +3 -0
  207. package/esm/PileupRPC/index.js +7 -0
  208. package/esm/PileupRPC/index.js.map +1 -0
  209. package/esm/PileupRPC/methods/GetGlobalValueForTag.d.ts +14 -0
  210. package/esm/PileupRPC/methods/GetGlobalValueForTag.js +23 -0
  211. package/esm/PileupRPC/methods/GetGlobalValueForTag.js.map +1 -0
  212. package/esm/PileupRPC/methods/GetReducedFeatures.d.ts +25 -0
  213. package/esm/PileupRPC/methods/GetReducedFeatures.js +55 -0
  214. package/esm/PileupRPC/methods/GetReducedFeatures.js.map +1 -0
  215. package/esm/PileupRPC/methods/GetVisibleModifications.d.ts +14 -0
  216. package/esm/PileupRPC/methods/GetVisibleModifications.js +26 -0
  217. package/esm/PileupRPC/methods/GetVisibleModifications.js.map +1 -0
  218. package/esm/PileupRPC/rpcMethods.d.ts +4 -34
  219. package/esm/PileupRPC/rpcMethods.js +4 -74
  220. package/esm/PileupRPC/rpcMethods.js.map +1 -1
  221. package/esm/PileupRPC/util.d.ts +8 -0
  222. package/esm/PileupRPC/util.js +15 -0
  223. package/esm/PileupRPC/util.js.map +1 -0
  224. package/esm/PileupRenderer/PileupRenderer.d.ts +1 -1
  225. package/esm/PileupRenderer/PileupRenderer.js +5 -5
  226. package/esm/PileupRenderer/PileupRenderer.js.map +1 -1
  227. package/esm/PileupRenderer/index.js +1 -0
  228. package/esm/PileupRenderer/index.js.map +1 -1
  229. package/esm/PileupRenderer/sortUtil.d.ts +1 -1
  230. package/esm/PileupRenderer/sortUtil.js +1 -1
  231. package/esm/PileupRenderer/sortUtil.js.map +1 -1
  232. package/esm/SNPCoverageAdapter/generateCoverageBins.js +1 -1
  233. package/esm/SNPCoverageAdapter/generateCoverageBins.js.map +1 -1
  234. package/esm/SNPCoverageAdapter/index.js +1 -3
  235. package/esm/SNPCoverageAdapter/index.js.map +1 -1
  236. package/esm/index.d.ts +2 -2
  237. package/esm/index.js +10 -56
  238. package/esm/index.js.map +1 -1
  239. package/esm/{LinearPileupDisplay/components → shared}/FilterByTag.d.ts +0 -0
  240. package/esm/{LinearPileupDisplay/components → shared}/FilterByTag.js +3 -9
  241. package/esm/shared/FilterByTag.js.map +1 -0
  242. package/esm/shared/color.d.ts +17 -0
  243. package/esm/shared/color.js +37 -0
  244. package/esm/shared/color.js.map +1 -0
  245. package/esm/shared/fetchChains.d.ts +27 -0
  246. package/esm/shared/fetchChains.js +26 -0
  247. package/esm/shared/fetchChains.js.map +1 -0
  248. package/esm/shared/index.d.ts +36 -0
  249. package/esm/{shared.js → shared/index.js} +11 -1
  250. package/esm/shared/index.js.map +1 -0
  251. package/package.json +4 -4
  252. package/src/AlignmentsFeatureDetail/AlignmentsFeatureDetail.tsx +1 -1
  253. package/src/AlignmentsTrack/index.ts +1 -0
  254. package/src/BamAdapter/BamSlightlyLazyFeature.ts +13 -19
  255. package/src/BamAdapter/index.ts +1 -0
  256. package/src/CramAdapter/CramSlightlyLazyFeature.ts +13 -15
  257. package/src/CramAdapter/__snapshots__/CramAdapter.test.ts.snap +0 -10
  258. package/src/CramAdapter/index.ts +1 -0
  259. package/src/GuessAlignmentsTypes/index.ts +79 -0
  260. package/src/HtsgetBamAdapter/index.ts +11 -15
  261. package/src/LinearAlignmentsDisplay/components/AlignmentsDisplay.tsx +21 -29
  262. package/src/LinearAlignmentsDisplay/index.ts +1 -0
  263. package/src/LinearAlignmentsDisplay/models/configSchema.ts +2 -6
  264. package/src/LinearAlignmentsDisplay/models/model.tsx +238 -199
  265. package/src/LinearPileupDisplay/components/SetFeatureHeight.tsx +4 -6
  266. package/src/LinearPileupDisplay/configSchema.ts +1 -3
  267. package/src/LinearPileupDisplay/index.ts +2 -0
  268. package/src/LinearPileupDisplay/model.ts +36 -23
  269. package/src/LinearReadArcsDisplay/components/ReactComponent.tsx +86 -0
  270. package/src/LinearReadArcsDisplay/configSchema.ts +58 -0
  271. package/src/LinearReadArcsDisplay/declare.d.ts +1 -0
  272. package/src/LinearReadArcsDisplay/drawFeats.ts +199 -0
  273. package/src/LinearReadArcsDisplay/index.ts +23 -0
  274. package/src/LinearReadArcsDisplay/model.tsx +370 -0
  275. package/src/LinearReadCloudDisplay/components/ReactComponent.tsx +86 -0
  276. package/src/LinearReadCloudDisplay/configSchema.ts +57 -0
  277. package/src/LinearReadCloudDisplay/drawFeats.ts +201 -0
  278. package/src/LinearReadCloudDisplay/index.ts +23 -0
  279. package/src/LinearReadCloudDisplay/model.tsx +289 -0
  280. package/src/LinearSNPCoverageDisplay/index.ts +1 -0
  281. package/src/LinearSNPCoverageDisplay/models/model.ts +3 -13
  282. package/src/{BamAdapter/MismatchParser.test.ts → MismatchParser/index.test.ts} +1 -1
  283. package/src/{BamAdapter/MismatchParser.ts → MismatchParser/index.ts} +129 -2
  284. package/src/PileupRPC/base.ts +24 -0
  285. package/src/PileupRPC/index.ts +12 -0
  286. package/src/PileupRPC/methods/GetGlobalValueForTag.ts +41 -0
  287. package/src/PileupRPC/methods/GetReducedFeatures.ts +76 -0
  288. package/src/PileupRPC/methods/GetVisibleModifications.ts +45 -0
  289. package/src/PileupRPC/rpcMethods.ts +8 -113
  290. package/src/PileupRPC/util.ts +19 -0
  291. package/src/PileupRenderer/PileupRenderer.ts +5 -8
  292. package/src/PileupRenderer/index.ts +1 -0
  293. package/src/PileupRenderer/sortUtil.ts +2 -3
  294. package/src/SNPCoverageAdapter/generateCoverageBins.ts +1 -1
  295. package/src/SNPCoverageAdapter/index.ts +1 -3
  296. package/src/index.ts +12 -93
  297. package/src/{LinearPileupDisplay/components → shared}/FilterByTag.tsx +3 -9
  298. package/src/shared/color.ts +47 -0
  299. package/src/shared/fetchChains.ts +63 -0
  300. package/src/{shared.ts → shared/index.ts} +17 -4
  301. package/dist/BamAdapter/MismatchParser.js.map +0 -1
  302. package/dist/LinearPileupDisplay/components/FilterByTag.js.map +0 -1
  303. package/dist/shared.d.ts +0 -25
  304. package/dist/shared.js.map +0 -1
  305. package/esm/BamAdapter/MismatchParser.js.map +0 -1
  306. package/esm/LinearPileupDisplay/components/FilterByTag.js.map +0 -1
  307. package/esm/shared.d.ts +0 -25
  308. package/esm/shared.js.map +0 -1
@@ -0,0 +1,370 @@
1
+ import React, { lazy } from 'react'
2
+ import { autorun } from 'mobx'
3
+ import { addDisposer, cast, types, Instance } from 'mobx-state-tree'
4
+ import {
5
+ AnyConfigurationSchemaType,
6
+ ConfigurationReference,
7
+ ConfigurationSchema,
8
+ getConf,
9
+ } from '@jbrowse/core/configuration'
10
+ import { getSession, getContainingView } from '@jbrowse/core/util'
11
+
12
+ import {
13
+ BaseLinearDisplay,
14
+ LinearGenomeViewModel,
15
+ } from '@jbrowse/plugin-linear-genome-view'
16
+
17
+ // icons
18
+ import PaletteIcon from '@mui/icons-material/Palette'
19
+ import FilterListIcon from '@mui/icons-material/ClearAll'
20
+
21
+ // locals
22
+ import { FilterModel } from '../shared'
23
+ import drawFeats from './drawFeats'
24
+ import { fetchChains, ChainData } from '../shared/fetchChains'
25
+ import { ExportSvgOptions } from '@jbrowse/plugin-linear-genome-view/src/LinearGenomeView'
26
+
27
+ // async
28
+ const FilterByTagDlg = lazy(() => import('../shared/FilterByTag'))
29
+
30
+ interface Filter {
31
+ flagInclude: number
32
+ flagExclude: number
33
+ readName?: string
34
+ tagFilter?: { tag: string; value: string }
35
+ }
36
+
37
+ type LGV = LinearGenomeViewModel
38
+
39
+ /**
40
+ * #stateModel LinearReadArcsDisplay
41
+ * extends `BaseLinearDisplay`
42
+ */
43
+ function stateModelFactory(configSchema: AnyConfigurationSchemaType) {
44
+ return types
45
+ .compose(
46
+ 'LinearReadArcsDisplay',
47
+ BaseLinearDisplay,
48
+ types.model({
49
+ /**
50
+ * #property
51
+ */
52
+ type: types.literal('LinearReadArcsDisplay'),
53
+ /**
54
+ * #property
55
+ */
56
+ configuration: ConfigurationReference(configSchema),
57
+
58
+ /**
59
+ * #property
60
+ */
61
+ filterBy: types.optional(FilterModel, {}),
62
+
63
+ /**
64
+ * #property
65
+ */
66
+ lineWidth: types.maybe(types.number),
67
+
68
+ /**
69
+ * #property
70
+ */
71
+ colorBy: types.maybe(
72
+ types.model({
73
+ type: types.string,
74
+ tag: types.maybe(types.string),
75
+ extra: types.frozen(),
76
+ }),
77
+ ),
78
+
79
+ /**
80
+ * #property
81
+ */
82
+ drawInter: true,
83
+
84
+ /**
85
+ * #property
86
+ */
87
+ drawLongRange: true,
88
+ }),
89
+ )
90
+ .volatile(() => ({
91
+ loading: false,
92
+ drawn: false,
93
+ chainData: undefined as ChainData | undefined,
94
+ ref: null as HTMLCanvasElement | null,
95
+ lastDrawnOffsetPx: 0,
96
+ }))
97
+ .actions(self => ({
98
+ /**
99
+ * #action
100
+ * internal, a reference to a HTMLCanvas because we use a autorun to draw the canvas
101
+ */
102
+ reload() {
103
+ self.error = undefined
104
+ },
105
+ /**
106
+ * #action
107
+ * internal, a reference to a HTMLCanvas because we use a autorun to draw the canvas
108
+ */
109
+ setRef(ref: HTMLCanvasElement | null) {
110
+ self.ref = ref
111
+ },
112
+
113
+ /**
114
+ * #action
115
+ */
116
+ setColorScheme(s: { type: string }) {
117
+ self.colorBy = cast(s)
118
+ },
119
+
120
+ /**
121
+ * #action
122
+ */
123
+ setChainData(args: ChainData) {
124
+ self.chainData = args
125
+ },
126
+
127
+ /**
128
+ * #action
129
+ */
130
+ setDrawInter(f: boolean) {
131
+ self.drawInter = f
132
+ },
133
+
134
+ /**
135
+ * #action
136
+ */
137
+ setDrawLongRange(f: boolean) {
138
+ self.drawLongRange = f
139
+ },
140
+
141
+ /**
142
+ * #action
143
+ */
144
+ setLoading(f: boolean) {
145
+ self.loading = f
146
+ },
147
+
148
+ /**
149
+ * #action
150
+ * used during tests to detect when we can complete a snapshot test
151
+ */
152
+ setDrawn(f: boolean) {
153
+ self.drawn = f
154
+ },
155
+
156
+ /**
157
+ * #action
158
+ */
159
+ setFilterBy(filter: Filter) {
160
+ self.filterBy = cast(filter)
161
+ },
162
+
163
+ /**
164
+ * #action
165
+ * allows the drawing to slide around a little bit if it takes a long time to refresh
166
+ */
167
+ setLastDrawnOffsetPx(n: number) {
168
+ self.lastDrawnOffsetPx = n
169
+ },
170
+
171
+ /**
172
+ * #action
173
+ * thin, bold, extrabold, etc
174
+ */
175
+ setLineWidth(n: number) {
176
+ self.lineWidth = n
177
+ },
178
+ }))
179
+
180
+ .views(self => {
181
+ const {
182
+ trackMenuItems: superTrackMenuItems,
183
+ renderProps: superRenderProps,
184
+ } = self
185
+
186
+ return {
187
+ /**
188
+ * #getter
189
+ */
190
+ get lineWidthSetting() {
191
+ return self.lineWidth ?? getConf(self, 'lineWidth')
192
+ },
193
+ /**
194
+ * #getter
195
+ */
196
+ get ready() {
197
+ return !!self.chainData
198
+ },
199
+ // we don't use a server side renderer, but we need to provide this
200
+ // to avoid confusing the system currently
201
+ get rendererTypeName() {
202
+ return 'PileupRenderer'
203
+ },
204
+ // we don't use a server side renderer, so this fills in minimal
205
+ // info so as not to crash
206
+ renderProps() {
207
+ return {
208
+ ...superRenderProps(),
209
+ // never ready, we don't want to use server side render
210
+ notReady: true,
211
+ config: ConfigurationSchema('empty', {}).create(),
212
+ }
213
+ },
214
+
215
+ /**
216
+ * #method
217
+ */
218
+ trackMenuItems() {
219
+ return [
220
+ ...superTrackMenuItems(),
221
+ {
222
+ label: 'Filter by',
223
+ icon: FilterListIcon,
224
+ onClick: () => {
225
+ getSession(self).queueDialog(handleClose => [
226
+ FilterByTagDlg,
227
+ { model: self, handleClose },
228
+ ])
229
+ },
230
+ },
231
+ {
232
+ label: 'Line width',
233
+ subMenu: [
234
+ {
235
+ label: 'Thin',
236
+ onClick: () => self.setLineWidth(1),
237
+ },
238
+ {
239
+ label: 'Bold',
240
+ onClick: () => self.setLineWidth(2),
241
+ },
242
+ {
243
+ label: 'Extra bold',
244
+ onClick: () => self.setLineWidth(5),
245
+ },
246
+ ],
247
+ },
248
+ {
249
+ label: 'Draw inter-region vertical lines',
250
+ type: 'checkbox',
251
+ checked: self.drawInter,
252
+ onClick: () => self.setDrawInter(!self.drawInter),
253
+ },
254
+ {
255
+ label: 'Draw long range connections',
256
+ type: 'checkbox',
257
+ checked: self.drawLongRange,
258
+ onClick: () => self.setDrawLongRange(!self.drawLongRange),
259
+ },
260
+ {
261
+ label: 'Color scheme',
262
+ icon: PaletteIcon,
263
+ subMenu: [
264
+ {
265
+ label: 'Insert size ± 3σ and orientation',
266
+ onClick: () =>
267
+ self.setColorScheme({ type: 'insertSizeAndOrientation' }),
268
+ },
269
+ {
270
+ label: 'Insert size ± 3σ',
271
+ onClick: () => self.setColorScheme({ type: 'insertSize' }),
272
+ },
273
+ {
274
+ label: 'Orientation',
275
+ onClick: () => self.setColorScheme({ type: 'orientation' }),
276
+ },
277
+ {
278
+ label: 'Insert size gradient',
279
+ onClick: () => self.setColorScheme({ type: 'gradient' }),
280
+ },
281
+ ],
282
+ },
283
+ ]
284
+ },
285
+ }
286
+ })
287
+ .views(self => ({
288
+ /**
289
+ * #method
290
+ */
291
+ async renderSvg(opts: ExportSvgOptions) {
292
+ const view = getContainingView(self) as LGV
293
+ const width = view.dynamicBlocks.totalWidthPx
294
+ const height = self.height
295
+ let str
296
+ if (opts.rasterizeLayers) {
297
+ const canvas = document.createElement('canvas')
298
+ canvas.width = width * 2
299
+ canvas.height = height * 2
300
+ const ctx = canvas.getContext('2d')
301
+ if (!ctx) {
302
+ return
303
+ }
304
+ ctx.scale(2, 2)
305
+ await drawFeats(self, ctx)
306
+ str = (
307
+ <image
308
+ width={width}
309
+ height={height}
310
+ xlinkHref={canvas.toDataURL('image/png')}
311
+ />
312
+ )
313
+ } else {
314
+ // @ts-ignore
315
+ const C2S = await import('canvas2svg')
316
+ const ctx = new C2S.default(width, height)
317
+ await drawFeats(self, ctx)
318
+ str = (
319
+ // eslint-disable-next-line react/no-danger
320
+ <g dangerouslySetInnerHTML={{ __html: ctx.getSvg().innerHTML }} />
321
+ )
322
+ }
323
+
324
+ return <g>{str}</g>
325
+ },
326
+ }))
327
+ .actions(self => ({
328
+ afterAttach() {
329
+ addDisposer(
330
+ self,
331
+ autorun(() => fetchChains(self), { delay: 1000 }),
332
+ )
333
+
334
+ addDisposer(
335
+ self,
336
+ autorun(
337
+ async () => {
338
+ try {
339
+ const canvas = self.ref
340
+ if (!canvas) {
341
+ return
342
+ }
343
+ const ctx = canvas.getContext('2d')
344
+ if (!ctx) {
345
+ return
346
+ }
347
+ ctx.clearRect(0, 0, canvas.width, self.height * 2)
348
+ ctx.resetTransform()
349
+ ctx.scale(2, 2)
350
+ await drawFeats(self, ctx)
351
+ self.setDrawn(true)
352
+ } catch (e) {
353
+ console.error(e)
354
+ self.setError(e)
355
+ }
356
+ },
357
+ { delay: 1000 },
358
+ ),
359
+ )
360
+ },
361
+ }))
362
+ }
363
+
364
+ export type LinearReadArcsDisplayStateModel = ReturnType<
365
+ typeof stateModelFactory
366
+ >
367
+ export type LinearReadArcsDisplayModel =
368
+ Instance<LinearReadArcsDisplayStateModel>
369
+
370
+ export default stateModelFactory
@@ -0,0 +1,86 @@
1
+ import React from 'react'
2
+ import { isAlive } from 'mobx-state-tree'
3
+ import { observer } from 'mobx-react'
4
+ import { makeStyles } from 'tss-react/mui'
5
+ import { getContainingView } from '@jbrowse/core/util'
6
+ import { LoadingEllipses } from '@jbrowse/core/ui'
7
+ import {
8
+ BlockMsg,
9
+ LinearGenomeViewModel,
10
+ } from '@jbrowse/plugin-linear-genome-view'
11
+
12
+ // local
13
+ import { LinearReadCloudDisplayModel } from '../model'
14
+
15
+ type LGV = LinearGenomeViewModel
16
+
17
+ const useStyles = makeStyles()(theme => ({
18
+ loading: {
19
+ paddingLeft: '0.6em',
20
+ backgroundColor: theme.palette.action.disabledBackground,
21
+ backgroundImage:
22
+ 'repeating-linear-gradient(45deg, transparent, transparent 5px, rgba(255,255,255,.5) 5px, rgba(255,255,255,.5) 10px)',
23
+ height: '100%',
24
+ width: '100%',
25
+ pointerEvents: 'none',
26
+ textAlign: 'center',
27
+ },
28
+ }))
29
+
30
+ const Cloud = observer(function ({
31
+ model,
32
+ }: {
33
+ model: LinearReadCloudDisplayModel
34
+ }) {
35
+ const view = getContainingView(model) as LGV
36
+ return (
37
+ <canvas
38
+ data-testid={`ReadCloud-display-${model.drawn}`}
39
+ ref={ref => {
40
+ if (isAlive(model)) {
41
+ model.setRef(ref)
42
+ }
43
+ }}
44
+ style={{
45
+ position: 'absolute',
46
+ left: -view.offsetPx + model.lastDrawnOffsetPx,
47
+ width: view.dynamicBlocks.totalWidthPx,
48
+ height: model.height,
49
+ }}
50
+ width={view.dynamicBlocks.totalWidthPx * 2}
51
+ height={model.height * 2}
52
+ />
53
+ )
54
+ })
55
+
56
+ export default observer(function ({
57
+ model,
58
+ }: {
59
+ model: LinearReadCloudDisplayModel
60
+ }) {
61
+ const view = getContainingView(model)
62
+ const { classes } = useStyles()
63
+ const err = model.error
64
+ return err ? (
65
+ <BlockMsg
66
+ message={`${err}`}
67
+ severity="error"
68
+ buttonText={'Reload'}
69
+ action={model.reload}
70
+ />
71
+ ) : model.loading ? (
72
+ <div
73
+ className={classes.loading}
74
+ style={{
75
+ width: view.dynamicBlocks.totalWidthPx,
76
+ height: 20,
77
+ position: 'absolute',
78
+ left: Math.max(0, -view.offsetPx),
79
+ }}
80
+ >
81
+ <LoadingEllipses message={model.message} />
82
+ </div>
83
+ ) : (
84
+ <Cloud model={model} />
85
+ )
86
+ })
@@ -0,0 +1,57 @@
1
+ import PluginManager from '@jbrowse/core/PluginManager'
2
+ import { ConfigurationSchema } from '@jbrowse/core/configuration'
3
+ import { linearBasicDisplayConfigSchemaFactory } from '@jbrowse/plugin-linear-genome-view'
4
+ import { types } from 'mobx-state-tree'
5
+
6
+ /**
7
+ * #config LinearReadCloudDisplay
8
+ */
9
+ function configSchemaF(pluginManager: PluginManager) {
10
+ return ConfigurationSchema(
11
+ 'LinearReadCloudDisplay',
12
+ {
13
+ /**
14
+ * #slot
15
+ */
16
+ maxFeatureScreenDensity: {
17
+ type: 'number',
18
+ description: 'maximum features per pixel that is displayed in the view',
19
+ defaultValue: 5,
20
+ },
21
+
22
+ /**
23
+ * #slot
24
+ */
25
+ featureHeight: {
26
+ type: 'number',
27
+ defaultValue: 7,
28
+ },
29
+
30
+ /**
31
+ * #slot
32
+ */
33
+ colorScheme: {
34
+ type: 'stringEnum',
35
+ model: types.enumeration('colorScheme', [
36
+ 'strand',
37
+ 'normal',
38
+ 'insertSize',
39
+ 'insertSizeAndOrientation',
40
+ 'mappingQuality',
41
+ 'tag',
42
+ ]),
43
+ description: 'color scheme to use',
44
+ defaultValue: 'normal',
45
+ },
46
+ },
47
+ {
48
+ /**
49
+ * #baseConfiguration
50
+ */
51
+ baseConfiguration: linearBasicDisplayConfigSchemaFactory(pluginManager),
52
+ explicitlyTyped: true,
53
+ },
54
+ )
55
+ }
56
+
57
+ export default configSchemaF
@@ -0,0 +1,201 @@
1
+ import { getConf } from '@jbrowse/core/configuration'
2
+ import { getContainingView } from '@jbrowse/core/util'
3
+
4
+ import { LinearGenomeViewModel } from '@jbrowse/plugin-linear-genome-view'
5
+ // locals
6
+ import {
7
+ getOrientationColor,
8
+ getInsertSizeColor,
9
+ getInsertSizeAndOrientationColor,
10
+ } from '../shared/color'
11
+ import { ChainData, ReducedFeature } from '../shared/fetchChains'
12
+
13
+ type LGV = LinearGenomeViewModel
14
+
15
+ interface ChainCoord {
16
+ distance: number
17
+ r1s: number
18
+ r1e: number
19
+ r2s: number
20
+ r2e: number
21
+ v0: ReducedFeature
22
+ v1: ReducedFeature
23
+ }
24
+
25
+ // avoid drawing negative width features for SVG exports
26
+ function fillRectCtx(
27
+ x: number,
28
+ y: number,
29
+ width: number,
30
+ height: number,
31
+ ctx: CanvasRenderingContext2D,
32
+ color?: string,
33
+ ) {
34
+ if (width < 0) {
35
+ x += width
36
+ width = -width
37
+ }
38
+ if (height < 0) {
39
+ y += height
40
+ height = -height
41
+ }
42
+
43
+ if (color) {
44
+ ctx.fillStyle = color
45
+ }
46
+ ctx.fillRect(x, y, width, height)
47
+ }
48
+
49
+ export default async function drawFeats(
50
+ self: {
51
+ setLastDrawnOffsetPx: (n: number) => void
52
+ setError: (e: unknown) => void
53
+ colorBy?: { type: string }
54
+ height: number
55
+ chainData?: ChainData
56
+ },
57
+ ctx: CanvasRenderingContext2D,
58
+ ) {
59
+ const { chainData } = self
60
+ if (!chainData) {
61
+ return
62
+ }
63
+ const featureHeight = getConf(self, 'featureHeight')
64
+ const displayHeight = self.height
65
+ const view = getContainingView(self) as LGV
66
+
67
+ self.setLastDrawnOffsetPx(view.offsetPx)
68
+
69
+ const { chains, stats } = chainData
70
+ const coords: ChainCoord[] = []
71
+ for (let i = 0; i < chains.length; i++) {
72
+ const chain = chains[i]
73
+ // if we're looking at a paired read (flag 1) then assume it is just two
74
+ // reads (some small cases may defy this assumption such as secondary
75
+ // alignments but this may be uncommon)
76
+ if (chain[0].flags & 1 && chain.length > 1) {
77
+ const v0 = chain[0]
78
+ const v1 = chain[1]
79
+ const r1s = view.bpToPx({
80
+ refName: v0.refName,
81
+ coord: v0.start,
82
+ })
83
+ const r1e = view.bpToPx({
84
+ refName: v0.refName,
85
+ coord: v0.end,
86
+ })
87
+ const r2s = view.bpToPx({
88
+ refName: v1.refName,
89
+ coord: v1.start,
90
+ })
91
+ const r2e = view.bpToPx({
92
+ refName: v1.refName,
93
+ coord: v1.end,
94
+ })
95
+ let distance = 0
96
+
97
+ if (
98
+ r1s !== undefined &&
99
+ r1e !== undefined &&
100
+ r2s !== undefined &&
101
+ r2e !== undefined
102
+ ) {
103
+ if (v0.refName === v1.refName) {
104
+ const s = Math.min(v0.start, v1.start)
105
+ const e = Math.max(v0.end, v1.end)
106
+ distance = Math.abs(e - s)
107
+ }
108
+ coords.push({
109
+ r1s: r1s.offsetPx,
110
+ r1e: r1e.offsetPx,
111
+ r2s: r2s.offsetPx,
112
+ r2e: r2e.offsetPx,
113
+ v0,
114
+ v1,
115
+ distance,
116
+ })
117
+ }
118
+ } else {
119
+ // if we're not looking at pairs, then it could be a multiply-split-long
120
+ // read, so traverse chain
121
+ for (let i = 1; i < chain.length; i++) {
122
+ const v0 = chain[i - 1]
123
+ const v1 = chain[i]
124
+ const r1s = view.bpToPx({
125
+ refName: v0.refName,
126
+ coord: v0.start,
127
+ })
128
+ const r1e = view.bpToPx({
129
+ refName: v0.refName,
130
+ coord: v0.end,
131
+ })
132
+ const r2s = view.bpToPx({
133
+ refName: v1.refName,
134
+ coord: v1.start,
135
+ })
136
+ const r2e = view.bpToPx({
137
+ refName: v1.refName,
138
+ coord: v1.end,
139
+ })
140
+ let distance = 0
141
+
142
+ if (
143
+ r1s !== undefined &&
144
+ r1e !== undefined &&
145
+ r2s !== undefined &&
146
+ r2e !== undefined
147
+ ) {
148
+ if (v0.refName === v1.refName) {
149
+ const s = Math.min(v0.start, v1.start)
150
+ const e = Math.max(v0.end, v1.end)
151
+ distance = Math.abs(e - s)
152
+ }
153
+ coords.push({
154
+ r1s: r1s.offsetPx,
155
+ r1e: r1e.offsetPx,
156
+ r2s: r2s.offsetPx,
157
+ r2e: r2e.offsetPx,
158
+ v0,
159
+ v1,
160
+ distance,
161
+ })
162
+ }
163
+ }
164
+ }
165
+ }
166
+
167
+ let max = 0
168
+ for (let i = 0; i < coords.length; i++) {
169
+ const { distance } = coords[i]
170
+ max = Math.max(max, distance)
171
+ }
172
+ const halfHeight = featureHeight / 2 - 0.5
173
+ const scaler = (displayHeight - 20) / Math.log(max)
174
+
175
+ for (let i = 0; i < coords.length; i++) {
176
+ const { r1s, r1e, r2s, r2e, v0, v1, distance } = coords[i]
177
+ const type = self.colorBy?.type || 'insertSizeAndOrientation'
178
+
179
+ const top = Math.log(distance) * scaler
180
+ ctx.fillStyle = 'black'
181
+ const w = r2s - r1e
182
+ fillRectCtx(r1e - view.offsetPx, top + halfHeight, w, 1, ctx)
183
+
184
+ if (type === 'insertSizeAndOrientation') {
185
+ ctx.fillStyle = getInsertSizeAndOrientationColor(v0, v1, stats)
186
+ } else if (type === 'orientation') {
187
+ ctx.fillStyle = getOrientationColor(v0)
188
+ } else if (type === 'insertSize') {
189
+ ctx.fillStyle = getInsertSizeColor(v0, v1, stats) || 'grey'
190
+ } else if (type === 'gradient') {
191
+ const s = Math.min(v0.start, v1.start)
192
+ const e = Math.max(v0.end, v1.end)
193
+ ctx.fillStyle = `hsl(${Math.log10(Math.abs(e - s)) * 10},50%,50%)`
194
+ }
195
+
196
+ const w1 = Math.max(r1e - r1s, 2)
197
+ const w2 = Math.max(r2e - r2s, 2)
198
+ fillRectCtx(r1s - view.offsetPx, top, w1, featureHeight, ctx)
199
+ fillRectCtx(r2s - view.offsetPx, top, w2, featureHeight, ctx)
200
+ }
201
+ }