higlass 1.13.5 → 2.0.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 (392) hide show
  1. package/README.md +48 -54
  2. package/app/globals.d.ts +1 -1
  3. package/app/missing-types.d.ts +4 -1
  4. package/app/scripts/AddTrackDialog.jsx +11 -4
  5. package/app/scripts/AddTrackPositionMenu.jsx +28 -7
  6. package/app/scripts/Annotations1dTrack.js +90 -251
  7. package/app/scripts/Annotations2dTrack.js +12 -7
  8. package/app/scripts/Autocomplete.jsx +13 -28
  9. package/app/scripts/AxisPixi.js +6 -10
  10. package/app/scripts/BarTrack.js +3 -3
  11. package/app/scripts/BedLikeTrack.js +556 -449
  12. package/app/scripts/Button.jsx +1 -1
  13. package/app/scripts/CNVIntervalTrack.js +1 -1
  14. package/app/scripts/CenterTrack.jsx +8 -7
  15. package/app/scripts/Chromosome2DAnnotations.js +1 -1
  16. package/app/scripts/Chromosome2DLabels.js +1 -1
  17. package/app/scripts/ChromosomeGrid.js +49 -38
  18. package/app/scripts/ChromosomeInfo.js +1 -1
  19. package/app/scripts/CombinedTrack.js +3 -1
  20. package/app/scripts/ConfigTrackMenu.jsx +1 -1
  21. package/app/scripts/ConfigViewMenu.jsx +2 -2
  22. package/app/scripts/ContextMenuContainer.jsx +4 -2
  23. package/app/scripts/ContextMenuItem.jsx +14 -2
  24. package/app/scripts/CrossRule.js +1 -1
  25. package/app/scripts/CustomTrackDialog.jsx +2 -2
  26. package/app/scripts/Dialog.jsx +2 -2
  27. package/app/scripts/DragListeningDiv.jsx +1 -1
  28. package/app/scripts/DraggableDiv.jsx +2 -3
  29. package/app/scripts/ExportLinkDialog.jsx +1 -1
  30. package/app/scripts/FilledLine.js +349 -0
  31. package/app/scripts/GalleryTracks.jsx +77 -78
  32. package/app/scripts/GenomePositionSearchBox.jsx +184 -482
  33. package/app/scripts/HeatmapOptions.jsx +4 -2
  34. package/app/scripts/HeatmapTiledPixiTrack.js +23 -32
  35. package/app/scripts/HiGlassComponent.jsx +515 -444
  36. package/app/scripts/HiGlassComponentContext.js +5 -0
  37. package/app/scripts/Horizontal1dHeatmapTrack.js +1 -1
  38. package/app/scripts/Horizontal2DDomainsTrack.js +1 -1
  39. package/app/scripts/HorizontalChromosomeLabels.js +28 -22
  40. package/app/scripts/HorizontalGeneAnnotationsTrack.js +1 -1
  41. package/app/scripts/HorizontalHeatmapTrack.js +2 -2
  42. package/app/scripts/HorizontalMultivecTrack.js +6 -7
  43. package/app/scripts/HorizontalRule.js +1 -2
  44. package/app/scripts/HorizontalTiled1DPixiTrack.js +4 -4
  45. package/app/scripts/HorizontalTiledPlot.jsx +9 -9
  46. package/app/scripts/LeftTrackModifier.js +4 -0
  47. package/app/scripts/ListWrapper.jsx +1 -2
  48. package/app/scripts/MapboxTilesTrack.js +1 -2
  49. package/app/scripts/Modal.jsx +2 -2
  50. package/app/scripts/MoveableTrack.jsx +10 -12
  51. package/app/scripts/NestedContextMenu.jsx +2 -1
  52. package/app/scripts/OSMTileIdsTrack.js +1 -1
  53. package/app/scripts/OverlayTrack.js +4 -4
  54. package/app/scripts/PixiTrack.js +27 -13
  55. package/app/scripts/PlotTypeChooser.jsx +3 -4
  56. package/app/scripts/SearchField.js +5 -5
  57. package/app/scripts/SeriesListItems.jsx +3 -4
  58. package/app/scripts/SeriesListMenu.jsx +95 -53
  59. package/app/scripts/SeriesListSubmenuMixin.jsx +2 -1
  60. package/app/scripts/SketchInlinePicker.jsx +2 -2
  61. package/app/scripts/SortableList.jsx +1 -1
  62. package/app/scripts/Tiled1DPixiTrack.js +4 -1
  63. package/app/scripts/TiledPixiTrack.js +244 -102
  64. package/app/scripts/TiledPlot.jsx +565 -118
  65. package/app/scripts/TilesetFinder.jsx +12 -4
  66. package/app/scripts/Track.js +1 -1
  67. package/app/scripts/TrackArea.jsx +4 -0
  68. package/app/scripts/TrackControl.jsx +2 -2
  69. package/app/scripts/TrackRenderer.jsx +32 -33
  70. package/app/scripts/ValueIntervalTrack.js +1 -1
  71. package/app/scripts/VerticalRule.js +2 -2
  72. package/app/scripts/VerticalTiledPlot.jsx +7 -7
  73. package/app/scripts/ViewConfigEditor.jsx +1 -1
  74. package/app/scripts/ViewContextMenu.jsx +53 -5
  75. package/app/scripts/ViewHeader.jsx +9 -9
  76. package/app/scripts/ViewportTracker2D.js +1 -1
  77. package/app/scripts/api.js +92 -12
  78. package/app/scripts/configs/available-track-types.js +1 -1
  79. package/app/scripts/configs/index.js +6 -1
  80. package/app/scripts/configs/positions-by-datatype.js +2 -2
  81. package/app/scripts/configs/primitives.js +2 -0
  82. package/app/scripts/configs/themes.js +0 -1
  83. package/app/scripts/configs/tracks-info-by-type.js +11 -8
  84. package/app/scripts/configs/tracks-info.js +3 -2
  85. package/app/scripts/d3-context-menu.js +3 -4
  86. package/app/scripts/data-fetchers/DataFetcher.js +35 -36
  87. package/app/scripts/data-fetchers/genbank-fetcher.js +13 -22
  88. package/app/scripts/data-fetchers/local-tile-fetcher.js +10 -8
  89. package/app/scripts/hglib.jsx +62 -71
  90. package/app/scripts/hocs/with-modal.jsx +32 -10
  91. package/app/scripts/hocs/with-pub-sub.js +12 -3
  92. package/app/scripts/hocs/with-theme.jsx +21 -14
  93. package/app/scripts/icons.jsx +3 -2
  94. package/app/scripts/mixwith.js +2 -2
  95. package/app/scripts/options-info.js +49 -11
  96. package/app/scripts/plugins/get-data-fetcher.js +2 -3
  97. package/app/scripts/services/chrom-info.js +32 -4
  98. package/app/scripts/services/element-resize-listener.js +2 -2
  99. package/app/scripts/services/index.js +0 -1
  100. package/app/scripts/services/tile-proxy.js +368 -285
  101. package/app/scripts/services/worker.js +31 -28
  102. package/app/scripts/test-helpers/index.js +2 -1
  103. package/app/scripts/test-helpers/test-helpers.jsx +157 -69
  104. package/app/scripts/types.ts +118 -47
  105. package/app/scripts/utils/LruCache.js +3 -2
  106. package/app/scripts/utils/assert.js +19 -0
  107. package/app/scripts/utils/background-task-scheduler.js +2 -0
  108. package/app/scripts/utils/color-domain-to-rgba-array.js +13 -3
  109. package/app/scripts/utils/copy-text-to-clipboard.js +36 -0
  110. package/app/scripts/utils/decompress.js +33 -0
  111. package/app/scripts/utils/default-tracks.js +46 -0
  112. package/app/scripts/utils/dict-items.js +1 -0
  113. package/app/scripts/utils/dict-keys.js +1 -0
  114. package/app/scripts/utils/dict-values.js +1 -0
  115. package/app/scripts/utils/expand-combined-tracks.js +11 -7
  116. package/app/scripts/utils/fill-in-min-widths.js +47 -21
  117. package/app/scripts/utils/flatten.js +0 -1
  118. package/app/scripts/utils/get-aggregation-function.js +1 -1
  119. package/app/scripts/utils/get-default-track-for-datatype.js +37 -10
  120. package/app/scripts/utils/get-default-tracks-for-datatype.ts +46 -0
  121. package/app/scripts/utils/get-higlass-components.js +27 -3
  122. package/app/scripts/utils/get-track-position-by-uid.js +8 -1
  123. package/app/scripts/utils/get-xylofon.js +12 -9
  124. package/app/scripts/utils/has-parent.js +5 -5
  125. package/app/scripts/utils/hex-string-to-int.js +1 -1
  126. package/app/scripts/utils/index.js +1 -0
  127. package/app/scripts/utils/interval-tree.js +222 -177
  128. package/app/scripts/utils/load-chrom-infos.js +4 -1
  129. package/app/scripts/utils/pixi-text-to-svg.js +5 -9
  130. package/app/scripts/utils/positioned-tracks-to-all-tracks.js +55 -0
  131. package/app/scripts/utils/range-query-2d.js +3 -3
  132. package/app/scripts/utils/reduce.js +12 -5
  133. package/app/scripts/utils/segments-to-rows.js +14 -11
  134. package/app/scripts/utils/svg-line.js +7 -8
  135. package/app/scripts/utils/type-guards.js +16 -7
  136. package/app/scripts/utils/visit-positioned-tracks.js +9 -4
  137. package/app/styles/AddTrackPositionMenu.module.scss +37 -0
  138. package/app/styles/HiGlass.module.scss +3 -1
  139. package/app/styles/d3-context-menu.css +0 -1
  140. package/app/styles/prism.css +1 -0
  141. package/dist/app/schema.json +525 -0
  142. package/dist/app/scripts/AddTrackDialog.d.ts +64 -0
  143. package/dist/app/scripts/AddTrackPositionMenu.d.ts +5 -0
  144. package/dist/app/scripts/Annotations1dTrack.d.ts +15 -0
  145. package/dist/app/scripts/Annotations2dTrack.d.ts +95 -0
  146. package/dist/app/scripts/ArrowheadDomainsTrack.d.ts +36 -0
  147. package/dist/app/scripts/Autocomplete.d.ts +102 -0
  148. package/dist/app/scripts/AxisPixi.d.ts +25 -0
  149. package/dist/app/scripts/BarTrack.d.ts +28 -0
  150. package/dist/app/scripts/BedLikeTrack.d.ts +84 -0
  151. package/dist/app/scripts/Button.d.ts +3 -0
  152. package/dist/app/scripts/CNVIntervalTrack.d.ts +12 -0
  153. package/dist/app/scripts/CenterTiledPlot.d.ts +3 -0
  154. package/dist/app/scripts/CenterTrack.d.ts +92 -0
  155. package/dist/app/scripts/Chromosome2DAnnotations.d.ts +10 -0
  156. package/dist/app/scripts/Chromosome2DLabels.d.ts +13 -0
  157. package/dist/app/scripts/ChromosomeGrid.d.ts +24 -0
  158. package/dist/app/scripts/ChromosomeInfo.d.ts +14 -0
  159. package/dist/app/scripts/CloseTrackMenu.d.ts +10 -0
  160. package/dist/app/scripts/CombinedTrack.d.ts +32 -0
  161. package/dist/app/scripts/ConfigTrackMenu.d.ts +10 -0
  162. package/dist/app/scripts/ConfigViewMenu.d.ts +34 -0
  163. package/dist/app/scripts/ConfigureSeriesMenu.d.ts +3 -0
  164. package/dist/app/scripts/ContextMenuContainer.d.ts +36 -0
  165. package/dist/app/scripts/ContextMenuItem.d.ts +34 -0
  166. package/dist/app/scripts/Cross.d.ts +3 -0
  167. package/dist/app/scripts/CrossRule.d.ts +24 -0
  168. package/dist/app/scripts/CustomTrackDialog.d.ts +17 -0
  169. package/dist/app/scripts/Dialog.d.ts +5 -0
  170. package/dist/app/scripts/DivergentBarTrack.d.ts +4 -0
  171. package/dist/app/scripts/DragListeningDiv.d.ts +32 -0
  172. package/dist/app/scripts/DraggableDiv.d.ts +63 -0
  173. package/dist/app/scripts/ExportLinkDialog.d.ts +21 -0
  174. package/dist/app/scripts/FilledLine.d.ts +5 -0
  175. package/dist/app/scripts/FixedTrack.d.ts +5 -0
  176. package/dist/app/scripts/GalleryTracks.d.ts +20 -0
  177. package/dist/app/scripts/GenomePositionSearchBox.d.ts +95 -0
  178. package/dist/app/scripts/HeatmapOptions.d.ts +30 -0
  179. package/dist/app/scripts/HeatmapTiledPixiTrack.d.ts +184 -0
  180. package/dist/app/scripts/HiGlassComponent.d.ts +762 -0
  181. package/dist/app/scripts/HiGlassComponentContext.d.ts +3 -0
  182. package/dist/app/scripts/HiGlassTrackComponent.d.ts +37 -0
  183. package/dist/app/scripts/Horizontal1dHeatmapTrack.d.ts +9 -0
  184. package/dist/app/scripts/Horizontal2DDomainsTrack.d.ts +21 -0
  185. package/dist/app/scripts/HorizontalChromosomeLabels.d.ts +47 -0
  186. package/dist/app/scripts/HorizontalGeneAnnotationsTrack.d.ts +25 -0
  187. package/dist/app/scripts/HorizontalHeatmapTrack.d.ts +12 -0
  188. package/dist/app/scripts/HorizontalItem.d.ts +3 -0
  189. package/dist/app/scripts/HorizontalLine1DPixiTrack.d.ts +23 -0
  190. package/dist/app/scripts/HorizontalMultivecTrack.d.ts +50 -0
  191. package/dist/app/scripts/HorizontalPoint1DPixiTrack.d.ts +5 -0
  192. package/dist/app/scripts/HorizontalRule.d.ts +22 -0
  193. package/dist/app/scripts/HorizontalTiled1DPixiTrack.d.ts +26 -0
  194. package/dist/app/scripts/HorizontalTiledPlot.d.ts +49 -0
  195. package/dist/app/scripts/HorizontalTrack.d.ts +6 -0
  196. package/dist/app/scripts/Id2DTiledPixiTrack.d.ts +10 -0
  197. package/dist/app/scripts/IdHorizontal1DTiledPixiTrack.d.ts +6 -0
  198. package/dist/app/scripts/IdVertical1DTiledPixiTrack.d.ts +7 -0
  199. package/dist/app/scripts/LeftAxisTrack.d.ts +9 -0
  200. package/dist/app/scripts/LeftTrackModifier.d.ts +29 -0
  201. package/dist/app/scripts/ListWrapper.d.ts +64 -0
  202. package/dist/app/scripts/MapboxTilesTrack.d.ts +9 -0
  203. package/dist/app/scripts/Modal.d.ts +5 -0
  204. package/dist/app/scripts/MoveableTrack.d.ts +18 -0
  205. package/dist/app/scripts/NestedContextMenu.d.ts +7 -0
  206. package/dist/app/scripts/OSMTileIdsTrack.d.ts +5 -0
  207. package/dist/app/scripts/OSMTilesTrack.d.ts +129 -0
  208. package/dist/app/scripts/OverlayTrack.d.ts +13 -0
  209. package/dist/app/scripts/PixiTrack.d.ts +174 -0
  210. package/dist/app/scripts/PlotTypeChooser.d.ts +25 -0
  211. package/dist/app/scripts/PopupMenu.d.ts +28 -0
  212. package/dist/app/scripts/RasterTilesTrack.d.ts +9 -0
  213. package/dist/app/scripts/RuleMixin.d.ts +2 -0
  214. package/dist/app/scripts/SVGTrack.d.ts +15 -0
  215. package/dist/app/scripts/SearchField.d.ts +13 -0
  216. package/dist/app/scripts/SeriesListItems.d.ts +2 -0
  217. package/dist/app/scripts/SeriesListMenu.d.ts +51 -0
  218. package/dist/app/scripts/SeriesListSubmenuMixin.d.ts +2 -0
  219. package/dist/app/scripts/SketchInlinePicker.d.ts +25 -0
  220. package/dist/app/scripts/SortableList.d.ts +22 -0
  221. package/dist/app/scripts/SquareMarkersTrack.d.ts +22 -0
  222. package/dist/app/scripts/Tiled1DPixiTrack.d.ts +60 -0
  223. package/dist/app/scripts/TiledPixiTrack.d.ts +369 -0
  224. package/dist/app/scripts/TiledPlot.d.ts +313 -0
  225. package/dist/app/scripts/TilesetFinder.d.ts +65 -0
  226. package/dist/app/scripts/TopAxisTrack.d.ts +9 -0
  227. package/dist/app/scripts/Track.d.ts +196 -0
  228. package/dist/app/scripts/TrackArea.d.ts +26 -0
  229. package/dist/app/scripts/TrackControl.d.ts +5 -0
  230. package/dist/app/scripts/TrackRenderer.d.ts +724 -0
  231. package/dist/app/scripts/UnknownPixiTrack.d.ts +7 -0
  232. package/dist/app/scripts/ValueIntervalTrack.d.ts +6 -0
  233. package/dist/app/scripts/VerticalItem.d.ts +3 -0
  234. package/dist/app/scripts/VerticalRule.d.ts +21 -0
  235. package/dist/app/scripts/VerticalTiled1DPixiTrack.d.ts +6 -0
  236. package/dist/app/scripts/VerticalTiledPlot.d.ts +50 -0
  237. package/dist/app/scripts/VerticalTrack.d.ts +6 -0
  238. package/dist/app/scripts/ViewConfigEditor.d.ts +53 -0
  239. package/dist/app/scripts/ViewContextMenu.d.ts +17 -0
  240. package/dist/app/scripts/ViewHeader.d.ts +75 -0
  241. package/dist/app/scripts/ViewportTracker2D.d.ts +17 -0
  242. package/dist/app/scripts/ViewportTracker2DPixi.d.ts +11 -0
  243. package/dist/app/scripts/ViewportTrackerHorizontal.d.ts +17 -0
  244. package/dist/app/scripts/ViewportTrackerVertical.d.ts +17 -0
  245. package/dist/app/scripts/api.d.ts +640 -0
  246. package/dist/app/scripts/configs/available-track-types.d.ts +2 -0
  247. package/dist/app/scripts/configs/colormaps.d.ts +2 -0
  248. package/dist/app/scripts/configs/datatype-to-track-type.d.ts +4 -0
  249. package/dist/app/scripts/configs/default-tracks-for-datatype.d.ts +38 -0
  250. package/dist/app/scripts/configs/dense-data-extrema-config.d.ts +2 -0
  251. package/dist/app/scripts/configs/globals.d.ts +5 -0
  252. package/dist/app/scripts/configs/index.d.ts +16 -0
  253. package/dist/app/scripts/configs/positions-by-datatype.d.ts +2 -0
  254. package/dist/app/scripts/configs/primitives.d.ts +20 -0
  255. package/dist/app/scripts/configs/themes.d.ts +3 -0
  256. package/dist/app/scripts/configs/tracks-info-by-type.d.ts +4 -0
  257. package/dist/app/scripts/configs/tracks-info.d.ts +24 -0
  258. package/dist/app/scripts/d3-context-menu.d.ts +2 -0
  259. package/dist/app/scripts/data-fetchers/DataFetcher.d.ts +151 -0
  260. package/dist/app/scripts/data-fetchers/genbank-fetcher.d.ts +86 -0
  261. package/dist/app/scripts/data-fetchers/index.d.ts +3 -0
  262. package/dist/app/scripts/data-fetchers/local-tile-fetcher.d.ts +47 -0
  263. package/dist/app/scripts/gosling-exports.d.ts +17 -0
  264. package/dist/app/scripts/hglib.d.ts +24 -0
  265. package/dist/app/scripts/hocs/with-modal.d.ts +19 -0
  266. package/dist/app/scripts/hocs/with-pub-sub.d.ts +22 -0
  267. package/dist/app/scripts/hocs/with-theme.d.ts +13 -0
  268. package/dist/app/scripts/icons.d.ts +161 -0
  269. package/dist/app/scripts/mixwith.d.ts +27 -0
  270. package/dist/app/scripts/options-info.d.ts +1355 -0
  271. package/dist/app/scripts/plugins/available-for-plugins.d.ts +2338 -0
  272. package/dist/app/scripts/plugins/get-data-fetcher.d.ts +2 -0
  273. package/dist/app/scripts/plugins/index.d.ts +2 -0
  274. package/dist/app/scripts/services/chrom-info.d.ts +10 -0
  275. package/dist/app/scripts/services/dom-event.d.ts +7 -0
  276. package/dist/app/scripts/services/element-resize-listener.d.ts +5 -0
  277. package/dist/app/scripts/services/index.d.ts +5 -0
  278. package/dist/app/scripts/services/tile-proxy.d.ts +180 -0
  279. package/dist/app/scripts/services/worker.d.ts +157 -0
  280. package/dist/app/scripts/symbol.d.ts +13 -0
  281. package/dist/app/scripts/test-helpers/index.d.ts +1 -0
  282. package/dist/app/scripts/test-helpers/test-helpers.d.ts +33 -0
  283. package/dist/app/scripts/track-utils.d.ts +73 -0
  284. package/dist/app/scripts/types.d.ts +199 -0
  285. package/dist/app/scripts/utils/DenseDataExtrema1D.d.ts +88 -0
  286. package/dist/app/scripts/utils/DenseDataExtrema2D.d.ts +97 -0
  287. package/dist/app/scripts/utils/LruCache.d.ts +44 -0
  288. package/dist/app/scripts/utils/abs-to-chr.d.ts +14 -0
  289. package/dist/app/scripts/utils/accessor-transposition.d.ts +14 -0
  290. package/dist/app/scripts/utils/add-arrays.d.ts +18 -0
  291. package/dist/app/scripts/utils/add-class.d.ts +8 -0
  292. package/dist/app/scripts/utils/add-event-listener-once.d.ts +11 -0
  293. package/dist/app/scripts/utils/assert.d.ts +17 -0
  294. package/dist/app/scripts/utils/background-task-scheduler.d.ts +47 -0
  295. package/dist/app/scripts/utils/base64-to-canvas.d.ts +9 -0
  296. package/dist/app/scripts/utils/chr-to-abs.d.ts +10 -0
  297. package/dist/app/scripts/utils/chrom-info-bisector.d.ts +4 -0
  298. package/dist/app/scripts/utils/clone-event.d.ts +12 -0
  299. package/dist/app/scripts/utils/color-domain-to-rgba-array.d.ts +13 -0
  300. package/dist/app/scripts/utils/color-to-hex.d.ts +9 -0
  301. package/dist/app/scripts/utils/color-to-rgba.d.ts +9 -0
  302. package/dist/app/scripts/utils/copy-text-to-clipboard.d.ts +2 -0
  303. package/dist/app/scripts/utils/data-to-genomic-loci.d.ts +11 -0
  304. package/dist/app/scripts/utils/debounce.d.ts +5 -0
  305. package/dist/app/scripts/utils/dec-to-hex-str.d.ts +8 -0
  306. package/dist/app/scripts/utils/decompress.d.ts +27 -0
  307. package/dist/app/scripts/utils/default-tracks.d.ts +3 -0
  308. package/dist/app/scripts/utils/dict-from-tuples.d.ts +11 -0
  309. package/dist/app/scripts/utils/dict-items.d.ts +18 -0
  310. package/dist/app/scripts/utils/dict-keys.d.ts +10 -0
  311. package/dist/app/scripts/utils/dict-values.d.ts +8 -0
  312. package/dist/app/scripts/utils/download.d.ts +7 -0
  313. package/dist/app/scripts/utils/expand-combined-tracks.d.ts +11 -0
  314. package/dist/app/scripts/utils/fake-pub-sub.d.ts +11 -0
  315. package/dist/app/scripts/utils/fill-in-min-widths.d.ts +44 -0
  316. package/dist/app/scripts/utils/flatten.d.ts +9 -0
  317. package/dist/app/scripts/utils/for-each.d.ts +9 -0
  318. package/dist/app/scripts/utils/forward-event.d.ts +7 -0
  319. package/dist/app/scripts/utils/genome-loci-to-pixels.d.ts +9 -0
  320. package/dist/app/scripts/utils/genomic-range-to-chromosome-chunks.d.ts +21 -0
  321. package/dist/app/scripts/utils/get-aggregation-function.d.ts +10 -0
  322. package/dist/app/scripts/utils/get-default-track-for-datatype.d.ts +21 -0
  323. package/dist/app/scripts/utils/get-default-tracks-for-datatype.d.ts +3 -0
  324. package/dist/app/scripts/utils/get-element-dim.d.ts +7 -0
  325. package/dist/app/scripts/utils/get-higlass-components.d.ts +7 -0
  326. package/dist/app/scripts/utils/get-track-by-uid.d.ts +7 -0
  327. package/dist/app/scripts/utils/get-track-conf-from-hgc.d.ts +10 -0
  328. package/dist/app/scripts/utils/get-track-obj-by-id.d.ts +2 -0
  329. package/dist/app/scripts/utils/get-track-position-by-uid.d.ts +13 -0
  330. package/dist/app/scripts/utils/get-xylofon.d.ts +2 -0
  331. package/dist/app/scripts/utils/gradient.d.ts +14 -0
  332. package/dist/app/scripts/utils/has-class.d.ts +8 -0
  333. package/dist/app/scripts/utils/has-parent.d.ts +9 -0
  334. package/dist/app/scripts/utils/hex-string-to-int.d.ts +14 -0
  335. package/dist/app/scripts/utils/index.d.ts +89 -0
  336. package/dist/app/scripts/utils/interval-tree.d.ts +109 -0
  337. package/dist/app/scripts/utils/into-the-void.d.ts +6 -0
  338. package/dist/app/scripts/utils/is-track-or-child-track.d.ts +7 -0
  339. package/dist/app/scripts/utils/is-track-range-selectable.d.ts +2 -0
  340. package/dist/app/scripts/utils/is-within.d.ts +12 -0
  341. package/dist/app/scripts/utils/lat-to-y.d.ts +9 -0
  342. package/dist/app/scripts/utils/lng-to-x.d.ts +8 -0
  343. package/dist/app/scripts/utils/load-chrom-infos.d.ts +8 -0
  344. package/dist/app/scripts/utils/map.d.ts +13 -0
  345. package/dist/app/scripts/utils/max-non-zero.d.ts +6 -0
  346. package/dist/app/scripts/utils/max.d.ts +10 -0
  347. package/dist/app/scripts/utils/min-non-zero.d.ts +6 -0
  348. package/dist/app/scripts/utils/min.d.ts +10 -0
  349. package/dist/app/scripts/utils/mod.d.ts +9 -0
  350. package/dist/app/scripts/utils/ndarray-assign.d.ts +2 -0
  351. package/dist/app/scripts/utils/ndarray-flatten.d.ts +2 -0
  352. package/dist/app/scripts/utils/ndarray-to-list.d.ts +2 -0
  353. package/dist/app/scripts/utils/numericify-version.d.ts +6 -0
  354. package/dist/app/scripts/utils/obj-vals.d.ts +8 -0
  355. package/dist/app/scripts/utils/or.d.ts +8 -0
  356. package/dist/app/scripts/utils/parse-chromsizes-rows.d.ts +34 -0
  357. package/dist/app/scripts/utils/pixi-text-to-svg.d.ts +2 -0
  358. package/dist/app/scripts/utils/positioned-tracks-to-all-tracks.d.ts +26 -0
  359. package/dist/app/scripts/utils/q.d.ts +18 -0
  360. package/dist/app/scripts/utils/rad-to-deg.d.ts +7 -0
  361. package/dist/app/scripts/utils/range-query-2d.d.ts +17 -0
  362. package/dist/app/scripts/utils/reduce.d.ts +14 -0
  363. package/dist/app/scripts/utils/rel-to-abs-chrom-pos.d.ts +10 -0
  364. package/dist/app/scripts/utils/remove-class.d.ts +7 -0
  365. package/dist/app/scripts/utils/reset-d3-brush-style.d.ts +10 -0
  366. package/dist/app/scripts/utils/rgb-to-hex.d.ts +8 -0
  367. package/dist/app/scripts/utils/scales-center-and-k.d.ts +12 -0
  368. package/dist/app/scripts/utils/scales-to-genome-loci.d.ts +3 -0
  369. package/dist/app/scripts/utils/segments-to-rows.d.ts +15 -0
  370. package/dist/app/scripts/utils/selected-items-to-cum-weights.d.ts +12 -0
  371. package/dist/app/scripts/utils/selected-items-to-size.d.ts +13 -0
  372. package/dist/app/scripts/utils/show-mouse-position.d.ts +54 -0
  373. package/dist/app/scripts/utils/some.d.ts +10 -0
  374. package/dist/app/scripts/utils/sum.d.ts +8 -0
  375. package/dist/app/scripts/utils/svg-line.d.ts +2 -0
  376. package/dist/app/scripts/utils/throttle-and-debounce.d.ts +33 -0
  377. package/dist/app/scripts/utils/tile-to-canvas.d.ts +9 -0
  378. package/dist/app/scripts/utils/timeout.d.ts +3 -0
  379. package/dist/app/scripts/utils/to-void.d.ts +3 -0
  380. package/dist/app/scripts/utils/total-track-pixel-height.d.ts +27 -0
  381. package/dist/app/scripts/utils/trim-trailing-slash.d.ts +7 -0
  382. package/dist/app/scripts/utils/type-guards.d.ts +36 -0
  383. package/dist/app/scripts/utils/value-to-color.d.ts +12 -0
  384. package/dist/app/scripts/utils/visit-positioned-tracks.d.ts +18 -0
  385. package/dist/app/scripts/utils/visit-tracks.d.ts +9 -0
  386. package/dist/esm.html +1 -3
  387. package/dist/hglib.js +86315 -100592
  388. package/dist/hglib.min.js +123 -131
  389. package/dist/higlass.mjs +88861 -103138
  390. package/dist/index.html +1 -3
  391. package/dist/package.json +134 -0
  392. package/package.json +25 -27
@@ -1,30 +1,28 @@
1
1
  // @ts-nocheck
2
+ import clsx from 'clsx';
3
+ import { queue } from 'd3-queue';
2
4
  import { select } from 'd3-selection';
5
+ import PropTypes from 'prop-types';
3
6
  import React from 'react';
4
7
  import slugid from 'slugid';
5
- import PropTypes from 'prop-types';
6
- import clsx from 'clsx';
7
8
 
8
9
  import Autocomplete from './Autocomplete';
9
10
  import ChromosomeInfo from './ChromosomeInfo';
10
- import SearchField from './SearchField';
11
11
  import PopupMenu from './PopupMenu';
12
+ import SearchField from './SearchField';
13
+ import { THEME_DARK, ZOOM_TRANSITION_DURATION } from './configs';
12
14
 
13
15
  // Services
14
16
  import { tileProxy } from './services';
15
- import withPubSub from './hocs/with-pub-sub';
16
17
 
18
+ import withPubSub from './hocs/with-pub-sub';
17
19
  // Utils
18
- import { scalesCenterAndK, dictKeys, toVoid } from './utils';
20
+ import { scalesCenterAndK } from './utils';
19
21
 
20
- // HOCS
21
- import withTheme from './hocs/with-theme';
22
22
  import { SearchIcon } from './icons';
23
- // Configs
24
- import { THEME_DARK, ZOOM_TRANSITION_DURATION } from './configs';
25
23
 
26
24
  // Styles
27
- import styles from '../styles/GenomePositionSearchBox.module.scss'; // eslint-disable-line no-unused-vars
25
+ import styles from '../styles/GenomePositionSearchBox.module.scss';
28
26
 
29
27
  class GenomePositionSearchBox extends React.Component {
30
28
  constructor(props) {
@@ -38,34 +36,28 @@ class GenomePositionSearchBox extends React.Component {
38
36
 
39
37
  this.xScale = null;
40
38
  this.yScale = null;
41
- // this.props.zoomDispatch.on('zoom.' + this.uid, this.zoomed.bind(this))
42
-
43
- /*
44
- this.xOrigScale = scaleLinear().domain(this.props.xDomain)
45
- .range(this.props.xRange);
46
- this.yOrigScale = scaleLinear().domain(this.props.yDomain)
47
- .range(this.props.yRange);
48
-
49
- this.zoomedXScale = this.xOrigScale.copy();
50
- this.zoomedYScale = this.yOrigScale.copy();
51
- */
52
-
53
39
  this.prevParts = [];
54
40
 
55
41
  this.props.registerViewportChangedListener(this.scalesChanged.bind(this));
56
42
 
57
43
  this.menuPosition = { left: 0, top: 0 };
58
44
 
45
+ this.currentChromInfoServer = this.props.chromInfoServer;
46
+ this.currentChromInfoId = this.props.chromInfoId;
47
+
59
48
  // the position text is maintained both here and in
60
49
  // in state.value so that it can be quickly updated in
61
50
  // response to zoom events
62
- this.positionText = 'chr4:190,998,876-191,000,255';
51
+ // this.positionText = 'no chromosome track present';
52
+ this.positionText = props.error;
63
53
 
64
54
  this.state = {
55
+ value: this.positionText,
56
+ loading: false,
57
+ menuPosition: [0, 0],
65
58
  genes: [],
66
59
  isFocused: false,
67
- autocompleteServer: this.props.autocompleteServer,
68
- autocompleteId: this.props.autocompleteId,
60
+ menuOpened: false,
69
61
  availableAssemblies: [],
70
62
  selectedAssembly: null,
71
63
  };
@@ -87,29 +79,6 @@ class GenomePositionSearchBox extends React.Component {
87
79
  border: 'solid 1px #ccc',
88
80
  },
89
81
  };
90
-
91
- this.availableAutocompletes = {};
92
-
93
- if (this.props.autocompleteId) {
94
- this.availableAutocompletes[this.props.chromInfoId] = new Set([
95
- {
96
- server: this.props.autocompleteServer,
97
- acId: this.props.autocompleteId,
98
- },
99
- ]);
100
- }
101
-
102
- this.availableChromSizes = {};
103
-
104
- /*
105
- if (this.props.chromInfoServer && this.props.chromInfoId) {
106
- // if we've been passed a server and chromInfo ID we trust that it exists
107
- // and use that
108
- this.availableChromSizes[this.props.chromInfoId] =
109
- new Set([{server: this.props.chromInfoServer, uuid: this.props.chromInfoId} ]);
110
- this.fetchChromInfo(this.props.chromInfoId);
111
- }
112
- */
113
82
  }
114
83
 
115
84
  componentDidMount() {
@@ -120,25 +89,7 @@ class GenomePositionSearchBox extends React.Component {
120
89
  this.autocompleteKeyPress.bind(this),
121
90
  );
122
91
 
123
- this.findAvailableAutocompleteSources();
124
- this.findAvailableChromSizes();
125
-
126
- if (this.props.chromInfoPath) {
127
- this.searchPosition = true;
128
-
129
- ChromosomeInfo(this.props.chromInfoPath, (chromInfo) => {
130
- if (!chromInfo) {
131
- this.searchPosition = null;
132
- return;
133
- }
134
-
135
- this.chromInfo = chromInfo;
136
- this.searchField = new SearchField(this.chromInfo);
137
-
138
- this.setPositionText();
139
- });
140
- }
141
-
92
+ this.fetchChromInfo(this.props.chromInfoServer, this.props.chromInfoId);
142
93
  this.setPositionText();
143
94
  }
144
95
 
@@ -147,161 +98,50 @@ class GenomePositionSearchBox extends React.Component {
147
98
  this.props.removeViewportChangedListener();
148
99
  }
149
100
 
150
- onAutocompleteChange(evt, value) {
151
- this.positionText = value;
152
- this.setState({
153
- value,
154
- loading: true,
155
- });
156
-
157
- this.changedPart = null;
158
- const spaceParts = value.split(/ /);
159
- let partIndex = 0;
160
- const newParts = [];
161
- let changedAtStartOfWord = false;
162
-
163
- for (let j = 0; j < spaceParts.length; j++) {
164
- const parts = spaceParts[j].split(/-/);
165
-
166
- for (let i = 0; i < parts.length; i++) {
167
- partIndex += 1;
168
- newParts.push(parts[i]);
169
-
170
- if (i === 0) changedAtStartOfWord = true;
171
- else changedAtStartOfWord = false;
172
-
173
- if (i === this.prevParts.length) {
174
- // new part added
175
- this.changedPart = partIndex - 1;
176
- break;
177
- }
178
-
179
- if (parts[i] !== this.prevParts[i]) {
180
- this.changedPart = partIndex - 1;
181
- break;
182
- }
183
- }
184
- }
185
-
186
- this.prevParts = newParts;
187
-
188
- // no autocomplete repository is provided, so we don't try to autcomplete anything
189
- if (!(this.state.autocompleteServer && this.state.autocompleteId)) {
190
- return;
191
- }
101
+ /**
102
+ * The user has selected an assembly to use for the coordinate search box
103
+ *
104
+ * @param {string} chromInfoServer
105
+ * @param {string} chromInfoId - The name of the chromosome info set to use
106
+ *
107
+ * @returns {void} Once the appropriate ChromInfo file is fetched, it is stored locally
108
+ */
109
+ fetchChromInfo(chromInfoServer, chromInfoId) {
110
+ if (!chromInfoId) {
111
+ this.positionText = 'no chromosome track present';
192
112
 
193
- if (this.changedPart !== null) {
194
- // if something has changed in the input text
195
113
  this.setState({
196
- loading: true,
114
+ value: this.positionText,
197
115
  });
198
- // send out a request for the autcomplete suggestions
199
- let url = `${this.state.autocompleteServer}/suggest/`;
200
- url += `?d=${this.state.autocompleteId}&ac=${newParts[
201
- this.changedPart
202
- ].toLowerCase()}`;
203
- tileProxy.json(
204
- url,
205
- (error, data) => {
206
- if (error) {
207
- this.setState({
208
- loading: false,
209
- genes: [],
210
- });
211
- } else if (this.changedPart > 0 && !changedAtStartOfWord) {
212
- // send out another request for genes with dashes in them
213
- // but we need to distinguish things that have a dash in front
214
- // from things that just have a space in front
215
-
216
- const url1 =
217
- `${this.state.autocompleteServer}/suggest/` +
218
- `?d=${this.state.autocompleteId}` +
219
- `&ac=${newParts[this.changedPart - 1].toLowerCase()}` +
220
- `-${newParts[this.changedPart].toLowerCase()}`;
221
- tileProxy.json(
222
- url1,
223
- (error1, data1) => {
224
- if (error1) {
225
- this.setState({
226
- loading: false,
227
- genes: data,
228
- });
229
- } else {
230
- this.setState({
231
- loading: false,
232
- genes: data1.concat(data),
233
- });
234
- }
235
- },
236
- this.props.pubSub,
237
- );
238
- } else {
239
- // we've received a list of autocomplete suggestions
240
- this.setState({ loading: false, genes: data });
241
- }
242
- },
243
- this.props.pubSub,
244
- );
245
- }
246
- }
247
116
 
248
- setAvailableAssemblies() {
249
- const chromsizeKeys = new Set(dictKeys(this.availableChromSizes));
250
-
251
- const commonKeys = new Set([...chromsizeKeys]);
252
-
253
- if (this.gpsbForm) {
254
- // only set the state if this comonent is mounted
255
- this.setState({
256
- availableAssemblies: [...commonKeys],
257
- });
117
+ return;
258
118
  }
259
- }
260
-
261
- setSelectedAssembly(assemblyName) {
262
- // component is probably about to be unmounted
263
- if (!this.mounted) return;
264
119
 
265
- if (!this.availableChromSizes[assemblyName]) return;
266
- // we don't know of any available chromosome sizes so just ignore
267
- // this function call (usually called from the constructor)
268
-
269
- // use the first available server that we have on record for this chromInfoId
270
- const serverAndChromInfoToUse = [
271
- ...this.availableChromSizes[assemblyName],
272
- ][0];
120
+ if (!this.mounted)
121
+ // component is probably about to be unmounted
122
+ return;
273
123
 
274
124
  this.setState({
275
- autocompleteServer: serverAndChromInfoToUse.server,
125
+ autocompleteServer: chromInfoServer,
276
126
  });
277
127
 
278
- const { server } = serverAndChromInfoToUse;
279
-
280
- // we need to set a an autocompleteId that matches the chromInfo
281
- // that was received, but if none has been retrieved yet...
282
- if (this.availableAutocompletes[assemblyName]) {
283
- const newAcId = [...this.availableAutocompletes[assemblyName]][0].acId;
284
- this.props.onSelectedAssemblyChanged(assemblyName, newAcId, server);
128
+ ChromosomeInfo(
129
+ `${chromInfoServer}/chrom-sizes/?id=${chromInfoId}`,
130
+ (newChromInfo) => {
131
+ this.chromInfo = newChromInfo;
132
+ this.searchField = new SearchField(this.chromInfo);
285
133
 
286
- if (this.gpsbForm) {
287
- this.setState({
288
- autocompleteId: newAcId,
289
- });
290
- }
291
- } else {
292
- this.props.onSelectedAssemblyChanged(assemblyName, null, server);
134
+ this.setPositionText();
135
+ },
136
+ );
137
+ }
293
138
 
294
- if (this.gpsbForm) {
295
- this.setState({
296
- autocompleteId: null,
297
- });
298
- }
299
- }
139
+ scalesChanged(xScale, yScale) {
140
+ this.xScale = xScale;
141
+ this.yScale = yScale;
300
142
 
301
- this.fetchChromInfo(
302
- serverAndChromInfoToUse.uuid,
303
- serverAndChromInfoToUse.server,
304
- );
143
+ // make sure that this component is loaded first
144
+ this.setPositionText();
305
145
  }
306
146
 
307
147
  setPositionText() {
@@ -318,164 +158,12 @@ class GenomePositionSearchBox extends React.Component {
318
158
  this.props.twoD,
319
159
  );
320
160
 
321
- // ReactDOM.findDOMNode( this.refs.searchFieldText).value = positionString;
322
161
  // used for autocomplete
323
162
  this.prevParts = positionString.split(/[ -]/);
324
-
325
163
  if (this.gpsbForm) {
326
164
  this.positionText = positionString;
327
-
328
- // this.origPositionText is used to reset the text if somebody clicks submit
329
- // on an empty field
330
- this.origPositionText = positionString;
331
-
332
165
  this.autocompleteMenu.inputEl.value = positionString;
333
- // this.setState({ value: positionString });
334
- }
335
- }
336
-
337
- scalesChanged(xScale, yScale) {
338
- this.xScale = xScale;
339
- this.yScale = yScale;
340
-
341
- // make sure that this component is loaded first
342
- this.setPositionText();
343
- }
344
-
345
- findAvailableChromSizes() {
346
- if (!this.props.trackSourceServers) {
347
- // if we don't know where to look for track source servers then
348
- // just give up
349
- return;
350
- }
351
-
352
- this.props.trackSourceServers.forEach((sourceServer) => {
353
- tileProxy.json(
354
- `${sourceServer}/available-chrom-sizes/`,
355
- (error, data) => {
356
- if (error) {
357
- console.error(error);
358
- } else {
359
- data.results.forEach((x) => {
360
- if (!(x.coordSystem in this.availableChromSizes)) {
361
- this.availableChromSizes[x.coordSystem] = new Set();
362
- }
363
-
364
- this.availableChromSizes[x.coordSystem].add({
365
- server: sourceServer,
366
- uuid: x.uuid,
367
- });
368
- this.setAvailableAssemblies();
369
- });
370
-
371
- // we haven't set an assembly yet so set it now
372
- // props.chromInfoId will be set to the suggested assembly (e.g. "hg19")
373
- // this will be mapped to an available chromSize (with its own unique uuid)
374
- if (!this.searchField) {
375
- // only fetch chromsizes if there isn't a specified chromInfoServer
376
- this.fetchChromInfo(
377
- this.props.chromInfoId in this.availableChromSizes
378
- ? [...this.availableChromSizes[this.props.chromInfoId]][0]
379
- .uuid
380
- : this.props.chromInfoId,
381
- this.props.chromInfoId in this.availableChromSizes
382
- ? [...this.availableChromSizes[this.props.chromInfoId]][0]
383
- .server
384
- : this.props.chromInfoServer,
385
- );
386
- }
387
- }
388
- },
389
- this.props.pubSub,
390
- );
391
- });
392
- }
393
-
394
- findAvailableAutocompleteSources() {
395
- if (!this.props.trackSourceServers) {
396
- // if there's no available track source servers
397
- // we can't search for autocomplete sources
398
- return;
399
166
  }
400
-
401
- this.props.trackSourceServers.forEach((sourceServer) => {
402
- tileProxy.json(
403
- `${sourceServer}/tilesets/?limit=100&dt=gene-annotation`,
404
- (error, data) => {
405
- if (error) {
406
- console.error(error);
407
- } else {
408
- data.results.forEach((x) => {
409
- if (!(x.coordSystem in this.availableAutocompletes)) {
410
- this.availableAutocompletes[x.coordSystem] = new Set();
411
- }
412
-
413
- this.availableAutocompletes[x.coordSystem].add({
414
- server: sourceServer,
415
- acId: x.uuid,
416
- });
417
- this.setAvailableAssemblies();
418
- });
419
-
420
- if (!this.state.autocompleteId) {
421
- // We don't have an autocomplete source yet, so set the one matching the current
422
- // assembly
423
- if (this.gpsbForm) {
424
- // only set the state if this component is mounted
425
- if (this.availableAutocompletes[this.props.chromInfoId]) {
426
- this.setState({
427
- autocompleteId: [
428
- ...this.availableAutocompletes[this.props.chromInfoId],
429
- ][0].acId,
430
- });
431
- }
432
- }
433
- }
434
- }
435
- },
436
- this.props.pubSub,
437
- );
438
- });
439
- }
440
-
441
- /**
442
- * The user has selected an assembly to use for the coordinate search box.
443
- * Once the appropriate ChromInfo file is fetched, it is stored locally
444
- *
445
- * @param {string} chromInfoId The name of the chromosome info set to use
446
- */
447
- fetchChromInfo(chromInfoId, server) {
448
- ChromosomeInfo(
449
- `${server}/chrom-sizes/?id=${chromInfoId}`,
450
- (newChromInfo) => {
451
- if (!newChromInfo) {
452
- return;
453
- }
454
-
455
- tileProxy.json(
456
- `${server}/tileset_info/?d=${chromInfoId}`,
457
- (error2, tilesetInfo) => {
458
- if (error2) {
459
- return;
460
- }
461
-
462
- if (this.gpsbForm) {
463
- // only set the state if this component is mounted
464
- this.setState({
465
- selectedAssembly: tilesetInfo[chromInfoId].coordSystem,
466
- });
467
- }
468
- },
469
- this.props.pubSub,
470
- );
471
-
472
- this.chromInfo = newChromInfo;
473
- this.searchField = new SearchField(this.chromInfo);
474
-
475
- this.setPositionText();
476
- },
477
- this.props.pubSub,
478
- );
479
167
  }
480
168
 
481
169
  autocompleteKeyPress(event) {
@@ -486,8 +174,6 @@ class GenomePositionSearchBox extends React.Component {
486
174
  }
487
175
  }
488
176
 
489
- genePositionToSearchBarText(genePosition) {}
490
-
491
177
  replaceGenesWithLoadedPositions(genePositions) {
492
178
  // iterate over all non-position oriented words and try
493
179
  // to replace them with the positions loaded from the suggestions
@@ -537,7 +223,8 @@ class GenomePositionSearchBox extends React.Component {
537
223
  }
538
224
  foundGeneSymbol = true; // we found a gene symbol
539
225
  break;
540
- } else if (k === j + 1) {
226
+ }
227
+ if (k === j + 1) {
541
228
  if (spacePart.length) {
542
229
  spacePart += '-';
543
230
  }
@@ -568,68 +255,65 @@ class GenomePositionSearchBox extends React.Component {
568
255
  replaceGenesWithPositions(finished) {
569
256
  // replace any gene names in the input with their corresponding positions
570
257
  const valueParts = this.positionText.split(/[ -]/);
571
- const requests = [];
258
+ let q = queue();
572
259
 
573
260
  for (let i = 0; i < valueParts.length; i++) {
574
261
  if (valueParts[i].length === 0) {
575
262
  continue;
576
263
  }
577
264
 
578
- const retPos = this.searchField.parsePosition(valueParts[i])[2];
265
+ const [, , retPos] = this.searchField.parsePosition(valueParts[i]);
579
266
 
580
- if (retPos === null || Number.isNaN(+retPos)) {
267
+ if (retPos == null || Number.isNaN(retPos)) {
581
268
  // not a chromsome position, let's see if it's a gene name
582
- const url = `${this.state.autocompleteServer}/suggest/?d=${
583
- this.state.autocompleteId
269
+ const url = `${this.props.autocompleteServer}/suggest/?d=${
270
+ this.props.autocompleteId
584
271
  }&ac=${valueParts[i].toLowerCase()}`;
585
- requests.push(tileProxy.json(url, toVoid, this.props.pubSub));
272
+
273
+ const fetchJson = (callback) => {
274
+ tileProxy.json(url, callback, this.props.pubSub);
275
+ };
276
+ q = q.defer(fetchJson);
586
277
  }
587
278
  }
588
279
 
589
- Promise.all(requests)
590
- .then((files) => {
591
- if (files) {
592
- const genePositions = {};
280
+ q.awaitAll((error, files) => {
281
+ if (files) {
282
+ const genePositions = {};
593
283
 
594
- // extract the position of the top match from the list of files
595
- for (let i = 0; i < files.length; i++) {
596
- if (!files[i][0]) {
597
- continue;
598
- }
284
+ // extract the position of the top match from the list of files
285
+ for (let i = 0; i < files.length; i++) {
286
+ if (!files[i][0]) {
287
+ continue;
288
+ }
599
289
 
600
- for (let j = 0; j < files[i].length; j++) {
601
- genePositions[files[i][j].geneName.toLowerCase()] = files[i][j];
602
- }
290
+ for (let j = 0; j < files[i].length; j++) {
291
+ genePositions[files[i][j].geneName.toLowerCase()] = files[i][j];
603
292
  }
293
+ }
604
294
 
605
- const geneSymbol =
606
- this.replaceGenesWithLoadedPositions(genePositions);
295
+ this.replaceGenesWithLoadedPositions(genePositions);
607
296
 
608
- finished(geneSymbol);
609
- }
610
- })
611
- .catch((error) => console.error(error));
297
+ finished();
298
+ }
299
+ });
612
300
  }
613
301
 
614
302
  buttonClick() {
615
- this.setState({ genes: [] }); // no menu should be open
303
+ this.setState({
304
+ genes: [],
305
+ }); // no menu should be open
616
306
 
617
- this.replaceGenesWithPositions((geneSymbol) => {
307
+ this.replaceGenesWithPositions(() => {
618
308
  const searchFieldValue = this.positionText;
619
309
 
620
- if (this.searchField !== null) {
621
- const rangePair = this.searchField.searchPosition(searchFieldValue);
622
- const range1 = rangePair[0];
623
- let range2 = rangePair[1];
624
-
625
- if (!range1) {
626
- this.setPositionText();
627
- return;
628
- }
310
+ if (this.searchField != null) {
311
+ let [range1, range2] =
312
+ this.searchField.searchPosition(searchFieldValue);
629
313
 
630
314
  if (
631
- (range1 && (Number.isNaN(+range1[0]) || Number.isNaN(+range1[1]))) ||
632
- (range2 && (Number.isNaN(+range2[0]) || Number.isNaN(+range2[1])))
315
+ (range1 && (Number.isNaN(range1[0]) || Number.isNaN(range1[1]))) ||
316
+ (range2 && (Number.isNaN(range2[0]) || Number.isNaN(range2[1])))
633
317
  ) {
634
318
  return;
635
319
  }
@@ -638,21 +322,19 @@ class GenomePositionSearchBox extends React.Component {
638
322
  range2 = range1;
639
323
  }
640
324
 
641
- const newXScale = this.xScale.copy().domain(range1);
642
- const newYScale = this.yScale.copy().domain(range2);
643
-
644
- const [centerX, centerY, k] = scalesCenterAndK(newXScale, newYScale);
325
+ const newXScale = this.xScale.copy();
326
+ const newYScale = this.yScale.copy();
645
327
 
646
- if (geneSymbol) {
647
- // call the callback function of the `onGeneSearch` api if a user searched for a gene symbol
648
- this.props.onGeneSearch({
649
- geneSymbol,
650
- range: range1,
651
- centerX,
652
- centerY,
653
- });
328
+ // If someone doesn't enter anything in the searcbar then
329
+ // range1 will be empty. In that case, we'll just stay in the
330
+ // current position
331
+ if (range1) {
332
+ newXScale.domain(range1);
333
+ newYScale.domain(range1);
654
334
  }
655
335
 
336
+ const [centerX, centerY, k] = scalesCenterAndK(newXScale, newYScale);
337
+
656
338
  this.props.setCenters(centerX, centerY, k, ZOOM_TRANSITION_DURATION);
657
339
  }
658
340
  });
@@ -668,6 +350,66 @@ class GenomePositionSearchBox extends React.Component {
668
350
  return parts.join(separator).replace(replace, separator);
669
351
  }
670
352
 
353
+ onAutocompleteChange(event, value) {
354
+ this.positionText = value;
355
+ this.setState({
356
+ value,
357
+ loading: true,
358
+ });
359
+
360
+ const parts = value.split(/[ -]/);
361
+ this.changedPart = null;
362
+
363
+ for (let i = 0; i < parts.length; i++) {
364
+ if (i === this.prevParts.length) {
365
+ // new part added
366
+ this.changedPart = i;
367
+ break;
368
+ }
369
+
370
+ if (parts[i] !== this.prevParts[i]) {
371
+ this.changedPart = i;
372
+ break;
373
+ }
374
+ }
375
+
376
+ this.prevParts = parts;
377
+
378
+ // no autocomplete repository is provided, so we don't try to autcomplete anything
379
+ if (!(this.props.autocompleteServer && this.props.autocompleteId)) {
380
+ return;
381
+ }
382
+
383
+ if (this.changedPart != null) {
384
+ // if something has changed in the input text
385
+ this.setState({ loading: true });
386
+ // spend out a request for the autcomplete suggestions
387
+ const url = `${this.props.autocompleteServer}/suggest/?d=${
388
+ this.props.autocompleteId
389
+ }&ac=${parts[this.changedPart].toLowerCase()}`;
390
+
391
+ tileProxy.json(
392
+ url,
393
+ (error, data) => {
394
+ if (error) {
395
+ this.setState({
396
+ loading: false,
397
+ genes: [],
398
+ });
399
+ return;
400
+ }
401
+
402
+ // we've received a list of autocomplete suggestions
403
+ this.setState({
404
+ loading: false,
405
+ genes: data,
406
+ });
407
+ },
408
+ this.props.pubSub,
409
+ );
410
+ }
411
+ }
412
+
671
413
  geneSelected(value, objct) {
672
414
  const parts = this.positionText.split(' ');
673
415
  let partCount = this.changedPart;
@@ -675,34 +417,11 @@ class GenomePositionSearchBox extends React.Component {
675
417
  // change the part that was selected
676
418
  for (let i = 0; i < parts.length; i++) {
677
419
  const dashParts = parts[i].split('-');
678
- const geneParts = objct.geneName.split('-');
679
-
680
420
  if (partCount > dashParts.length - 1) {
681
421
  partCount -= dashParts.length;
682
422
  } else {
683
423
  dashParts[partCount] = objct.geneName;
684
-
685
- if (
686
- geneParts.length === 2 &&
687
- partCount > 0 &&
688
- dashParts[partCount - 1].toLowerCase() === geneParts[0].toLowerCase()
689
- ) {
690
- // the gene to be added contains a dash and is
691
- // meant to replace a part of the previous gene
692
- // e.g. SOX2-O should be replaced with SOX2-OT
693
-
694
- const newDashParts = dashParts.slice(0, partCount - 1);
695
- newDashParts.push(geneParts.join('-'));
696
-
697
- if (partCount < dashParts.length - 1) {
698
- newDashParts.push(dashParts.slice(partCount + 1));
699
- }
700
-
701
- parts[i] = newDashParts.join('-');
702
- } else {
703
- parts[i] = dashParts.join('-');
704
- }
705
-
424
+ parts[i] = dashParts.join('-');
706
425
  break;
707
426
  }
708
427
  }
@@ -718,7 +437,10 @@ class GenomePositionSearchBox extends React.Component {
718
437
  this.prevParts = parts.join(' ').split(/[ -]/);
719
438
 
720
439
  this.positionText = parts.join(' ');
721
- this.setState({ value: parts.join(' '), genes: [] });
440
+ this.setState({
441
+ value: parts.join(' '),
442
+ genes: [],
443
+ });
722
444
  }
723
445
 
724
446
  handleMenuVisibilityChange(isOpen, inputEl) {
@@ -738,11 +460,11 @@ class GenomePositionSearchBox extends React.Component {
738
460
  return (
739
461
  <PopupMenu>
740
462
  <div
741
- className={styles['genome-position-search-bar-suggestions']}
742
463
  style={{
743
464
  left: this.menuPosition.left,
744
465
  top: this.menuPosition.top,
745
466
  }}
467
+ className={styles['genome-position-search-bar-suggestions']}
746
468
  >
747
469
  {items}
748
470
  </div>
@@ -750,15 +472,11 @@ class GenomePositionSearchBox extends React.Component {
750
472
  );
751
473
  }
752
474
 
753
- handleAssemblySelectEvt(evt) {
754
- this.handleAssemblySelect(evt.target.value);
755
- }
756
-
757
- handleAssemblySelect(assembly) {
758
- this.setSelectedAssembly(assembly);
475
+ handleAssemblySelect(evt) {
476
+ this.fetchChromInfo(evt);
759
477
 
760
478
  this.setState({
761
- selectedAssembly: assembly,
479
+ selectedAssembly: evt,
762
480
  });
763
481
  }
764
482
 
@@ -768,13 +486,19 @@ class GenomePositionSearchBox extends React.Component {
768
486
  });
769
487
  }
770
488
 
771
- render() {
772
- const assemblyMenuItems = this.state.availableAssemblies.map((x) => (
773
- <option key={x} value={x}>
774
- {x}
775
- </option>
776
- ));
489
+ UNSAFE_componentWillReceiveProps(nextProps) {
490
+ if (
491
+ nextProps.chromInfoId !== this.currentChromInfoId ||
492
+ nextProps.chromInfoServer !== this.currentChromInfoServer
493
+ ) {
494
+ this.currentChromInfoId = nextProps.chromInfoId;
495
+ this.currentChromInfoServer = nextProps.chromInfoServer;
496
+
497
+ this.fetchChromInfo(nextProps.chromInfoServer, nextProps.chromInfoId);
498
+ }
499
+ }
777
500
 
501
+ render() {
778
502
  return (
779
503
  <div
780
504
  ref={(c) => {
@@ -787,20 +511,6 @@ class GenomePositionSearchBox extends React.Component {
787
511
  this.props.theme === THEME_DARK,
788
512
  })}
789
513
  >
790
- {!this.props.hideAvailableAssemblies && (
791
- <select
792
- ref={(c) => {
793
- this.assemblyPickButton = c;
794
- }}
795
- className={styles['genome-position-search-bar-button']}
796
- id={this.uid}
797
- onChange={this.handleAssemblySelectEvt.bind(this)}
798
- value={this.state.selectedAssembly || undefined}
799
- >
800
- {assemblyMenuItems}
801
- </select>
802
- )}
803
-
804
514
  <Autocomplete
805
515
  ref={(c) => {
806
516
  this.autocompleteMenu = c;
@@ -808,8 +518,6 @@ class GenomePositionSearchBox extends React.Component {
808
518
  getItemValue={(item) => item.geneName}
809
519
  inputProps={{
810
520
  className: styles['genome-position-search-bar'],
811
- title:
812
- 'Current location: enter a symbol or location to change the position of the current view',
813
521
  }}
814
522
  items={this.state.genes}
815
523
  menuStyle={{
@@ -825,8 +533,8 @@ class GenomePositionSearchBox extends React.Component {
825
533
  onSubmit={this.searchFieldSubmit.bind(this)}
826
534
  renderItem={(item, isHighlighted) => (
827
535
  <div
828
- key={item.refseqid}
829
- id={item.refseqid}
536
+ key={item.geneName}
537
+ id={item.geneName}
830
538
  style={
831
539
  isHighlighted ? this.styles.highlightedItem : this.styles.item
832
540
  }
@@ -835,12 +543,10 @@ class GenomePositionSearchBox extends React.Component {
835
543
  </div>
836
544
  )}
837
545
  renderMenu={this.handleRenderMenu.bind(this)}
838
- value={
839
- this.state.selectedAssembly
840
- ? this.positionText
841
- : 'No valid assembly selected'
842
- }
843
- wrapperStyle={{ width: '100%' }}
546
+ value={this.props.error || this.positionText}
547
+ wrapperStyle={{
548
+ width: '100%',
549
+ }}
844
550
  />
845
551
 
846
552
  <SearchIcon
@@ -857,19 +563,15 @@ GenomePositionSearchBox.propTypes = {
857
563
  autocompleteServer: PropTypes.string,
858
564
  chromInfoId: PropTypes.string,
859
565
  chromInfoServer: PropTypes.string,
860
- chromInfoPath: PropTypes.string,
861
- hideAvailableAssemblies: PropTypes.bool,
862
566
  isFocused: PropTypes.bool,
863
- pubSub: PropTypes.object,
864
567
  onFocus: PropTypes.func,
865
- onGeneSearch: PropTypes.func,
866
568
  onSelectedAssemblyChanged: PropTypes.func,
867
569
  registerViewportChangedListener: PropTypes.func,
868
570
  removeViewportChangedListener: PropTypes.func,
869
571
  setCenters: PropTypes.func,
870
- theme: PropTypes.symbol.isRequired,
572
+ theme: PropTypes.string,
871
573
  trackSourceServers: PropTypes.array,
872
574
  twoD: PropTypes.bool,
873
575
  };
874
576
 
875
- export default withPubSub(withTheme(GenomePositionSearchBox));
577
+ export default withPubSub(GenomePositionSearchBox);