@sjcrh/proteinpaint-client 2.76.2 → 2.77.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 (232) hide show
  1. package/dist/{2dmaf-f240211f.js → 2dmaf-dbeff225.js} +1 -1
  2. package/dist/{AppHeader-c9432a24.js → AppHeader-1fc7f7bd.js} +1 -1
  3. package/dist/{ColorScale-b991fc9e.js → ColorScale-23c17654.js} +1 -1
  4. package/dist/{DEanalysis-bbfad00d.js → DEanalysis-a3cf1900.js} +1 -1
  5. package/dist/{Disco-b7c9bf72.js → Disco-b26a0556.js} +1 -1
  6. package/dist/{Disco.UI-a5296c36.js → Disco.UI-891c4c35.js} +1 -1
  7. package/dist/{DragControls-ca3fa0cf.js → DragControls-2fabac26.js} +1 -1
  8. package/dist/{DziViewer-28915c11.js → DziViewer-5b830c31.js} +1 -1
  9. package/dist/FilterRxComp-fb608459.js +1 -0
  10. package/dist/FilterStateless-fc4e4e1b.js +1 -0
  11. package/dist/{HicApp-e713aa40.js → HicApp-5ed85d49.js} +1 -1
  12. package/dist/{OrbitControls-2466d420.js → OrbitControls-604f40af.js} +1 -1
  13. package/dist/{WSIViewer-957695a8.js → WSIViewer-dcce2a10.js} +1 -1
  14. package/dist/{adSandbox-27d93bc0.js → adSandbox-5fa90964.js} +1 -1
  15. package/dist/app-0de0ae35.js +1 -0
  16. package/dist/{app-d215327f.js → app-7f695ce7.js} +1 -1
  17. package/dist/app-977b083f.js +1 -0
  18. package/dist/app.js +1 -1
  19. package/dist/{bam-d67e5315.js → bam-06a5a6a2.js} +1 -1
  20. package/dist/{barchart-2898d229.js → barchart-978fb21a.js} +1 -1
  21. package/dist/{barchart.events-426d737a.js → barchart.events-9b482604.js} +1 -1
  22. package/dist/{bars.renderer-71935d34.js → bars.renderer-d7461d5d.js} +1 -1
  23. package/dist/{block-75d4ff92.js → block-3db9c74c.js} +1 -1
  24. package/dist/block.lazyload-19a55cac.js +1 -0
  25. package/dist/{block.legend-93d85a6e.js → block.legend-97401467.js} +1 -1
  26. package/dist/{block.mds-84b9d1c1.js → block.mds-dc409568.js} +1 -1
  27. package/dist/{block.mds.cnv-a991ed79.js → block.mds.cnv-cdabd3f6.js} +1 -1
  28. package/dist/{block.mds.expressionrank-33b858de.js → block.mds.expressionrank-d768640f.js} +1 -1
  29. package/dist/{block.mds.expressionstat-3093599f.js → block.mds.expressionstat-7e40426f.js} +1 -1
  30. package/dist/{block.mds.geneboxplot-b8391d18.js → block.mds.geneboxplot-dae9cfa3.js} +1 -1
  31. package/dist/{block.mds.junction-69708c7f.js → block.mds.junction-3bc8baea.js} +1 -1
  32. package/dist/{block.mds.svcnv-322baea6.js → block.mds.svcnv-456dc845.js} +1 -1
  33. package/dist/{block.mds.svcnv.share-c5c38237.js → block.mds.svcnv.share-4776459b.js} +1 -1
  34. package/dist/{block.mds2-de4811dd.js → block.mds2-cc586d9d.js} +1 -1
  35. package/dist/{block.svg-ac9fec2d.js → block.svg-adf47e3a.js} +1 -1
  36. package/dist/{block.tk.aicheck-ac4b8d4d.js → block.tk.aicheck-f284f080.js} +1 -1
  37. package/dist/{block.tk.ase-6dc0f9f1.js → block.tk.ase-0477c9f4.js} +1 -1
  38. package/dist/{block.tk.bam-8f68b41d.js → block.tk.bam-d4c998d4.js} +1 -1
  39. package/dist/{block.tk.bedgraphdot-d8878860.js → block.tk.bedgraphdot-0177d836.js} +1 -1
  40. package/dist/{block.tk.bigwig.ui-f6ed051c.js → block.tk.bigwig.ui-95531269.js} +1 -1
  41. package/dist/{block.tk.hicstraw-725bdc8a.js → block.tk.hicstraw-06e97317.js} +1 -1
  42. package/dist/{block.tk.junction-f8b0b51d.js → block.tk.junction-18b6b825.js} +1 -1
  43. package/dist/{block.tk.junction.textmatrixui-252e7d7e.js → block.tk.junction.textmatrixui-ffdbdf81.js} +1 -1
  44. package/dist/{block.tk.ld-11acf730.js → block.tk.ld-2b56500f.js} +1 -1
  45. package/dist/{block.tk.menu-5e04436d.js → block.tk.menu-707a4226.js} +1 -1
  46. package/dist/{block.tk.pgv-fef17dc4.js → block.tk.pgv-63c956c4.js} +1 -1
  47. package/dist/{boxplot-4c9a5479.js → boxplot-1f229616.js} +1 -1
  48. package/dist/{brainImaging-7716bc66.js → brainImaging-a0c72fad.js} +1 -1
  49. package/dist/{brush-9faa7ae7.js → brush-4c775f74.js} +1 -1
  50. package/dist/{categorical-1dea48ba.js → categorical-25b06bc5.js} +1 -1
  51. package/dist/{condition-ebac4f75.js → condition-70084a85.js} +1 -1
  52. package/dist/{controls-268e40e6.js → controls-1f3ac9d0.js} +1 -1
  53. package/dist/controls.btns-5b44e5d0.js +1 -0
  54. package/dist/{controls.config-2f0fa061.js → controls.config-b0339f96.js} +1 -1
  55. package/dist/{cuminc-8dffb765.js → cuminc-6d1de932.js} +1 -1
  56. package/dist/{customdata.inputui-b229d3a0.js → customdata.inputui-5ad0f25c.js} +1 -1
  57. package/dist/{dataDownload-452ae3cd.js → dataDownload-a60d80e4.js} +1 -1
  58. package/dist/databrowser.ui-a5c8194c.js +1 -0
  59. package/dist/{density-09feb0c9.js → density-30dbad8b.js} +1 -1
  60. package/dist/{dictionary-a132a3cc.js → dictionary-d8435ddc.js} +1 -1
  61. package/dist/{drag-2e9c80bb.js → drag-ad04f964.js} +1 -1
  62. package/dist/{e2pca-4f1648e3.js → e2pca-02adebbd.js} +1 -1
  63. package/dist/{ep-1d4c58b4.js → ep-b2e464fe.js} +1 -1
  64. package/dist/{facet-fa4fe49c.js → facet-e7612200.js} +1 -1
  65. package/dist/{filter-b3d3964e.js → filter-67d51c09.js} +1 -1
  66. package/dist/{fusion.parse-7dfd6988.js → fusion.parse-68670e99.js} +1 -1
  67. package/dist/{geneExpClustering-ed9121b8.js → geneExpClustering-d96c27ef.js} +1 -1
  68. package/dist/geneExpression-072e0be1.js +1 -0
  69. package/dist/{geneExpression-394672ff.js → geneExpression-4901955e.js} +1 -1
  70. package/dist/{geneExpression-66208299.js → geneExpression-65346c08.js} +1 -1
  71. package/dist/{geneORA-9456872c.js → geneORA-e3d6619e.js} +1 -1
  72. package/dist/geneVariant-9fc29f37.js +1 -0
  73. package/dist/{geneVariant-beaf9adb.js → geneVariant-f6bbc247.js} +1 -1
  74. package/dist/{genefusion.ui-9238ec7f.js → genefusion.ui-a5a08183.js} +1 -1
  75. package/dist/{genesearch-ffd88bf2.js → genesearch-5fa13afa.js} +1 -1
  76. package/dist/{geneset-0315daf8.js → geneset-c36036bd.js} +1 -1
  77. package/dist/genomeBrowser-d4515002.js +1 -0
  78. package/dist/{genomeBrowser.controls-2601cab5.js → genomeBrowser.controls-b89629b0.js} +1 -1
  79. package/dist/{groupsetting-e3a4ecd5.js → groupsetting-a3de9ec7.js} +1 -1
  80. package/dist/{gsea-0c0cf8de.js → gsea-af1a7cec.js} +1 -1
  81. package/dist/{hierCluster-7ab62ca5.js → hierCluster-8aa2265a.js} +1 -1
  82. package/dist/hierCluster.config-11a176e2.js +1 -0
  83. package/dist/{hierCluster.interactivity-7f475259.js → hierCluster.interactivity-103b2f0f.js} +1 -1
  84. package/dist/{hierCluster.renderers-19b79639.js → hierCluster.renderers-48bdf7a6.js} +1 -1
  85. package/dist/{html.legend-80b2b3ec.js → html.legend-455f7881.js} +1 -1
  86. package/dist/{imagePlot-1ef24562.js → imagePlot-862c7baf.js} +1 -1
  87. package/dist/{lasso-1a02a545.js → lasso-e12204af.js} +1 -1
  88. package/dist/launch.adhoc-b8af0ace.js +1 -0
  89. package/dist/leftlabel.sample-784c5aeb.js +1 -0
  90. package/dist/{legacyDataset-fbaa5ebb.js → legacyDataset-501a0298.js} +1 -1
  91. package/dist/{log-c26b6cfd.js → log-d560d2a5.js} +1 -1
  92. package/dist/{lollipop-3aebe5d3.js → lollipop-aa25084e.js} +1 -1
  93. package/dist/{maf-c439c851.js → maf-13befc91.js} +1 -1
  94. package/dist/{maftimeline-0da64e54.js → maftimeline-f9ee156e.js} +1 -1
  95. package/dist/{matrix-38cd47c3.js → matrix-971b44da.js} +1 -1
  96. package/dist/{matrix.cells-a018d731.js → matrix.cells-92037b17.js} +1 -1
  97. package/dist/{matrix.cluster-a6e713e8.js → matrix.cluster-0bca59fd.js} +1 -1
  98. package/dist/{matrix.config-2c550b5d.js → matrix.config-b8d8faef.js} +1 -1
  99. package/dist/matrix.controls-07c6128c.js +1 -0
  100. package/dist/{matrix.data-2b814c9f.js → matrix.data-1090f6c7.js} +1 -1
  101. package/dist/{matrix.dom-1e0da5b3.js → matrix.dom-1154156c.js} +1 -1
  102. package/dist/{matrix.groups-824a7244.js → matrix.groups-f10a8c05.js} +1 -1
  103. package/dist/{matrix.interactivity-1cb56534.js → matrix.interactivity-99de0399.js} +1 -1
  104. package/dist/{matrix.layout-47e44357.js → matrix.layout-405db70f.js} +1 -1
  105. package/dist/{matrix.legend-9af0c757.js → matrix.legend-d06de359.js} +1 -1
  106. package/dist/{matrix.renderers-337ce240.js → matrix.renderers-2211c4b2.js} +1 -1
  107. package/dist/{matrix.serieses-7b7184c9.js → matrix.serieses-f0803a76.js} +1 -1
  108. package/dist/{matrix.sort-1ac05842.js → matrix.sort-3d376f1a.js} +1 -1
  109. package/dist/{matrix.sorterUi-1c60c145.js → matrix.sorterUi-469ed804.js} +1 -1
  110. package/dist/{mavb-da8d1a0a.js → mavb-e5cbd894.js} +1 -1
  111. package/dist/{mds.fimo-8604c3f8.js → mds.fimo-f9215ef6.js} +1 -1
  112. package/dist/{mds.samplescatterplot-3f09ae0e.js → mds.samplescatterplot-6fce6594.js} +1 -1
  113. package/dist/{mds.survivalplot-1d8f2b7e.js → mds.survivalplot-16e9e8c5.js} +1 -1
  114. package/dist/{metaboliteIntensity-bbb23c76.js → metaboliteIntensity-b47fb792.js} +1 -1
  115. package/dist/{niceNumLabels-29a7c6ca.js → niceNumLabels-1bd7a93b.js} +1 -1
  116. package/dist/{nodrag-b2737073.js → nodrag-0fa60f70.js} +1 -1
  117. package/dist/{notify-0cb8904f.js → notify-42149e65.js} +1 -1
  118. package/dist/{numeric-24dacbee.js → numeric-5b626171.js} +1 -1
  119. package/dist/{numeric.binary-f382cc98.js → numeric.binary-07e15211.js} +1 -1
  120. package/dist/numeric.continuous-76dd29ba.js +1 -0
  121. package/dist/numeric.discrete-6d697c68.js +1 -0
  122. package/dist/{numeric.spline-a35cfbf0.js → numeric.spline-cf331bad.js} +1 -1
  123. package/dist/{numeric.toggle-2f98d6e5.js → numeric.toggle-332c2578.js} +1 -1
  124. package/dist/oncomatrix-7c84c94b.js +1 -0
  125. package/dist/{parseData-292648dd.js → parseData-05ab5f81.js} +1 -1
  126. package/dist/{plot.2dvaf-6ae22dc1.js → plot.2dvaf-1debbf12.js} +1 -1
  127. package/dist/plot.app-0b02df66.js +1 -0
  128. package/dist/{plot.barplot-34841e70.js → plot.barplot-45b57df9.js} +1 -1
  129. package/dist/{plot.boxplot-87ac2ce9.js → plot.boxplot-06cef6e2.js} +1 -1
  130. package/dist/{plot.brainImaging-32a484b6.js → plot.brainImaging-07795744.js} +1 -1
  131. package/dist/{plot.disco-1fdfee3c.js → plot.disco-9c631d77.js} +1 -1
  132. package/dist/{plot.dzi-e3d0f610.js → plot.dzi-a9a81de5.js} +1 -1
  133. package/dist/{plot.ssgq-d33113d5.js → plot.ssgq-02ffde06.js} +1 -1
  134. package/dist/{plot.vaf2cov-9f4f1776.js → plot.vaf2cov-c111c5fb.js} +1 -1
  135. package/dist/{plot.wsi-dea124a7.js → plot.wsi-6ccc7bb2.js} +1 -1
  136. package/dist/{profileBarchart-58f0a8c0.js → profileBarchart-0c97e8c9.js} +1 -1
  137. package/dist/{profileHome-7f404152.js → profileHome-2255d66d.js} +1 -1
  138. package/dist/profilePlot-ba7e03ab.js +1 -0
  139. package/dist/{profilePolar-50b8e40e.js → profilePolar-d38d502f.js} +1 -1
  140. package/dist/{profileRadar-fff0b004.js → profileRadar-f95cfa87.js} +1 -1
  141. package/dist/{profileRadarFacility-d6d34c15.js → profileRadarFacility-7e200a91.js} +1 -1
  142. package/dist/profileSummary-8c41a731.js +1 -0
  143. package/dist/{recover-299ffdb3.js → recover-6f2f3379.js} +1 -1
  144. package/dist/{regression.inputs-14df7c31.js → regression.inputs-b515101d.js} +1 -1
  145. package/dist/{regression.inputs.values.table-d79efa9e.js → regression.inputs.values.table-f8a0cad9.js} +1 -1
  146. package/dist/{regression.results-4767144e.js → regression.results-91a486f0.js} +1 -1
  147. package/dist/{renderPvalueTable-002cc8ff.js → renderPvalueTable-d4d2624c.js} +1 -1
  148. package/dist/sampleScatter-7c2773de.js +1 -0
  149. package/dist/{sampleScatter.rendererThree-ef289434.js → sampleScatter.rendererThree-b6db5a09.js} +2 -2
  150. package/dist/{sampleView-1dff3fca.js → sampleView-8885e86b.js} +1 -1
  151. package/dist/{samplelst-d2db0f24.js → samplelst-83e593da.js} +1 -1
  152. package/dist/{samplematrix-0841387f.js → samplematrix-a8b3f845.js} +1 -1
  153. package/dist/{scatter-f8285107.js → scatter-34d52e2d.js} +1 -1
  154. package/dist/{select2Terms-d48d037e.js → select2Terms-d9320d21.js} +1 -1
  155. package/dist/{selectGenomeWithTklst-9af86d31.js → selectGenomeWithTklst-fed6a2ea.js} +1 -1
  156. package/dist/shapes-21ebfec4.js +1 -0
  157. package/dist/singleCellCellType-e6848f45.js +1 -0
  158. package/dist/{singleCellGeneExpression-537f1157.js → singleCellGeneExpression-d3a5394e.js} +1 -1
  159. package/dist/singleCellPlot-3cad6bd8.js +1 -0
  160. package/dist/{singlecell-38336cbc.js → singlecell-0754aab0.js} +1 -1
  161. package/dist/{singlecell-87b4b9a9.js → singlecell-7c57cd77.js} +1 -1
  162. package/dist/{snp-b81ef740.js → snp-6b23e7a6.js} +1 -1
  163. package/dist/snp-a0cdd2a5.js +1 -0
  164. package/dist/snplocus-c60eab56.js +1 -0
  165. package/dist/{spliceevent.a53ss.diagram-5f8352eb.js → spliceevent.a53ss.diagram-8714f740.js} +1 -1
  166. package/dist/{spliceevent.exonskip.diagram-0d30a735.js → spliceevent.exonskip.diagram-40c1e363.js} +1 -1
  167. package/dist/spliceevent.exonskip.getdefault-4bb6f19f.js +1 -0
  168. package/dist/{spliceevent.noeventdiagram-df9ce4bc.js → spliceevent.noeventdiagram-41a56db9.js} +1 -1
  169. package/dist/{spliceevent.phrase-a8401d53.js → spliceevent.phrase-7f34e3b1.js} +1 -1
  170. package/dist/{stattable-46cde32c.js → stattable-78dc5c34.js} +1 -1
  171. package/dist/{style.gdc-72d730f2.js → style.gdc-cd49882c.js} +1 -1
  172. package/dist/summary-45c56298.js +1 -0
  173. package/dist/{sunburst-fe95832e.js → sunburst-2140e468.js} +1 -1
  174. package/dist/{survival-57ff3c03.js → survival-db972025.js} +1 -1
  175. package/dist/{survival-52714cd3.js → survival-ed4bdad2.js} +1 -1
  176. package/dist/{svg.download-f4aa48e4.js → svg.download-a5e20a92.js} +1 -1
  177. package/dist/{svg.legend-749348e0.js → svg.legend-8d21872d.js} +1 -1
  178. package/dist/{svgraph-b46f1f92.js → svgraph-f6a28b78.js} +1 -1
  179. package/dist/{svmr-9a76c6d4.js → svmr-8b4b4c59.js} +1 -1
  180. package/dist/{table-bf40249b.js → table-1cbe3a36.js} +1 -1
  181. package/dist/{table-0daf2b89.js → table-e2a307e6.js} +1 -1
  182. package/dist/{termInfo-491b10af.js → termInfo-5477ba96.js} +1 -1
  183. package/dist/termdb.bins-7ecc48db.js +1 -0
  184. package/dist/{termsetting-492eefa7.js → termsetting-2e75e729.js} +1 -1
  185. package/dist/tk-a8a4481a.js +1 -0
  186. package/dist/{toggleButtons-c4d6f260.js → toggleButtons-7ce58d97.js} +1 -1
  187. package/dist/{tp.ui-0a476325.js → tp.ui-be14f635.js} +1 -1
  188. package/dist/{tvs.density-034b506d.js → tvs.density-8b953cef.js} +1 -1
  189. package/dist/{tvs.geneVariant-c59c8b54.js → tvs.geneVariant-ecad287d.js} +1 -1
  190. package/dist/{tvs.numeric-aa1f892f.js → tvs.numeric-b56a5aba.js} +1 -1
  191. package/dist/{tvs.samplelst-515f27b9.js → tvs.samplelst-3150e0b7.js} +1 -1
  192. package/dist/{uiUtils-ea7dfea2.js → uiUtils-71cc22de.js} +1 -1
  193. package/dist/{variantBrowser-14d5c3f6.js → variantBrowser-df2f9c22.js} +1 -1
  194. package/dist/{vcf-d357ce08.js → vcf-3e370c9b.js} +1 -1
  195. package/dist/{violin-74d26b75.js → violin-4595cef4.js} +1 -1
  196. package/dist/{violin.interactivity-bf40ddde.js → violin.interactivity-8b63e000.js} +1 -1
  197. package/dist/{violin.renderer-469fa0ff.js → violin.renderer-0b7431a2.js} +1 -1
  198. package/dist/{violinRenderer-14fa200d.js → violinRenderer-7b0a4e98.js} +1 -1
  199. package/dist/{viridis-cc59f478.js → viridis-725f66e0.js} +1 -1
  200. package/dist/{y-59cbff5e.js → y-300bac24.js} +1 -1
  201. package/dist/{zoom-f445cfef.js → zoom-d3d38b3b.js} +1 -1
  202. package/package.json +2 -4
  203. package/dist/FilterRxComp-02e68f1b.js +0 -1
  204. package/dist/FilterStateless-16a33070.js +0 -1
  205. package/dist/app-42f69951.js +0 -1
  206. package/dist/app-6fb77603.js +0 -1
  207. package/dist/block.lazyload-d2951c91.js +0 -1
  208. package/dist/controls.btns-5bf9e7d7.js +0 -1
  209. package/dist/databrowser.ui-2197fc73.js +0 -1
  210. package/dist/downloadTextfile-5723af95.js +0 -1
  211. package/dist/geneExpression-c61e8f1c.js +0 -1
  212. package/dist/geneVariant-f17cda85.js +0 -1
  213. package/dist/genomeBrowser-608b924e.js +0 -1
  214. package/dist/hierCluster.config-f4daaf92.js +0 -1
  215. package/dist/launch.adhoc-e124c993.js +0 -1
  216. package/dist/leftlabel.sample-59f99ef5.js +0 -1
  217. package/dist/matrix.controls-42ad4912.js +0 -1
  218. package/dist/numeric.continuous-6feb34a7.js +0 -1
  219. package/dist/numeric.discrete-ed10bbc1.js +0 -1
  220. package/dist/oncomatrix-c0b2d635.js +0 -1
  221. package/dist/plot.app-2a805759.js +0 -1
  222. package/dist/profilePlot-4db8ca78.js +0 -1
  223. package/dist/profileSummary-04b8b15b.js +0 -1
  224. package/dist/sampleScatter-55d9eb74.js +0 -1
  225. package/dist/singleCellCellType-fd1606b8.js +0 -1
  226. package/dist/singleCellPlot-eff5760b.js +0 -1
  227. package/dist/snp-f6123244.js +0 -1
  228. package/dist/snplocus-acafb1ba.js +0 -1
  229. package/dist/spliceevent.exonskip.getdefault-237c481c.js +0 -1
  230. package/dist/summary-a6c15c9e.js +0 -1
  231. package/dist/termdb.bins-39d11f24.js +0 -1
  232. package/dist/tk-ac524564.js +0 -1
@@ -1 +1 @@
1
- import{h as e,T as t,d as s,Y as i,i as r,a,k as o,y as l,o as n,M as p,b as d,K as c}from"./app-6fb77603.js";import{T as m,n as h,t as u,e as f,d as y}from"./termsetting-492eefa7.js";import{g as b,i as v,a as _,f as g,s as T,v as x}from"./FilterRxComp-02e68f1b.js";import{termInfoInit as S}from"./termInfo-491b10af.js";import{_ as I}from"./tslib.es6-c3c2d88f.js";import{T as k}from"./toggleButtons-c4d6f260.js";import"path";import"./table-0daf2b89.js";import"./partjson.esm-b3f1fc21.js";import"./termdb.bins-39d11f24.js";const C="25px";const A="root";const w=20;const N="400px";const D="termdiv",E="termchilddiv",O="termbtn",j="termlabel",L="termloading",B="termcheck";class V{constructor(e){this.type="tree";G(this);R(this);this.loadingTermSet=new Set;this.termsByCohort={};this.expandAll="expandAll"in e?e.expandAll:false}init(){this.dom={holder:this.opts.holder.append("div")}}reactsTo(e){if(e.type.startsWith("tree_"))return true;if(e.type.startsWith("filter_"))return true;if(e.type.startsWith("cohort_"))return true;if(e.type.startsWith("info_"))return true;if(e.type.startsWith("submenu_"))return true;if(e.type=="app_refresh")return true;if(e.type=="set_term_type_group")return true}getState(e){const t=b(e.termfilter.filter);const s={isVisible:!e.submenu.term,activeCohort:e.activeCohort,expandedTermIds:e.tree.expandedTermIds,selectedTerms:e.selectedTerms,termfilter:{filter:t},usecase:e.tree.usecase,termTypeGroup:e.termTypeGroup};if(e.termdbConfig.selectCohort){s.toSelectCohort=true;const t=e.termdbConfig.selectCohort.values[e.activeCohort];if(t){s.cohortValuelst=t.keys}}return s}async main(){if(this.state.termTypeGroup!=t.DICTIONARY_VARIABLES){this.dom.holder.style("display","none");return}if(!this.state.isVisible){this.dom.holder.style("display","none");return}if(this.state.toSelectCohort){if(!this.state.cohortValuelst){return}}this.termsById=this.getTermsById();const e=this.termsById[A];e.terms=await this.requestTermRecursive(e);this.dom.holder.style("display","block");await this.renderBranch(e,this.dom.holder);this.dom.holder.selectAll(".termbtn, .sja_tree_click_term").attr("tabindex",0).attr("data-testid","sjpp_termdbbutton").on("keyup",(e=>{if(e.key=="Enter")e.target.click()}))}getTermsById(){if(!(this.state.activeCohort in this.termsByCohort)){this.termsByCohort[this.state.activeCohort]={[A]:{id:A,__tree_isroot:true}}}return this.termsByCohort[this.state.activeCohort]}async requestTermRecursive(e){const t=await this.app.vocabApi.getTermChildren(e,this.state.toSelectCohort?this.state.cohortValuelst:null);if(t.error)throw t.error;if(!t.lst||t.lst.length==0){return[]}const s=[];for(const e of t.lst){const t=Object.assign({},e);s.push(t);if(this.state.expandedTermIds.includes(t.id)){t.terms=await this.requestTermRecursive(t)}else{const e=this.termsById[t.id];if(e&&e.terms){t.terms=e.terms}}this.termsById[t.id]=t}return s}bindKey(e){return e.id}}const P=e(V);function R(e){e.renderBranch=(t,s,i)=>{if(!t||!t.terms)return;if(t.terms.length>=w){if(s.classed("sjpp_show_scrollbar"));else{s.style("max-height",N).style("padding","10px").style("resize","vertical").classed("sjpp_show_scrollbar",true)}}if(e.opts.disable_terms){t.terms.forEach((t=>{if(t.disabled)e.opts.disable_terms.push(t)}))}e.included_terms=[];if(e.state.usecase){for(const s of t.terms){if(v(s,e.state.usecase,e.app.vocabApi.termdbConfig).size){e.included_terms.push(s)}}}else{e.included_terms.push(...t.terms)}if(!(t.id in e.termsById)||!e.included_terms.length){s.style("display","none");return}if(e.loadingTermSet.has(t.id)){e.loadingTermSet.delete(t.id);s.select("."+L).remove()}const r=e.state.expandedTermIds;if(!r.includes(t.id)){s.style("display","none");if(i)i.text("+");return}s.style("display","block");if(i)i.text("-");const a=s.selectAll("."+D).data(e.included_terms,e.bindKey);a.exit().each(e.hideTerm);a.each(e.updateTerm);a.enter().append("div").each(e.addTerm);for(const i of t.terms){if(r.includes(i.id)){e.renderBranch(i,s.selectAll("."+E).filter((e=>e.id==i.id)),s.selectAll("."+O).filter((e=>e.id==i.id)))}}};e.hideTerm=function(t){if(t.id in e.termsById&&e.state.expandedTermIds.includes(t.id))return;s(this).style("display","none")};e.updateTerm=function(t){const i=s(this);if(!(t.id in e.termsById)){i.style("display","none");return}const r=e.opts.disable_terms?.includes(t.id);const a=v(t,e.state.usecase,e.app.vocabApi.termdbConfig);i.style("display","");const o=e.state.expandedTermIds.includes(t.id);i.select("."+O).text(o?"-":"+");i.select("."+E).style("display",o?"block":"none");const l=e.state.selectedTerms.find((e=>e.name===t.name&&e.type===t.type));i.select("."+j).style("background-color",!a.has("plot")||r?"":l?"rgba(255, 194, 10,0.5)":"#cfe2f3");i.select("."+B).style("display",a.has("plot")&&l&&!r?"inline-block":"none")};e.addTerm=async function(t){const i=e.opts.disable_terms?.includes(t.id);const r=v(t,e.state.usecase,e.app.vocabApi.termdbConfig);const a=s(this).attr("class",D).style("margin",t.isleaf?"":"2px").style("padding","0px 5px");if(r.has("branch")){a.append("div").attr("class","sja_menuoption "+O).style("display","inline-block").style("padding","4px 9px").style("font-family","courier").text("+").on("click",(s=>{s.stopPropagation();e.toggleBranch(t)}));if(e.expandAll)e.toggleBranch(t)}const o=e.state.selectedTerms.find((e=>e.name===t.name&&e.type===t.type));const l=a.append("div").attr("class",j).style("display","inline-block").style("padding","5px").style("opacity",i?.4:null).text(t.name);let n;if(t.hashtmldetail){n=a.append("div").style("display","inline-block")}if(r.size>0){if(i){l.attr("class","sja_tree_click_term_disabled "+j).style("padding","5px 8px").style("margin","1px 0px").style("opacity",.7)}else if(r.has("plot")){l.attr("class","ts_pill sja_filter_tag_btn sja_tree_click_term "+j).style("color","black").style("padding","5px 8px").style("border-radius","6px").style("background-color",o?"rgba(255, 194, 10,0.5)":"#cfe2f3").style("margin","1px 0px").style("cursor","default").on("click",(()=>e.clickTerm(t)))}if(t.samplecount!==undefined){a.append("div").style("font-size",".8em").style("display","inline-block").style("margin-left","5px").style("color",t.samplecount?"#777":"#ddd").text("n="+t.samplecount)}}if(t.hashtmldetail){S({vocabApi:e.app.vocabApi,icon_holder:n,content_holder:a.append("div"),id:t.id,state:{term:t}})}if(e.opts.submit_lst){a.append("div").attr("class",B).style("color","#008000").style("display",o?"inline-block":"none").html("&check;")}if(!t.isleaf){a.append("div").attr("class",E).style("padding-left",C)}}}function G(e){e.toggleBranch=function(t){if(t.isleaf)return;const i=e.termsById[t.id];if(!i)throw"invalid term id";if(!i.terms){if(e.loadingTermSet.has(i.id))return;e.loadingTermSet.add(i.id);s(this.parentNode).selectAll("."+E).filter((e=>e.id===i.id)).style("display","block").append("div").text("Loading...").attr("class",L).style("opacity",.5).style("padding","5px")}const r=e.state.expandedTermIds.includes(t.id);const a=r?"tree_collapse":"tree_expand";e.app.dispatch({type:a,termId:t.id})};e.clickTerm=async t=>{if(e.opts.click_term2select_tvs){e.app.dispatch({type:"submenu_set",submenu:{term:t,type:"tvs"}});return}if(e.opts.click_term_wrapper){e.opts.click_term_wrapper(t);return}if(e.opts.submit_lst){const s=e.state.selectedTerms.findIndex((e=>e.name===t.name));if(s==-1){e.app.dispatch({type:"app_refresh",state:{selectedTerms:[...e.state.selectedTerms,t]}})}else{const t=e.state.selectedTerms.slice(0);t.splice(s,1);e.app.dispatch({type:"app_refresh",state:{selectedTerms:t}})}return}throw"missing term click callback"}}const U={header_mode:"search_only",activeCohort:0,tree:{usecase:{},expandedTermIds:[]},submenu:{},search:{isVisible:true},selectedTerms:[],termfilter:{filter:{type:"tvslst",in:true,join:"",lst:[]}}};class M{constructor(e){this.type="store";this.defaultState=U;i(this,e);this.prevGeneratedId=0}validateOpts(e){if(!e.state)throw".state{} missing";const t=e.state;if(t.vocab){if(t.vocab.dslabel){if(!t.vocab.genome)throw".state[.vocab].genome missing"}else if(t.vocab.genome){if(!t.vocab.dslabel)throw".state[.vocab].dslabel missing"}else{if(!Array.isArray(t.vocab.terms))throw"vocab.terms must be an array of objects"}}}validateState(){const e=this.state;if(e.tree.expandedTermIds.length==0){e.tree.expandedTermIds.push(A)}else{if(e.tree.expandedTermIds[0]!=A){e.tree.expandedTermIds.unshift(A)}}}async init(){this.state.termdbConfig=await this.app.vocabApi.getTermdbConfig();let e=_(this.state.termfilter.filter,"filterUiRoot");if(!e){this.state.termfilter.filter.tag="filterUiRoot";e=this.state.termfilter.filter}if(this.state.termdbConfig.selectCohort){let t=_(this.state.termfilter.filter,"cohortFilter");if(!t){t={tag:"cohortFilter",type:"tvs",tvs:{term:JSON.parse(JSON.stringify(this.state.termdbConfig.selectCohort.term)),values:this.state.activeCohort==-1?[]:this.state.termdbConfig.selectCohort.values[this.state.activeCohort].keys.map((e=>({key:e,label:e})))}};this.state.termfilter.filter={type:"tvslst",in:true,join:"and",lst:[t,e]}}else{const e=(e,t)=>e<t?-1:1;t.tvs.values.sort(((e,t)=>e.key<t.key?-1:1));const s=JSON.stringify(t.tvs.values.map((e=>e.key)).sort(e));const i=this.state.termdbConfig.selectCohort.values.findIndex((t=>s==JSON.stringify(t.keys.sort(e))));if(this.state.activeCohort!==-1&&this.state.activeCohort!==0&&i!==this.state.activeCohort){console.log("Warning: cohortFilter will override the state.activeCohort due to mismatch")}this.state.activeCohort=i}}else{this.state.activeCohort=-1;if(this.state.header_mode==="with_cohortHtmlSelect"){console.warn(`no termdbConfig.selectCohort to use for state.header_mode = 'with_cohortHtmlSelect'`);this.state.header_mode="search_only"}}}fromJson(e){const t=JSON.parse(e);return t}setId(e){e.$id=this.prevGeneratedId++;if(e.$lst){for(const t of e.$lst){this.setId(t)}}}}M.prototype.actions={app_refresh(e={}){this.state=this.copyMerge(this.toJson(this.state),e.state?e.state:{},this.replaceKeyVals)},cohort_set(e){this.state.activeCohort=e.activeCohort;const t=this.state.termdbConfig.selectCohort.values[e.activeCohort];const s=_(this.state.termfilter.filter,"cohortFilter");if(!s)throw`No item tagged with 'cohortFilter'`;s.tvs.values=t.keys.map((e=>({key:e,label:e})))},tree_expand(e){if(this.state.tree.expandedTermIds.includes(e.termId))return;this.state.tree.expandedTermIds.push(e.termId)},tree_collapse(e){const t=this.state.tree.expandedTermIds.indexOf(e.termId);if(t==-1)return;this.state.tree.expandedTermIds.splice(t,1)},filter_replace(e){const t=e.filter?e.filter:{type:"tvslst",join:"",in:1,lst:[]};if(!e.filter.tag){this.state.termfilter.filter=t}else{const s=_(this.state.termfilter.filter,e.filter.tag);if(!s)throw`cannot replace missing filter with tag '${e.filter.tag}'`;const i=g(this.state.termfilter.filter,s.$id);if(i==s){this.state.termfilter.filter=t}else{const e=i.lst.indexOf(s);i.lst[e]=t}}},submenu_set(e){const t=e.submenu&&e.submenu.term;if(!t){this.state.submenu={};this.state.tree.expandedTermIds=[A]}else{const s=[A];if(t.__ancestors){s.push(...t.__ancestors)}if(v(t,{},this.state.termdbConfig).has("plot")){Object.assign(this.state.submenu,e.submenu)}else{s.push(t.id);delete this.state.submenu.term}this.state.tree.expandedTermIds=s}},set_term_type_group({value:e}){this.state.termTypeGroup=e}};const Y=r(M);function F(e){switch(e){case"./handlers/geneExpression.ts":return import("./geneExpression-c61e8f1c.js");case"./handlers/geneVariant.ts":return import("./geneVariant-f17cda85.js");case"./handlers/snp.ts":return import("./snp-f6123244.js");case"./handlers/snplocus.ts":return import("./snplocus-90e52cf4.js");case"./handlers/snplst.ts":return import("./snplst-7c59f059.js");default:return new Promise((function(t,s){(typeof queueMicrotask==="function"?queueMicrotask:setTimeout)(s.bind(null,new Error("Unknown variable dynamic import: "+e)))}))}}const $={matrix:[t.SNP_LOCUS,t.SNP_LIST],filter:[t.SNP_LOCUS,t.SNP_LIST],dictionary:[t.SNP_LOCUS,t.SNP_LIST],summary:[t.SNP_LOCUS,t.SNP_LIST],barchart:[t.SNP_LOCUS,t.SNP_LIST],violin:[t.SNP_LOCUS,t.SNP_LIST],sampleScatter:[t.SNP_LOCUS,t.SNP_LIST],cuminc:[t.SNP_LOCUS,t.SNP_LIST,t.MUTATION_CNV_FUSION,t.METABOLITE_INTENSITY],dataDownload:[t.MUTATION_CNV_FUSION],survival:[t.SNP_LOCUS,t.SNP_LIST],default:[t.SNP_LOCUS,t.SNP_LIST],regression:[t.SNP_LIST,t.SNP_LOCUS,t.GENE_EXPRESSION,t.METABOLITE_INTENSITY],metaboliteIntensity:[t.SNP_LOCUS,t.SNP_LIST,t.MUTATION_CNV_FUSION,t.DICTIONARY_VARIABLES,t.GENE_EXPRESSION],geneExpression:[t.SNP_LOCUS,t.SNP_LIST,t.MUTATION_CNV_FUSION,t.DICTIONARY_VARIABLES,t.METABOLITE_INTENSITY]};class q{constructor(e){this.type="termTypeSearch";this.genomeObj=e.genome;this.click_term=e.click_term;this.submit_lst=e.submit_lst;const t=e.topbar.append("div").append("div").style("width","99%").style("display","flex").style("flex-wrap","wrap").style("gap","5px").style("min-height","20px").style("border","solid 1px #aaa").style("margin","10px 0px").style("padding","6px 2px").style("min-height","30px");this.types=[];this.tabs=[];this.handlerByType={};this.dom={holder:e.holder,topbar:e.topbar,selectedTermsDiv:t,submitDiv:e.submitDiv};this.useCasesExcluded=structuredClone($)}init(e){var s,i,r;return I(this,void 0,void 0,(function*(){this.types=((s=this.app.vocabApi.termdbConfig)===null||s===void 0?void 0:s.allowedTermTypes)||["categorical"];if(!this.types)return;if((i=this.app.vocabApi.termdbConfig)===null||i===void 0?void 0:i.useCasesExcluded)Object.assign(this.useCasesExcluded,(r=this.app.vocabApi.termdbConfig)===null||r===void 0?void 0:r.useCasesExcluded);const a=this.getState(e);yield this.addTabsAllowed(a);if(this.submit_lst)this.dom.clearbt=this.dom.submitDiv.append("button").style("margin-left","5px").text("Clear").on("click",(()=>this.selectTerms([])));if(this.tabs.length==0)throw"No term types allowed for this use case";this.app.dispatch({type:"set_term_type_group",value:this.tabs[0].termTypeGroup});if(this.tabs.length==1&&this.tabs[0].termTypeGroup==t.DICTIONARY_VARIABLES)return;new k({holder:this.dom.holder,tabsPosition:"vertical",linePosition:"right",tabs:this.tabs}).main();for(const[e]of this.tabs.entries()){const t=this.tabs[e].contentHolder.style("padding-left","20px");t.append("div")}}))}reactsTo(e){if(e.type.startsWith("submenu_"))return true;if(e.type=="set_term_type_group")return true;if(e.type=="app_refresh")return true}main(){this.dom.holder.style("display",this.state.isVisible?"inline-block":"none");this.dom.topbar.style("display",this.state.isVisible?"inline-block":"none");if(this.submit_lst){this.renderTermsSelected();this.dom.selectedTermsDiv.style("display",this.state.selectedTerms.length>0?"inline-block":"none")}else this.dom.selectedTermsDiv.style("display","none");this.renderTermsSelected();if(this.dom.clearbt)this.dom.clearbt.property("disabled",this.state.selectedTerms.length==0)}renderTermsSelected(){this.dom.selectedTermsDiv.selectAll("*").remove();this.dom.selectedTermsDiv.selectAll("div").data(this.state.selectedTerms).enter().append("div").attr("aria-label","Click to delete").attr("class","sja_menuoption").attr("tabindex",0).style("position","relative").style("display","inline-block").style("padding","5px 16px 5px 9px").style("margin-left","5px").each(e).on("click",((e,t)=>this.deleteTerm(e,t))).on("mouseover",(function(e){const t=`<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="#000" class="bi bi-x-lg" viewBox="0 0 16 16">\n\t\t\t\t<path stroke='#f00' d="M2.146 2.854a.5.5 0 1 1 .708-.708L8 7.293l5.146-5.147a.5.5 0 0 1 .708.708L8.707 8l5.147 5.146a.5.5 0 0 1-.708.708L8 8.707l-5.146 5.147a.5.5 0 0 1-.708-.708L7.293 8 2.146 2.854Z"/>\n\t\t\t\t</svg>`;const i=s(e.target);i.append("div").style("margin-left","4px").classed("sjpp_deletebt",true).style("display","inline-block").style("position","absolute").style("right","0px").style("top","0px").style("transform","scale(0.6)").style("pointer-events","none").html(t)})).on("mouseout",(function(e){s(e.target).select(".sjpp_deletebt").remove()}));function e(e){const t=s(this).style("border-radius","5px");t.insert("div").style("display","inline-block").html(e.name)}}deleteTerm(e,t){const s=this.state.selectedTerms.findIndex((e=>e.name===t.name));if(s!=-1){const e=[...this.state.selectedTerms];e.splice(s,1);this.app.dispatch({type:"app_refresh",state:{selectedTerms:e}})}}getState(e){return{dslabel:e.dslabel,termTypeGroup:e.termTypeGroup,usecase:e.tree.usecase,isVisible:!e.submenu.term,selectedTerms:e.selectedTerms,termfilter:e.termfilter}}addTabsAllowed(e){var s;return I(this,void 0,void 0,(function*(){for(const i of this.types){const r=u[i];let a=r;if(i==m.GENE_VARIANT){const e=[];if(this.app.vocabApi.termdbConfig.queries.snvindel)e.push("Mutation");if(this.app.vocabApi.termdbConfig.queries.cnv)e.push("CNV");if(this.app.vocabApi.termdbConfig.queries.svfusion)e.push("Fusion");if(e.length==0)continue;a=e.join("/")}if(i==m.SNP_LIST||i==m.SNP_LOCUS){continue}if(r&&!this.tabs.some((e=>e.label==r))){if(e.usecase.target=="regression"){if(i==m.SNP)continue;if(i==m.GENE_VARIANT&&e.usecase.detail!="independent")continue}if(e.usecase.target=="sampleScatter"){if(e.usecase.detail=="numeric"&&!h.has(i))continue}if((e.usecase.target=="survival"||e.usecase.target=="cuminc")&&r!=t.DICTIONARY_VARIABLES){if(e.usecase.detail=="term")continue}if(e.usecase.target=="dataDownload"){if(i==m.SNP)continue}if(e.usecase.target&&((s=this.useCasesExcluded[e.usecase.target])===null||s===void 0?void 0:s.includes(r)))continue;try{if(!this.usesDefaultSearch(r)){const e=yield F(`./handlers/${i}.ts`);this.handlerByType[i]=yield new e.SearchHandler;if(!this.handlerByType[i].init)throw"init not implemented"}this.addLoadTopTerms(i)}catch(e){throw`error with handler='./handlers/${i}.ts': ${e}`}this.tabs.push({label:a,callback:()=>this.setTermTypeGroup(i,r),termTypeGroup:r})}}}))}usesDefaultSearch(e){return e==t.DICTIONARY_VARIABLES||e==t.METABOLITE_INTENSITY}addLoadTopTerms(e){return I(this,void 0,void 0,(function*(){if(e==m.METABOLITE_INTENSITY)this.dom.submitDiv.append("button").style("margin-left","5px").text("Load top terms").on("click",(()=>I(this,void 0,void 0,(function*(){const t={filter0:this.state.termfilter.filter0,filter:this.state.termfilter.filter,type:e};const s=yield this.app.vocabApi.getTopTermsByType(t);this.selectTerms(s.terms)}))))}))}selectTerms(e){this.app.dispatch({type:"app_refresh",state:{selectedTerms:e}})}setTermTypeGroup(e,s){return I(this,void 0,void 0,(function*(){yield this.app.dispatch({type:"set_term_type_group",value:s});const i=this.tabs.find((e=>e.termTypeGroup==s));if(!i)return;const r=i.contentHolder;r.selectAll("*").remove();if(i.termTypeGroup!=t.DICTIONARY_VARIABLES&&i.termTypeGroup!=t.METABOLITE_INTENSITY){const t=this.handlerByType[e];yield t.init({holder:r,app:this.app,genomeObj:this.genomeObj,callback:e=>this.selectTerm(e)})}}))}selectTerm(e){if(this.click_term)this.click_term(e);else if(this.submit_lst){this.app.dispatch({type:"app_refresh",state:{selectedTerms:[...this.state.selectedTerms,e]}})}else this.app.dispatch({type:"submenu_set",submenu:{term:e,type:"tvs"}})}}const z=e(q);class K{constructor(e){this.type="submenu";this.dom={holder:e.holder};H(this)}reactsTo(e){if(e.type.startsWith("submenu_"))return true;if(e.type=="app_refresh")return true}getState(e){return{type:e.submenu.type,term:e.submenu.term,termfilter:e.termfilter}}main(){if(!this.state.term){this.dom.holder.style("display","none");return}if(this.state.type=="tvs")this.showTvsMenu(this.state.term);else throw`unsupported submenu.type='${this.state.type}'`}}const W=e(K);function H(e){e.showTvsMenu=function(t){e.dom.holder.selectAll("*").remove();e.dom.holder.style("display","block").append("div").style("margin","10px").append("span").html("&laquo; Back to variable selection").attr("class","sja_clbtext").on("click",(()=>e.app.dispatch({type:"submenu_set",submenu:{}})));e.dom.holder.style("display","block").append("div").style("margin","15px 0px 5px 10px").style("font-weight","bold").style("font-size",".9em").text(t.name);T({term:t,filter:e.state.termfilter.filter,holder:e.dom.holder.append("div"),vocabApi:e.app.vocabApi,debug:e.app.debug,getCategoriesArguments:e.app.opts.getCategoriesArguments,callback:e.app.opts.tree.click_term2select_tvs})}}class J{constructor(e){this.type="search";this.customEvents=["postSearch"];Z(this);Q(this);this.dom={holder:e.holder};this.isVisible="isVisible"in e?e.isVisible:true}async init(e){this.initUI(this.getState(e))}reactsTo(e){if(e.type=="set_term_type_group")return true;if(e.type=="app_refresh")return true;const t=e.type.split("_")[0];return["search","cohort","submenu"].includes(t)}getState(e){return{isVisible:!e.submenu.term&&this.isVisible,cohortStr:e.activeCohort==-1||!e.termdbConfig.selectCohort?"":e.termdbConfig.selectCohort.values[e.activeCohort].keys.slice().sort().join(","),allowedTermTypes:e.termdbConfig?.allowedTermTypes||[],expandedTermIds:e.tree.expandedTermIds,selectedTerms:e.selectedTerms,usecase:e.tree.usecase,search:e.search,isGeneSetTermdb:e.termdbConfig.isGeneSetTermdb,termTypeGroup:e.termTypeGroup}}isTermTypeSupported(){const e=this.state.termTypeGroup;if(e==t.DICTIONARY_VARIABLES)return true;if(e==t.METABOLITE_INTENSITY)return true;return false}async main(){if(!this.isTermTypeSupported()){this.dom.holder.style("display","none");return}this.dom.input.node().value="";this.dom.input.attr("placeholder","Search "+this.state.termTypeGroup);this.clear();this.dom.holder.style("display",this.state.isVisible?"block":"none")}async doSearch(e){if(!e||e.length<3){this.clear();this.bus.emit("postSearch",[]);return}const t=await this.app.vocabApi.findTerm(e,this.state.cohortStr,this.state.usecase,this.state.termTypeGroup);this.currData=t;if(!t.lst||t.lst.length==0){this.noResult()}else{this.showTerms(t)}this.bus.emit("postSearch",t)}}const X=e(J);function Z(e){e.initUI=t=>{e.dom.holder.style("display",e.search&&e.search.isVisible==false?"none":"block");const s=e.dom.holder.append("div").style("text-align","left");e.dom.input=s.append("input").attr("type","search").attr("class","tree_search").style("width","250px").style("margin","10px").style("display","inline-block").on("input",a.debounce(e.onInput,300)).on("keyup",e.onKeyup);e.dom.resultCntDiv=s.append("div").style("display","none");if(e.opts.focus!="off")e.dom.input.node().focus();e.dom.resultDiv=(e.opts.resultsHolder||e.dom.holder).append("div").attr("class","sjpp_show_scrollbar").style("max-height","35vh").style("display","none").style("grid-template-columns","auto auto");const i=e.dom.resultDiv.append("div");const r=e.dom.resultDiv.append("div");e.dom.resultDiv_genes=i.append("div").style("border-left","solid 1px rgb(133,182,225)").style("margin","0px 0px 10px 10px").style("padding-left","5px");e.dom.resultDiv_terms=r.append("div").style("border-left",e.opts.resultsHolder?"":"solid 1px rgb(133,182,225)").style("margin","0px 0px 10px 10px").style("padding-left","5px")};e.getPrompt=e=>{const t=e.allowedTermTypes.includes("geneVariant")&&v({type:"geneVariant"},e.usecase).has("plot");if(t)return" variables or genes";if(e.isGeneSetTermdb)return" gene sets";return" variables"};e.noResult=()=>{e.clear();e.dom.resultDiv.style("display","inline-grid");e.dom.resultDiv_terms.append("div").style("padding","3px 3px 3px 0px").style("opacity",.5).text("No match"+(e.app.vocabApi.termdbConfig?.queries?.snvindel?.allowSNPs?". Press ENTER to search SNP":""))};e.showTerms=t=>{if(e.opts.disable_terms){t.lst.forEach((t=>{if(t.disabled)e.opts.disable_terms.push(t)}))}e.clear();e.dom.resultDiv.style("display","inline-grid");const s=[],i=[];for(const e of t.lst){if(e.type=="geneVariant"){s.push(e)}else{i.push(e)}}if(s.length){e.dom.resultDiv_genes.append("table").selectAll().data(s).enter().append("tr").each(e.showTerm)}if(i.length){e.dom.resultDiv_terms.append("table").selectAll().data(i).enter().append("tr").each(e.showTerm)}if(t.lst.length>1)e.dom.resultCntDiv.style("display","inline-block").text(`${t.lst.length} results`);e.focusableResults=[...e.dom.resultDiv.node().querySelectorAll(".sja_tree_click_term, .sja_menuoption")]};e.showTerm=function(t){const i=s(this);const r=i.append("td").text(t.name);const a=v(t,e.state.usecase,e.app.vocabApi.termdbConfig);if((e.opts.click_term||e.app.opts?.tree?.click_term_wrapper)&&a.has("plot")){if(t&&e.opts.disable_terms?.find((e=>f(t,e)))){r.attr("class","sja_tree_click_term_disabled").style("display","block").style("padding","5px 8px").style("margin","1px 0px").style("opacity",.4)}else{r.attr("class","ts_pill sja_filter_tag_btn sja_tree_click_term").attr("tabindex",0).style("display","block").style("color","black").style("padding","5px 8px").style("border-radius","6px").style("background-color",t.type=="geneVariant"?"rgba(251,171,96,0.5)":"#cfe2f3").style("margin","1px 0px").style("cursor","default").on("click",(()=>{if(e.opts.click_term){e.opts.click_term(t)}else{e.app.opts.tree.click_term_wrapper(t)}e.clear();e.dom.input.property("value","")})).on("keyup",e.navInputValueByKeyboard)}if(t.samplecount!==undefined){i.append("td").append("div").style("font-size",".8em").style("display","inline-block").style("margin-left","5px").style("color",t.samplecount?"#777":"#ddd").text("n="+t.samplecount)}}else{r.attr("class","sja_menuoption").attr("tabindex",0).on("click",(()=>{e.clear();e.dom.input.property("value","");const s=[A];if(t.type=="geneVariant"&&e.opts.handleGeneVariant){e.opts.handleGeneVariant(t)}else if(y(t.type)){e.app.dispatch({type:"app_refresh",state:{selectedTerms:[...e.state.selectedTerms,t]}})}else{if(t.__ancestors){s.push(...t.__ancestors)}if(!e.app.vocabApi.graphable(t))s.push(t.id);e.app.dispatch({type:"app_refresh",state:{tree:{expandedTermIds:s}}})}})).on("keyup",e.navInputValueByKeyboard)}i.append("td").text(t.type=="geneVariant"?"gene variant":(t.__ancestorNames||[]).join(" > ")).style("opacity",.5).style("font-size",".7em")};e.clear=()=>{e.dom.resultDiv_genes.selectAll("*").remove();e.dom.resultDiv_terms.selectAll("*").remove();e.dom.resultDiv.style("display","none");e.dom.resultCntDiv.style("display","none")}}function Q(e){e.onKeyup=t=>{if(t.key=="ArrowDown"&&e.currData?.lst?.length){e.dom.resultDiv.select(".sja_tree_click_term, .sja_menuoption").node().focus();return}if(!o(t))return;e.onInput(t)};e.onInput=async t=>{const s=e.dom.input.property("value");try{await e.doSearch(s)}catch(t){e.clear();e.dom.resultDiv.style("display","inline-grid");l(e.dom.resultDiv_terms,"Error: "+(t.message||t));if(t.stack)console.log(t.stack)}};e.navInputValueByKeyboard=t=>{if(t.key=="Enter")t.target.click();else if(t.key.startsWith("Arrow")){const s=e.focusableResults.findIndex((e=>e===t.target));if(t.key=="ArrowDown"){if(s<e.focusableResults.length-1)e.focusableResults[s+1].focus();else e.focusableResults[0].focus()}else if(t.key=="ArrowUp"){if(s!=0)e.focusableResults[s-1].focus();else e.focusableResults[e.focusableResults.length-1].focus()}}}}class ee{constructor(e){this.type="app";if(!e.holder)s("body").append("div");const t=e.holder.append("div").style("display",e.tree?.submit_lst?"":"none").style("text-align","center").style("margin","10px 5px");const i=t.append("button").property("disabled",true).text(this.noSelectionPrompt).on("click",(()=>this.opts.tree?.submit_lst(this.state.selectedTerms)));const r=e.holder.append("div");const a=r.append("div").style("display","inline-block");const o=r.append("div").style("display","inline-block").style("vertical-align","top");this.dom={topbar:r,holder:e.holder,termTypeSearchDiv:a,searchDiv:o.append("div"),treeDiv:o.append("div"),customTermDiv:o.append("div").style("margin","10px"),submitDiv:t,submitBtn:i,filterDiv:r.append("div").style("display","none"),errdiv:e.holder.append("div"),tip:new p({padding:"5px"})}}validateOpts(e){if(e.vocabApi);else if(e.state&&e.state.vocab){if(typeof e.state.vocab!="object")throw"opts.state.vocab{} is not an object"}else if(e.state&&e.state.genome){const t=e.state;if(!t.vocab)t.vocab={};t.vocab.genome=t.genome;delete t.genome;if(t.dslabel){t.vocab.dslabel=t.dslabel;delete t.dslabel}}else{throw"neither state.vocab{} or opts.vocabApi provided"}if(e.tree){if(e.tree.disable_terms&&!e.tree.click_term&&!e.tree.click_term2select_tvs&&(!e.barchart||!e.barchart.bar_click_override)){throw`opts.tree.disable_terms is used only when opts.tree.click_term, opts.tree.click_term2select_tvs, or opts.barchart.bar_click_override is set`}if(!e.search)e.search={};if(e.tree.click_term2select_tvs){e.search.click_term=e=>this.api.dispatch({type:"submenu_set",submenu:{term:e,type:"tvs"}})}if(e.tree.click_term){e.tree.click_term_wrapper=async t=>{if(this.state.termdbConfig.termMatch2geneSet){const e=await d("termdb",{body:{genome:this.state.vocab.genome,dslabel:this.state.vocab.dslabel,genesetByTermId:t.id}});t._geneset=e}e.tree.click_term(t)}}if(e.tree.disable_terms)e.search.disable_terms=e.tree.disable_terms}return e}async preApiFreeze(e){try{if(this.opts.vocabApi){e.vocabApi=this.opts.vocabApi}else{const t={vocab:this.opts.state.vocab||{genome:this.opts.state.genome,dslabel:this.opts.state.dslabel}};e.vocabApi=await x({app:this.api,state:t,fetchOpts:this.opts.fetchOpts})}e.appInit=te}catch(e){console.log(e);throw e}}async init(){try{this.store=await Y({app:this.api,state:this.opts.state});this.state=await this.store.copyState();await this.setComponents();await this.api.dispatch()}catch(e){this.printError(e)}}async setComponents(){try{const e=this.state.nav?.header_mode;const t={search:X({app:this.api,holder:this.dom.searchDiv,isVisible:e!=="hide_search"}),termTypeSearch:z({app:this.api,holder:this.dom.termTypeSearchDiv,topbar:this.dom.topbar,genome:this.opts.vocabApi?.app?.opts?.genome,click_term:this.opts.tree?.click_term,submit_lst:this.opts.tree?.submit_lst,submitDiv:this.dom.submitDiv}),tree:P({app:this.api,holder:this.dom.treeDiv,headerDiv:this.dom.headerDiv,expandAll:e=="hide_search"})};if(this.opts.tree&&this.opts.tree.click_term2select_tvs){t.submenu=W({app:this.api,holder:this.dom.holder.append("div").style("display","none")})}this.components=await c(t)}catch(e){throw e}}async main(){this.api.vocabApi.main();const e=this.state.selectedTerms.length;this.dom.submitBtn.property("disabled",!e).text(!e?"Search or click term(s)":`Submit ${e} term${e>1?"s":""}`);await this.mayShowCustomTerms();this.dom.holder.selectAll("search, .termbtn, button").attr("tabindex",0);this.dom.holder.selectAll(".termbtn").on("keyup",(e=>{if(e.key=="Enter")e.target.click()}))}printError(e){l(this.dom.errdiv,"Error: "+(e.message||e));if(e.stack)console.log(e.stack)}async mayShowCustomTerms(){if(Object.keys(this.state.submenu).length)return this.dom.customTermDiv.style("display","none");const e=await this.api.vocabApi.getCustomTerms();if(!Array.isArray(e)||e.length==0)return this.dom.customTermDiv.style("display","none");const t=[];for(const s of e){const e=v(s.term,this.state.tree.usecase,this.state.termdbConfig);if(e.has("plot"))t.push(s)}if(t.length==0)return this.dom.customTermDiv.style("display","none");this.dom.customTermDiv.selectAll("*").remove();this.dom.customTermDiv.append("div").text("CUSTOM VARIABLES").style("font-size",".7em");for(const e of t){this.dom.customTermDiv.append("div").style("margin-bottom","3px").append("div").text(e.term.name).attr("class","sja_filter_tag_btn").style("padding","3px 6px").style("border-radius","6px").on("click",(()=>{if(!this.opts.tree)return;if(this.opts.tree.click_term){this.opts.tree.click_term(e);return}if(this.opts.tree.click_term2select_tvs){this.api.dispatch({type:"submenu_set",submenu:{term:e.term,type:"tvs"}});return}}))}}}const te=n(ee);export{te as appInit};
1
+ import{h as e,T as t,d as s,Y as i,i as r,a,k as o,y as l,o as n,M as p,b as d,K as c}from"./app-0de0ae35.js";import{T as m,n as h,t as u,e as f,d as y}from"./termsetting-2e75e729.js";import{g as b,i as v,a as _,f as g,s as T,v as x}from"./FilterRxComp-fb608459.js";import{termInfoInit as S}from"./termInfo-5477ba96.js";import{_ as I}from"./tslib.es6-c3c2d88f.js";import{T as k}from"./toggleButtons-7ce58d97.js";import"path";import"./table-e2a307e6.js";import"./partjson.esm-b3f1fc21.js";import"./termdb.bins-7ecc48db.js";const C="25px";const A="root";const w=20;const N="400px";const D="termdiv",E="termchilddiv",O="termbtn",j="termlabel",L="termloading",B="termcheck";class V{constructor(e){this.type="tree";G(this);R(this);this.loadingTermSet=new Set;this.termsByCohort={};this.expandAll="expandAll"in e?e.expandAll:false}init(){this.dom={holder:this.opts.holder.append("div")}}reactsTo(e){if(e.type.startsWith("tree_"))return true;if(e.type.startsWith("filter_"))return true;if(e.type.startsWith("cohort_"))return true;if(e.type.startsWith("info_"))return true;if(e.type.startsWith("submenu_"))return true;if(e.type=="app_refresh")return true;if(e.type=="set_term_type_group")return true}getState(e){const t=b(e.termfilter.filter);const s={isVisible:!e.submenu.term,activeCohort:e.activeCohort,expandedTermIds:e.tree.expandedTermIds,selectedTerms:e.selectedTerms,termfilter:{filter:t},usecase:e.tree.usecase,termTypeGroup:e.termTypeGroup};if(e.termdbConfig.selectCohort){s.toSelectCohort=true;const t=e.termdbConfig.selectCohort.values[e.activeCohort];if(t){s.cohortValuelst=t.keys}}return s}async main(){if(this.state.termTypeGroup!=t.DICTIONARY_VARIABLES){this.dom.holder.style("display","none");return}if(!this.state.isVisible){this.dom.holder.style("display","none");return}if(this.state.toSelectCohort){if(!this.state.cohortValuelst){return}}this.termsById=this.getTermsById();const e=this.termsById[A];e.terms=await this.requestTermRecursive(e);this.dom.holder.style("display","block");await this.renderBranch(e,this.dom.holder);this.dom.holder.selectAll(".termbtn, .sja_tree_click_term").attr("tabindex",0).attr("data-testid","sjpp_termdbbutton").on("keyup",(e=>{if(e.key=="Enter")e.target.click()}))}getTermsById(){if(!(this.state.activeCohort in this.termsByCohort)){this.termsByCohort[this.state.activeCohort]={[A]:{id:A,__tree_isroot:true}}}return this.termsByCohort[this.state.activeCohort]}async requestTermRecursive(e){const t=await this.app.vocabApi.getTermChildren(e,this.state.toSelectCohort?this.state.cohortValuelst:null);if(t.error)throw t.error;if(!t.lst||t.lst.length==0){return[]}const s=[];for(const e of t.lst){const t=Object.assign({},e);s.push(t);if(this.state.expandedTermIds.includes(t.id)){t.terms=await this.requestTermRecursive(t)}else{const e=this.termsById[t.id];if(e&&e.terms){t.terms=e.terms}}this.termsById[t.id]=t}return s}bindKey(e){return e.id}}const P=e(V);function R(e){e.renderBranch=(t,s,i)=>{if(!t||!t.terms)return;if(t.terms.length>=w){if(s.classed("sjpp_show_scrollbar"));else{s.style("max-height",N).style("padding","10px").style("resize","vertical").classed("sjpp_show_scrollbar",true)}}if(e.opts.disable_terms){t.terms.forEach((t=>{if(t.disabled)e.opts.disable_terms.push(t)}))}e.included_terms=[];if(e.state.usecase){for(const s of t.terms){if(v(s,e.state.usecase,e.app.vocabApi.termdbConfig).size){e.included_terms.push(s)}}}else{e.included_terms.push(...t.terms)}if(!(t.id in e.termsById)||!e.included_terms.length){s.style("display","none");return}if(e.loadingTermSet.has(t.id)){e.loadingTermSet.delete(t.id);s.select("."+L).remove()}const r=e.state.expandedTermIds;if(!r.includes(t.id)){s.style("display","none");if(i)i.text("+");return}s.style("display","block");if(i)i.text("-");const a=s.selectAll("."+D).data(e.included_terms,e.bindKey);a.exit().each(e.hideTerm);a.each(e.updateTerm);a.enter().append("div").each(e.addTerm);for(const i of t.terms){if(r.includes(i.id)){e.renderBranch(i,s.selectAll("."+E).filter((e=>e.id==i.id)),s.selectAll("."+O).filter((e=>e.id==i.id)))}}};e.hideTerm=function(t){if(t.id in e.termsById&&e.state.expandedTermIds.includes(t.id))return;s(this).style("display","none")};e.updateTerm=function(t){const i=s(this);if(!(t.id in e.termsById)){i.style("display","none");return}const r=e.opts.disable_terms?.includes(t.id);const a=v(t,e.state.usecase,e.app.vocabApi.termdbConfig);i.style("display","");const o=e.state.expandedTermIds.includes(t.id);i.select("."+O).text(o?"-":"+");i.select("."+E).style("display",o?"block":"none");const l=e.state.selectedTerms.find((e=>e.name===t.name&&e.type===t.type));i.select("."+j).style("background-color",!a.has("plot")||r?"":l?"rgba(255, 194, 10,0.5)":"#cfe2f3");i.select("."+B).style("display",a.has("plot")&&l&&!r?"inline-block":"none")};e.addTerm=async function(t){const i=e.opts.disable_terms?.includes(t.id);const r=v(t,e.state.usecase,e.app.vocabApi.termdbConfig);const a=s(this).attr("class",D).style("margin",t.isleaf?"":"2px").style("padding","0px 5px");if(r.has("branch")){a.append("div").attr("class","sja_menuoption "+O).style("display","inline-block").style("padding","4px 9px").style("font-family","courier").text("+").on("click",(s=>{s.stopPropagation();e.toggleBranch(t)}));if(e.expandAll)e.toggleBranch(t)}const o=e.state.selectedTerms.find((e=>e.name===t.name&&e.type===t.type));const l=a.append("div").attr("class",j).style("display","inline-block").style("padding","5px").style("opacity",i?.4:null).text(t.name);let n;if(t.hashtmldetail){n=a.append("div").style("display","inline-block")}if(r.size>0){if(i){l.attr("class","sja_tree_click_term_disabled "+j).style("padding","5px 8px").style("margin","1px 0px").style("opacity",.7)}else if(r.has("plot")){l.attr("class","ts_pill sja_filter_tag_btn sja_tree_click_term "+j).style("color","black").style("padding","5px 8px").style("border-radius","6px").style("background-color",o?"rgba(255, 194, 10,0.5)":"#cfe2f3").style("margin","1px 0px").style("cursor","default").on("click",(()=>e.clickTerm(t)))}if(t.samplecount!==undefined){a.append("div").style("font-size",".8em").style("display","inline-block").style("margin-left","5px").style("color",t.samplecount?"#777":"#ddd").text("n="+t.samplecount)}}if(t.hashtmldetail){S({vocabApi:e.app.vocabApi,icon_holder:n,content_holder:a.append("div"),id:t.id,state:{term:t}})}if(e.opts.submit_lst){a.append("div").attr("class",B).style("color","#008000").style("display",o?"inline-block":"none").html("&check;")}if(!t.isleaf){a.append("div").attr("class",E).style("padding-left",C)}}}function G(e){e.toggleBranch=function(t){if(t.isleaf)return;const i=e.termsById[t.id];if(!i)throw"invalid term id";if(!i.terms){if(e.loadingTermSet.has(i.id))return;e.loadingTermSet.add(i.id);s(this.parentNode).selectAll("."+E).filter((e=>e.id===i.id)).style("display","block").append("div").text("Loading...").attr("class",L).style("opacity",.5).style("padding","5px")}const r=e.state.expandedTermIds.includes(t.id);const a=r?"tree_collapse":"tree_expand";e.app.dispatch({type:a,termId:t.id})};e.clickTerm=async t=>{if(e.opts.click_term2select_tvs){e.app.dispatch({type:"submenu_set",submenu:{term:t,type:"tvs"}});return}if(e.opts.click_term_wrapper){e.opts.click_term_wrapper(t);return}if(e.opts.submit_lst){const s=e.state.selectedTerms.findIndex((e=>e.name===t.name));if(s==-1){e.app.dispatch({type:"app_refresh",state:{selectedTerms:[...e.state.selectedTerms,t]}})}else{const t=e.state.selectedTerms.slice(0);t.splice(s,1);e.app.dispatch({type:"app_refresh",state:{selectedTerms:t}})}return}throw"missing term click callback"}}const U={header_mode:"search_only",activeCohort:0,tree:{usecase:{},expandedTermIds:[]},submenu:{},search:{isVisible:true},selectedTerms:[],termfilter:{filter:{type:"tvslst",in:true,join:"",lst:[]}}};class M{constructor(e){this.type="store";this.defaultState=U;i(this,e);this.prevGeneratedId=0}validateOpts(e){if(!e.state)throw".state{} missing";const t=e.state;if(t.vocab){if(t.vocab.dslabel){if(!t.vocab.genome)throw".state[.vocab].genome missing"}else if(t.vocab.genome){if(!t.vocab.dslabel)throw".state[.vocab].dslabel missing"}else{if(!Array.isArray(t.vocab.terms))throw"vocab.terms must be an array of objects"}}}validateState(){const e=this.state;if(e.tree.expandedTermIds.length==0){e.tree.expandedTermIds.push(A)}else{if(e.tree.expandedTermIds[0]!=A){e.tree.expandedTermIds.unshift(A)}}}async init(){this.state.termdbConfig=await this.app.vocabApi.getTermdbConfig();let e=_(this.state.termfilter.filter,"filterUiRoot");if(!e){this.state.termfilter.filter.tag="filterUiRoot";e=this.state.termfilter.filter}if(this.state.termdbConfig.selectCohort){let t=_(this.state.termfilter.filter,"cohortFilter");if(!t){t={tag:"cohortFilter",type:"tvs",tvs:{term:JSON.parse(JSON.stringify(this.state.termdbConfig.selectCohort.term)),values:this.state.activeCohort==-1?[]:this.state.termdbConfig.selectCohort.values[this.state.activeCohort].keys.map((e=>({key:e,label:e})))}};this.state.termfilter.filter={type:"tvslst",in:true,join:"and",lst:[t,e]}}else{const e=(e,t)=>e<t?-1:1;t.tvs.values.sort(((e,t)=>e.key<t.key?-1:1));const s=JSON.stringify(t.tvs.values.map((e=>e.key)).sort(e));const i=this.state.termdbConfig.selectCohort.values.findIndex((t=>s==JSON.stringify(t.keys.sort(e))));if(this.state.activeCohort!==-1&&this.state.activeCohort!==0&&i!==this.state.activeCohort){console.log("Warning: cohortFilter will override the state.activeCohort due to mismatch")}this.state.activeCohort=i}}else{this.state.activeCohort=-1;if(this.state.header_mode==="with_cohortHtmlSelect"){console.warn(`no termdbConfig.selectCohort to use for state.header_mode = 'with_cohortHtmlSelect'`);this.state.header_mode="search_only"}}}fromJson(e){const t=JSON.parse(e);return t}setId(e){e.$id=this.prevGeneratedId++;if(e.$lst){for(const t of e.$lst){this.setId(t)}}}}M.prototype.actions={app_refresh(e={}){this.state=this.copyMerge(this.toJson(this.state),e.state?e.state:{},this.replaceKeyVals)},cohort_set(e){this.state.activeCohort=e.activeCohort;const t=this.state.termdbConfig.selectCohort.values[e.activeCohort];const s=_(this.state.termfilter.filter,"cohortFilter");if(!s)throw`No item tagged with 'cohortFilter'`;s.tvs.values=t.keys.map((e=>({key:e,label:e})))},tree_expand(e){if(this.state.tree.expandedTermIds.includes(e.termId))return;this.state.tree.expandedTermIds.push(e.termId)},tree_collapse(e){const t=this.state.tree.expandedTermIds.indexOf(e.termId);if(t==-1)return;this.state.tree.expandedTermIds.splice(t,1)},filter_replace(e){const t=e.filter?e.filter:{type:"tvslst",join:"",in:1,lst:[]};if(!e.filter.tag){this.state.termfilter.filter=t}else{const s=_(this.state.termfilter.filter,e.filter.tag);if(!s)throw`cannot replace missing filter with tag '${e.filter.tag}'`;const i=g(this.state.termfilter.filter,s.$id);if(i==s){this.state.termfilter.filter=t}else{const e=i.lst.indexOf(s);i.lst[e]=t}}},submenu_set(e){const t=e.submenu&&e.submenu.term;if(!t){this.state.submenu={};this.state.tree.expandedTermIds=[A]}else{const s=[A];if(t.__ancestors){s.push(...t.__ancestors)}if(v(t,{},this.state.termdbConfig).has("plot")){Object.assign(this.state.submenu,e.submenu)}else{s.push(t.id);delete this.state.submenu.term}this.state.tree.expandedTermIds=s}},set_term_type_group({value:e}){this.state.termTypeGroup=e}};const Y=r(M);function F(e){switch(e){case"./handlers/geneExpression.ts":return import("./geneExpression-072e0be1.js");case"./handlers/geneVariant.ts":return import("./geneVariant-9fc29f37.js");case"./handlers/snp.ts":return import("./snp-a0cdd2a5.js");case"./handlers/snplocus.ts":return import("./snplocus-90e52cf4.js");case"./handlers/snplst.ts":return import("./snplst-7c59f059.js");default:return new Promise((function(t,s){(typeof queueMicrotask==="function"?queueMicrotask:setTimeout)(s.bind(null,new Error("Unknown variable dynamic import: "+e)))}))}}const $={matrix:[t.SNP_LOCUS,t.SNP_LIST],filter:[t.SNP_LOCUS,t.SNP_LIST],dictionary:[t.SNP_LOCUS,t.SNP_LIST],summary:[t.SNP_LOCUS,t.SNP_LIST],barchart:[t.SNP_LOCUS,t.SNP_LIST],violin:[t.SNP_LOCUS,t.SNP_LIST],sampleScatter:[t.SNP_LOCUS,t.SNP_LIST],cuminc:[t.SNP_LOCUS,t.SNP_LIST,t.MUTATION_CNV_FUSION,t.METABOLITE_INTENSITY],dataDownload:[t.MUTATION_CNV_FUSION],survival:[t.SNP_LOCUS,t.SNP_LIST],default:[t.SNP_LOCUS,t.SNP_LIST],regression:[t.SNP_LIST,t.SNP_LOCUS,t.GENE_EXPRESSION,t.METABOLITE_INTENSITY],metaboliteIntensity:[t.SNP_LOCUS,t.SNP_LIST,t.MUTATION_CNV_FUSION,t.DICTIONARY_VARIABLES,t.GENE_EXPRESSION],geneExpression:[t.SNP_LOCUS,t.SNP_LIST,t.MUTATION_CNV_FUSION,t.DICTIONARY_VARIABLES,t.METABOLITE_INTENSITY]};class q{constructor(e){this.type="termTypeSearch";this.genomeObj=e.genome;this.click_term=e.click_term;this.submit_lst=e.submit_lst;const t=e.topbar.append("div").append("div").style("width","99%").style("display","flex").style("flex-wrap","wrap").style("gap","5px").style("min-height","20px").style("border","solid 1px #aaa").style("margin","10px 0px").style("padding","6px 2px").style("min-height","30px");this.types=[];this.tabs=[];this.handlerByType={};this.dom={holder:e.holder,topbar:e.topbar,selectedTermsDiv:t,submitDiv:e.submitDiv};this.useCasesExcluded=structuredClone($)}init(e){var s,i,r;return I(this,void 0,void 0,(function*(){this.types=((s=this.app.vocabApi.termdbConfig)===null||s===void 0?void 0:s.allowedTermTypes)||["categorical"];if(!this.types)return;if((i=this.app.vocabApi.termdbConfig)===null||i===void 0?void 0:i.useCasesExcluded)Object.assign(this.useCasesExcluded,(r=this.app.vocabApi.termdbConfig)===null||r===void 0?void 0:r.useCasesExcluded);const a=this.getState(e);yield this.addTabsAllowed(a);if(this.submit_lst)this.dom.clearbt=this.dom.submitDiv.append("button").style("margin-left","5px").text("Clear").on("click",(()=>this.selectTerms([])));if(this.tabs.length==0)throw"No term types allowed for this use case";this.app.dispatch({type:"set_term_type_group",value:this.tabs[0].termTypeGroup});if(this.tabs.length==1&&this.tabs[0].termTypeGroup==t.DICTIONARY_VARIABLES)return;new k({holder:this.dom.holder,tabsPosition:"vertical",linePosition:"right",tabs:this.tabs}).main();for(const[e]of this.tabs.entries()){const t=this.tabs[e].contentHolder.style("padding-left","20px");t.append("div")}}))}reactsTo(e){if(e.type.startsWith("submenu_"))return true;if(e.type=="set_term_type_group")return true;if(e.type=="app_refresh")return true}main(){this.dom.holder.style("display",this.state.isVisible?"inline-block":"none");this.dom.topbar.style("display",this.state.isVisible?"inline-block":"none");if(this.submit_lst){this.renderTermsSelected();this.dom.selectedTermsDiv.style("display",this.state.selectedTerms.length>0?"inline-block":"none")}else this.dom.selectedTermsDiv.style("display","none");this.renderTermsSelected();if(this.dom.clearbt)this.dom.clearbt.property("disabled",this.state.selectedTerms.length==0)}renderTermsSelected(){this.dom.selectedTermsDiv.selectAll("*").remove();this.dom.selectedTermsDiv.selectAll("div").data(this.state.selectedTerms).enter().append("div").attr("aria-label","Click to delete").attr("class","sja_menuoption").attr("tabindex",0).style("position","relative").style("display","inline-block").style("padding","5px 16px 5px 9px").style("margin-left","5px").each(e).on("click",((e,t)=>this.deleteTerm(e,t))).on("mouseover",(function(e){const t=`<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="#000" class="bi bi-x-lg" viewBox="0 0 16 16">\n\t\t\t\t<path stroke='#f00' d="M2.146 2.854a.5.5 0 1 1 .708-.708L8 7.293l5.146-5.147a.5.5 0 0 1 .708.708L8.707 8l5.147 5.146a.5.5 0 0 1-.708.708L8 8.707l-5.146 5.147a.5.5 0 0 1-.708-.708L7.293 8 2.146 2.854Z"/>\n\t\t\t\t</svg>`;const i=s(e.target);i.append("div").style("margin-left","4px").classed("sjpp_deletebt",true).style("display","inline-block").style("position","absolute").style("right","0px").style("top","0px").style("transform","scale(0.6)").style("pointer-events","none").html(t)})).on("mouseout",(function(e){s(e.target).select(".sjpp_deletebt").remove()}));function e(e){const t=s(this).style("border-radius","5px");t.insert("div").style("display","inline-block").html(e.name)}}deleteTerm(e,t){const s=this.state.selectedTerms.findIndex((e=>e.name===t.name));if(s!=-1){const e=[...this.state.selectedTerms];e.splice(s,1);this.app.dispatch({type:"app_refresh",state:{selectedTerms:e}})}}getState(e){return{dslabel:e.dslabel,termTypeGroup:e.termTypeGroup,usecase:e.tree.usecase,isVisible:!e.submenu.term,selectedTerms:e.selectedTerms,termfilter:e.termfilter}}addTabsAllowed(e){var s;return I(this,void 0,void 0,(function*(){for(const i of this.types){const r=u[i];let a=r;if(i==m.GENE_VARIANT){const e=[];if(this.app.vocabApi.termdbConfig.queries.snvindel)e.push("Mutation");if(this.app.vocabApi.termdbConfig.queries.cnv)e.push("CNV");if(this.app.vocabApi.termdbConfig.queries.svfusion)e.push("Fusion");if(e.length==0)continue;a=e.join("/")}if(i==m.SNP_LIST||i==m.SNP_LOCUS){continue}if(r&&!this.tabs.some((e=>e.label==r))){if(e.usecase.target=="regression"){if(i==m.SNP)continue;if(i==m.GENE_VARIANT&&e.usecase.detail!="independent")continue}if(e.usecase.target=="sampleScatter"){if(e.usecase.detail=="numeric"&&!h.has(i))continue}if((e.usecase.target=="survival"||e.usecase.target=="cuminc")&&r!=t.DICTIONARY_VARIABLES){if(e.usecase.detail=="term")continue}if(e.usecase.target=="dataDownload"){if(i==m.SNP)continue}if(e.usecase.target&&((s=this.useCasesExcluded[e.usecase.target])===null||s===void 0?void 0:s.includes(r)))continue;try{if(!this.usesDefaultSearch(r)){const e=yield F(`./handlers/${i}.ts`);this.handlerByType[i]=yield new e.SearchHandler;if(!this.handlerByType[i].init)throw"init not implemented"}this.addLoadTopTerms(i)}catch(e){throw`error with handler='./handlers/${i}.ts': ${e}`}this.tabs.push({label:a,callback:()=>this.setTermTypeGroup(i,r),termTypeGroup:r})}}}))}usesDefaultSearch(e){return e==t.DICTIONARY_VARIABLES||e==t.METABOLITE_INTENSITY}addLoadTopTerms(e){return I(this,void 0,void 0,(function*(){if(e==m.METABOLITE_INTENSITY)this.dom.submitDiv.append("button").style("margin-left","5px").text("Load top terms").on("click",(()=>I(this,void 0,void 0,(function*(){const t={filter0:this.state.termfilter.filter0,filter:this.state.termfilter.filter,type:e};const s=yield this.app.vocabApi.getTopTermsByType(t);this.selectTerms(s.terms)}))))}))}selectTerms(e){this.app.dispatch({type:"app_refresh",state:{selectedTerms:e}})}setTermTypeGroup(e,s){return I(this,void 0,void 0,(function*(){yield this.app.dispatch({type:"set_term_type_group",value:s});const i=this.tabs.find((e=>e.termTypeGroup==s));if(!i)return;const r=i.contentHolder;r.selectAll("*").remove();if(i.termTypeGroup!=t.DICTIONARY_VARIABLES&&i.termTypeGroup!=t.METABOLITE_INTENSITY){const t=this.handlerByType[e];yield t.init({holder:r,app:this.app,genomeObj:this.genomeObj,callback:e=>this.selectTerm(e)})}}))}selectTerm(e){if(this.click_term)this.click_term(e);else if(this.submit_lst){this.app.dispatch({type:"app_refresh",state:{selectedTerms:[...this.state.selectedTerms,e]}})}else this.app.dispatch({type:"submenu_set",submenu:{term:e,type:"tvs"}})}}const z=e(q);class K{constructor(e){this.type="submenu";this.dom={holder:e.holder};H(this)}reactsTo(e){if(e.type.startsWith("submenu_"))return true;if(e.type=="app_refresh")return true}getState(e){return{type:e.submenu.type,term:e.submenu.term,termfilter:e.termfilter}}main(){if(!this.state.term){this.dom.holder.style("display","none");return}if(this.state.type=="tvs")this.showTvsMenu(this.state.term);else throw`unsupported submenu.type='${this.state.type}'`}}const W=e(K);function H(e){e.showTvsMenu=function(t){e.dom.holder.selectAll("*").remove();e.dom.holder.style("display","block").append("div").style("margin","10px").append("span").html("&laquo; Back to variable selection").attr("class","sja_clbtext").on("click",(()=>e.app.dispatch({type:"submenu_set",submenu:{}})));e.dom.holder.style("display","block").append("div").style("margin","15px 0px 5px 10px").style("font-weight","bold").style("font-size",".9em").text(t.name);T({term:t,filter:e.state.termfilter.filter,holder:e.dom.holder.append("div"),vocabApi:e.app.vocabApi,debug:e.app.debug,getCategoriesArguments:e.app.opts.getCategoriesArguments,callback:e.app.opts.tree.click_term2select_tvs})}}class J{constructor(e){this.type="search";this.customEvents=["postSearch"];Z(this);Q(this);this.dom={holder:e.holder};this.isVisible="isVisible"in e?e.isVisible:true}async init(e){this.initUI(this.getState(e))}reactsTo(e){if(e.type=="set_term_type_group")return true;if(e.type=="app_refresh")return true;const t=e.type.split("_")[0];return["search","cohort","submenu"].includes(t)}getState(e){return{isVisible:!e.submenu.term&&this.isVisible,cohortStr:e.activeCohort==-1||!e.termdbConfig.selectCohort?"":e.termdbConfig.selectCohort.values[e.activeCohort].keys.slice().sort().join(","),allowedTermTypes:e.termdbConfig?.allowedTermTypes||[],expandedTermIds:e.tree.expandedTermIds,selectedTerms:e.selectedTerms,usecase:e.tree.usecase,search:e.search,isGeneSetTermdb:e.termdbConfig.isGeneSetTermdb,termTypeGroup:e.termTypeGroup}}isTermTypeSupported(){const e=this.state.termTypeGroup;if(e==t.DICTIONARY_VARIABLES)return true;if(e==t.METABOLITE_INTENSITY)return true;return false}async main(){if(!this.isTermTypeSupported()){this.dom.holder.style("display","none");return}this.dom.input.node().value="";this.dom.input.attr("placeholder","Search "+this.state.termTypeGroup);this.clear();this.dom.holder.style("display",this.state.isVisible?"block":"none")}async doSearch(e){if(!e||e.length<3){this.clear();this.bus.emit("postSearch",[]);return}const t=await this.app.vocabApi.findTerm(e,this.state.cohortStr,this.state.usecase,this.state.termTypeGroup);this.currData=t;if(!t.lst||t.lst.length==0){this.noResult()}else{this.showTerms(t)}this.bus.emit("postSearch",t)}}const X=e(J);function Z(e){e.initUI=t=>{e.dom.holder.style("display",e.search&&e.search.isVisible==false?"none":"block");const s=e.dom.holder.append("div").style("text-align","left");e.dom.input=s.append("input").attr("type","search").attr("class","tree_search").style("width","250px").style("margin","10px").style("display","inline-block").on("input",a.debounce(e.onInput,300)).on("keyup",e.onKeyup);e.dom.resultCntDiv=s.append("div").style("display","none");if(e.opts.focus!="off")e.dom.input.node().focus();e.dom.resultDiv=(e.opts.resultsHolder||e.dom.holder).append("div").attr("class","sjpp_show_scrollbar").style("max-height","35vh").style("display","none").style("grid-template-columns","auto auto");const i=e.dom.resultDiv.append("div");const r=e.dom.resultDiv.append("div");e.dom.resultDiv_genes=i.append("div").style("border-left","solid 1px rgb(133,182,225)").style("margin","0px 0px 10px 10px").style("padding-left","5px");e.dom.resultDiv_terms=r.append("div").style("border-left",e.opts.resultsHolder?"":"solid 1px rgb(133,182,225)").style("margin","0px 0px 10px 10px").style("padding-left","5px")};e.getPrompt=e=>{const t=e.allowedTermTypes.includes("geneVariant")&&v({type:"geneVariant"},e.usecase).has("plot");if(t)return" variables or genes";if(e.isGeneSetTermdb)return" gene sets";return" variables"};e.noResult=()=>{e.clear();e.dom.resultDiv.style("display","inline-grid");e.dom.resultDiv_terms.append("div").style("padding","3px 3px 3px 0px").style("opacity",.5).text("No match"+(e.app.vocabApi.termdbConfig?.queries?.snvindel?.allowSNPs?". Press ENTER to search SNP":""))};e.showTerms=t=>{if(e.opts.disable_terms){t.lst.forEach((t=>{if(t.disabled)e.opts.disable_terms.push(t)}))}e.clear();e.dom.resultDiv.style("display","inline-grid");const s=[],i=[];for(const e of t.lst){if(e.type=="geneVariant"){s.push(e)}else{i.push(e)}}if(s.length){e.dom.resultDiv_genes.append("table").selectAll().data(s).enter().append("tr").each(e.showTerm)}if(i.length){e.dom.resultDiv_terms.append("table").selectAll().data(i).enter().append("tr").each(e.showTerm)}if(t.lst.length>1)e.dom.resultCntDiv.style("display","inline-block").text(`${t.lst.length} results`);e.focusableResults=[...e.dom.resultDiv.node().querySelectorAll(".sja_tree_click_term, .sja_menuoption")]};e.showTerm=function(t){const i=s(this);const r=i.append("td").text(t.name);const a=v(t,e.state.usecase,e.app.vocabApi.termdbConfig);if((e.opts.click_term||e.app.opts?.tree?.click_term_wrapper)&&a.has("plot")){if(t&&e.opts.disable_terms?.find((e=>f(t,e)))){r.attr("class","sja_tree_click_term_disabled").style("display","block").style("padding","5px 8px").style("margin","1px 0px").style("opacity",.4)}else{r.attr("class","ts_pill sja_filter_tag_btn sja_tree_click_term").attr("tabindex",0).style("display","block").style("color","black").style("padding","5px 8px").style("border-radius","6px").style("background-color",t.type=="geneVariant"?"rgba(251,171,96,0.5)":"#cfe2f3").style("margin","1px 0px").style("cursor","default").on("click",(()=>{if(e.opts.click_term){e.opts.click_term(t)}else{e.app.opts.tree.click_term_wrapper(t)}e.clear();e.dom.input.property("value","")})).on("keyup",e.navInputValueByKeyboard)}if(t.samplecount!==undefined){i.append("td").append("div").style("font-size",".8em").style("display","inline-block").style("margin-left","5px").style("color",t.samplecount?"#777":"#ddd").text("n="+t.samplecount)}}else{r.attr("class","sja_menuoption").attr("tabindex",0).on("click",(()=>{e.clear();e.dom.input.property("value","");const s=[A];if(t.type=="geneVariant"&&e.opts.handleGeneVariant){e.opts.handleGeneVariant(t)}else if(y(t.type)){e.app.dispatch({type:"app_refresh",state:{selectedTerms:[...e.state.selectedTerms,t]}})}else{if(t.__ancestors){s.push(...t.__ancestors)}if(!e.app.vocabApi.graphable(t))s.push(t.id);e.app.dispatch({type:"app_refresh",state:{tree:{expandedTermIds:s}}})}})).on("keyup",e.navInputValueByKeyboard)}i.append("td").text(t.type=="geneVariant"?"gene variant":(t.__ancestorNames||[]).join(" > ")).style("opacity",.5).style("font-size",".7em")};e.clear=()=>{e.dom.resultDiv_genes.selectAll("*").remove();e.dom.resultDiv_terms.selectAll("*").remove();e.dom.resultDiv.style("display","none");e.dom.resultCntDiv.style("display","none")}}function Q(e){e.onKeyup=t=>{if(t.key=="ArrowDown"&&e.currData?.lst?.length){e.dom.resultDiv.select(".sja_tree_click_term, .sja_menuoption").node().focus();return}if(!o(t))return;e.onInput(t)};e.onInput=async t=>{const s=e.dom.input.property("value");try{await e.doSearch(s)}catch(t){e.clear();e.dom.resultDiv.style("display","inline-grid");l(e.dom.resultDiv_terms,"Error: "+(t.message||t));if(t.stack)console.log(t.stack)}};e.navInputValueByKeyboard=t=>{if(t.key=="Enter")t.target.click();else if(t.key.startsWith("Arrow")){const s=e.focusableResults.findIndex((e=>e===t.target));if(t.key=="ArrowDown"){if(s<e.focusableResults.length-1)e.focusableResults[s+1].focus();else e.focusableResults[0].focus()}else if(t.key=="ArrowUp"){if(s!=0)e.focusableResults[s-1].focus();else e.focusableResults[e.focusableResults.length-1].focus()}}}}class ee{constructor(e){this.type="app";if(!e.holder)s("body").append("div");const t=e.holder.append("div").style("display",e.tree?.submit_lst?"":"none").style("text-align","center").style("margin","10px 5px");const i=t.append("button").property("disabled",true).text(this.noSelectionPrompt).on("click",(()=>this.opts.tree?.submit_lst(this.state.selectedTerms)));const r=e.holder.append("div");const a=r.append("div").style("display","inline-block");const o=r.append("div").style("display","inline-block").style("vertical-align","top");this.dom={topbar:r,holder:e.holder,termTypeSearchDiv:a,searchDiv:o.append("div"),treeDiv:o.append("div"),customTermDiv:o.append("div").style("margin","10px"),submitDiv:t,submitBtn:i,filterDiv:r.append("div").style("display","none"),errdiv:e.holder.append("div"),tip:new p({padding:"5px"})}}validateOpts(e){if(e.vocabApi);else if(e.state&&e.state.vocab){if(typeof e.state.vocab!="object")throw"opts.state.vocab{} is not an object"}else if(e.state&&e.state.genome){const t=e.state;if(!t.vocab)t.vocab={};t.vocab.genome=t.genome;delete t.genome;if(t.dslabel){t.vocab.dslabel=t.dslabel;delete t.dslabel}}else{throw"neither state.vocab{} or opts.vocabApi provided"}if(e.tree){if(e.tree.disable_terms&&!e.tree.click_term&&!e.tree.click_term2select_tvs&&(!e.barchart||!e.barchart.bar_click_override)){throw`opts.tree.disable_terms is used only when opts.tree.click_term, opts.tree.click_term2select_tvs, or opts.barchart.bar_click_override is set`}if(!e.search)e.search={};if(e.tree.click_term2select_tvs){e.search.click_term=e=>this.api.dispatch({type:"submenu_set",submenu:{term:e,type:"tvs"}})}if(e.tree.click_term){e.tree.click_term_wrapper=async t=>{if(this.state.termdbConfig.termMatch2geneSet){const e=await d("termdb",{body:{genome:this.state.vocab.genome,dslabel:this.state.vocab.dslabel,genesetByTermId:t.id}});t._geneset=e}e.tree.click_term(t)}}if(e.tree.disable_terms)e.search.disable_terms=e.tree.disable_terms}return e}async preApiFreeze(e){try{if(this.opts.vocabApi){e.vocabApi=this.opts.vocabApi}else{const t={vocab:this.opts.state.vocab||{genome:this.opts.state.genome,dslabel:this.opts.state.dslabel}};e.vocabApi=await x({app:this.api,state:t,fetchOpts:this.opts.fetchOpts})}e.appInit=te}catch(e){console.log(e);throw e}}async init(){try{this.store=await Y({app:this.api,state:this.opts.state});this.state=await this.store.copyState();await this.setComponents();await this.api.dispatch()}catch(e){this.printError(e)}}async setComponents(){try{const e=this.state.nav?.header_mode;const t={search:X({app:this.api,holder:this.dom.searchDiv,isVisible:e!=="hide_search"}),termTypeSearch:z({app:this.api,holder:this.dom.termTypeSearchDiv,topbar:this.dom.topbar,genome:this.opts.vocabApi?.app?.opts?.genome,click_term:this.opts.tree?.click_term,submit_lst:this.opts.tree?.submit_lst,submitDiv:this.dom.submitDiv}),tree:P({app:this.api,holder:this.dom.treeDiv,headerDiv:this.dom.headerDiv,expandAll:e=="hide_search"})};if(this.opts.tree&&this.opts.tree.click_term2select_tvs){t.submenu=W({app:this.api,holder:this.dom.holder.append("div").style("display","none")})}this.components=await c(t)}catch(e){throw e}}async main(){this.api.vocabApi.main();const e=this.state.selectedTerms.length;this.dom.submitBtn.property("disabled",!e).text(!e?"Search or click term(s)":`Submit ${e} term${e>1?"s":""}`);await this.mayShowCustomTerms();this.dom.holder.selectAll("search, .termbtn, button").attr("tabindex",0);this.dom.holder.selectAll(".termbtn").on("keyup",(e=>{if(e.key=="Enter")e.target.click()}))}printError(e){l(this.dom.errdiv,"Error: "+(e.message||e));if(e.stack)console.log(e.stack)}async mayShowCustomTerms(){if(Object.keys(this.state.submenu).length)return this.dom.customTermDiv.style("display","none");const e=await this.api.vocabApi.getCustomTerms();if(!Array.isArray(e)||e.length==0)return this.dom.customTermDiv.style("display","none");const t=[];for(const s of e){const e=v(s.term,this.state.tree.usecase,this.state.termdbConfig);if(e.has("plot"))t.push(s)}if(t.length==0)return this.dom.customTermDiv.style("display","none");this.dom.customTermDiv.selectAll("*").remove();this.dom.customTermDiv.append("div").text("CUSTOM VARIABLES").style("font-size",".7em");for(const e of t){this.dom.customTermDiv.append("div").style("margin-bottom","3px").append("div").text(e.term.name).attr("class","sja_filter_tag_btn").style("padding","3px 6px").style("border-radius","6px").on("click",(()=>{if(!this.opts.tree)return;if(this.opts.tree.click_term){this.opts.tree.click_term(e);return}if(this.opts.tree.click_term2select_tvs){this.api.dispatch({type:"submenu_set",submenu:{term:e.term,type:"tvs"}});return}}))}}}const te=n(ee);export{te as appInit};
@@ -0,0 +1 @@
1
+ import{h as t,d as e,M as s,o as r,n as o,y as i}from"./app-0de0ae35.js";import{r as a,s as n}from"./recover-6f2f3379.js";import{v as p}from"./FilterRxComp-fb608459.js";import{n as c}from"./sampleScatter-7c2773de.js";import{summaryInit as l}from"./summary-45c56298.js";import"./termsetting-2e75e729.js";import"./tslib.es6-c3c2d88f.js";import"path";import"./FilterStateless-fc4e4e1b.js";import"./app-7f695ce7.js";import"./termInfo-5477ba96.js";import"./toggleButtons-7ce58d97.js";import"./table-e2a307e6.js";import"./genesearch-5fa13afa.js";import"./checkbox-96437f4d.js";import"./rehydrateFilter-12d118cb.js";import"./partjson.esm-b3f1fc21.js";import"./termdb.bins-7ecc48db.js";import"./controls-1f3ac9d0.js";import"./controls.btns-5b44e5d0.js";import"./controls.config-b0339f96.js";import"./zoom-d3d38b3b.js";import"./pointer-c7475677.js";import"./nodrag-0fa60f70.js";import"./lasso-e12204af.js";import"./drag-ad04f964.js";import"./shapes-21ebfec4.js";import"./sampleView-8885e86b.js";import"./select2Terms-d9320d21.js";import"./svg.download-a5e20a92.js";import"./sampleScatter.rendererThree-b6db5a09.js";import"./axis-747c801e.js";import"./line-264f8f9e.js";import"./constant-426a1483.js";import"./violin-4595cef4.js";import"./violin.renderer-0b7431a2.js";import"./brush-4c775f74.js";import"./basis-3870f5ba.js";import"./log-d560d2a5.js";import"./html.legend-455f7881.js";import"./violin.interactivity-8b63e000.js";import"./niceNumLabels-1bd7a93b.js";import"./barchart-978fb21a.js";import"./bars.settings-64bb4642.js";import"./bars.renderer-d7461d5d.js";import"./svg.legend-8d21872d.js";import"./barchart.events-9b482604.js";function d(t){switch(t){case"../plots/DEanalysis.js":return import("./DEanalysis-a3cf1900.js");case"../plots/Disco.js":return import("./Disco-b26a0556.js");case"../plots/DziViewer.js":return import("./DziViewer-5b830c31.js");case"../plots/WSIViewer.js":return import("./WSIViewer-dcce2a10.js");case"../plots/barchart.data.js":return import("./FilterRxComp-fb608459.js").then((function(t){return t.j}));case"../plots/barchart.events.js":return import("./barchart.events-9b482604.js");case"../plots/barchart.js":return import("./barchart-978fb21a.js");case"../plots/bars.renderer.js":return import("./bars.renderer-d7461d5d.js");case"../plots/bars.settings.js":return import("./bars.settings-64bb4642.js");case"../plots/boxplot.js":return import("./boxplot-1f229616.js");case"../plots/brainImaging.js":return import("./brainImaging-a0c72fad.js");case"../plots/controls.btns.js":return import("./controls.btns-5b44e5d0.js");case"../plots/controls.config.js":return import("./controls.config-b0339f96.js");case"../plots/controls.js":return import("./controls-1f3ac9d0.js");case"../plots/cuminc.js":return import("./cuminc-6d1de932.js");case"../plots/dataDownload.js":return import("./dataDownload-a60d80e4.js");case"../plots/dictionary.js":return import("./dictionary-d8435ddc.js");case"../plots/facet.js":return import("./facet-e7612200.js");case"../plots/geneExpression.js":return import("./geneExpression-65346c08.js");case"../plots/geneORA.js":return import("./geneORA-e3d6619e.js");case"../plots/geneset.js":return import("./geneset-c36036bd.js");case"../plots/genomeBrowser.controls.js":return import("./genomeBrowser.controls-b89629b0.js");case"../plots/genomeBrowser.js":return import("./genomeBrowser-d4515002.js");case"../plots/gsea.js":return import("./gsea-af1a7cec.js");case"../plots/hierCluster.config.js":return import("./hierCluster.config-11a176e2.js");case"../plots/hierCluster.interactivity.js":return import("./hierCluster.interactivity-103b2f0f.js").then((function(t){return t.i}));case"../plots/hierCluster.js":return import("./hierCluster-8aa2265a.js");case"../plots/hierCluster.renderers.js":return import("./hierCluster.renderers-48bdf7a6.js").then((function(t){return t.r}));case"../plots/imagePlot.js":return import("./imagePlot-862c7baf.js");case"../plots/matrix.cells.js":return import("./matrix.cells-92037b17.js");case"../plots/matrix.cluster.js":return import("./matrix.cluster-0bca59fd.js");case"../plots/matrix.config.js":return import("./matrix.config-b8d8faef.js");case"../plots/matrix.controls.js":return import("./matrix.controls-07c6128c.js");case"../plots/matrix.data.js":return import("./matrix.data-1090f6c7.js").then((function(t){return t.m}));case"../plots/matrix.dom.js":return import("./matrix.dom-1154156c.js");case"../plots/matrix.groups.js":return import("./matrix.groups-f10a8c05.js").then((function(t){return t.m}));case"../plots/matrix.interactivity.js":return import("./matrix.interactivity-99de0399.js");case"../plots/matrix.js":return import("./matrix-971b44da.js");case"../plots/matrix.layout.js":return import("./matrix.layout-405db70f.js").then((function(t){return t.m}));case"../plots/matrix.legend.js":return import("./matrix.legend-d06de359.js").then((function(t){return t.m}));case"../plots/matrix.renderers.js":return import("./matrix.renderers-2211c4b2.js");case"../plots/matrix.serieses.js":return import("./matrix.serieses-f0803a76.js").then((function(t){return t.m}));case"../plots/matrix.sort.js":return import("./matrix.sort-3d376f1a.js");case"../plots/matrix.sorterUi.js":return import("./matrix.sorterUi-469ed804.js");case"../plots/plot.app.js":return import("./plot.app-0b02df66.js");case"../plots/plot.brainImaging.js":return import("./plot.brainImaging-07795744.js");case"../plots/plot.disco.js":return import("./plot.disco-9c631d77.js");case"../plots/plot.ssgq.js":return import("./plot.ssgq-02ffde06.js");case"../plots/profileBarchart.js":return import("./profileBarchart-0c97e8c9.js");case"../plots/profilePlot.js":return import("./profilePlot-ba7e03ab.js");case"../plots/profilePolar.js":return import("./profilePolar-d38d502f.js");case"../plots/profileRadar.js":return import("./profileRadar-f95cfa87.js");case"../plots/profileRadarFacility.js":return import("./profileRadarFacility-7e200a91.js");case"../plots/profileSummary.js":return import("./profileSummary-8c41a731.js");case"../plots/regression.inputs.js":return import("./regression.inputs-b515101d.js").then((function(t){return t.b}));case"../plots/regression.inputs.term.js":return import("./regression.inputs-b515101d.js").then((function(t){return t.a}));case"../plots/regression.inputs.values.table.js":return import("./regression.inputs.values.table-f8a0cad9.js");case"../plots/regression.js":return import("./regression.inputs-b515101d.js").then((function(t){return t.r}));case"../plots/regression.results.js":return import("./regression.results-91a486f0.js").then((function(t){return t.r}));case"../plots/sampleScatter.interactivity.js":return import("./sampleScatter-7c2773de.js").then((function(t){return t.a}));case"../plots/sampleScatter.js":return import("./sampleScatter-7c2773de.js").then((function(t){return t.b}));case"../plots/sampleScatter.renderer.js":return import("./sampleScatter-7c2773de.js").then((function(t){return t.s}));case"../plots/sampleScatter.rendererThree.js":return import("./sampleScatter.rendererThree-b6db5a09.js").then((function(t){return t.c}));case"../plots/sampleView.js":return import("./sampleView-8885e86b.js");case"../plots/scatter.js":return import("./scatter-34d52e2d.js");case"../plots/singleCellPlot.js":return import("./singleCellPlot-3cad6bd8.js");case"../plots/stattable.js":return import("./stattable-78dc5c34.js");case"../plots/summary.js":return import("./summary-45c56298.js");case"../plots/survival.js":return import("./survival-ed4bdad2.js");case"../plots/table.js":return import("./table-1cbe3a36.js");case"../plots/variantBrowser.js":return import("./variantBrowser-df2f9c22.js");case"../plots/violin.interactivity.js":return import("./violin.interactivity-8b63e000.js");case"../plots/violin.js":return import("./violin-4595cef4.js");case"../plots/violin.renderer.js":return import("./violin.renderer-0b7431a2.js");default:return new Promise((function(e,s){(typeof queueMicrotask==="function"?queueMicrotask:setTimeout)(s.bind(null,new Error("Unknown variable dynamic import: "+t)))}))}}class m{constructor(t){this.type="plot";u(this);this.initUi(t)}reactsTo(t){if(t.type.includes("cache_termq"))return true;if(t.type.endsWith("_group"))return true;if(t.type.startsWith("plot_"))return t.id===this.id;if(t.type.startsWith("filter"))return true;if(t.type.startsWith("cohort"))return true;if(t.type=="app_refresh")return true;if(t.type.endsWith("customTerm"))return true}getState(t){const e=t.plots.find((t=>t.id===this.id));if(!e){throw`No plot with id='${this.id}' found. Did you set this.id before this.api = getComponentApi(this)?`}return{config:e,groups:t.groups,_scope_:t._scope_}}async main(){this.dom.errdiv.style("display","none");if(!this.components)await this.setComponents(this.opts)}async setComponents(t){this.components={recover:await a({app:this.app,holder:this.dom.localRecoverDiv,getState:t=>this.getState(t),reactsTo:t=>t.id==this.id&&(t.type=="plot_edit"||t.type=="plot_nestedEdits")&&t._track_!="none",plot_id:this.id,maxHistoryLen:10})};const s=await d(`../plots/${t.chartType}.js`);this.components.chart=await s.componentInit({app:this.app,holder:this.dom.viz,header:this.dom.paneTitleDiv,id:this.id,plotDiv:e(this.dom.holder.app_div.node().parentNode)})}destroy(){this.dom.holder.app_div.selectAll("*").remove();this.dom.holder.app_div.remove();for(const t in this.dom){delete this.dom[t]}}}const j=t(m);function u(t){t.initUi=function(e){const r=e.holder;r.header.style("padding",0);try{t.dom={tip:new s({padding:"0px"}),holder:r,paneTitleDiv:r.header.append("div").style("display","inline-block").style("color","#555").style("padding-left","7px").style("vertical-align","sub"),localRecoverDiv:r.header.append("div").style("display","inline-block"),body:r.body.style("white-space","nowrap").style("overflow-x","auto"),errdiv:r.body.append("div").style("display","none").style("padding","5px").style("background-color","rgba(255,100,100,0.2)"),viz:r.body.append("div")}}catch(e){t.dom.errdiv.style("display","none").text(e)}}}class h{constructor(t){if(t.addLoginCallback){t.addLoginCallback((()=>this.api.dispatch({type:"app_refresh"})))}this.type="app";this.dom={holder:t.holder,topbar:t.holder.append("div"),errdiv:t.holder.append("div"),plotDiv:t.holder.append("div")};this.plotIdToSandboxId={}}validateOpts(t={}){if(!t.holder)throw`missing opts.holder in the MassApp constructor argument`;if(!t.callbacks)t.callbacks={};if(!t.state.vocab)t.state.vocab={};if(typeof t.state.vocab!="object")throw"opts.state.vocab{} is not an object";if(t.state.genome){t.state.vocab.genome=t.state.genome;delete t.state.genome}if(t.state.dslabel){t.state.vocab.dslabel=t.state.dslabel;delete t.state.dslabel}return t}async preApiFreeze(t){try{t.tip=new s({padding:"5px"});t.tip.d.on("keyup",(e=>{if(e.key=="Escape")t.tip.hide()}));t.printError=t=>this.printError(t);const e=this.opts.state.vocab;t.vocabApi=await p({app:t,state:{vocab:this.opts.state.vocab},fetchOpts:this.opts.fetchOpts,getDatasetAccessToken:this.opts.getDatasetAccessToken});t.hasWebGL=function(){try{var t=document.createElement("canvas");return!!(window.WebGLRenderingContext&&(t.getContext("webgl")||t.getContext("experimental-webgl")))}catch(t){return false}};this.opts.state.vocab=t.vocabApi.vocab}catch(t){throw t}}async init(){try{const t="debounceInterval"in this.opts?this.opts.debounceInterval:0;if(this.opts.embeddedSessionState){Object.assign(this.opts.state,this.opts.embeddedSessionState)}this.store=await n({app:this.api,state:this.opts.state,debounceInterval:t});this.state=await this.store.copyState();this.components={};if(this.state.nav.header_mode!="hidden"){this.components.nav=await c({app:this.api,holder:this.dom.topbar,header_mode:this.state&&this.state.nav&&this.state.nav.header_mode,vocab:this.state.vocab,massSessionDuration:this.state.termdbConfig.massSessionDuration})}this.components.plots={};await this.api.dispatch()}catch(t){this.printError(t);throw t}}async main(){await this.api.vocabApi.main();const t={};let e;for(const s of this.state.plots){if(this.components.plots&&!(s.id in this.components.plots)){e=o(this.dom.plotDiv,{close:()=>{this.api.dispatch({type:"plot_delete",id:s.id})},plotId:s.id,beforePlotId:s.insertBefore||null,style:{width:"98.5%"}});if(s.chartType=="summary")t[s.id]=l(Object.assign({app:this.api,holder:e},s));else t[s.id]=j(Object.assign({app:this.api,holder:e},s))}}const s=Object.keys(t).length;if(s){await Promise.all(Object.values(t));for(const e in t){this.components.plots[e]=await t[e]}}for(const t in this.components.plots){if(!this.state.plots.find((e=>e.id===t))){this.components.plots[t].destroy();delete this.components.plots[t]}}}printError(t){i(this.dom.errdiv||this.opts.holder,"Error: "+(t.message||t));if(t.stack)console.log(t.stack);this.bus.emit("error")}}const b=r(h);export{b as appInit};
package/dist/app.js CHANGED
@@ -1 +1 @@
1
- export{c2 as runproteinpaint}from"./app-6fb77603.js";
1
+ export{c2 as runproteinpaint}from"./app-0de0ae35.js";
@@ -1 +1 @@
1
- import{M as e,u as t,k as s,b as n,D as i,z as a,y as l,f as o,aj as r}from"./app-6fb77603.js";import{a as c,s as d}from"./genesearch-ffd88bf2.js";import{T as p}from"./toggleButtons-c4d6f260.js";import{r as f}from"./table-0daf2b89.js";import{m as u}from"./checkbox-96437f4d.js";import"./tslib.es6-c3c2d88f.js";const y=new e({padding:""});const m="hg38";const h="GDC";const g=60;const b=[{title:"Entity ID",key:"entity_id"},{title:"Experimental Strategy",key:"experimental_strategy"},{title:"Tissue Type",key:"tissue_type"},{title:"Tumor Descriptor",key:"tumor_descriptor"},{title:"Size",key:"file_size",width:"10vw"}];const k="You are attempting to access a Sequence Read file that you are not authorized to access. <a href=https://gdc.cancer.gov/access-data/obtaining-access-controlled-data target=_blank>Please request dbGaP Access to the project</a>.";async function v({genomes:e,holder:r,filter0:v,hideTokenInput:S=false,callbacks:A={},stream2download:F=false,inputValue:I,debugmode:T=false}){if(A.postRender&&typeof A.postRender!="function")throw"callbacks.postRender is not function";const $={dom:{tip:y}};const j=e[m];if(!j)throw"missing genome for "+m;const E={bam_files:[],runFlags:{runflag_caseFileList:1,runflag_gdcInput:1}};const C=t();const N=r.append("div").style("margin-left","30px").style("display","none");N.append("button").html("&#171; Back To Input Form").on("click",(()=>{N.style("display","none");B.style("display","none").selectAll("*").remove();G.style("display","block")}));const G=r.append("div").style("margin-left","30px");const M=G.append("div");const B=r.append("div").style("display","none");if(!S)H();const D=await V();const O=G.append("div").style("padding","3px 10px").style("display","none");const[z,U,P]=Q();const R=I||C.get("gdc_id");if(R){D.property("value",R).node().dispatchEvent(new Event("search"))}else{delete E.runFlags.runflag_gdcInput;L()}function L(){if(!A.postRender)return;if(Object.keys(E.runFlags).length==0){A.postRender($)}}function H(){const e=M.insert("div").attr("class","sja-gdcbam-tokendiv");e.insert("div").style("display","inline-block").style("width","15vw").text("GDC Token File");const t=e.insert("div").style("display","inline-block");const s=t.append("input").attr("type","file").attr("aria-label","GDC token file");const n=t.append("span").style("margin-left","20px").style("display","none");s.on("change",(e=>{const t=e.target.files[0];if(!t){s.property("value","");return}if(!t.size){s.property("value","");w(n,"Blank file "+t.name);return}const i=new FileReader;i.onload=e=>{const t=e.target.result.trim();if(t.length<100){s.property("value","");w(n,"Does not look like a toke file (content too short)");return}if(t.length>1e3){s.property("value","");w(n,"Does not look like a toke file (content too long)");return}E.gdc_token=t};i.onerror=function(){s.property("value","");w(n,"Error reading file "+t.name);return};w(n);i.readAsText(t,"utf8")}));setTimeout((()=>s.node().focus()),1100)}async function V(){const e=M.insert("div");e.append("div").style("display","inline-block").style("width","15vw").style("padding-top","5px").text("Enter Search String").style("vertical-align","top");const t=e.append("div").style("display","inline-block");const a=t.append("input").attr("type","search").attr("size",45).attr("aria-label","Specify File Name / File UUID / Case ID / Case UUID").style("padding","3px 10px").property("placeholder","File Name / File UUID / Case ID / Case UUID").attr("class","sja-gdcbam-input").on("search",y).on("keyup",(e=>{if(s(e)){y();return}l.style("display","").text("Press ENTER to search");o.style("display","none")}));const l=t.append("span").style("padding-left","10px").style("display","none");const o=t.append("span").attr("class","sja-gdcbam-gdcid_error_div").style("display","none").style("padding","2px 5px");t.append("br");const r=t.append("div").attr("class","sja-gdcbam-listCaseFileHandle").style("margin","5px").style("display","inline-block").text("Looking for BAM files from current cohort...");q(r);const c=t.append("div").style("display","none").style("width","500px").style("margin","20px 3px").html(k);const d=G.append("div").style("display","none").style("margin","20px 20px 20px 40px");const p=d.append("div").attr("class","sja-gdcbam-onefiletable").style("display","none");const u=d.append("div").attr("class","sja-gdcbam-multifiletable").style("display","none");$.update=e=>{y(null,e?.filter0||v);q(r,e?.filter0||v)};async function y(e,t){U.selectAll("*").remove();P.style("display","none");z.style("display","inline-block");o.style("display","none");l.style("display","none");try{await m(Object.keys(t||{}).length?t:v||null)}catch(e){w(o,e.message||e);d.style("display","none");O.style("display","none")}L()}async function m(e){const t=a.property("value").trim();if(!t.length){d.style("display","none");U.selectAll("*").remove();O.style("display","none");return}a.attr("disabled",1);l.style("display","").text("Loading...");E.runFlags.runflag_gdcInput=1;const s={gdc_id:t};if(e)s.filter0=e;let i;try{i=await n("gdcbam",{body:s})}catch(e){throw e}finally{delete E.runFlags.runflag_gdcInput}a.attr("disabled",null);l.style("display","none");E.bam_files=[];if(i.error)throw"Error: "+i.error;if(!Array.isArray(i.file_metadata))throw"Error: .file_metadata[] missing";if(i.file_metadata.length==0){if(i.numFilesSkippedByWorkflow){throw`File${i.numFilesSkippedByWorkflow>1?"s":""} not viewable due to workflow type.`}throw"No viewable BAM files found"}c.style("display",i.userHasNoAccess?"block":"none");E.case_id=i.file_metadata[0].case_id;if(i.file_metadata.length==1){h(i)}else{g(i.file_metadata)}w(o);E.runFlags.ssmSearch=1;try{await X()}catch(e){throw e}finally{delete E.runFlags.ssmSearch}}function h(e,t){d.style("display","block");p.style("display","block").selectAll("*").remove();u.style("display","none");const s=e.file_metadata[0];const n={file_id:s.file_uuid,track_name:s.entity_id,about:[]};E.bam_files.push(n);const a=i({holder:p});for(const e of b){const[t,i]=a.addRow();t.text(e.title);i.html(e.url?`<a href=${e.url}${s.file_uuid} target=_blank>${s[e.key]}</a>`:s[e.key]);n.about.push({k:e.title,v:s[e.key]})}p.select("input").node()?.focus()}function g(e){const t=b.map((e=>({label:e.title,width:e.width})));const s=[];for(const[t,n]of e.entries()){const e=[];for(const t of b){if(t.url){e.push({html:`<a href=${e.url}${n.file_uuid} target=_blank>${n[e.key]}</a>`})}else{e.push({value:n[t.key]})}}s.push(e)}d.style("display","block");u.style("display","block").selectAll("*").remove();p.style("display","none");f({rows:s,columns:t,div:u,singleMode:F?true:false,noButtonCallback:(t,s)=>{const n=e[t];if(F){E.bam_files=[{file_id:n.file_uuid,track_name:`${n.tissue_type}, ${n.tumor_descriptor}, ${n.experimental_strategy}, ${n.entity_id}`,about:b.map((e=>({k:e.title,v:n[e.key]})))}]}else{if(s.checked){E.bam_files.push({file_id:n.file_uuid,track_name:`${n.tissue_type}, ${n.tumor_descriptor}, ${n.experimental_strategy}, ${n.entity_id}`,about:b.map((e=>({k:e.title,v:n[e.key]})))})}else{E.bam_files=E.bam_files.filter((e=>e.file_id!=n.file_uuid))}}}})}return a}async function q(e,t){E.runFlags.runflag_caseFileList=1;try{await W(e,t)}catch(t){e.text(t.message||t)}finally{delete E.runFlags.runflag_caseFileList}L()}async function W(e,t){const s=Object.keys(t||{}).length?t:v||null;const i={};if(s)i.filter0=s;const a=await n("gdcbam",{body:i});if(a.error)throw a.error;if(typeof a.case2files!="object")throw"wrong return";if(!a.restapihost)throw"data.restapihost is missing";E.restapihost=a.restapihost;e.text(`Or, Browse ${a.total} Available BAM Files`);const l=new Map;for(const e in a.case2files){for(const t of a.case2files[e]){const e=t.experimental_strategy;if(!l.has(e)){l.set(e,{count:1,checked:true})}else{l.get(e).count+=1}}}e.classed("sja_clbtext",true).attr("tabindex",0).on("keyup",(e=>{if(e.key=="Enter"){e.target.click()}})).on("click",(e=>{y.clear().showunder(e.target);{const e=y.d.append("div").style("margin","10px");for(const[s,n]of l){u({holder:e,labeltext:`${s}, ${n.count}`,divstyle:{display:"inline","margin-right":"15px"},checked:n.checked,callback:()=>{n.checked=!n.checked;o(t)}})}}const t=y.d.append("div").style("margin","10px").attr("class","sjpp_show_scrollbar").style("height","300px").style("resize","vertical");o(t)}));function o(e){e.selectAll("*").remove();const t=e.append("table").style("border-spacing","0px");const s=t.append("tr").style("position","sticky").style("top","0px").style("background-color","white").style("color","#888");s.append("td").text("CASE");s.append("td").text("BAM FILES, SELECT ONE TO VIEW");for(const e in a.case2files){const s=t.append("tr").attr("class","sja_clb_gray");s.append("td").style("vertical-align","top").style("color","#888").text(e);const n=s.append("td");for(const t of a.case2files[e]){if(!l.get(t.experimental_strategy).checked)continue;n.append("div").attr("class","sja_clbtext").attr("tabindex",0).html(`${t.tissue_type}, ${t.tumor_descriptor=="Not Applicable"?"":t.tumor_descriptor+", "}${t.experimental_strategy} <span style="font-size:.8em">${t.file_size}</span>`).on("click",(()=>{y.hide();D.property("value",t.file_uuid).node().dispatchEvent(new Event("search"))})).on("keyup",(e=>{if(e.key=="Enter")e.target.click()}))}}t.select(".sja_clbtext")?.node()?.focus()}}async function X(){delete E.ssmInput;O.style("display","block").selectAll("*").remove();const e=O.append("p").text("Searching for mutations...");const t=await n("termdb/singleSampleMutation",{body:{sample:"___"+E.case_id,genome:m,dslabel:h}});if(t.error)throw t.error;const s=t.mlst.filter((e=>e.dt==1));if(s.length==0){e.text("No mutations from this case.");if(F){const e=[{label:"Gene or position",callback:()=>E.useSsmOrGene="gene"},{label:"Unmapped reads",callback:()=>E.useSsmOrGene="unmapped"}];new p({holder:O,tabs:e}).main();await J(e[0].contentHolder);e[1].contentHolder.append("p").text("Only download unmapped reads from this BAM file.")}else{await J(O.append("div"))}return}e.remove();const i=[{label:`${s.length} variants${t.dt2total?.[0]?" ("+t.dt2total[0].total+" total)":""}`,callback:()=>{E.useSsmOrGene="ssm"}},{label:"Gene or position",callback:()=>{E.useSsmOrGene="gene"}}];if(F){i.push({label:"Unmapped reads",callback:()=>E.useSsmOrGene="unmapped"})}new p({holder:O,tabs:i}).main();Y(i[0].contentHolder,s);await J(i[1].contentHolder);if(i[2])i[2].contentHolder.append("p").text("Only download unmapped reads from this BAM file.")}function Y(e,t){const s=[{label:"Gene",width:"10vw"},{label:"Mutation"},{label:"Consequence"},{label:"Position"}];const n=new Map;for(const e of t){if(!n.has(e.gene))n.set(e.gene,[]);n.get(e.gene).push(e)}const i=[];for(const[e,t]of n){for(const s of t){const t=[];t.push({value:e,data:s});t.push({value:s.mname});t.push({value:a[s.class]?.label||"Unknown"});t.push({value:s.chr+":"+s.pos+" "+s.ref+">"+s.alt});i.push(t)}}f({rows:i,columns:s,div:e,noButtonCallback:(e,t)=>{const s=i[e][0].data;E.ssmInput={chr:s.chr,pos:s.pos-1,ref:s.ref,alt:s.alt}},singleMode:true});if(C.has("gdc_ssm")){for(const[e,t]of n){for(const e of t){if(e.mname==C.get("gdc_ssm")){E.ssmInput={chr:e.chr,pos:e.pos-1,ref:e.ref,alt:e.alt}}}}}e.select("input").node().focus()}async function J(e){const t=e.append("div").style("display","grid").style("grid-template-columns","300px auto");t.append("div").text("Enter gene, position, SNP, or variant");E.coordInput=c(await K(t));_(e)}async function K(e){const t={genome:j,tip:y,row:e.append("div"),allowVariant:true};if(C.has("gdc_pos")){const e=C.get("gdc_pos").split(/[:\-]/);if(e.length==3){t.defaultCoord={chr:e[0],start:Number(e[1]),stop:Number(e[2])}}}else if(C.has("gdc_var")){const e=await d(C.get("gdc_var"),j);if(e){t.defaultCoord=e}}return t}function Q(){const e=G.append("div");const t=e.insert("div").style("display","inline-block").append("button").style("margin","20px 20px 20px 40px").style("padding","10px 25px").style("border-radius","35px").text("Submit").on("click",(async()=>{try{s.selectAll("*").remove();x(E,j,S);t.text("Loading ...");t.property("disabled",true);await Z()}catch(e){if(e=="Permission denied"){n.style("display","inline-block");t.style("display","none")}else{s.selectAll("*").remove();l(s,e)}}t.text("Submit");t.property("disabled",false)}));const s=e.insert("div").style("display","inline-block");const n=e.insert("div").style("display","none").style("margin","20px");n.append("div").text("Access Alert").style("font-size","1.5em").style("opacity",.4);n.append("div").style("border-top","solid 1px #eee").style("border-bottom","solid 1px #eee").style("padding","20px 0px").style("margin-top","5px").html(k);return[t,s,n]}async function Z(){const e=E;const t={nobox:1,genome:j,holder:B,debugmode:T};if(e.useSsmOrGene=="unmapped"){t.unmapped=1}else{if(e.position){t.chr=e.position.chr;t.start=e.position.start;t.stop=e.position.stop}else if(e.variant){t.chr=e.variant.chr;t.start=e.variant.pos-g;t.stop=e.variant.pos+g}else{throw"SV_EXPAND here"}}const s={"Content-Type":"application/json",Accept:"application/json"};if(e.gdc_token){s["X-Auth-Token"]=e.gdc_token}for(const[i,a]of e.bam_files.entries()){z.text(`Slicing BAM File ${i+1} of ${e.bam_files.length}...`);const l={downloadgdc:1,gdcFileUUID:a.file_id};if(t.unmapped){l.gdcFilePosition="unmapped";l.unmapped=1}else{l.gdcFilePosition=t.chr+":"+t.start+"-"+t.stop;l.regions=[{chr:t.chr,start:t.start,stop:t.stop}]}if(F){s.compression=false;const e=`${E.restapihost}/slicing/view/${a.file_id}?region=${l.gdcFilePosition}`;const n=await fetch(e,{method:"GET",headers:s});const i=await n.blob();const o=document.createElement("a");o.href=URL.createObjectURL(i);if(t.unmapped){o.download=a.track_name+".unmapped.bam"}else{o.download=`${a.track_name}.${t.chr}.${t.start}.${t.stop}.bam`}o.style.display="none";document.body.appendChild(o);o.click();document.body.removeChild(o);return}const o=await n("tkbam",{headers:s,body:l});if(o.error)throw o.error;{const e=a.about.find((e=>e.k=="Slice file size"));if(e)e.v=o.size;else a.about.push({k:"Slice file size",v:o.size})}if(o.time){const e=a.about.find((e=>e.k=="Stream time"));if(e)e.v=Math.round(o.time)+" seconds";else a.about.push({k:"Stream time",v:Math.round(o.time)+" seconds"})}if(o.truncated){if(!a.about.find((e=>e.k=="Truncated")))a.about.push({k:"Truncated",v:"BAM slice size exceeds limit and is truncated"})}else{const e=a.about.findIndex((e=>e.k=="Truncated"));if(e>0)a.about.splice(e,1)}}G.style("display","none");N.style("display","block");B.style("display","block");t.tklst=[];for(const s of e.bam_files){const n={type:"bam",name:s.track_name||"Sample BAM slice",gdcToken:e.gdc_token,gdcFile:{uuid:s.file_id,position:t.chr+":"+t.start+"-"+t.stop},aboutThisFile:s.about};if(e.variant){n.variants=[e.variant]}t.tklst.push(n)}o(j,t.tklst);const i=await import("./block-75d4ff92.js").then((function(e){return e.c}));new i.Block(t)}return $}function _(e){e.append("div").style("opacity",.6).html(`<ul>\n\t\t<li>Enter gene, position, SNP, or variant.\n\t\tThe BAM file will be sliced at the given position and visualized.</li>\n\t\t<li>Position</li>\n\t\t<ul><li>Example: chr17:7676339-7676767</li>\n\t\t <li>Coordinates are hg38 and 1-based.</li>\n\t\t</ul>\n\t\t<li>SNP example: rs28934574</li>\n\t\t<li>Variant:</li>\n\t\t<ul>\n\t\t <li>Example: chr2.208248388.C.T</li>\n\t\t <li>Fields are separated by periods. Coordinate is hg38 and 1-based. Reference and alternative alleles are on forward strand.</li>\n\t\t</ul>\n\t\t<li>Supported HGVS formats for variants:</li>\n\t\t<ul>\n\t\t <li>SNV: chr2:g.208248388C>T</li>\n\t\t <li>MNV: chr2:g.119955155_119955159delinsTTTTT</li>\n\t\t <li>Insertion: chr5:g.171410539_171410540insTCTG</li>\n\t\t <li>Deletion: chr10:g.8073734delTTTAGA</li>\n\t\t</ul>\n\t\t</ul>`)}function w(e,t){e.style("display","inline-block").style("color",t?"red":"green").html(t?"&#10060; "+t:"&#10003;")}function x(e,t,s=false){if(!s){if(!e.gdc_token)throw"GDC token missing";if(typeof e.gdc_token!=="string")throw"GDC token is not string"}if(!e.bam_files.length)throw"No BAM file selected";for(const t of e.bam_files){if(!t.file_id)throw"file uuid is missing";if(typeof t.file_id!=="string")throw"file uuid is not string"}if(e.useSsmOrGene=="unmapped"){return}delete e.position;delete e.variant;if(e.useSsmOrGene=="ssm"){const t=e.ssmInput;if(!t)throw"No variant selected";if(!t.chr)throw"ssmInput.chr missing";if(!Number.isInteger(t.pos))throw"ssmInput.pos not integer";if(!t.ref)throw"ssmInput.ref missing";if(!t.alt)throw"ssmInput.alt missing";e.variant=t;return}const n=e.coordInput;if(!n.chr)throw"No valid position or variant was entered";const[i,a]=r(t,[n.chr]);if(i+a==0)throw"Invalid chromosome name: "+n.chr;const l=i?"chr"+n.chr:n.chr;if(Number.isInteger(n.pos)){if(!n.ref)throw"Reference allele missing from variant string";if(!n.alt)throw"Alternative allele missing from variant string";e.variant={chr:l,pos:n.pos-1,ref:n.ref,alt:n.alt}}else{if(!Number.isInteger(n.start)||!Number.isInteger(n.stop))throw"non-integer start/stop";e.position={chr:l,start:n.start,stop:n.stop}}}export{v as bamsliceui};
1
+ import{M as e,u as t,k as s,b as n,D as i,z as a,y as l,f as o,aj as r}from"./app-0de0ae35.js";import{a as c,s as d}from"./genesearch-5fa13afa.js";import{T as p}from"./toggleButtons-7ce58d97.js";import{r as f}from"./table-e2a307e6.js";import{m as u}from"./checkbox-96437f4d.js";import"./tslib.es6-c3c2d88f.js";const y=new e({padding:""});const m="hg38";const h="GDC";const g=60;const b=[{title:"Entity ID",key:"entity_id"},{title:"Experimental Strategy",key:"experimental_strategy"},{title:"Tissue Type",key:"tissue_type"},{title:"Tumor Descriptor",key:"tumor_descriptor"},{title:"Size",key:"file_size",width:"10vw"}];const k="You are attempting to access a Sequence Read file that you are not authorized to access. <a href=https://gdc.cancer.gov/access-data/obtaining-access-controlled-data target=_blank>Please request dbGaP Access to the project</a>.";async function v({genomes:e,holder:r,filter0:v,hideTokenInput:S=false,callbacks:A={},stream2download:F=false,inputValue:I,debugmode:T=false}){if(A.postRender&&typeof A.postRender!="function")throw"callbacks.postRender is not function";const $={dom:{tip:y}};const j=e[m];if(!j)throw"missing genome for "+m;const E={bam_files:[],runFlags:{runflag_caseFileList:1,runflag_gdcInput:1}};const C=t();const N=r.append("div").style("margin-left","30px").style("display","none");N.append("button").html("&#171; Back To Input Form").on("click",(()=>{N.style("display","none");B.style("display","none").selectAll("*").remove();G.style("display","block")}));const G=r.append("div").style("margin-left","30px");const M=G.append("div");const B=r.append("div").style("display","none");if(!S)H();const D=await V();const O=G.append("div").style("padding","3px 10px").style("display","none");const[z,U,P]=Q();const R=I||C.get("gdc_id");if(R){D.property("value",R).node().dispatchEvent(new Event("search"))}else{delete E.runFlags.runflag_gdcInput;L()}function L(){if(!A.postRender)return;if(Object.keys(E.runFlags).length==0){A.postRender($)}}function H(){const e=M.insert("div").attr("class","sja-gdcbam-tokendiv");e.insert("div").style("display","inline-block").style("width","15vw").text("GDC Token File");const t=e.insert("div").style("display","inline-block");const s=t.append("input").attr("type","file").attr("aria-label","GDC token file");const n=t.append("span").style("margin-left","20px").style("display","none");s.on("change",(e=>{const t=e.target.files[0];if(!t){s.property("value","");return}if(!t.size){s.property("value","");w(n,"Blank file "+t.name);return}const i=new FileReader;i.onload=e=>{const t=e.target.result.trim();if(t.length<100){s.property("value","");w(n,"Does not look like a toke file (content too short)");return}if(t.length>1e3){s.property("value","");w(n,"Does not look like a toke file (content too long)");return}E.gdc_token=t};i.onerror=function(){s.property("value","");w(n,"Error reading file "+t.name);return};w(n);i.readAsText(t,"utf8")}));setTimeout((()=>s.node().focus()),1100)}async function V(){const e=M.insert("div");e.append("div").style("display","inline-block").style("width","15vw").style("padding-top","5px").text("Enter Search String").style("vertical-align","top");const t=e.append("div").style("display","inline-block");const a=t.append("input").attr("type","search").attr("size",45).attr("aria-label","Specify File Name / File UUID / Case ID / Case UUID").style("padding","3px 10px").property("placeholder","File Name / File UUID / Case ID / Case UUID").attr("class","sja-gdcbam-input").on("search",y).on("keyup",(e=>{if(s(e)){y();return}l.style("display","").text("Press ENTER to search");o.style("display","none")}));const l=t.append("span").style("padding-left","10px").style("display","none");const o=t.append("span").attr("class","sja-gdcbam-gdcid_error_div").style("display","none").style("padding","2px 5px");t.append("br");const r=t.append("div").attr("class","sja-gdcbam-listCaseFileHandle").style("margin","5px").style("display","inline-block").text("Looking for BAM files from current cohort...");q(r);const c=t.append("div").style("display","none").style("width","500px").style("margin","20px 3px").html(k);const d=G.append("div").style("display","none").style("margin","20px 20px 20px 40px");const p=d.append("div").attr("class","sja-gdcbam-onefiletable").style("display","none");const u=d.append("div").attr("class","sja-gdcbam-multifiletable").style("display","none");$.update=e=>{y(null,e?.filter0||v);q(r,e?.filter0||v)};async function y(e,t){U.selectAll("*").remove();P.style("display","none");z.style("display","inline-block");o.style("display","none");l.style("display","none");try{await m(Object.keys(t||{}).length?t:v||null)}catch(e){w(o,e.message||e);d.style("display","none");O.style("display","none")}L()}async function m(e){const t=a.property("value").trim();if(!t.length){d.style("display","none");U.selectAll("*").remove();O.style("display","none");return}a.attr("disabled",1);l.style("display","").text("Loading...");E.runFlags.runflag_gdcInput=1;const s={gdc_id:t};if(e)s.filter0=e;let i;try{i=await n("gdcbam",{body:s})}catch(e){throw e}finally{delete E.runFlags.runflag_gdcInput}a.attr("disabled",null);l.style("display","none");E.bam_files=[];if(i.error)throw"Error: "+i.error;if(!Array.isArray(i.file_metadata))throw"Error: .file_metadata[] missing";if(i.file_metadata.length==0){if(i.numFilesSkippedByWorkflow){throw`File${i.numFilesSkippedByWorkflow>1?"s":""} not viewable due to workflow type.`}throw"No viewable BAM files found"}c.style("display",i.userHasNoAccess?"block":"none");E.case_id=i.file_metadata[0].case_id;if(i.file_metadata.length==1){h(i)}else{g(i.file_metadata)}w(o);E.runFlags.ssmSearch=1;try{await X()}catch(e){throw e}finally{delete E.runFlags.ssmSearch}}function h(e,t){d.style("display","block");p.style("display","block").selectAll("*").remove();u.style("display","none");const s=e.file_metadata[0];const n={file_id:s.file_uuid,track_name:s.entity_id,about:[]};E.bam_files.push(n);const a=i({holder:p});for(const e of b){const[t,i]=a.addRow();t.text(e.title);i.html(e.url?`<a href=${e.url}${s.file_uuid} target=_blank>${s[e.key]}</a>`:s[e.key]);n.about.push({k:e.title,v:s[e.key]})}p.select("input").node()?.focus()}function g(e){const t=b.map((e=>({label:e.title,width:e.width})));const s=[];for(const[t,n]of e.entries()){const e=[];for(const t of b){if(t.url){e.push({html:`<a href=${e.url}${n.file_uuid} target=_blank>${n[e.key]}</a>`})}else{e.push({value:n[t.key]})}}s.push(e)}d.style("display","block");u.style("display","block").selectAll("*").remove();p.style("display","none");f({rows:s,columns:t,div:u,singleMode:F?true:false,noButtonCallback:(t,s)=>{const n=e[t];if(F){E.bam_files=[{file_id:n.file_uuid,track_name:`${n.tissue_type}, ${n.tumor_descriptor}, ${n.experimental_strategy}, ${n.entity_id}`,about:b.map((e=>({k:e.title,v:n[e.key]})))}]}else{if(s.checked){E.bam_files.push({file_id:n.file_uuid,track_name:`${n.tissue_type}, ${n.tumor_descriptor}, ${n.experimental_strategy}, ${n.entity_id}`,about:b.map((e=>({k:e.title,v:n[e.key]})))})}else{E.bam_files=E.bam_files.filter((e=>e.file_id!=n.file_uuid))}}}})}return a}async function q(e,t){E.runFlags.runflag_caseFileList=1;try{await W(e,t)}catch(t){e.text(t.message||t)}finally{delete E.runFlags.runflag_caseFileList}L()}async function W(e,t){const s=Object.keys(t||{}).length?t:v||null;const i={};if(s)i.filter0=s;const a=await n("gdcbam",{body:i});if(a.error)throw a.error;if(typeof a.case2files!="object")throw"wrong return";if(!a.restapihost)throw"data.restapihost is missing";E.restapihost=a.restapihost;e.text(`Or, Browse ${a.total} Available BAM Files`);const l=new Map;for(const e in a.case2files){for(const t of a.case2files[e]){const e=t.experimental_strategy;if(!l.has(e)){l.set(e,{count:1,checked:true})}else{l.get(e).count+=1}}}e.classed("sja_clbtext",true).attr("tabindex",0).on("keyup",(e=>{if(e.key=="Enter"){e.target.click()}})).on("click",(e=>{y.clear().showunder(e.target);{const e=y.d.append("div").style("margin","10px");for(const[s,n]of l){u({holder:e,labeltext:`${s}, ${n.count}`,divstyle:{display:"inline","margin-right":"15px"},checked:n.checked,callback:()=>{n.checked=!n.checked;o(t)}})}}const t=y.d.append("div").style("margin","10px").attr("class","sjpp_show_scrollbar").style("height","300px").style("resize","vertical");o(t)}));function o(e){e.selectAll("*").remove();const t=e.append("table").style("border-spacing","0px");const s=t.append("tr").style("position","sticky").style("top","0px").style("background-color","white").style("color","#888");s.append("td").text("CASE");s.append("td").text("BAM FILES, SELECT ONE TO VIEW");for(const e in a.case2files){const s=t.append("tr").attr("class","sja_clb_gray");s.append("td").style("vertical-align","top").style("color","#888").text(e);const n=s.append("td");for(const t of a.case2files[e]){if(!l.get(t.experimental_strategy).checked)continue;n.append("div").attr("class","sja_clbtext").attr("tabindex",0).html(`${t.tissue_type}, ${t.tumor_descriptor=="Not Applicable"?"":t.tumor_descriptor+", "}${t.experimental_strategy} <span style="font-size:.8em">${t.file_size}</span>`).on("click",(()=>{y.hide();D.property("value",t.file_uuid).node().dispatchEvent(new Event("search"))})).on("keyup",(e=>{if(e.key=="Enter")e.target.click()}))}}t.select(".sja_clbtext")?.node()?.focus()}}async function X(){delete E.ssmInput;O.style("display","block").selectAll("*").remove();const e=O.append("p").text("Searching for mutations...");const t=await n("termdb/singleSampleMutation",{body:{sample:"___"+E.case_id,genome:m,dslabel:h}});if(t.error)throw t.error;const s=t.mlst.filter((e=>e.dt==1));if(s.length==0){e.text("No mutations from this case.");if(F){const e=[{label:"Gene or position",callback:()=>E.useSsmOrGene="gene"},{label:"Unmapped reads",callback:()=>E.useSsmOrGene="unmapped"}];new p({holder:O,tabs:e}).main();await J(e[0].contentHolder);e[1].contentHolder.append("p").text("Only download unmapped reads from this BAM file.")}else{await J(O.append("div"))}return}e.remove();const i=[{label:`${s.length} variants${t.dt2total?.[0]?" ("+t.dt2total[0].total+" total)":""}`,callback:()=>{E.useSsmOrGene="ssm"}},{label:"Gene or position",callback:()=>{E.useSsmOrGene="gene"}}];if(F){i.push({label:"Unmapped reads",callback:()=>E.useSsmOrGene="unmapped"})}new p({holder:O,tabs:i}).main();Y(i[0].contentHolder,s);await J(i[1].contentHolder);if(i[2])i[2].contentHolder.append("p").text("Only download unmapped reads from this BAM file.")}function Y(e,t){const s=[{label:"Gene",width:"10vw"},{label:"Mutation"},{label:"Consequence"},{label:"Position"}];const n=new Map;for(const e of t){if(!n.has(e.gene))n.set(e.gene,[]);n.get(e.gene).push(e)}const i=[];for(const[e,t]of n){for(const s of t){const t=[];t.push({value:e,data:s});t.push({value:s.mname});t.push({value:a[s.class]?.label||"Unknown"});t.push({value:s.chr+":"+s.pos+" "+s.ref+">"+s.alt});i.push(t)}}f({rows:i,columns:s,div:e,noButtonCallback:(e,t)=>{const s=i[e][0].data;E.ssmInput={chr:s.chr,pos:s.pos-1,ref:s.ref,alt:s.alt}},singleMode:true});if(C.has("gdc_ssm")){for(const[e,t]of n){for(const e of t){if(e.mname==C.get("gdc_ssm")){E.ssmInput={chr:e.chr,pos:e.pos-1,ref:e.ref,alt:e.alt}}}}}e.select("input").node().focus()}async function J(e){const t=e.append("div").style("display","grid").style("grid-template-columns","300px auto");t.append("div").text("Enter gene, position, SNP, or variant");E.coordInput=c(await K(t));_(e)}async function K(e){const t={genome:j,tip:y,row:e.append("div"),allowVariant:true};if(C.has("gdc_pos")){const e=C.get("gdc_pos").split(/[:\-]/);if(e.length==3){t.defaultCoord={chr:e[0],start:Number(e[1]),stop:Number(e[2])}}}else if(C.has("gdc_var")){const e=await d(C.get("gdc_var"),j);if(e){t.defaultCoord=e}}return t}function Q(){const e=G.append("div");const t=e.insert("div").style("display","inline-block").append("button").style("margin","20px 20px 20px 40px").style("padding","10px 25px").style("border-radius","35px").text("Submit").on("click",(async()=>{try{s.selectAll("*").remove();x(E,j,S);t.text("Loading ...");t.property("disabled",true);await Z()}catch(e){if(e=="Permission denied"){n.style("display","inline-block");t.style("display","none")}else{s.selectAll("*").remove();l(s,e)}}t.text("Submit");t.property("disabled",false)}));const s=e.insert("div").style("display","inline-block");const n=e.insert("div").style("display","none").style("margin","20px");n.append("div").text("Access Alert").style("font-size","1.5em").style("opacity",.4);n.append("div").style("border-top","solid 1px #eee").style("border-bottom","solid 1px #eee").style("padding","20px 0px").style("margin-top","5px").html(k);return[t,s,n]}async function Z(){const e=E;const t={nobox:1,genome:j,holder:B,debugmode:T};if(e.useSsmOrGene=="unmapped"){t.unmapped=1}else{if(e.position){t.chr=e.position.chr;t.start=e.position.start;t.stop=e.position.stop}else if(e.variant){t.chr=e.variant.chr;t.start=e.variant.pos-g;t.stop=e.variant.pos+g}else{throw"SV_EXPAND here"}}const s={"Content-Type":"application/json",Accept:"application/json"};if(e.gdc_token){s["X-Auth-Token"]=e.gdc_token}for(const[i,a]of e.bam_files.entries()){z.text(`Slicing BAM File ${i+1} of ${e.bam_files.length}...`);const l={downloadgdc:1,gdcFileUUID:a.file_id};if(t.unmapped){l.gdcFilePosition="unmapped";l.unmapped=1}else{l.gdcFilePosition=t.chr+":"+t.start+"-"+t.stop;l.regions=[{chr:t.chr,start:t.start,stop:t.stop}]}if(F){s.compression=false;const e=`${E.restapihost}/slicing/view/${a.file_id}?region=${l.gdcFilePosition}`;const n=await fetch(e,{method:"GET",headers:s});const i=await n.blob();const o=document.createElement("a");o.href=URL.createObjectURL(i);if(t.unmapped){o.download=a.track_name+".unmapped.bam"}else{o.download=`${a.track_name}.${t.chr}.${t.start}.${t.stop}.bam`}o.style.display="none";document.body.appendChild(o);o.click();document.body.removeChild(o);return}const o=await n("tkbam",{headers:s,body:l});if(o.error)throw o.error;{const e=a.about.find((e=>e.k=="Slice file size"));if(e)e.v=o.size;else a.about.push({k:"Slice file size",v:o.size})}if(o.time){const e=a.about.find((e=>e.k=="Stream time"));if(e)e.v=Math.round(o.time)+" seconds";else a.about.push({k:"Stream time",v:Math.round(o.time)+" seconds"})}if(o.truncated){if(!a.about.find((e=>e.k=="Truncated")))a.about.push({k:"Truncated",v:"BAM slice size exceeds limit and is truncated"})}else{const e=a.about.findIndex((e=>e.k=="Truncated"));if(e>0)a.about.splice(e,1)}}G.style("display","none");N.style("display","block");B.style("display","block");t.tklst=[];for(const s of e.bam_files){const n={type:"bam",name:s.track_name||"Sample BAM slice",gdcToken:e.gdc_token,gdcFile:{uuid:s.file_id,position:t.chr+":"+t.start+"-"+t.stop},aboutThisFile:s.about};if(e.variant){n.variants=[e.variant]}t.tklst.push(n)}o(j,t.tklst);const i=await import("./block-3db9c74c.js").then((function(e){return e.c}));new i.Block(t)}return $}function _(e){e.append("div").style("opacity",.6).html(`<ul>\n\t\t<li>Enter gene, position, SNP, or variant.\n\t\tThe BAM file will be sliced at the given position and visualized.</li>\n\t\t<li>Position</li>\n\t\t<ul><li>Example: chr17:7676339-7676767</li>\n\t\t <li>Coordinates are hg38 and 1-based.</li>\n\t\t</ul>\n\t\t<li>SNP example: rs28934574</li>\n\t\t<li>Variant:</li>\n\t\t<ul>\n\t\t <li>Example: chr2.208248388.C.T</li>\n\t\t <li>Fields are separated by periods. Coordinate is hg38 and 1-based. Reference and alternative alleles are on forward strand.</li>\n\t\t</ul>\n\t\t<li>Supported HGVS formats for variants:</li>\n\t\t<ul>\n\t\t <li>SNV: chr2:g.208248388C>T</li>\n\t\t <li>MNV: chr2:g.119955155_119955159delinsTTTTT</li>\n\t\t <li>Insertion: chr5:g.171410539_171410540insTCTG</li>\n\t\t <li>Deletion: chr10:g.8073734delTTTAGA</li>\n\t\t</ul>\n\t\t</ul>`)}function w(e,t){e.style("display","inline-block").style("color",t?"red":"green").html(t?"&#10060; "+t:"&#10003;")}function x(e,t,s=false){if(!s){if(!e.gdc_token)throw"GDC token missing";if(typeof e.gdc_token!=="string")throw"GDC token is not string"}if(!e.bam_files.length)throw"No BAM file selected";for(const t of e.bam_files){if(!t.file_id)throw"file uuid is missing";if(typeof t.file_id!=="string")throw"file uuid is not string"}if(e.useSsmOrGene=="unmapped"){return}delete e.position;delete e.variant;if(e.useSsmOrGene=="ssm"){const t=e.ssmInput;if(!t)throw"No variant selected";if(!t.chr)throw"ssmInput.chr missing";if(!Number.isInteger(t.pos))throw"ssmInput.pos not integer";if(!t.ref)throw"ssmInput.ref missing";if(!t.alt)throw"ssmInput.alt missing";e.variant=t;return}const n=e.coordInput;if(!n.chr)throw"No valid position or variant was entered";const[i,a]=r(t,[n.chr]);if(i+a==0)throw"Invalid chromosome name: "+n.chr;const l=i?"chr"+n.chr:n.chr;if(Number.isInteger(n.pos)){if(!n.ref)throw"Reference allele missing from variant string";if(!n.alt)throw"Alternative allele missing from variant string";e.variant={chr:l,pos:n.pos-1,ref:n.ref,alt:n.alt}}else{if(!Number.isInteger(n.start)||!Number.isInteger(n.stop))throw"non-integer start/stop";e.position={chr:l,start:n.start,stop:n.stop}}}export{v as bamsliceui};
@@ -1 +1 @@
1
- import{h as t,Q as e,P as s,C as i,r,z as a,d as o,U as n}from"./app-6fb77603.js";import l from"./bars.settings-64bb4642.js";import c from"./bars.renderer-71935d34.js";import{h as d}from"./html.legend-80b2b3ec.js";import{s as h}from"./svg.legend-749348e0.js";import p from"./barchart.events-426d737a.js";import{renderTerm1Label as m,term0_term2_defaultQ as f,controlsInit as g}from"./controls-268e40e6.js";import{r as u}from"./table-0daf2b89.js";import{f as b,i as y}from"./termsetting-492eefa7.js";import"./axis-747c801e.js";import"./log-c26b6cfd.js";import"./FilterRxComp-02e68f1b.js";import"./partjson.esm-b3f1fc21.js";import"./termdb.bins-39d11f24.js";import"./controls.btns-5bf9e7d7.js";import"./controls.config-2f0fa061.js";import"./tslib.es6-c3c2d88f.js";import"path";class v{constructor(t){this.type="barchart"}preApiFreeze(t){t.download=this.download}async init(t){const e=this.opts;const s=this.opts.controls?null:e.holder.append("div");const i=e.controls?e.holder:e.holder.append("div");this.dom={loadingDiv:i.append("div").style("position","absolute").style("display","none").style("padding","20px").html("Loading ..."),header:e.header,controls:s,holder:i,banner:i.append("div").style("display","none").style("text-align","center").style("padding","24px").style("font-size","16px").style("color","#aaa"),barDiv:i.append("div"),legendDiv:i.append("div").style("margin","5px 5px 15px 5px")};if(this.dom.header)this.dom.header.html("Barchart");this.settings=JSON.parse(l);C(this);w(this);this.renderers={};this.legendRenderer=d(this.dom.legendDiv,{settings:{legendOrientation:"vertical"},handlers:this.handlers},this.dom.barDiv);this.controls={};this.term2toColor={};await this.setControls(this.getState(t));if(this.opts.bar_click_override);else if(!this.opts.bar_click_opts){this.opts.bar_click_opts=["hide_bar"];if(this.app.getState().nav.header_mode==="with_tabs")this.opts.bar_click_opts.push("add_filter")}}async setControls(t){if(this.opts.controls){this.opts.controls.on("downloadClick.barchart",this.download)}else{this.dom.holder.attr("class","pp-termdb-plot-viz").style("display","inline-block").style("min-width","300px").style("margin-left","50px");const t=[{type:"term",configKey:"term",chartType:"barchart",usecase:{target:"barchart",detail:"term"},label:m,vocabApi:this.app.vocabApi,menuOptions:"edit"},{type:"term",configKey:"term2",chartType:"barchart",usecase:{target:"barchart",detail:"term2"},title:"Overlay data",label:"Overlay",vocabApi:this.app.vocabApi,numericEditMenuVersion:this.opts.numericEditMenuVersion,defaultQ4fillTW:f},{type:"term",configKey:"term0",chartType:"barchart",usecase:{target:"barchart",detail:"term0"},title:"Divide by data",label:"Divide by",vocabApi:this.app.vocabApi,numericEditMenuVersion:this.opts.numericEditMenuVersion,defaultQ4fillTW:f},{label:"Orientation",type:"radio",chartType:"barchart",settingsKey:"orientation",options:[{label:"Vertical",value:"vertical"},{label:"Horizontal",value:"horizontal"}]},{label:"Scale",type:"radio",chartType:"barchart",settingsKey:"unit",options:[{label:"Linear",value:"abs"},{label:"Log",value:"log",getDisplayStyle:t=>t.term2?"none":"inline-block"},{label:"Proportion",value:"pct",getDisplayStyle:t=>t.term2?"inline-block":"none"}]},{label:"Multicolor bars",title:"Color bars using the colors preassigned if available, otherwise generates a color",type:"checkbox",chartType:"barchart",settingsKey:"colorBars",boxLabel:"Yes",getDisplayStyle:t=>t.term2?"none":"table-row"},{label:"Deduplicate",title:"Use separate bars samples that has multiple values or belong to multiple groups",type:"checkbox",chartType:"barchart",settingsKey:"dedup",boxLabel:"Yes",getDisplayStyle:t=>this.chartsData.charts.find((t=>t.serieses.length!=t.dedupedSerieses.length))?"table-row":"none"},{label:"Default color",title:"Default color for bars when there is no overlay",type:"color",chartType:"barchart",settingsKey:"defaultColor"}];if(this.app.getState().termdbConfig.multipleTestingCorrection){t.push({label:"Asterisks",boxLabel:"Visible",type:"checkbox",chartType:"barchart",settingsKey:"asterisksVisible",title:"Display the asterisks"})}this.components={controls:await g({app:this.app,id:this.id,holder:this.dom.controls.attr("class","pp-termdb-plot-controls").style("display","inline-block"),inputs:t})};this.components.controls.on("downloadClick.barchart",this.download)}}reactsTo(t){if(t.type.startsWith("plot_")){return t.id===this.id&&(!t.config.childType||t.config.childType==this.type)}return true}getState(t){const e=t.plots.find((t=>t.id===this.id));if(!e){throw`No plot with id='${this.id}' found. Did you set this.id before this.api = getComponentApi(this)?`}return{nav:{header_mode:t.nav.header_mode},termfilter:t.termfilter,config:Object.assign({},e,{settings:{barchart:e.settings.barchart,common:e.settings.common},displaySampleIds:t.termdbConfig.displaySampleIds&&this.app.vocabApi.hasVerifiedToken()}),multipleTestingCorrection:t.termdbConfig.multipleTestingCorrection,bar_click_menu:t.bar_click_menu||{}}}async main(){const t=this.state.config;if(t.chartType!=this.type&&t.childType!=this.type)return;try{this.config=structuredClone(t);if(!this.currServerData)this.dom.barDiv.style("max-width",window.innerWidth+"px");this.prevConfig=this.config||{};if(this.dom.header)this.dom.header.html(this.config.term.term.name+` <span style="opacity:.6;font-size:.7em;margin-left:10px;">BARCHART</span>`);this.toggleLoadingDiv();const e=this.getDataRequestOpts();await this.getDescrStats();const s=await this.app.vocabApi.getNestedChartSeriesData(e);const r=s.data;this.sampleType=s.sampleType;this.bins=s.bins;this.toggleLoadingDiv("none");this.app.vocabApi.syncTermData(this.config,r,this.prevConfig);this.currServerData=r;if(this.currServerData.refs&&this.currServerData.refs.q){for(const t of this.currServerData.refs.q){if(t.error)throw t.error}}this.term1toColor={};this.term2toColor={};this.updateSettings(this.config);this.colorScale=i(this.config.term2?this.settings.rows.length:this.settings.cols.length);this.chartsData=this.processData(this.currServerData);this.render()}catch(t){throw t}}getDataRequestOpts(){const t=this.config;const e={term:t.term,filter:this.state.termfilter.filter};if(this.state.termfilter.filter0)e.filter0=this.state.termfilter.filter0;if(t.term2)e.term2=t.term2;if(t.term0)e.term0=t.term0;return e}async getDescrStats(){const t=[this.config.term];if(this.config.term2)t.push(this.config.term2);if(this.config.term0)t.push(this.config.term0);for(const e of t){if(y(e.term)){const t=await this.app.vocabApi.getDescrStats(e,this.state.termfilter);if(t.error)throw t.error;e.q.descrStats=t.values}}}updateSettings(t){if(!t)return;this.state;const e={term0:t.term0?t.term0.term.id:"",term1:t.term.term.id,term2:t.term2?t.term2.term.id:"",unit:t.settings.barchart.unit,orientation:t.settings.barchart.orientation,asterisksVisible:t.settings.barchart.asterisksVisible,defaultColor:t.settings.barchart.defaultColor,colorBars:t.settings.barchart.colorBars,dedup:t.settings.barchart.dedup,colw:t.settings.common.barwidth,rowh:t.settings.common.barwidth,colspace:t.settings.common.barspace,rowspace:t.settings.common.barspace};this.setExclude(this.config.term,this.config.term2);Object.assign(this.settings,e,this.currServerData.refs||{},{exclude:this.settings.exclude});this.settings.cols=this.settings.dedup?this.currServerData.refs.dedupCols:this.currServerData.refs.cols;this.settings.numCharts=this.currServerData.charts?this.currServerData.charts.length:0;if(!t.term2&&this.settings.unit=="pct"){this.settings.unit="abs"}}mayResetHidden(t,e,s){const i=(t&&t.term.id)+";;"+(e&&e.term.id)+";;"+(s&&s.term.id);if(i===this.currCombinedTermIds)return;for(const s of this.currServerData.charts){if(t.q&&t.q.hiddenValues){this.mayEditHiddenValues(t,s.serieses.length,"term")}if(e&&e.q&&e.q.hiddenValues){for(const t of s.serieses){this.mayEditHiddenValues(e,t.data.length,"term2")}}}this.currCombinedTermIds=i}mayEditHiddenValues(t,e,s){const i=Object.keys(t.q.hiddenValues).filter((e=>t.q.hiddenValues[e])).length;if(i<e)return;for(const e in t.q.hiddenValues){if(!t.q.hiddenValues[e])return;delete t.q.hiddenValues[e]}this.app.save({type:"plot_edit",id:this.id,config:{[s]:t}})}setExclude(t,e){this.settings.exclude.cols=Object.keys(t.q?.hiddenValues||{}).filter((e=>t.q.hiddenValues[e])).map((e=>t.term.type=="categorical"?e:this.settings.cols?.includes(e)?e:t.term.values[e]?.label?t.term.values[e].label:e));this.settings.exclude.rows=!e?.q?.hiddenValues?[]:Object.keys(e.q.hiddenValues).filter((t=>e.q.hiddenValues[t])).map((t=>e.term.type=="categorical"?t:this.settings.rows?.includes(t)?t:e.term.values[t]?.label?e.term.values[t].label:t))}processData(t){this.seriesOrder=this.setMaxVisibleTotals(t);if(!t.charts.length){this.seriesOrder=[]}else if(t.refs.useColOrder){this.seriesOrder=this.settings.cols}const e=t.refs.rows;this.barSorter=(t,e)=>this.seriesOrder.indexOf(t)-this.seriesOrder.indexOf(e);this.overlaySorter=t.refs.useRowOrder?(t,s)=>e.indexOf(t.dataId)-e.indexOf(s.dataId):(t,e)=>this.totalsByDataId[e.dataId]>this.totalsByDataId[t.dataId]?1:this.totalsByDataId[e.dataId]<this.totalsByDataId[t.dataId]?-1:t.dataId<e.dataId?-1:1;this.visibleCharts=t.charts.filter((t=>t.visibleSerieses.length));const s=this.config.term;const i=this.config.term2;const r=t.tests;for(const t in r){const e=r[t];for(const t of e){const e=s.term.values&&t.term1comparison in s.term.values?s.term.values[t.term1comparison].label:t.term1comparison;t.term1Label=e;for(const e of t.term2tests){const t=i.term.values&&e.term2id in i.term.values?i.term.values[e.term2id].label:e.term2id;e.term2Label=t}}}return t}setMaxVisibleTotals(t){this.totalsByDataId={};const e=this.config.term;const s=this.config.term2;const i={};let r=0;for(const a of t.charts){if(!a.settings)a.settings=JSON.parse(l);Object.assign(a.settings,this.settings);a.visibleTotal=0;const t=this.settings.dedup?a.dedupedSerieses:a.serieses;a.visibleSerieses=t.filter((t=>{if(a.settings.exclude.cols.includes(t.seriesId))return false;t.visibleData=t.data.filter((t=>!a.settings.exclude.rows.includes(t.dataId)));t.visibleTotal=t.visibleData.reduce(((t,e)=>t+e.total),0);if(!t.visibleTotal)return false;a.visibleTotal+=t.visibleTotal;if(!(t.seriesId in i))i[t.seriesId]=t.visibleTotal;for(const i of t.data){i.seriesId=t.seriesId;if(e.term.type=="geneVariant"&&e.q.type=="values"||s?.term.type=="geneVariant"&&s?.q.type=="values"){if(!(i.dataId in this.totalsByDataId)){this.totalsByDataId[i.dataId]={}}this.totalsByDataId[i.dataId][a.chartId]=this.totalsByDataId[i.dataId][a.chartId]?this.totalsByDataId[i.dataId][a.chartId]+i.total:0+i.total}else{if(!(i.dataId in this.totalsByDataId)){this.totalsByDataId[i.dataId]=0}this.totalsByDataId[i.dataId]+=i.total}}return true}));a.settings.colLabels=a.visibleSerieses.map((t=>{const i=t.seriesId;const r=e.term.values&&i in e.term.values?e.term.values[i].label:i;const a=t&&"AF"in t?", AF="+t.AF:"";const o=s&&s.term.type=="condition"&&s.q.value_by_computable_grade?"":`, n=${t.visibleTotal}`;return{id:i,label:r+a+o}}));a.maxVisibleSeriesTotal=a.visibleSerieses.reduce(((t,e)=>e.visibleTotal>t?e.visibleTotal:t),0);if(a.maxVisibleSeriesTotal>r){r=a.maxVisibleSeriesTotal}}for(const e of t.charts){e.maxVisibleAcrossCharts=r}return Object.keys(i).sort(((t,e)=>i[e]-i[t]))}sortStacking(t,e,s){this.term1toColor[t.seriesId]=this.settings.colorBars?this.getColor(this.config.term.term,t.seriesId,this.bins?.[1]):this.settings.defaultColor;t.visibleData.sort(this.overlaySorter);let i=0;for(const r of t.visibleData){r.colgrp="-";r.rowgrp="-";r.chartId=e.chartId;r.seriesId=t.seriesId;if(s.tests){r.groupPvalues=s.tests[e.chartId].find((e=>e.term1comparison===t.seriesId))}r.seriesTotal=t.total;r.chartTotal=e.visibleTotal;r.logTotal=Math.log10(r.total);i+=r.logTotal;this.setTerm2Color(r);r.color=this.term2toColor[r.dataId]||this.term1toColor[t.seriesId]}if(i>e.maxSeriesLogTotal){e.maxSeriesLogTotal=i}for(const e of t.data){if(e.color)continue;this.setTerm2Color(e);e.color=this.term2toColor[e.dataId]||this.term1toColor[t.seriesId]}}setTerm2Color(t){if(!this.config.term2)return;this.term2toColor[t.dataId]=this.getColor(this.config.term2,t.dataId,this.bins?.[2])}getColor(t,e,s){if(!t.term)return;if(t.term.values){for(const[s,i]of Object.entries(t.term.values)){if(!i.color)continue;if(s===e)return i.color;if(i.label===e)return i.color}}const i=s?.find((t=>t.label==e));if(i?.color)return i.color;if(t.term.type=="geneVariant"&&t.q.type=="values")return this.getMutationColor(e);return r(this.colorScale(e)).toString()}getMutationColor(t){for(const e of Object.values(a))if(e.label===t&&e.color)return e.color;for(const e in a){if(a[e].label===t&&a[e].color)return a[e].color}}getLegendGrps(){const t=this.config.term;const e=this.config.term2;if(t.term.type=="geneVariant"&&t.q.type=="values"||e?.term.type=="geneVariant"&&e?.q.type=="values"){const t=[];for(const e of this.chartsData.charts){t.push(this.getOneLegendGrps(e))}return t}return this.getOneLegendGrps()}getOneLegendGrps(t){const e=[];const s=this.settings;const i=this.config.term;const r=this.config.term2;const a="color: #aaa; font-weight: 400";if(i.q.descrStats){const t=i.q.descrStats.map((t=>({text:`${t.label}: ${t.value}`,noIcon:true})));const s=r?`Descriptive statistics: ${i.term.name}`:"Descriptive statistics";const o=`<span style="${a}">${s}</span>`;e.push({name:o,items:t})}if(r?.q.descrStats){const t=r.q.descrStats.map((t=>({text:`${t.label}: ${t.value}`,noIcon:true})));const s=`Descriptive statistics: ${r.term.name}`;const i=`<span style="${a}">${s}</span>`;e.push({name:i,items:t})}if(s.cols&&s.exclude.cols.length){const o=(t,e)=>t+e.total;const n=s.exclude.cols.filter((t=>s.cols.includes(t))).flatMap((e=>{const s=t=>t.seriesId==e;const a=r?.term?.type=="condition"?0:i.term.type=="geneVariant"&&i.q.type=="values"||r?.term.type=="geneVariant"&&r?.q.type=="values"?t.serieses.filter(s).reduce(o,0):this.currServerData.charts.reduce(((t,e)=>t+e.serieses.filter(s).reduce(o,0)),0);if(!a&&!r?.term?.type)return[];const n=i.term.values&&e in i.term.values?i.term.values[e].label:e;const l=a?", n="+a:"";return[{id:e,text:n+l,color:"#fff",textColor:"#000",border:"1px solid #333",noIcon:true,type:"col",isHidden:true,hiddenOpacity:1}]})).sort(this.barSorter);if(n.length){const t=r?i.term.name:"Other categories";e.push({name:`<span style="${a}">${t}</span>`,items:n})}}if(s.rows&&!s.hidelegend&&r&&this.term2toColor){const i=r.term.type!="condition"||!r.q?"":r.q.value_by_max_grade?"max. grade":r.q.value_by_most_recent?"most recent":"";e.push({name:`<span style="${a}">`+r.term.name+(i?", "+i:"")+"</span>",items:s.rows.flatMap((e=>{const i=t?this.totalsByDataId[e]?.[t.chartId]:this.totalsByDataId[e];if(!i)return[];const a=i?", n="+i:"";const o=r.term.values&&e in r.term.values?r.term.values[e].label:e;return[{dataId:e,text:o+a,color:this.term2toColor[e],type:"row",isHidden:s.exclude.rows.includes(e)}]})).sort(this.overlaySorter)})}if(r&&this.state.multipleTestingCorrection){let t=0;for(const e in this.chartsData.tests){t+=this.chartsData.tests[e].reduce(((t,e)=>t+e.term2tests.filter((t=>!t.skipped)).length),0)}const s=t>1?[{text:`* p-value < (0.05 / ${t} tests)`,noEditColor:true}]:[{text:`* p-value < 0.05`,noEditColor:true}];e.push({name:`<span style="${a}">Statistical Significance</span>`,items:s})}return e}toggleLoadingDiv(t=""){if(t!="none"){this.dom.loadingDiv.style("opacity",0).style("display",t).transition().duration("loadingWait"in this?this.loadingWait:0).style("opacity",1)}else{this.dom.loadingDiv.style("display",t)}this.loadingWait=1e3}}const x=t(v);const D=x;function C(t){t.render=function(){const e=t.dom.barDiv.selectAll(".pp-sbar-div").data(t.visibleCharts,(t=>t.chartId));e.exit().each(t.exitChart);e.each(t.updateChart);e.enter().append("div").each(t.addChart);t.dom.holder.selectAll(".pp-chart-title").style("display",t.visibleCharts.length<2?"none":"block");const s=t.getLegendGrps();t.legendRenderer(s);if(!t.visibleCharts.length){const e=t.settings.exclude.cols.length||t.settings.exclude.rows.length?`<br/><span>click on a legend label below to display the barchart</span>`:"";t.dom.banner.html(`<span>No visible barchart data to render</span>${e}`).style("display","block");t.dom.legendDiv.selectAll("*").remove()}else{t.dom.banner.text("").style("display","none")}};t.exitChart=function(e){delete t.renderers[e.chartId];o(this).remove()};t.updateChart=function(s){s.settings.cols.sort(t.barSorter);s.maxAcrossCharts=t.chartsData.maxAcrossCharts;s.handlers=t.handlers;s.maxSeriesLogTotal=0;s.visibleSerieses.forEach((e=>t.sortStacking(e,s,t.chartsData)));t.renderers[s.chartId](s);const i=o(this);i.select(".pp-sbar-div-chartLengends").selectAll("*").remove();if(t.chartsData.tests&&t.chartsData.tests[s.chartId]){e(s,i)}};t.addChart=function(s,i){const r=o(this).attr("class","pp-sbar-div").style("display","inline-block").style("padding","20px").style("vertical-align","top");t.renderers[s.chartId]=c(t,o(this));s.settings.cols.sort(t.barSorter);s.maxAcrossCharts=t.chartsData.maxAcrossCharts;s.handlers=t.handlers;s.maxSeriesLogTotal=0;s.visibleSerieses.forEach((e=>t.sortStacking(e,s,t.chartsData)));t.renderers[s.chartId](s);r.append("div").attr("class","pp-sbar-div-chartLengends").attr("data-testid","sjpcb-bars-chartLengends").style("vertical-align","top").style("margin","10px 10px 10px 30px").style("display","none");if(t.chartsData.tests&&t.chartsData.tests[s.chartId]){e(s,r)}};function e(e,i){const r=i.select(".pp-sbar-div-chartLengends").style("display","inline-block").style("vertical-align","top").style("text-align","center").append("div");t.chartsData.tests[e.chartId].sort((function(e,s){return t.settings.cols.indexOf(e.term1comparison)-t.settings.cols.indexOf(s.term1comparison)}));for(const s of t.chartsData.tests[e.chartId]){s.term2tests.sort((function(e,s){return t.chartsData.refs.rows.indexOf(e.term2id)-t.chartsData.refs.rows.indexOf(s.term2id)}))}const a=[{label:"Row 1"},{label:"Row 2"},{label:"Column 1"},{label:"Column 2"},{label:"P-value"}];const o=t.chartsData.tests[e.chartId].every((t=>t.term2tests.every((t=>!t.skipped))));const n=[];const l=t.chartsData.tests[e.chartId].filter((t=>e.visibleSerieses.some((e=>e.seriesId===t.term1comparison))));for(const[t,i]of l.entries()){if(l.length==2&&t==1){break}const r=e.visibleSerieses.find((t=>t.seriesId===i.term1comparison));const a=i.term2tests.filter((t=>r.visibleData.some((e=>e.dataId===t.term2id))));for(const[t,e]of a.entries()){if(a.length==2&&t==1){break}n.push([{value:`${i.term1Label}`},{value:l.length==2?l[1].term1Label:s(i.term1Label)},{value:e.term2Label},{value:a.length==2?a[1].term2Label:s(e.term2Label)},{html:e.skipped?"N/A":e.pvalue>1e-4?Number(e.pvalue.toFixed(4)):Number(e.pvalue.toPrecision(4)).toExponential()}])}}r.append("div").style("font-weight","bold").style("padding-bottom","0.5em").html("2x2 Association test (Fisher's exact test)").style("font-size","0.9em");const c=r.append("div").style("font-size","0.9em");u({columns:a,rows:n,div:c,showLines:false,maxWidth:"70vw",maxHeight:`${e.svgh-100}px`,resize:true});c.append("div").style("margin-top","10px").style("text-align","left").style("font-size","10px").style("font-weight","normal").html(o?"":"N/A: association test skipped because of limited sample size <br>")}function s(t){if(t.toUpperCase().startsWith("NOT ")){return t.substring(4)}else{return"not "+t}}}function w(t){t.handlers=p(t);t.download=function(){if(!t.state)return;const e=[];const s={x:undefined,y:undefined};const i=[];let r=0,a=0,l=0;let c=0,d=0;t.dom.barDiv.selectAll(".sjpcb-bars-mainG").each((function(){e.push(this);const t=this.getBBox();if(t.width>r)r=t.width;if(t.height>a)a=t.height;const n=Math.round(this.parentNode.parentNode.getBoundingClientRect().y);if(!d){c=n;d++}else if(Math.abs(n-c)<5){d++}const h=o(this).attr("transform").split("translate(")[1].split(")")[0].split(",").map((t=>+t.trim()));if(s.x===undefined||h[0]>s.x)s.x=+h[0];if(s.y===undefined||h[1]>s.y)s.y=+h[1];const p=this.parentNode.parentNode.firstChild;const m=p.getBoundingClientRect();if(m.width>r)r=m.width;if(m.height>l)l=m.height;i.push({text:p.innerText,styles:window.getComputedStyle(p)})}));r+=30;a+=30;const p=document.createElementNS("http://www.w3.org/2000/svg","svg");const m=o(p).style("display","block").style("opacity",1).attr("width",d*r).attr("height",Math.floor(e.length/d)*a);const f=window.getComputedStyle(document.querySelector(".pp-bars-svg"));for(const t of f){if(t.startsWith("font"))m.style(t,f.getPropertyValue(t))}e.forEach(((t,e)=>{const n=t.cloneNode(true);const c=e%d;const h=Math.floor(e/d);const m={x:c*r+s.x,y:h*a+s.y};const f=o(p).append("text").attr("transform","translate("+m.x+","+m.y+")").text(i[e].text);for(const t of i[e].styles){if(t.startsWith("font"))f.style(t,i[e].styles.getPropertyValue(t))}o(n).attr("transform","translate("+m.x+","+(m.y+l)+")");p.appendChild(n)}));const g=o("body").append("div").style("opacity",0);g.node().appendChild(p);t.svgLegendRenderer=h({holder:m.append("g"),rectFillFxn:t=>t.color,iconStroke:"#aaa"});t.settings;const u=t.dom.barDiv.select("svg").node().getBoundingClientRect();let b=t.getLegendGrps();b.forEach((t=>{t.name=t.name.replace(/<[^>]*>?/gm,"");if(t.items)t.items=t.items.filter((t=>!t.isHidden))}));b=b.filter((t=>t.items.length&&!t.name.includes("tatistic")));const y=14;t.svgLegendRenderer(b,{settings:Object.assign({ontop:false,lineh:25,padx:5,padleft:0,padright:20,padbtm:30,fontsize:y,iconh:y-2,iconw:y-2,hangleft:1,linesep:false},{svgw:t.visibleCharts.length*u.width,svgh:u.height,dimensions:{xOffset:50},padleft:50})});const v=t.dom.legendDiv.node().getBoundingClientRect();o(p).attr("height",u.height+v.height+30);if(v.width>u.width)o(p).attr("width",v.width);g.remove();const x=t.config.term.term.name+" barchart";n(p,x,{apply_dom_styles:true})}}function I(t){return{orientation:"horizontal",unit:"abs",overlay:"none",divideBy:"none",rowlabelw:250,asterisksVisible:t?.getState()?.termdbConfig?.multipleTestingCorrection?true:false,defaultColor:e,colorBars:false,dedup:false}}async function S(t,e){if(!t.term)throw"barchart getPlotConfig: opts.term{} missing";try{await b(t.term,e.vocabApi);if(t.term2)await b(t.term2,e.vocabApi);if(t.term0)await b(t.term0,e.vocabApi)}catch(t){throw`${t} [barchart getPlotConfig()]`}const i={id:t.term.term.id,settings:{controls:{term2:null,term0:null},common:{use_logscale:false,use_percentage:false,barheight:300,barwidth:20,barspace:2},barchart:I(e)}};return s(i,t)}export{x as barInit,D as componentInit,I as getDefaultBarSettings,S as getPlotConfig};
1
+ import{h as t,Q as e,P as s,C as i,r,z as a,d as o,U as n}from"./app-0de0ae35.js";import l from"./bars.settings-64bb4642.js";import c from"./bars.renderer-d7461d5d.js";import{h as d}from"./html.legend-455f7881.js";import{s as h}from"./svg.legend-8d21872d.js";import p from"./barchart.events-9b482604.js";import{renderTerm1Label as m,term0_term2_defaultQ as f,controlsInit as g}from"./controls-1f3ac9d0.js";import{r as u}from"./table-e2a307e6.js";import{f as b,i as y}from"./termsetting-2e75e729.js";import"./axis-747c801e.js";import"./log-d560d2a5.js";import"./FilterRxComp-fb608459.js";import"./partjson.esm-b3f1fc21.js";import"./termdb.bins-7ecc48db.js";import"./controls.btns-5b44e5d0.js";import"./controls.config-b0339f96.js";import"./tslib.es6-c3c2d88f.js";import"path";class v{constructor(t){this.type="barchart"}preApiFreeze(t){t.download=this.download}async init(t){const e=this.opts;const s=this.opts.controls?null:e.holder.append("div");const i=e.controls?e.holder:e.holder.append("div");this.dom={loadingDiv:i.append("div").style("position","absolute").style("display","none").style("padding","20px").html("Loading ..."),header:e.header,controls:s,holder:i,banner:i.append("div").style("display","none").style("text-align","center").style("padding","24px").style("font-size","16px").style("color","#aaa"),barDiv:i.append("div"),legendDiv:i.append("div").style("margin","5px 5px 15px 5px")};if(this.dom.header)this.dom.header.html("Barchart");this.settings=JSON.parse(l);C(this);w(this);this.renderers={};this.legendRenderer=d(this.dom.legendDiv,{settings:{legendOrientation:"vertical"},handlers:this.handlers},this.dom.barDiv);this.controls={};this.term2toColor={};await this.setControls(this.getState(t));if(this.opts.bar_click_override);else if(!this.opts.bar_click_opts){this.opts.bar_click_opts=["hide_bar"];if(this.app.getState().nav.header_mode==="with_tabs")this.opts.bar_click_opts.push("add_filter")}}async setControls(t){if(this.opts.controls){this.opts.controls.on("downloadClick.barchart",this.download)}else{this.dom.holder.attr("class","pp-termdb-plot-viz").style("display","inline-block").style("min-width","300px").style("margin-left","50px");const t=[{type:"term",configKey:"term",chartType:"barchart",usecase:{target:"barchart",detail:"term"},label:m,vocabApi:this.app.vocabApi,menuOptions:"edit"},{type:"term",configKey:"term2",chartType:"barchart",usecase:{target:"barchart",detail:"term2"},title:"Overlay data",label:"Overlay",vocabApi:this.app.vocabApi,numericEditMenuVersion:this.opts.numericEditMenuVersion,defaultQ4fillTW:f},{type:"term",configKey:"term0",chartType:"barchart",usecase:{target:"barchart",detail:"term0"},title:"Divide by data",label:"Divide by",vocabApi:this.app.vocabApi,numericEditMenuVersion:this.opts.numericEditMenuVersion,defaultQ4fillTW:f},{label:"Orientation",type:"radio",chartType:"barchart",settingsKey:"orientation",options:[{label:"Vertical",value:"vertical"},{label:"Horizontal",value:"horizontal"}]},{label:"Scale",type:"radio",chartType:"barchart",settingsKey:"unit",options:[{label:"Linear",value:"abs"},{label:"Log",value:"log",getDisplayStyle:t=>t.term2?"none":"inline-block"},{label:"Proportion",value:"pct",getDisplayStyle:t=>t.term2?"inline-block":"none"}]},{label:"Multicolor bars",title:"Color bars using the colors preassigned if available, otherwise generates a color",type:"checkbox",chartType:"barchart",settingsKey:"colorBars",boxLabel:"Yes",getDisplayStyle:t=>t.term2?"none":"table-row"},{label:"Deduplicate",title:"Use separate bars samples that has multiple values or belong to multiple groups",type:"checkbox",chartType:"barchart",settingsKey:"dedup",boxLabel:"Yes",getDisplayStyle:t=>this.chartsData.charts.find((t=>t.serieses.length!=t.dedupedSerieses.length))?"table-row":"none"},{label:"Default color",title:"Default color for bars when there is no overlay",type:"color",chartType:"barchart",settingsKey:"defaultColor"}];if(this.app.getState().termdbConfig.multipleTestingCorrection){t.push({label:"Asterisks",boxLabel:"Visible",type:"checkbox",chartType:"barchart",settingsKey:"asterisksVisible",title:"Display the asterisks"})}this.components={controls:await g({app:this.app,id:this.id,holder:this.dom.controls.attr("class","pp-termdb-plot-controls").style("display","inline-block"),inputs:t})};this.components.controls.on("downloadClick.barchart",this.download)}}reactsTo(t){if(t.type.startsWith("plot_")){return t.id===this.id&&(!t.config.childType||t.config.childType==this.type)}return true}getState(t){const e=t.plots.find((t=>t.id===this.id));if(!e){throw`No plot with id='${this.id}' found. Did you set this.id before this.api = getComponentApi(this)?`}return{nav:{header_mode:t.nav.header_mode},termfilter:t.termfilter,config:Object.assign({},e,{settings:{barchart:e.settings.barchart,common:e.settings.common},displaySampleIds:t.termdbConfig.displaySampleIds&&this.app.vocabApi.hasVerifiedToken()}),multipleTestingCorrection:t.termdbConfig.multipleTestingCorrection,bar_click_menu:t.bar_click_menu||{}}}async main(){const t=this.state.config;if(t.chartType!=this.type&&t.childType!=this.type)return;try{this.config=structuredClone(t);if(!this.currServerData)this.dom.barDiv.style("max-width",window.innerWidth+"px");this.prevConfig=this.config||{};if(this.dom.header)this.dom.header.html(this.config.term.term.name+` <span style="opacity:.6;font-size:.7em;margin-left:10px;">BARCHART</span>`);this.toggleLoadingDiv();const e=this.getDataRequestOpts();await this.getDescrStats();const s=await this.app.vocabApi.getNestedChartSeriesData(e);const r=s.data;this.sampleType=s.sampleType;this.bins=s.bins;this.toggleLoadingDiv("none");this.app.vocabApi.syncTermData(this.config,r,this.prevConfig);this.currServerData=r;if(this.currServerData.refs&&this.currServerData.refs.q){for(const t of this.currServerData.refs.q){if(t.error)throw t.error}}this.term1toColor={};this.term2toColor={};this.updateSettings(this.config);this.colorScale=i(this.config.term2?this.settings.rows.length:this.settings.cols.length);this.chartsData=this.processData(this.currServerData);this.render()}catch(t){throw t}}getDataRequestOpts(){const t=this.config;const e={term:t.term,filter:this.state.termfilter.filter};if(this.state.termfilter.filter0)e.filter0=this.state.termfilter.filter0;if(t.term2)e.term2=t.term2;if(t.term0)e.term0=t.term0;return e}async getDescrStats(){const t=[this.config.term];if(this.config.term2)t.push(this.config.term2);if(this.config.term0)t.push(this.config.term0);for(const e of t){if(y(e.term)){const t=await this.app.vocabApi.getDescrStats(e,this.state.termfilter);if(t.error)throw t.error;e.q.descrStats=t.values}}}updateSettings(t){if(!t)return;this.state;const e={term0:t.term0?t.term0.term.id:"",term1:t.term.term.id,term2:t.term2?t.term2.term.id:"",unit:t.settings.barchart.unit,orientation:t.settings.barchart.orientation,asterisksVisible:t.settings.barchart.asterisksVisible,defaultColor:t.settings.barchart.defaultColor,colorBars:t.settings.barchart.colorBars,dedup:t.settings.barchart.dedup,colw:t.settings.common.barwidth,rowh:t.settings.common.barwidth,colspace:t.settings.common.barspace,rowspace:t.settings.common.barspace};this.setExclude(this.config.term,this.config.term2);Object.assign(this.settings,e,this.currServerData.refs||{},{exclude:this.settings.exclude});this.settings.cols=this.settings.dedup?this.currServerData.refs.dedupCols:this.currServerData.refs.cols;this.settings.numCharts=this.currServerData.charts?this.currServerData.charts.length:0;if(!t.term2&&this.settings.unit=="pct"){this.settings.unit="abs"}}mayResetHidden(t,e,s){const i=(t&&t.term.id)+";;"+(e&&e.term.id)+";;"+(s&&s.term.id);if(i===this.currCombinedTermIds)return;for(const s of this.currServerData.charts){if(t.q&&t.q.hiddenValues){this.mayEditHiddenValues(t,s.serieses.length,"term")}if(e&&e.q&&e.q.hiddenValues){for(const t of s.serieses){this.mayEditHiddenValues(e,t.data.length,"term2")}}}this.currCombinedTermIds=i}mayEditHiddenValues(t,e,s){const i=Object.keys(t.q.hiddenValues).filter((e=>t.q.hiddenValues[e])).length;if(i<e)return;for(const e in t.q.hiddenValues){if(!t.q.hiddenValues[e])return;delete t.q.hiddenValues[e]}this.app.save({type:"plot_edit",id:this.id,config:{[s]:t}})}setExclude(t,e){this.settings.exclude.cols=Object.keys(t.q?.hiddenValues||{}).filter((e=>t.q.hiddenValues[e])).map((e=>t.term.type=="categorical"?e:this.settings.cols?.includes(e)?e:t.term.values[e]?.label?t.term.values[e].label:e));this.settings.exclude.rows=!e?.q?.hiddenValues?[]:Object.keys(e.q.hiddenValues).filter((t=>e.q.hiddenValues[t])).map((t=>e.term.type=="categorical"?t:this.settings.rows?.includes(t)?t:e.term.values[t]?.label?e.term.values[t].label:t))}processData(t){this.seriesOrder=this.setMaxVisibleTotals(t);if(!t.charts.length){this.seriesOrder=[]}else if(t.refs.useColOrder){this.seriesOrder=this.settings.cols}const e=t.refs.rows;this.barSorter=(t,e)=>this.seriesOrder.indexOf(t)-this.seriesOrder.indexOf(e);this.overlaySorter=t.refs.useRowOrder?(t,s)=>e.indexOf(t.dataId)-e.indexOf(s.dataId):(t,e)=>this.totalsByDataId[e.dataId]>this.totalsByDataId[t.dataId]?1:this.totalsByDataId[e.dataId]<this.totalsByDataId[t.dataId]?-1:t.dataId<e.dataId?-1:1;this.visibleCharts=t.charts.filter((t=>t.visibleSerieses.length));const s=this.config.term;const i=this.config.term2;const r=t.tests;for(const t in r){const e=r[t];for(const t of e){const e=s.term.values&&t.term1comparison in s.term.values?s.term.values[t.term1comparison].label:t.term1comparison;t.term1Label=e;for(const e of t.term2tests){const t=i.term.values&&e.term2id in i.term.values?i.term.values[e.term2id].label:e.term2id;e.term2Label=t}}}return t}setMaxVisibleTotals(t){this.totalsByDataId={};const e=this.config.term;const s=this.config.term2;const i={};let r=0;for(const a of t.charts){if(!a.settings)a.settings=JSON.parse(l);Object.assign(a.settings,this.settings);a.visibleTotal=0;const t=this.settings.dedup?a.dedupedSerieses:a.serieses;a.visibleSerieses=t.filter((t=>{if(a.settings.exclude.cols.includes(t.seriesId))return false;t.visibleData=t.data.filter((t=>!a.settings.exclude.rows.includes(t.dataId)));t.visibleTotal=t.visibleData.reduce(((t,e)=>t+e.total),0);if(!t.visibleTotal)return false;a.visibleTotal+=t.visibleTotal;if(!(t.seriesId in i))i[t.seriesId]=t.visibleTotal;for(const i of t.data){i.seriesId=t.seriesId;if(e.term.type=="geneVariant"&&e.q.type=="values"||s?.term.type=="geneVariant"&&s?.q.type=="values"){if(!(i.dataId in this.totalsByDataId)){this.totalsByDataId[i.dataId]={}}this.totalsByDataId[i.dataId][a.chartId]=this.totalsByDataId[i.dataId][a.chartId]?this.totalsByDataId[i.dataId][a.chartId]+i.total:0+i.total}else{if(!(i.dataId in this.totalsByDataId)){this.totalsByDataId[i.dataId]=0}this.totalsByDataId[i.dataId]+=i.total}}return true}));a.settings.colLabels=a.visibleSerieses.map((t=>{const i=t.seriesId;const r=e.term.values&&i in e.term.values?e.term.values[i].label:i;const a=t&&"AF"in t?", AF="+t.AF:"";const o=s&&s.term.type=="condition"&&s.q.value_by_computable_grade?"":`, n=${t.visibleTotal}`;return{id:i,label:r+a+o}}));a.maxVisibleSeriesTotal=a.visibleSerieses.reduce(((t,e)=>e.visibleTotal>t?e.visibleTotal:t),0);if(a.maxVisibleSeriesTotal>r){r=a.maxVisibleSeriesTotal}}for(const e of t.charts){e.maxVisibleAcrossCharts=r}return Object.keys(i).sort(((t,e)=>i[e]-i[t]))}sortStacking(t,e,s){this.term1toColor[t.seriesId]=this.settings.colorBars?this.getColor(this.config.term.term,t.seriesId,this.bins?.[1]):this.settings.defaultColor;t.visibleData.sort(this.overlaySorter);let i=0;for(const r of t.visibleData){r.colgrp="-";r.rowgrp="-";r.chartId=e.chartId;r.seriesId=t.seriesId;if(s.tests){r.groupPvalues=s.tests[e.chartId].find((e=>e.term1comparison===t.seriesId))}r.seriesTotal=t.total;r.chartTotal=e.visibleTotal;r.logTotal=Math.log10(r.total);i+=r.logTotal;this.setTerm2Color(r);r.color=this.term2toColor[r.dataId]||this.term1toColor[t.seriesId]}if(i>e.maxSeriesLogTotal){e.maxSeriesLogTotal=i}for(const e of t.data){if(e.color)continue;this.setTerm2Color(e);e.color=this.term2toColor[e.dataId]||this.term1toColor[t.seriesId]}}setTerm2Color(t){if(!this.config.term2)return;this.term2toColor[t.dataId]=this.getColor(this.config.term2,t.dataId,this.bins?.[2])}getColor(t,e,s){if(!t.term)return;if(t.term.values){for(const[s,i]of Object.entries(t.term.values)){if(!i.color)continue;if(s===e)return i.color;if(i.label===e)return i.color}}const i=s?.find((t=>t.label==e));if(i?.color)return i.color;if(t.term.type=="geneVariant"&&t.q.type=="values")return this.getMutationColor(e);return r(this.colorScale(e)).toString()}getMutationColor(t){for(const e of Object.values(a))if(e.label===t&&e.color)return e.color;for(const e in a){if(a[e].label===t&&a[e].color)return a[e].color}}getLegendGrps(){const t=this.config.term;const e=this.config.term2;if(t.term.type=="geneVariant"&&t.q.type=="values"||e?.term.type=="geneVariant"&&e?.q.type=="values"){const t=[];for(const e of this.chartsData.charts){t.push(this.getOneLegendGrps(e))}return t}return this.getOneLegendGrps()}getOneLegendGrps(t){const e=[];const s=this.settings;const i=this.config.term;const r=this.config.term2;const a="color: #aaa; font-weight: 400";if(i.q.descrStats){const t=i.q.descrStats.map((t=>({text:`${t.label}: ${t.value}`,noIcon:true})));const s=r?`Descriptive statistics: ${i.term.name}`:"Descriptive statistics";const o=`<span style="${a}">${s}</span>`;e.push({name:o,items:t})}if(r?.q.descrStats){const t=r.q.descrStats.map((t=>({text:`${t.label}: ${t.value}`,noIcon:true})));const s=`Descriptive statistics: ${r.term.name}`;const i=`<span style="${a}">${s}</span>`;e.push({name:i,items:t})}if(s.cols&&s.exclude.cols.length){const o=(t,e)=>t+e.total;const n=s.exclude.cols.filter((t=>s.cols.includes(t))).flatMap((e=>{const s=t=>t.seriesId==e;const a=r?.term?.type=="condition"?0:i.term.type=="geneVariant"&&i.q.type=="values"||r?.term.type=="geneVariant"&&r?.q.type=="values"?t.serieses.filter(s).reduce(o,0):this.currServerData.charts.reduce(((t,e)=>t+e.serieses.filter(s).reduce(o,0)),0);if(!a&&!r?.term?.type)return[];const n=i.term.values&&e in i.term.values?i.term.values[e].label:e;const l=a?", n="+a:"";return[{id:e,text:n+l,color:"#fff",textColor:"#000",border:"1px solid #333",noIcon:true,type:"col",isHidden:true,hiddenOpacity:1}]})).sort(this.barSorter);if(n.length){const t=r?i.term.name:"Other categories";e.push({name:`<span style="${a}">${t}</span>`,items:n})}}if(s.rows&&!s.hidelegend&&r&&this.term2toColor){const i=r.term.type!="condition"||!r.q?"":r.q.value_by_max_grade?"max. grade":r.q.value_by_most_recent?"most recent":"";e.push({name:`<span style="${a}">`+r.term.name+(i?", "+i:"")+"</span>",items:s.rows.flatMap((e=>{const i=t?this.totalsByDataId[e]?.[t.chartId]:this.totalsByDataId[e];if(!i)return[];const a=i?", n="+i:"";const o=r.term.values&&e in r.term.values?r.term.values[e].label:e;return[{dataId:e,text:o+a,color:this.term2toColor[e],type:"row",isHidden:s.exclude.rows.includes(e)}]})).sort(this.overlaySorter)})}if(r&&this.state.multipleTestingCorrection){let t=0;for(const e in this.chartsData.tests){t+=this.chartsData.tests[e].reduce(((t,e)=>t+e.term2tests.filter((t=>!t.skipped)).length),0)}const s=t>1?[{text:`* p-value < (0.05 / ${t} tests)`,noEditColor:true}]:[{text:`* p-value < 0.05`,noEditColor:true}];e.push({name:`<span style="${a}">Statistical Significance</span>`,items:s})}return e}toggleLoadingDiv(t=""){if(t!="none"){this.dom.loadingDiv.style("opacity",0).style("display",t).transition().duration("loadingWait"in this?this.loadingWait:0).style("opacity",1)}else{this.dom.loadingDiv.style("display",t)}this.loadingWait=1e3}}const x=t(v);const D=x;function C(t){t.render=function(){const e=t.dom.barDiv.selectAll(".pp-sbar-div").data(t.visibleCharts,(t=>t.chartId));e.exit().each(t.exitChart);e.each(t.updateChart);e.enter().append("div").each(t.addChart);t.dom.holder.selectAll(".pp-chart-title").style("display",t.visibleCharts.length<2?"none":"block");const s=t.getLegendGrps();t.legendRenderer(s);if(!t.visibleCharts.length){const e=t.settings.exclude.cols.length||t.settings.exclude.rows.length?`<br/><span>click on a legend label below to display the barchart</span>`:"";t.dom.banner.html(`<span>No visible barchart data to render</span>${e}`).style("display","block");t.dom.legendDiv.selectAll("*").remove()}else{t.dom.banner.text("").style("display","none")}};t.exitChart=function(e){delete t.renderers[e.chartId];o(this).remove()};t.updateChart=function(s){s.settings.cols.sort(t.barSorter);s.maxAcrossCharts=t.chartsData.maxAcrossCharts;s.handlers=t.handlers;s.maxSeriesLogTotal=0;s.visibleSerieses.forEach((e=>t.sortStacking(e,s,t.chartsData)));t.renderers[s.chartId](s);const i=o(this);i.select(".pp-sbar-div-chartLengends").selectAll("*").remove();if(t.chartsData.tests&&t.chartsData.tests[s.chartId]){e(s,i)}};t.addChart=function(s,i){const r=o(this).attr("class","pp-sbar-div").style("display","inline-block").style("padding","20px").style("vertical-align","top");t.renderers[s.chartId]=c(t,o(this));s.settings.cols.sort(t.barSorter);s.maxAcrossCharts=t.chartsData.maxAcrossCharts;s.handlers=t.handlers;s.maxSeriesLogTotal=0;s.visibleSerieses.forEach((e=>t.sortStacking(e,s,t.chartsData)));t.renderers[s.chartId](s);r.append("div").attr("class","pp-sbar-div-chartLengends").attr("data-testid","sjpcb-bars-chartLengends").style("vertical-align","top").style("margin","10px 10px 10px 30px").style("display","none");if(t.chartsData.tests&&t.chartsData.tests[s.chartId]){e(s,r)}};function e(e,i){const r=i.select(".pp-sbar-div-chartLengends").style("display","inline-block").style("vertical-align","top").style("text-align","center").append("div");t.chartsData.tests[e.chartId].sort((function(e,s){return t.settings.cols.indexOf(e.term1comparison)-t.settings.cols.indexOf(s.term1comparison)}));for(const s of t.chartsData.tests[e.chartId]){s.term2tests.sort((function(e,s){return t.chartsData.refs.rows.indexOf(e.term2id)-t.chartsData.refs.rows.indexOf(s.term2id)}))}const a=[{label:"Row 1"},{label:"Row 2"},{label:"Column 1"},{label:"Column 2"},{label:"P-value"}];const o=t.chartsData.tests[e.chartId].every((t=>t.term2tests.every((t=>!t.skipped))));const n=[];const l=t.chartsData.tests[e.chartId].filter((t=>e.visibleSerieses.some((e=>e.seriesId===t.term1comparison))));for(const[t,i]of l.entries()){if(l.length==2&&t==1){break}const r=e.visibleSerieses.find((t=>t.seriesId===i.term1comparison));const a=i.term2tests.filter((t=>r.visibleData.some((e=>e.dataId===t.term2id))));for(const[t,e]of a.entries()){if(a.length==2&&t==1){break}n.push([{value:`${i.term1Label}`},{value:l.length==2?l[1].term1Label:s(i.term1Label)},{value:e.term2Label},{value:a.length==2?a[1].term2Label:s(e.term2Label)},{html:e.skipped?"N/A":e.pvalue>1e-4?Number(e.pvalue.toFixed(4)):Number(e.pvalue.toPrecision(4)).toExponential()}])}}r.append("div").style("font-weight","bold").style("padding-bottom","0.5em").html("2x2 Association test (Fisher's exact test)").style("font-size","0.9em");const c=r.append("div").style("font-size","0.9em");u({columns:a,rows:n,div:c,showLines:false,maxWidth:"70vw",maxHeight:`${e.svgh-100}px`,resize:true});c.append("div").style("margin-top","10px").style("text-align","left").style("font-size","10px").style("font-weight","normal").html(o?"":"N/A: association test skipped because of limited sample size <br>")}function s(t){if(t.toUpperCase().startsWith("NOT ")){return t.substring(4)}else{return"not "+t}}}function w(t){t.handlers=p(t);t.download=function(){if(!t.state)return;const e=[];const s={x:undefined,y:undefined};const i=[];let r=0,a=0,l=0;let c=0,d=0;t.dom.barDiv.selectAll(".sjpcb-bars-mainG").each((function(){e.push(this);const t=this.getBBox();if(t.width>r)r=t.width;if(t.height>a)a=t.height;const n=Math.round(this.parentNode.parentNode.getBoundingClientRect().y);if(!d){c=n;d++}else if(Math.abs(n-c)<5){d++}const h=o(this).attr("transform").split("translate(")[1].split(")")[0].split(",").map((t=>+t.trim()));if(s.x===undefined||h[0]>s.x)s.x=+h[0];if(s.y===undefined||h[1]>s.y)s.y=+h[1];const p=this.parentNode.parentNode.firstChild;const m=p.getBoundingClientRect();if(m.width>r)r=m.width;if(m.height>l)l=m.height;i.push({text:p.innerText,styles:window.getComputedStyle(p)})}));r+=30;a+=30;const p=document.createElementNS("http://www.w3.org/2000/svg","svg");const m=o(p).style("display","block").style("opacity",1).attr("width",d*r).attr("height",Math.floor(e.length/d)*a);const f=window.getComputedStyle(document.querySelector(".pp-bars-svg"));for(const t of f){if(t.startsWith("font"))m.style(t,f.getPropertyValue(t))}e.forEach(((t,e)=>{const n=t.cloneNode(true);const c=e%d;const h=Math.floor(e/d);const m={x:c*r+s.x,y:h*a+s.y};const f=o(p).append("text").attr("transform","translate("+m.x+","+m.y+")").text(i[e].text);for(const t of i[e].styles){if(t.startsWith("font"))f.style(t,i[e].styles.getPropertyValue(t))}o(n).attr("transform","translate("+m.x+","+(m.y+l)+")");p.appendChild(n)}));const g=o("body").append("div").style("opacity",0);g.node().appendChild(p);t.svgLegendRenderer=h({holder:m.append("g"),rectFillFxn:t=>t.color,iconStroke:"#aaa"});t.settings;const u=t.dom.barDiv.select("svg").node().getBoundingClientRect();let b=t.getLegendGrps();b.forEach((t=>{t.name=t.name.replace(/<[^>]*>?/gm,"");if(t.items)t.items=t.items.filter((t=>!t.isHidden))}));b=b.filter((t=>t.items.length&&!t.name.includes("tatistic")));const y=14;t.svgLegendRenderer(b,{settings:Object.assign({ontop:false,lineh:25,padx:5,padleft:0,padright:20,padbtm:30,fontsize:y,iconh:y-2,iconw:y-2,hangleft:1,linesep:false},{svgw:t.visibleCharts.length*u.width,svgh:u.height,dimensions:{xOffset:50},padleft:50})});const v=t.dom.legendDiv.node().getBoundingClientRect();o(p).attr("height",u.height+v.height+30);if(v.width>u.width)o(p).attr("width",v.width);g.remove();const x=t.config.term.term.name+" barchart";n(p,x,{apply_dom_styles:true})}}function I(t){return{orientation:"horizontal",unit:"abs",overlay:"none",divideBy:"none",rowlabelw:250,asterisksVisible:t?.getState()?.termdbConfig?.multipleTestingCorrection?true:false,defaultColor:e,colorBars:false,dedup:false}}async function S(t,e){if(!t.term)throw"barchart getPlotConfig: opts.term{} missing";try{await b(t.term,e.vocabApi);if(t.term2)await b(t.term2,e.vocabApi);if(t.term0)await b(t.term0,e.vocabApi)}catch(t){throw`${t} [barchart getPlotConfig()]`}const i={id:t.term.term.id,settings:{controls:{term2:null,term0:null},common:{use_logscale:false,use_percentage:false,barheight:300,barwidth:20,barspace:2},barchart:I(e)}};return s(i,t)}export{x as barInit,D as componentInit,I as getDefaultBarSettings,S as getPlotConfig};
@@ -1 +1 @@
1
- import{M as t,r as e,Z as a}from"./app-6fb77603.js";import{r as i}from"./table-0daf2b89.js";import"./termsetting-492eefa7.js";import{d as s,c as n,a as r,g as l}from"./FilterRxComp-02e68f1b.js";import"./tslib.es6-c3c2d88f.js";import"path";import"./partjson.esm-b3f1fc21.js";import"./termdb.bins-39d11f24.js";function o(a){const i=new t({padding:"5px"});a.dom.tip=i;const s=a.settings;function n(t){const e=t.target.__data__;if(e===undefined)return;e.type=="col"?"term":"term2";const i=a.config.term;a.app.dispatch({type:"plot_edit",id:a.id,config:{term:{isAtomic:true,term:i.term,q:u(e,i,true)}}})}return{chart:{title(t){if(!a.config.term0)return t.chartId;return a.config.term0.term.values&&t.chartId in a.config.term0.term.values?a.config.term0.term.values[t.chartId].label:t.chartId}},svg:{mouseout:()=>{i.hide()}},series:{mouseover(t,e){t.stopPropagation();const s=a.config.term.term;const n=a.config.term2&&a.config.term2.term;s.unit;const r=(s.values&&e.seriesId in s.values?s.values[e.seriesId].label:e.seriesId)+(s.unit?" "+s.unit:"");const l=(n&&n.values&&e.dataId in n.values?n.values[e.dataId].label:e.dataId)+(n&&n.unit?" "+n.unit:"");const o=!n?"":"<div style='display:inline-block; width:14px; height:14px; margin: 2px 3px; vertical-align:top; background:"+e.color+"'>&nbsp;</div>";const d=[`<tr><td colspan=2 style='padding:3px; text-align:center'>${r}</td></tr>`];if(n){d.push(`<tr><td colspan=2 style='padding:3px; text-align:center'>${o} <span>${l}</span></td></tr>`)}d.push(`<tr><td style='padding:3px; color:#aaa'>#Individuals</td><td style='padding:3px; text-align:center'>n=${e.total}</td></tr>`);if(n){const t=e.groupPvalues.term2tests.find((t=>t.term2id===e.dataId)).pvalue;const a=e.groupPvalues.term1Label;const i=e.groupPvalues.term2tests.find((t=>t.term2id===e.dataId)).term2Label;const s=e.groupPvalues.term2tests.find((t=>t.term2id===e.dataId)).tableValues;const n=e.groupPvalues.term2tests.find((t=>t.term2id===e.dataId)).skipped;d.push(`<tr>\n\t\t\t\t\t\t\t<td style='padding:3px; color:#aaa'>p-value</td>\n\t\t\t\t\t\t\t<td style='padding:3px; text-align:center'>${n?"N/A":t>1e-4?Number(t.toFixed(4)):Number(t.toPrecision(4)).toExponential()}</td>\n\t\t\t\t\t\t</tr>\n\t\t\t\t\t\t<table style="margin: 5px; text-align:left; font-size: 0.8em; border-spacing: 5px; border-collapse: separate;"\n\t\t\t\t\t\t\t<tr>\n\t\t\t\t\t\t\t\t<td style='color:#aaa'></td>\n\t\t\t\t\t\t\t\t<td style='color:#aaa'>${i}</td>\n\t\t\t\t\t\t\t\t<td style='color:#aaa'>not ${i}</td>\n\t\t\t\t\t\t\t</tr>\n\t\t\t\t\t\t\t<tr>\n\t\t\t\t\t\t\t\t<td style='color:#aaa'>${a}</td>\n\t\t\t\t\t\t\t\t<td>${s.R1C1}</td>\n\t\t\t\t\t\t\t\t<td>${s.R1C2}</td>\n\t\t\t\t\t\t\t</tr>\n\t\t\t\t\t\t\t<tr>\n\t\t\t\t\t\t\t\t<td style='color:#aaa'>not ${a}</td>\n\t\t\t\t\t\t\t\t<td>${s.R2C1}</td>\n\t\t\t\t\t\t\t\t<td>${s.R2C2}</td>\n\t\t\t\t\t\t\t</tr>\n\t\t\t\t\t\t</table>`)}if(!s.type=="condition"&&(!n||!n.type=="condition")){d.push(`<tr><td style='padding:3px; color:#aaa'>Percentage</td><td style='padding:3px; text-align:center'>${(100*e.total/(n?e.seriesTotal:e.chartTotal)).toFixed(1)}%</td></tr>`)}i.show(t.clientX,t.clientY).d.html(`<table class='sja_simpletable'>${d.join("\n")}</table>`)},mouseout:()=>{i.hide()},rectFill(t){return t.color},strokeFill(t){const a=e(t.color);const i=a.toString()==e("white").toString()?a.darker():a;return i},click:a.opts.bar_click_override?(t,e)=>a.opts.bar_click_override(v(e,a)):(t,e)=>m(t,a,e)},colLabel:{text:t=>"label"in t?t.label:a.config.term.values&&"id"in t&&t.id in a.config.term.values?a.config.term.values[t.id].label:t,click:n,mouseover:t=>{t.stopPropagation();i.show(t.clientX,t.clientY).d.html("Click to hide bar")},mouseout:()=>{i.hide()}},rowLabel:{text:t=>t.label?t.label:a.config.term.values&&"id"in t&&t.id in a.config.term.values?a.config.term.values[t.id].label:t,click:n,mouseover:t=>{t.stopPropagation();i.show(t.clientX,t.clientY).d.html("Click to hide bar")},mouseout:()=>{i.hide()}},legend:{onColorClick:t=>c(t.target,a),click:t=>c(t.target,a),mouseover:t=>{t.stopPropagation();const e=t.target.__data__;if(e===undefined)return;if(e.isHidden)i.show(t.clientX,t.clientY).d.html("Click to unhide bar")},mouseout:()=>{i.hide()}},yAxis:{text:t=>{const e=a.sampleType?.plural_name||"samples";const i=a.config.term;if(s.orientation=="vertical"){return s.unit=="pct"?`% of ${e}`:`# of ${e} `+(i.q.bar_by_children||i.q.value_by_most_recent||i.q.value_by_computable_grade?"":`(n=${t})`)}else{return i.q.bar_by_children?"Sub-condition":i.q.value_by_max_grade?"Maximum grade":i.q.value_by_most_recent?"Most recent grade":i.q.value_by_computable_grade?"Any grade":i.type=="categorical"||!i.unit?"":i.unit}}},xAxis:{text:t=>{const e=a.sampleType?.plural_name||"samples";const i=a.config.term;if(s.orientation=="vertical"){return i.q.bar_by_children?"Sub-condition":i.q.value_by_max_grade?"Maximum grade":i.q.value_by_most_recent?"Most recent grade":i.q.value_by_computable_grade?"Any grade":i.type=="categorical"||!i.unit?"":i.unit}else{return s.unit=="pct"?`% of ${e}`:`# of ${e} `+(i.q.bar_by_children||i.q.value_by_most_recent||i.q.value_by_computable_grade?"":`(n=${t})`)}}}}}function d(t,e,a){const i=t.type=="col"?"term":"term2";const s=e.config[i];let n=t.dataId;if(s.term.values&&!s.term.values?.[n])for(const[e,a]of Object.entries(s.term.values))if(a.label==t.dataId)n=e;if(s.term.values?.[n])s.term.values[n].color=a;if(s.term.type=="geneVariant"){if(!s.term.values)s.term.values={};s.term.values[t.dataId]={label:t.dataId,color:a}}let r=null;if(e.bins[2].length>0){r=e.bins[2].find((e=>e.label==t.dataId));if(r)r.color=a}e.app.dispatch({type:"plot_edit",id:e.id,config:{[i]:{isAtomic:true,term:s.term,q:u(t,s,t.isHidden,r)}}})}function c(t,a){const i=t.__data__;if(i===undefined)return;if(!("type"in i))return;const s=i.type=="col"?"term":"term2";const n=a.config[s];const r="isHidden"in i?!i.isHidden:!(n.q&&n.q.hiddenValues&&n.q.hiddenValues["dataId"in i?i.dataId:i.id]);const l=a.app.tip;const o=l.clear();o.showunder(t);const c=o.d.append("div");c.append("div").attr("class","sja_menuoption sja_sharp_border").text(!r?"Show":"Hide").on("click",(()=>{o.hide();p(i,a,r)}));if(n.q.hiddenValues&&Object.keys(n.q.hiddenValues).length>1)c.append("div").attr("class","sja_menuoption sja_sharp_border").text("Show all").on("click",(()=>{o.hide();const t=structuredClone(n);delete t.q.hiddenValues;a.app.dispatch({type:"plot_edit",id:a.id,config:{[s]:t}})}));const u=e(i.color).formatHex();if(u!="#ffffff"){const t=c.append("div").attr("class","sja_sharp_border").style("padding","0px 10px").text("Color:").append("input").attr("type","color").attr("value",u).on("change",(()=>{d(i,a,t.node().value);o.hide()}))}}function p(t,e,a){const i=t.type=="col"?"term":"term2";const s=e.config[i];e.app.dispatch({type:"plot_edit",id:e.id,config:{[i]:{isAtomic:true,term:s.term,q:u(t,s,a)}}})}function u(t,e,a=false,i=null){const s="id"in t?t.id:t.type=="col"?t.seriesId:t.dataId;const n=e.term.values&&Object.keys(e.term.values).find((t=>e.term.values[t].label===s));const r=!n?s:n;const l=JSON.parse(JSON.stringify(e.q));if(!l.hiddenValues)l.hiddenValues={};if(a)l.hiddenValues[r]=1;else delete l.hiddenValues[r];if(i)l.binColored=i;return l}function m(t,e,a){const i=t.target.__data__||t.target.parentNode.__data__;const n=e.config.term.term;const r=e.config.term2?e.config.term2.term:null;const l=n.values?Object.values(n.values).map((t=>t.label)):[];const o=r&&r.values?Object.values(r.values).map((t=>t.label)):[];const d=n.unit&&!l.includes(i.seriesId||i.id)?" "+n.unit:"";const c=r&&r.unit&&!o.includes(i.dataId||i.id)?" "+r.unit:"";const p=(n.values&&i.seriesId in n.values?n.values[i.seriesId].label:i.seriesId?i.seriesId:i.id)+d;const m=(r&&r.values&&i.dataId in r.values?r.values[i.dataId].label:i.dataId?i.dataId:i.id)+c;const b=!r?"":"<div style='display:inline-block; width:14px; height:14px; margin: 2px 3px; vertical-align:top; background:"+i.color+"'>&nbsp;</div>";const h=`<div style='padding:2px'><b>${n.name}</b>: ${p}</div>`+(i.seriesId&&r?`<div style='padding:2px'><b>${r.name}</b>: ${m} ${b}</div>`:"");const y=i.seriesId||i.seriesId===0?i:{seriesId:i.id,dataId:i.dataId};const I=[];if(e.opts.bar_click_opts.includes("hide_bar")){I.push({label:i.seriesId?'Hide "'+p+'"':"Hide",callback:()=>{const t=e.config.term;e.app.dispatch({type:"plot_edit",id:e.id,config:{term:{isAtomic:true,term:t.term,q:u({id:i.seriesId,type:"col"},t,true)}}})}});if(i.dataId||i.dataId===0){I.push({label:'Hide "'+m+'" '+b,callback:()=>{const t=e.config.term2;e.app.dispatch({isAtomic:true,type:"plot_edit",id:e.id,config:{term2:{isAtomic:true,term:t.term,q:u({id:i.dataId,type:"row"},t,true)}}})}})}}if(e.opts.bar_click_opts.includes("add_filter")&&(!r||!r.isgenotype)){const t=s(e.state.termfilter.filter,e.config.term.term.id);if(!t){I.push({label:"Add as filter",callback:g})}}if(e.config.displaySampleIds){I.push({label:"List samples",callback:async()=>await f(t,e,i.seriesId,i.dataId,a.chartId)})}if(e.opts.bar_click_opts.includes("select_to_gp")){I.push({label:"Select to GenomePaint",callback:_})}if(!I.length)return;e.app.tip.clear();if(h){e.app.tip.d.append("div").html(h)}const x=v(y,e);e.app.tip.d.append("div").selectAll("div").data(I).enter().append("div").attr("class","sja_menuoption").html((t=>t.label)).on("click",(async(t,a)=>{e.app.tip.hide();await a.callback(e,x)}));e.app.tip.show(t.clientX,t.clientY)}async function f(e,a,s,r,l){const o={type:"tvslst",in:true,join:"and",lst:[b(1,s)]};const d=[a.config.term];if(a.config.term2){d.push(a.config.term2);o.lst.push(b(2,r))}if(a.config.term0){d.push(a.config.term0);o.lst.push(b(0,l))}const c={terms:d,filter:n([a.state.termfilter.filter,o])};const p=await a.app.vocabApi.getAnnotatedSampleData(c);const u=[];for(const t of p.lst){const e=p.refs.bySampleId[Number(t.sample)].label;u.push([{value:e}])}const m=[{label:"Sample"}];const f=new t({padding:"5px"});const g=f.d.append("div");i({rows:u,columns:m,div:g,showLines:true,maxWidth:"27vw",maxHeight:"40vh",resize:true});f.show(e.clientX,e.clientY,false);function b(t,e){const i=t==0?a.config.term0:t==1?a.config.term:a.config.term2;const s={type:"tvs",tvs:{term:i.term,values:[{key:e}]}};if(i.term.type=="integer"||i.term.type=="float"){const i=a.bins[t];s.tvs.ranges=[i.find((t=>t.label==e))]}return s}}function g(t,e){if(!e)return;if(!t.state.termfilter||t.state.nav?.header_mode!=="with_tabs"){return}const a=r(t.state.termfilter.filter,"filterUiRoot");const i=n([a,{type:"tvslst",in:true,join:e.length>1?"and":"",lst:[...e.map(b)]}]);i.tag="filterUiRoot";t.app.dispatch({type:"filter_replace",filter:i})}function b(t){return t.type==="tvs"?t:{type:"tvs",tvs:t}}function _(t,e){const i=[];for(const a of e){b(a);const e=s(t.state.termfilter.filter,a.tvs.term.id);if(!e)i.push(b(a))}import("./block-75d4ff92.js").then((function(t){return t.c})).then((async e=>{const s={genome:t.app.opts.genome,dslabel:t.state.dslabel};const n=a({x:100,y:100});const o=l(t.state.termfilter.filter);const d=r(o,d);if(d&&d!=o)delete d.tag;o.tag="filterUiRoot";if(i.length){o.join="and";o.lst.push(...i)}const c=r(o,"cohortFilter");if(c){c.renderAs="htmlSelect";c.selectOptionsFrom="selectCohort"}new e.Block({hostURL:sessionStorage.getItem("hostURL"),holder:n.body,genome:s.genome,nobox:true,chr:s.genome.defaultcoord.chr,start:s.genome.defaultcoord.start,stop:s.genome.defaultcoord.stop,nativetracks:[s.genome.tracks.find((t=>t.__isgene)).name.toLowerCase()],tklst:[{type:"mds2",dslabel:s.dslabel,vcf:{numerical_axis:{AFtest:{groups:[{is_termdb:true,filter:o},{is_population:true,key:"gnomAD",allowto_adjust_race:true,adjust_race:true}]}}}}]})}))}function v(t,e){const a=[];if(e.state.nav?.header_mode=="with_cohortHtmlSelect"){const t=r(e.state.termfilter.filter,"cohortFilter");if(t)a.push(JSON.parse(JSON.stringify(t)))}const i=e.config.term;const s=i.term.values&&Object.keys(i.term.values).filter((e=>i.term.values[e].label===t.seriesId))[0];const n=i.term.values&&s in i.term.values?s:t.seriesId;const l=e.config.term2;const o=l&&l.term.values&&Object.keys(l.term.values).filter((e=>l.term.values[e].label===t.dataId))[0];const d=l&&l.term.values&&o in l.term.values?o:t.dataId;for(const s of[i,l]){if(!s)continue;const r=s==i?1:2;const o=s==i?n:d;const c=s.q;const p=!s||!s.term.values?o:o in s.term.values?s.term.values[o].label:o;if(c.type=="predefined-groupset"||c.type=="custom-groupset"){const t=c.type=="predefined-groupset"?s.term.groupsetting.lst[c.predefined_groupset_idx]:c.customset;const e=t.groups.find((t=>t.name===o));const i={term:s.term,values:e.values,groupset_label:e.name};if(s.term.type=="condition"){i.bar_by_children=s.q.bar_by_children;i.bar_by_grade=s.q.bar_by_grade;i.value_by_most_recent=s.q.value_by_most_recent;i.value_by_max_grade=s.q.value_by_max_grade}a.push(i)}else if(s.term.type=="condition"){if(!l||i.term.id!=l.term.id){a.push(Object.assign({term:s.term,values:[{key:o,label:p}]},c))}if(s==i&&l&&s.term.id==l.term.id){const i=l.q;const n=l.term.values&&t.dataId in l.term.values?e.config.term2.values[t.dataId].label:t.dataId;a.push(Object.assign({term:s.term,grade_and_child:[{grade:i.bar_by_grade?t.dataId:o,grade_label:i.bar_by_grade?n:p,child_id:i.bar_by_children?t.dataId:o,child_label:i.bar_by_children?n:p}]},i))}}else{const t=e.currServerData.refs.bins[r];if(!t||!t.length){a.push({term:s.term,values:[{key:o,label:p}]})}else{const e=t.find((t=>t.label==p||t.name==p));if(e)a.push({term:s.term,ranges:[e]});else if(s==i){a.push({term:s.term,ranges:[{value:o}]})}else if(s==l){a.push({term:s.term,ranges:[{value:o}]})}else{throw"should not happen"}}}}return a.map((t=>b(t)))}export{o as default,p as hideCategory};
1
+ import{M as t,r as e,Z as a}from"./app-0de0ae35.js";import{r as i}from"./table-e2a307e6.js";import"./termsetting-2e75e729.js";import{d as s,c as n,a as r,g as l}from"./FilterRxComp-fb608459.js";import"./tslib.es6-c3c2d88f.js";import"path";import"./partjson.esm-b3f1fc21.js";import"./termdb.bins-7ecc48db.js";function o(a){const i=new t({padding:"5px"});a.dom.tip=i;const s=a.settings;function n(t){const e=t.target.__data__;if(e===undefined)return;e.type=="col"?"term":"term2";const i=a.config.term;a.app.dispatch({type:"plot_edit",id:a.id,config:{term:{isAtomic:true,term:i.term,q:u(e,i,true)}}})}return{chart:{title(t){if(!a.config.term0)return t.chartId;return a.config.term0.term.values&&t.chartId in a.config.term0.term.values?a.config.term0.term.values[t.chartId].label:t.chartId}},svg:{mouseout:()=>{i.hide()}},series:{mouseover(t,e){t.stopPropagation();const s=a.config.term.term;const n=a.config.term2&&a.config.term2.term;s.unit;const r=(s.values&&e.seriesId in s.values?s.values[e.seriesId].label:e.seriesId)+(s.unit?" "+s.unit:"");const l=(n&&n.values&&e.dataId in n.values?n.values[e.dataId].label:e.dataId)+(n&&n.unit?" "+n.unit:"");const o=!n?"":"<div style='display:inline-block; width:14px; height:14px; margin: 2px 3px; vertical-align:top; background:"+e.color+"'>&nbsp;</div>";const d=[`<tr><td colspan=2 style='padding:3px; text-align:center'>${r}</td></tr>`];if(n){d.push(`<tr><td colspan=2 style='padding:3px; text-align:center'>${o} <span>${l}</span></td></tr>`)}d.push(`<tr><td style='padding:3px; color:#aaa'>#Individuals</td><td style='padding:3px; text-align:center'>n=${e.total}</td></tr>`);if(n){const t=e.groupPvalues.term2tests.find((t=>t.term2id===e.dataId)).pvalue;const a=e.groupPvalues.term1Label;const i=e.groupPvalues.term2tests.find((t=>t.term2id===e.dataId)).term2Label;const s=e.groupPvalues.term2tests.find((t=>t.term2id===e.dataId)).tableValues;const n=e.groupPvalues.term2tests.find((t=>t.term2id===e.dataId)).skipped;d.push(`<tr>\n\t\t\t\t\t\t\t<td style='padding:3px; color:#aaa'>p-value</td>\n\t\t\t\t\t\t\t<td style='padding:3px; text-align:center'>${n?"N/A":t>1e-4?Number(t.toFixed(4)):Number(t.toPrecision(4)).toExponential()}</td>\n\t\t\t\t\t\t</tr>\n\t\t\t\t\t\t<table style="margin: 5px; text-align:left; font-size: 0.8em; border-spacing: 5px; border-collapse: separate;"\n\t\t\t\t\t\t\t<tr>\n\t\t\t\t\t\t\t\t<td style='color:#aaa'></td>\n\t\t\t\t\t\t\t\t<td style='color:#aaa'>${i}</td>\n\t\t\t\t\t\t\t\t<td style='color:#aaa'>not ${i}</td>\n\t\t\t\t\t\t\t</tr>\n\t\t\t\t\t\t\t<tr>\n\t\t\t\t\t\t\t\t<td style='color:#aaa'>${a}</td>\n\t\t\t\t\t\t\t\t<td>${s.R1C1}</td>\n\t\t\t\t\t\t\t\t<td>${s.R1C2}</td>\n\t\t\t\t\t\t\t</tr>\n\t\t\t\t\t\t\t<tr>\n\t\t\t\t\t\t\t\t<td style='color:#aaa'>not ${a}</td>\n\t\t\t\t\t\t\t\t<td>${s.R2C1}</td>\n\t\t\t\t\t\t\t\t<td>${s.R2C2}</td>\n\t\t\t\t\t\t\t</tr>\n\t\t\t\t\t\t</table>`)}if(!s.type=="condition"&&(!n||!n.type=="condition")){d.push(`<tr><td style='padding:3px; color:#aaa'>Percentage</td><td style='padding:3px; text-align:center'>${(100*e.total/(n?e.seriesTotal:e.chartTotal)).toFixed(1)}%</td></tr>`)}i.show(t.clientX,t.clientY).d.html(`<table class='sja_simpletable'>${d.join("\n")}</table>`)},mouseout:()=>{i.hide()},rectFill(t){return t.color},strokeFill(t){const a=e(t.color);const i=a.toString()==e("white").toString()?a.darker():a;return i},click:a.opts.bar_click_override?(t,e)=>a.opts.bar_click_override(v(e,a)):(t,e)=>m(t,a,e)},colLabel:{text:t=>"label"in t?t.label:a.config.term.values&&"id"in t&&t.id in a.config.term.values?a.config.term.values[t.id].label:t,click:n,mouseover:t=>{t.stopPropagation();i.show(t.clientX,t.clientY).d.html("Click to hide bar")},mouseout:()=>{i.hide()}},rowLabel:{text:t=>t.label?t.label:a.config.term.values&&"id"in t&&t.id in a.config.term.values?a.config.term.values[t.id].label:t,click:n,mouseover:t=>{t.stopPropagation();i.show(t.clientX,t.clientY).d.html("Click to hide bar")},mouseout:()=>{i.hide()}},legend:{onColorClick:t=>c(t.target,a),click:t=>c(t.target,a),mouseover:t=>{t.stopPropagation();const e=t.target.__data__;if(e===undefined)return;if(e.isHidden)i.show(t.clientX,t.clientY).d.html("Click to unhide bar")},mouseout:()=>{i.hide()}},yAxis:{text:t=>{const e=a.sampleType?.plural_name||"samples";const i=a.config.term;if(s.orientation=="vertical"){return s.unit=="pct"?`% of ${e}`:`# of ${e} `+(i.q.bar_by_children||i.q.value_by_most_recent||i.q.value_by_computable_grade?"":`(n=${t})`)}else{return i.q.bar_by_children?"Sub-condition":i.q.value_by_max_grade?"Maximum grade":i.q.value_by_most_recent?"Most recent grade":i.q.value_by_computable_grade?"Any grade":i.type=="categorical"||!i.unit?"":i.unit}}},xAxis:{text:t=>{const e=a.sampleType?.plural_name||"samples";const i=a.config.term;if(s.orientation=="vertical"){return i.q.bar_by_children?"Sub-condition":i.q.value_by_max_grade?"Maximum grade":i.q.value_by_most_recent?"Most recent grade":i.q.value_by_computable_grade?"Any grade":i.type=="categorical"||!i.unit?"":i.unit}else{return s.unit=="pct"?`% of ${e}`:`# of ${e} `+(i.q.bar_by_children||i.q.value_by_most_recent||i.q.value_by_computable_grade?"":`(n=${t})`)}}}}}function d(t,e,a){const i=t.type=="col"?"term":"term2";const s=e.config[i];let n=t.dataId;if(s.term.values&&!s.term.values?.[n])for(const[e,a]of Object.entries(s.term.values))if(a.label==t.dataId)n=e;if(s.term.values?.[n])s.term.values[n].color=a;if(s.term.type=="geneVariant"){if(!s.term.values)s.term.values={};s.term.values[t.dataId]={label:t.dataId,color:a}}let r=null;if(e.bins[2].length>0){r=e.bins[2].find((e=>e.label==t.dataId));if(r)r.color=a}e.app.dispatch({type:"plot_edit",id:e.id,config:{[i]:{isAtomic:true,term:s.term,q:u(t,s,t.isHidden,r)}}})}function c(t,a){const i=t.__data__;if(i===undefined)return;if(!("type"in i))return;const s=i.type=="col"?"term":"term2";const n=a.config[s];const r="isHidden"in i?!i.isHidden:!(n.q&&n.q.hiddenValues&&n.q.hiddenValues["dataId"in i?i.dataId:i.id]);const l=a.app.tip;const o=l.clear();o.showunder(t);const c=o.d.append("div");c.append("div").attr("class","sja_menuoption sja_sharp_border").text(!r?"Show":"Hide").on("click",(()=>{o.hide();p(i,a,r)}));if(n.q.hiddenValues&&Object.keys(n.q.hiddenValues).length>1)c.append("div").attr("class","sja_menuoption sja_sharp_border").text("Show all").on("click",(()=>{o.hide();const t=structuredClone(n);delete t.q.hiddenValues;a.app.dispatch({type:"plot_edit",id:a.id,config:{[s]:t}})}));const u=e(i.color).formatHex();if(u!="#ffffff"){const t=c.append("div").attr("class","sja_sharp_border").style("padding","0px 10px").text("Color:").append("input").attr("type","color").attr("value",u).on("change",(()=>{d(i,a,t.node().value);o.hide()}))}}function p(t,e,a){const i=t.type=="col"?"term":"term2";const s=e.config[i];e.app.dispatch({type:"plot_edit",id:e.id,config:{[i]:{isAtomic:true,term:s.term,q:u(t,s,a)}}})}function u(t,e,a=false,i=null){const s="id"in t?t.id:t.type=="col"?t.seriesId:t.dataId;const n=e.term.values&&Object.keys(e.term.values).find((t=>e.term.values[t].label===s));const r=!n?s:n;const l=JSON.parse(JSON.stringify(e.q));if(!l.hiddenValues)l.hiddenValues={};if(a)l.hiddenValues[r]=1;else delete l.hiddenValues[r];if(i)l.binColored=i;return l}function m(t,e,a){const i=t.target.__data__||t.target.parentNode.__data__;const n=e.config.term.term;const r=e.config.term2?e.config.term2.term:null;const l=n.values?Object.values(n.values).map((t=>t.label)):[];const o=r&&r.values?Object.values(r.values).map((t=>t.label)):[];const d=n.unit&&!l.includes(i.seriesId||i.id)?" "+n.unit:"";const c=r&&r.unit&&!o.includes(i.dataId||i.id)?" "+r.unit:"";const p=(n.values&&i.seriesId in n.values?n.values[i.seriesId].label:i.seriesId?i.seriesId:i.id)+d;const m=(r&&r.values&&i.dataId in r.values?r.values[i.dataId].label:i.dataId?i.dataId:i.id)+c;const b=!r?"":"<div style='display:inline-block; width:14px; height:14px; margin: 2px 3px; vertical-align:top; background:"+i.color+"'>&nbsp;</div>";const h=`<div style='padding:2px'><b>${n.name}</b>: ${p}</div>`+(i.seriesId&&r?`<div style='padding:2px'><b>${r.name}</b>: ${m} ${b}</div>`:"");const y=i.seriesId||i.seriesId===0?i:{seriesId:i.id,dataId:i.dataId};const I=[];if(e.opts.bar_click_opts.includes("hide_bar")){I.push({label:i.seriesId?'Hide "'+p+'"':"Hide",callback:()=>{const t=e.config.term;e.app.dispatch({type:"plot_edit",id:e.id,config:{term:{isAtomic:true,term:t.term,q:u({id:i.seriesId,type:"col"},t,true)}}})}});if(i.dataId||i.dataId===0){I.push({label:'Hide "'+m+'" '+b,callback:()=>{const t=e.config.term2;e.app.dispatch({isAtomic:true,type:"plot_edit",id:e.id,config:{term2:{isAtomic:true,term:t.term,q:u({id:i.dataId,type:"row"},t,true)}}})}})}}if(e.opts.bar_click_opts.includes("add_filter")&&(!r||!r.isgenotype)){const t=s(e.state.termfilter.filter,e.config.term.term.id);if(!t){I.push({label:"Add as filter",callback:g})}}if(e.config.displaySampleIds){I.push({label:"List samples",callback:async()=>await f(t,e,i.seriesId,i.dataId,a.chartId)})}if(e.opts.bar_click_opts.includes("select_to_gp")){I.push({label:"Select to GenomePaint",callback:_})}if(!I.length)return;e.app.tip.clear();if(h){e.app.tip.d.append("div").html(h)}const x=v(y,e);e.app.tip.d.append("div").selectAll("div").data(I).enter().append("div").attr("class","sja_menuoption").html((t=>t.label)).on("click",(async(t,a)=>{e.app.tip.hide();await a.callback(e,x)}));e.app.tip.show(t.clientX,t.clientY)}async function f(e,a,s,r,l){const o={type:"tvslst",in:true,join:"and",lst:[b(1,s)]};const d=[a.config.term];if(a.config.term2){d.push(a.config.term2);o.lst.push(b(2,r))}if(a.config.term0){d.push(a.config.term0);o.lst.push(b(0,l))}const c={terms:d,filter:n([a.state.termfilter.filter,o])};const p=await a.app.vocabApi.getAnnotatedSampleData(c);const u=[];for(const t of p.lst){const e=p.refs.bySampleId[Number(t.sample)].label;u.push([{value:e}])}const m=[{label:"Sample"}];const f=new t({padding:"5px"});const g=f.d.append("div");i({rows:u,columns:m,div:g,showLines:true,maxWidth:"27vw",maxHeight:"40vh",resize:true});f.show(e.clientX,e.clientY,false);function b(t,e){const i=t==0?a.config.term0:t==1?a.config.term:a.config.term2;const s={type:"tvs",tvs:{term:i.term,values:[{key:e}]}};if(i.term.type=="integer"||i.term.type=="float"){const i=a.bins[t];s.tvs.ranges=[i.find((t=>t.label==e))]}return s}}function g(t,e){if(!e)return;if(!t.state.termfilter||t.state.nav?.header_mode!=="with_tabs"){return}const a=r(t.state.termfilter.filter,"filterUiRoot");const i=n([a,{type:"tvslst",in:true,join:e.length>1?"and":"",lst:[...e.map(b)]}]);i.tag="filterUiRoot";t.app.dispatch({type:"filter_replace",filter:i})}function b(t){return t.type==="tvs"?t:{type:"tvs",tvs:t}}function _(t,e){const i=[];for(const a of e){b(a);const e=s(t.state.termfilter.filter,a.tvs.term.id);if(!e)i.push(b(a))}import("./block-3db9c74c.js").then((function(t){return t.c})).then((async e=>{const s={genome:t.app.opts.genome,dslabel:t.state.dslabel};const n=a({x:100,y:100});const o=l(t.state.termfilter.filter);const d=r(o,d);if(d&&d!=o)delete d.tag;o.tag="filterUiRoot";if(i.length){o.join="and";o.lst.push(...i)}const c=r(o,"cohortFilter");if(c){c.renderAs="htmlSelect";c.selectOptionsFrom="selectCohort"}new e.Block({hostURL:sessionStorage.getItem("hostURL"),holder:n.body,genome:s.genome,nobox:true,chr:s.genome.defaultcoord.chr,start:s.genome.defaultcoord.start,stop:s.genome.defaultcoord.stop,nativetracks:[s.genome.tracks.find((t=>t.__isgene)).name.toLowerCase()],tklst:[{type:"mds2",dslabel:s.dslabel,vcf:{numerical_axis:{AFtest:{groups:[{is_termdb:true,filter:o},{is_population:true,key:"gnomAD",allowto_adjust_race:true,adjust_race:true}]}}}}]})}))}function v(t,e){const a=[];if(e.state.nav?.header_mode=="with_cohortHtmlSelect"){const t=r(e.state.termfilter.filter,"cohortFilter");if(t)a.push(JSON.parse(JSON.stringify(t)))}const i=e.config.term;const s=i.term.values&&Object.keys(i.term.values).filter((e=>i.term.values[e].label===t.seriesId))[0];const n=i.term.values&&s in i.term.values?s:t.seriesId;const l=e.config.term2;const o=l&&l.term.values&&Object.keys(l.term.values).filter((e=>l.term.values[e].label===t.dataId))[0];const d=l&&l.term.values&&o in l.term.values?o:t.dataId;for(const s of[i,l]){if(!s)continue;const r=s==i?1:2;const o=s==i?n:d;const c=s.q;const p=!s||!s.term.values?o:o in s.term.values?s.term.values[o].label:o;if(c.type=="predefined-groupset"||c.type=="custom-groupset"){const t=c.type=="predefined-groupset"?s.term.groupsetting.lst[c.predefined_groupset_idx]:c.customset;const e=t.groups.find((t=>t.name===o));const i={term:s.term,values:e.values,groupset_label:e.name};if(s.term.type=="condition"){i.bar_by_children=s.q.bar_by_children;i.bar_by_grade=s.q.bar_by_grade;i.value_by_most_recent=s.q.value_by_most_recent;i.value_by_max_grade=s.q.value_by_max_grade}a.push(i)}else if(s.term.type=="condition"){if(!l||i.term.id!=l.term.id){a.push(Object.assign({term:s.term,values:[{key:o,label:p}]},c))}if(s==i&&l&&s.term.id==l.term.id){const i=l.q;const n=l.term.values&&t.dataId in l.term.values?e.config.term2.values[t.dataId].label:t.dataId;a.push(Object.assign({term:s.term,grade_and_child:[{grade:i.bar_by_grade?t.dataId:o,grade_label:i.bar_by_grade?n:p,child_id:i.bar_by_children?t.dataId:o,child_label:i.bar_by_children?n:p}]},i))}}else{const t=e.currServerData.refs.bins[r];if(!t||!t.length){a.push({term:s.term,values:[{key:o,label:p}]})}else{const e=t.find((t=>t.label==p||t.name==p));if(e)a.push({term:s.term,ranges:[e]});else if(s==i){a.push({term:s.term,ranges:[{value:o}]})}else if(s==l){a.push({term:s.term,ranges:[{value:o}]})}else{throw"should not happen"}}}}return a.map((t=>b(t)))}export{o as default,p as hideCategory};