@sjcrh/proteinpaint-client 2.76.0 → 2.76.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.
- package/dist/{2dmaf-74b99126.js → 2dmaf-593951c7.js} +1 -1
- package/dist/{AppHeader-cecb39c2.js → AppHeader-29b88e14.js} +1 -1
- package/dist/{ColorScale-21cab8d2.js → ColorScale-3d3c42dc.js} +1 -1
- package/dist/{DEanalysis-95bad59a.js → DEanalysis-f81e0f19.js} +1 -1
- package/dist/{Disco-a6e921a0.js → Disco-db386f7a.js} +1 -1
- package/dist/{Disco.UI-9ad999ed.js → Disco.UI-8ed9cb39.js} +1 -1
- package/dist/{DragControls-e3b6a937.js → DragControls-d6250d18.js} +1 -1
- package/dist/{DziViewer-354a790d.js → DziViewer-9352e224.js} +1 -1
- package/dist/{FilterRxComp-701a1480.js → FilterRxComp-0f35b322.js} +1 -1
- package/dist/{FilterStateless-54c0b763.js → FilterStateless-b1c6ee04.js} +1 -1
- package/dist/{HicApp-d5a946bf.js → HicApp-14b94b20.js} +1 -1
- package/dist/{OrbitControls-694652cd.js → OrbitControls-45f56ed4.js} +1 -1
- package/dist/{WSIViewer-dc7f8eb0.js → WSIViewer-80f60272.js} +1 -1
- package/dist/{adSandbox-f438e388.js → adSandbox-94424b88.js} +1 -1
- package/dist/app-2cd97738.js +1 -0
- package/dist/{app-3320ab6f.js → app-686b9547.js} +1 -1
- package/dist/app-f031940d.js +1 -0
- package/dist/app.js +1 -1
- package/dist/{bam-431875ef.js → bam-6631640f.js} +1 -1
- package/dist/barchart-3c5d734c.js +1 -0
- package/dist/{barchart.events-da29c90d.js → barchart.events-df44e666.js} +1 -1
- package/dist/{bars.renderer-dcfdd59b.js → bars.renderer-b232d882.js} +1 -1
- package/dist/{block-6aedd569.js → block-4134e823.js} +1 -1
- package/dist/block.lazyload-eda77d9b.js +1 -0
- package/dist/{block.legend-d3f61ef7.js → block.legend-d2b7f1cb.js} +1 -1
- package/dist/{block.mds-3ad17dfa.js → block.mds-ebe7b58d.js} +1 -1
- package/dist/{block.mds.cnv-857ba868.js → block.mds.cnv-99f0a414.js} +1 -1
- package/dist/{block.mds.expressionrank-7e3b208c.js → block.mds.expressionrank-96bf864b.js} +1 -1
- package/dist/{block.mds.expressionstat-f2d31c86.js → block.mds.expressionstat-dcab3fd1.js} +1 -1
- package/dist/{block.mds.geneboxplot-f0fbaf12.js → block.mds.geneboxplot-e5b2a4ce.js} +1 -1
- package/dist/{block.mds.junction-7f87f48f.js → block.mds.junction-534eef9b.js} +1 -1
- package/dist/{block.mds.svcnv-ac035c12.js → block.mds.svcnv-de6a3c7d.js} +1 -1
- package/dist/{block.mds.svcnv.share-886d9479.js → block.mds.svcnv.share-2c2c16db.js} +1 -1
- package/dist/{block.mds2-7852c1ee.js → block.mds2-373fcb4d.js} +1 -1
- package/dist/{block.svg-9b916fa6.js → block.svg-be5d741d.js} +1 -1
- package/dist/{block.tk.aicheck-6770e333.js → block.tk.aicheck-f2da5e81.js} +1 -1
- package/dist/{block.tk.ase-ee807e59.js → block.tk.ase-ef848944.js} +1 -1
- package/dist/{block.tk.bam-00fba6e8.js → block.tk.bam-11fcba17.js} +1 -1
- package/dist/{block.tk.bedgraphdot-7fda78e9.js → block.tk.bedgraphdot-a81b0709.js} +1 -1
- package/dist/{block.tk.bigwig.ui-cc1a42f3.js → block.tk.bigwig.ui-f8e5ba71.js} +1 -1
- package/dist/{block.tk.hicstraw-526470e3.js → block.tk.hicstraw-e7072b25.js} +1 -1
- package/dist/{block.tk.junction-b43a4cda.js → block.tk.junction-1c9a7854.js} +1 -1
- package/dist/{block.tk.junction.textmatrixui-a60ed78a.js → block.tk.junction.textmatrixui-ffecbb16.js} +1 -1
- package/dist/{block.tk.ld-d15bde41.js → block.tk.ld-274c3a82.js} +1 -1
- package/dist/{block.tk.menu-3aeb93c6.js → block.tk.menu-e970cd4a.js} +1 -1
- package/dist/{block.tk.pgv-9af2bd64.js → block.tk.pgv-f4d4dbf7.js} +1 -1
- package/dist/{boxplot-e17a17b7.js → boxplot-44d3b48f.js} +1 -1
- package/dist/{brainImaging-bf2ceee9.js → brainImaging-2eaa419d.js} +1 -1
- package/dist/{brush-aa175142.js → brush-bb4ae2fb.js} +1 -1
- package/dist/{categorical-a52014a1.js → categorical-db9b0175.js} +1 -1
- package/dist/{condition-c646e357.js → condition-4e788f7d.js} +1 -1
- package/dist/{controls-287e6efa.js → controls-3c1691d7.js} +1 -1
- package/dist/{controls.btns-79b805dd.js → controls.btns-5b1240c8.js} +1 -1
- package/dist/controls.config-81cd5749.js +1 -0
- package/dist/cuminc-c4db28f0.js +1 -0
- package/dist/{customdata.inputui-dc49d94b.js → customdata.inputui-f9234d1f.js} +1 -1
- package/dist/{dataDownload-3a3d4f33.js → dataDownload-a4dfa2d0.js} +1 -1
- package/dist/{databrowser.ui-d8d3f8fd.js → databrowser.ui-a64bab0c.js} +1 -1
- package/dist/{density-a82a8b1c.js → density-69a732f6.js} +1 -1
- package/dist/{dictionary-c5a19d90.js → dictionary-e2232e84.js} +1 -1
- package/dist/{drag-7b30ba17.js → drag-d8daa62f.js} +1 -1
- package/dist/{e2pca-82765817.js → e2pca-f9324654.js} +1 -1
- package/dist/{ep-d017ec2f.js → ep-a5c1ee3a.js} +1 -1
- package/dist/{facet-a9b44ef3.js → facet-98971c68.js} +1 -1
- package/dist/{fusion.parse-d40d0b9d.js → fusion.parse-466ded6d.js} +1 -1
- package/dist/{geneExpClustering-34c3f518.js → geneExpClustering-66c05fb1.js} +1 -1
- package/dist/{geneExpression-0d1b7244.js → geneExpression-5685eae2.js} +1 -1
- package/dist/{geneExpression-589f485b.js → geneExpression-b5d0261f.js} +1 -1
- package/dist/{geneExpression-7d14983f.js → geneExpression-ff46a389.js} +1 -1
- package/dist/{geneORA-903a780f.js → geneORA-f1a90d02.js} +1 -1
- package/dist/{geneVariant-92c4e870.js → geneVariant-1cf17b3b.js} +1 -1
- package/dist/{geneVariant-89601b34.js → geneVariant-d0b9e1cb.js} +1 -1
- package/dist/{genefusion.ui-7e22e811.js → genefusion.ui-89a727ea.js} +1 -1
- package/dist/{genesearch-a4e19f0d.js → genesearch-41cb55ce.js} +1 -1
- package/dist/{geneset-108a39d2.js → geneset-b63496eb.js} +1 -1
- package/dist/{genomeBrowser-12f86a36.js → genomeBrowser-ec8fbddc.js} +1 -1
- package/dist/{genomeBrowser.controls-d5067811.js → genomeBrowser.controls-2dcaf4f5.js} +1 -1
- package/dist/{groupsetting-b4416a96.js → groupsetting-3fef59f9.js} +1 -1
- package/dist/{gsea-543dab25.js → gsea-3075c82c.js} +1 -1
- package/dist/{hierCluster-26e14090.js → hierCluster-33a828a1.js} +1 -1
- package/dist/hierCluster.config-fa799d06.js +1 -0
- package/dist/{hierCluster.interactivity-e56f6542.js → hierCluster.interactivity-6d453881.js} +1 -1
- package/dist/{hierCluster.renderers-74a64cf5.js → hierCluster.renderers-6279d7fb.js} +1 -1
- package/dist/{html.legend-a3f4ebfe.js → html.legend-fac5cb07.js} +1 -1
- package/dist/{imagePlot-b9eae4ae.js → imagePlot-38254245.js} +1 -1
- package/dist/{lasso-f767f634.js → lasso-e8b9500e.js} +1 -1
- package/dist/{launch.adhoc-abca6af3.js → launch.adhoc-2799109b.js} +1 -1
- package/dist/{leftlabel.sample-24c2388d.js → leftlabel.sample-afcdcefd.js} +1 -1
- package/dist/{legacyDataset-e0e201ab.js → legacyDataset-3b08c91a.js} +1 -1
- package/dist/{log-99af3443.js → log-4d84c357.js} +1 -1
- package/dist/{lollipop-806f8fa4.js → lollipop-64c5cdfc.js} +1 -1
- package/dist/{maf-b06579e4.js → maf-fd4ffbd0.js} +1 -1
- package/dist/{maftimeline-4840a380.js → maftimeline-3e892da7.js} +1 -1
- package/dist/{matrix-00bb50ff.js → matrix-e371888a.js} +1 -1
- package/dist/{matrix.cells-914dd0c6.js → matrix.cells-eb4110a7.js} +1 -1
- package/dist/{matrix.cluster-783ceab0.js → matrix.cluster-0df274ed.js} +1 -1
- package/dist/{matrix.config-6ce74dfe.js → matrix.config-3ef822b9.js} +1 -1
- package/dist/{matrix.controls-7b2a6f95.js → matrix.controls-42bb2063.js} +1 -1
- package/dist/{matrix.data-dac4f1b7.js → matrix.data-27b8e3a9.js} +1 -1
- package/dist/{matrix.dom-4e10bbe9.js → matrix.dom-1bbe1f39.js} +1 -1
- package/dist/{matrix.groups-b9fca14a.js → matrix.groups-67606700.js} +1 -1
- package/dist/{matrix.interactivity-84169b43.js → matrix.interactivity-cdcc56c9.js} +1 -1
- package/dist/{matrix.layout-dd5a44fd.js → matrix.layout-857cd336.js} +1 -1
- package/dist/{matrix.legend-ac6d45e6.js → matrix.legend-09f6dc57.js} +1 -1
- package/dist/{matrix.renderers-78010275.js → matrix.renderers-d392fb69.js} +1 -1
- package/dist/{matrix.serieses-9b4fd744.js → matrix.serieses-b03b62aa.js} +1 -1
- package/dist/{matrix.sort-014d798d.js → matrix.sort-9440c86a.js} +1 -1
- package/dist/{matrix.sorterUi-9bf7e6f9.js → matrix.sorterUi-2c5eb35f.js} +1 -1
- package/dist/{mavb-c6be46fc.js → mavb-9d86df89.js} +1 -1
- package/dist/{mds.fimo-bff6a1ed.js → mds.fimo-bffccb9f.js} +1 -1
- package/dist/{mds.samplescatterplot-9a02b9fb.js → mds.samplescatterplot-b3908cc7.js} +1 -1
- package/dist/{mds.survivalplot-055549f4.js → mds.survivalplot-9ad7dabc.js} +1 -1
- package/dist/{metaboliteIntensity-fac92f8b.js → metaboliteIntensity-ec3176f4.js} +1 -1
- package/dist/niceNumLabels-5f45218a.js +1 -0
- package/dist/{nodrag-16ad4b03.js → nodrag-ab7d5a9f.js} +1 -1
- package/dist/{notify-224cccbd.js → notify-59f61230.js} +1 -1
- package/dist/{numeric-b0b17185.js → numeric-4853b665.js} +1 -1
- package/dist/{numeric.binary-1f9e93f2.js → numeric.binary-1dd9a2b4.js} +1 -1
- package/dist/{numeric.continuous-ebcd0567.js → numeric.continuous-ed132eea.js} +1 -1
- package/dist/{numeric.discrete-7b97044a.js → numeric.discrete-d780d076.js} +1 -1
- package/dist/{numeric.spline-1be88f3d.js → numeric.spline-abe07708.js} +1 -1
- package/dist/{numeric.toggle-7fa2a770.js → numeric.toggle-647423dd.js} +1 -1
- package/dist/oncomatrix-7ac995a2.js +1 -0
- package/dist/{parseData-21fe9822.js → parseData-567f3d70.js} +1 -1
- package/dist/{plot.2dvaf-18a35e4b.js → plot.2dvaf-4016e75e.js} +1 -1
- package/dist/plot.app-d6fe76e2.js +1 -0
- package/dist/plot.barplot-d2fc5020.js +1 -0
- package/dist/{plot.boxplot-fe3046c6.js → plot.boxplot-76229491.js} +1 -1
- package/dist/{plot.brainImaging-2ceb6023.js → plot.brainImaging-39b80a1c.js} +1 -1
- package/dist/{plot.disco-6011f87f.js → plot.disco-9a544f9a.js} +1 -1
- package/dist/{plot.dzi-6728a7c8.js → plot.dzi-f1658ebf.js} +1 -1
- package/dist/{plot.ssgq-5581dc56.js → plot.ssgq-aeb2dabc.js} +1 -1
- package/dist/{plot.vaf2cov-b2284c64.js → plot.vaf2cov-ba8332ed.js} +1 -1
- package/dist/{plot.wsi-9a9d4034.js → plot.wsi-2d802557.js} +1 -1
- package/dist/{profileBarchart-0476f1f8.js → profileBarchart-72adc533.js} +1 -1
- package/dist/{profileHome-32eb9b50.js → profileHome-37fd52e5.js} +1 -1
- package/dist/{profilePlot-c7e099e8.js → profilePlot-0b897a05.js} +1 -1
- package/dist/profilePolar-a7248d48.js +1 -0
- package/dist/profileRadar-1ba5d8fd.js +1 -0
- package/dist/profileRadarFacility-452e76ef.js +1 -0
- package/dist/{profileSummary-b114204f.js → profileSummary-7f0eacf0.js} +1 -1
- package/dist/{recover-49e09de0.js → recover-74f2e965.js} +1 -1
- package/dist/{regression.inputs-a761f40d.js → regression.inputs-ff00f74e.js} +1 -1
- package/dist/{regression.inputs.values.table-5929d25a.js → regression.inputs.values.table-1753d56b.js} +1 -1
- package/dist/{regression.results-69bc42d0.js → regression.results-6f85a5dc.js} +1 -1
- package/dist/{renderPvalueTable-dc5d15f2.js → renderPvalueTable-17558d6a.js} +1 -1
- package/dist/{sampleScatter-2d0ed680.js → sampleScatter-97917406.js} +1 -1
- package/dist/{sampleScatter.rendererThree-0b12ac61.js → sampleScatter.rendererThree-4649d1ec.js} +2 -2
- package/dist/{sampleView-484ab133.js → sampleView-f86dc5ea.js} +1 -1
- package/dist/{samplelst-689796e6.js → samplelst-4a5512df.js} +1 -1
- package/dist/{samplematrix-2b137a05.js → samplematrix-1192e5e2.js} +1 -1
- package/dist/{scatter-205e013f.js → scatter-cc1b0d07.js} +1 -1
- package/dist/{select2Terms-b21e184a.js → select2Terms-d4f6ed9e.js} +1 -1
- package/dist/{selectGenomeWithTklst-466995b4.js → selectGenomeWithTklst-b5cfd153.js} +1 -1
- package/dist/{singleCellCellType-5db730bb.js → singleCellCellType-d8c58253.js} +1 -1
- package/dist/{singleCellGeneExpression-7147a2d0.js → singleCellGeneExpression-b7209531.js} +1 -1
- package/dist/{singleCellPlot-73b2738f.js → singleCellPlot-e6f83b2a.js} +1 -1
- package/dist/{singlecell-bca774ed.js → singlecell-321dd973.js} +1 -1
- package/dist/{singlecell-24409b72.js → singlecell-879235b3.js} +1 -1
- package/dist/snp-541ec14d.js +1 -0
- package/dist/{snp-a8388ce4.js → snp-b046b7e6.js} +1 -1
- package/dist/snplocus-61ff1c10.js +1 -0
- package/dist/{spliceevent.a53ss.diagram-e2eab72b.js → spliceevent.a53ss.diagram-1a84db58.js} +1 -1
- package/dist/{spliceevent.exonskip.diagram-4d5df3a1.js → spliceevent.exonskip.diagram-da10648b.js} +1 -1
- package/dist/{spliceevent.exonskip.getdefault-a94aad6e.js → spliceevent.exonskip.getdefault-8028e522.js} +1 -1
- package/dist/{spliceevent.noeventdiagram-ea97b0fb.js → spliceevent.noeventdiagram-1d6d790d.js} +1 -1
- package/dist/{spliceevent.phrase-c5832470.js → spliceevent.phrase-2ca0ce59.js} +1 -1
- package/dist/{stattable-7c5ecc2f.js → stattable-c5f12d9c.js} +1 -1
- package/dist/{style.gdc-131f3c77.js → style.gdc-5b7d90c6.js} +1 -1
- package/dist/summary-0624f5e6.js +1 -0
- package/dist/{sunburst-533902a7.js → sunburst-30295714.js} +1 -1
- package/dist/{survival-e16e068f.js → survival-816e055a.js} +1 -1
- package/dist/{survival-92250664.js → survival-fcc7719f.js} +1 -1
- package/dist/{svg.download-35926549.js → svg.download-e89a7369.js} +1 -1
- package/dist/{svg.legend-8d490df2.js → svg.legend-c93f2980.js} +1 -1
- package/dist/{svgraph-6fac8cbc.js → svgraph-6ab3011b.js} +1 -1
- package/dist/{svmr-d07ff695.js → svmr-3ad3d600.js} +1 -1
- package/dist/{table-ad744310.js → table-4d3a771e.js} +1 -1
- package/dist/{table-29d5a973.js → table-f50a9344.js} +1 -1
- package/dist/{termInfo-bf99a37e.js → termInfo-d0a9e65f.js} +1 -1
- package/dist/{termdb.bins-8b656cc3.js → termdb.bins-01e8cce6.js} +1 -1
- package/dist/{termsetting-33ea66f1.js → termsetting-ad8c4f3a.js} +1 -1
- package/dist/{tk-071a7550.js → tk-e74c9beb.js} +1 -1
- package/dist/{toggleButtons-dbdbad01.js → toggleButtons-04c5ad7c.js} +1 -1
- package/dist/{tp.ui-9c2e9fc5.js → tp.ui-7b24f0ef.js} +1 -1
- package/dist/{tvs.density-f6128793.js → tvs.density-b2790080.js} +1 -1
- package/dist/{tvs.geneVariant-ca4bdbb1.js → tvs.geneVariant-418ed4ff.js} +1 -1
- package/dist/{tvs.numeric-0260a825.js → tvs.numeric-de14101f.js} +1 -1
- package/dist/{tvs.samplelst-cb71b3bf.js → tvs.samplelst-15bb62f1.js} +1 -1
- package/dist/{uiUtils-f1bd2bcc.js → uiUtils-ff2d4a6a.js} +1 -1
- package/dist/{variantBrowser-7c540224.js → variantBrowser-261373bf.js} +1 -1
- package/dist/{vcf-5cc55588.js → vcf-145bf5dd.js} +1 -1
- package/dist/violin-e647aac9.js +1 -0
- package/dist/{violin.interactivity-4da6d7a9.js → violin.interactivity-30a239fe.js} +1 -1
- package/dist/{violin.renderer-ce024265.js → violin.renderer-e29d2700.js} +1 -1
- package/dist/{violinRenderer-f7c96a60.js → violinRenderer-08b3b58c.js} +1 -1
- package/dist/{viridis-01ab20c5.js → viridis-d86ad99b.js} +1 -1
- package/dist/{y-67939f83.js → y-06b0d47c.js} +1 -1
- package/dist/{zoom-25dce8b9.js → zoom-d6ef6f3f.js} +1 -1
- package/package.json +1 -1
- package/dist/app-649f8357.js +0 -1
- package/dist/app-b369b169.js +0 -1
- package/dist/barchart-8277ed43.js +0 -1
- package/dist/block.lazyload-87b12654.js +0 -1
- package/dist/controls.config-28d6d6a8.js +0 -1
- package/dist/cuminc-9e275854.js +0 -1
- package/dist/hierCluster.config-98e82dff.js +0 -1
- package/dist/niceNumLabels-238aabce.js +0 -1
- package/dist/oncomatrix-351af2a0.js +0 -1
- package/dist/plot.app-30c4b8e5.js +0 -1
- package/dist/plot.barplot-7c4865a2.js +0 -1
- package/dist/profilePolar-6b981e63.js +0 -1
- package/dist/profileRadar-bca1cc03.js +0 -1
- package/dist/profileRadarFacility-bbb1ecd8.js +0 -1
- package/dist/snp-37d06246.js +0 -1
- package/dist/snplocus-7a1ea8c9.js +0 -1
- package/dist/summary-5ec455d3.js +0 -1
- package/dist/violin-2ba509eb.js +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
import{aG as e,ar as t,aR as s,aQ as n,ab as o,an as a,bg as i,bh as r,at as l,bi as p,Z as c,M as d,p as f,ac as h,ba as u,b9 as g,bj as m,bk as b,j as x,d as y,ah as v,bl as k,a9 as A,ae as B,I as w,ag as N,bm as z}from"./app-b369b169.js";import{c as _}from"./axis-747c801e.js";function j(a,i){var r=[];for(const e of a.samples){for(const t of e.egglst){for(const e of t.lst){if(e.ismsg){const t=e.lst.map((e=>e.lst[0]));if(i){let e=false;for(const s of t){if(s.rating=="Major")e=true}if(e){r.push(t)}}else{r.push(t)}}else{for(const t of e.lst){for(const e of t.lst){if(i){if(e.rating=="Major")r.push([e])}else{r.push([e])}}}}}}}const l=[],p=[],c=[],d=[];for(const o of r){if(o.length==1&&o[0].usepair){const i=o[0];if(i.isitd){const s=i.usepair;const n=a.genome.isoformmatch(s.a.isoform,i.chrA,i.posA);if(!n){p.push(i.sample+" "+i.geneA+" ITD ("+i.rating+"): no gene model found for "+s.a.isoform);continue}const o=e(i.posA,n).rnapos;const r=e(i.posB,n).rnapos;if(o<=r){p.push(i.sample+" "+i.geneA+" ITD ("+i.rating+"): negative duplication length");continue}const c={typecode:t,gene:i.geneA,isoform:s.a.isoform,rating:i.rating,score:i.score,functioneffect:i.functioneffect,rnaposition:r,rnaduplength:o-r+1,a:{chr:i.chrA,position:i.posA,strand:i.ortA,ratio:i.ratioA,chimericreads:i.readsA,totalreads:i.totalreadsA,match:i.matchA,repeat:i.repeatA},b:{chr:i.chrB,position:i.posB,strand:i.ortB,ratio:i.ratioB,chimericreads:i.readsB,totalreads:i.totalreadsB,match:i.matchB,repeat:i.repeatB}};let d=0,f=0;if(s.a.contigaa&&s.b.contigaa){d=s.b.contigaa-s.a.contigaa-1}if(s.a.contigbp&&s.b.contigbp){f=s.b.contigbp-s.a.contigbp-1}if(d>0){c.interstitial={aalen:d}}if(f>0){if(!c.interstitial)c.interstitial={};c.interstitial.bplen=f}l.push([i.sample,i.geneA,i.usepair.a.isoform,JSON.stringify(c)]);continue}if(i.isnloss){const t=i.usepair.b;if(!t.isoform){c.push(i.sample+" "+i.geneB+" NLoss ("+i.rating+"): no isoform");continue}const n=a.genome.isoformmatch(t.isoform,i.chrB,i.posB);if(!n){c.push(i.sample+" "+i.geneB+" NLoss ("+i.rating+"): no gene model found for "+t.isoform);continue}const o=e(i.posB,n).rnapos;const r={typecode:s,gene:i.geneB,isoform:t.isoform,rating:i.rating,score:i.score,functioneffect:i.functioneffect,rnaposition:o,chr:i.chrB,position:i.posB,strand:i.ortB,ratio:i.ratioB,chimericreads:i.readsB,match:i.matchB,repeat:i.repeatB,partner:{chr:i.chrA,position:i.posA,strand:i.ortA,ratio:i.ratioA,chimericreads:i.readsA,match:i.matchA,repeat:i.repeatA}};if(i.geneA){r.partner.gene=i.geneA}if(i.usepair.a.isoform){r.partner.isoform=i.usepair.a.isoform}l.push([i.sample,i.geneB,t.isoform,JSON.stringify(r)]);continue}if(i.iscloss){const t=i.usepair.a;if(!t.isoform){c.push(i.sample+" "+i.geneA+" CLoss ("+i.rating+"): no isoform");continue}const s=a.genome.isoformmatch(t.isoform,i.chrA,i.posA);if(!s){c.push(i.sample+" "+i.geneA+" CLoss ("+i.rating+"): no gene model found by "+t.isoform);continue}const o=e(i.posA,s).rnapos;const r={typecode:n,gene:i.geneA,isoform:t.isoform,rating:i.rating,score:i.score,functioneffect:i.functioneffect,rnaposition:o,chr:i.chrA,position:i.posA,strand:i.ortA,ratio:i.ratioA,chimericreads:i.readsA,match:i.matchA,repeat:i.repeatA,partner:{chr:i.chrB,position:i.posB,strand:i.ortB,ratio:i.ratioB,chimericreads:i.readsB,match:i.matchB,repeat:i.repeatB}};if(i.geneB){r.partner.gene=i.geneB}if(i.usepair.b.isoform){r.partner.isoform=i.usepair.b.isoform}l.push([i.sample,i.geneA,t.isoform,JSON.stringify(r)]);continue}}const i=new Set,r=new Set,d=[];for(const e of o){if(e.geneA)i.add(e.geneA);if(e.geneB)i.add(e.geneB);if(e.usepair){if(e.usepair.a.isoform)r.add(e.usepair.a.isoform);if(e.usepair.b.isoform)r.add(e.usepair.b.isoform)}const t={type:e.type,type2:e.type2,rating:e.rating,score:e.score,functioneffect:e.functioneffect,a:{name:e.geneA,chr:e.chrA,position:e.posA,strand:e.ortA,ratio:e.ratioA,feature:e.featureA,chimericreads:e.readsA,contiglen:e.matchA,repeatscore:e.repeatA},b:{name:e.geneB,chr:e.chrB,position:e.posB,strand:e.ortB,ratio:e.ratioB,feature:e.featureB,chimericreads:e.readsB,contiglen:e.matchB,repeatscore:e.repeatB}};if(e.usepair){const s=e.usepair;t.frame=s.frame;if(s.a.isoform){t.a.isoform=s.a.isoform}if(s.b.isoform){t.b.isoform=s.b.isoform}let n=0,o=0;if(s.a.contigaa&&s.b.contigaa){n=s.b.contigaa-s.a.contigaa-1}if(s.a.contigbp&&s.b.contigbp){o=s.b.contigbp-s.a.contigbp-1}if(n>0){t.interstitial={aalen:n}}if(o>0){if(!t.interstitial)t.interstitial={};t.interstitial.bplen=o}}d.push(t)}const f=[...i];const h=[...r];l.push([o[0].sample,f.length?f.join(","):"none",h.length?h.join(","):"none",JSON.stringify(d)])}if(p.length){a.err(p.join("<br>"))}if(c.length){a.err(c.join("<br>"))}if(d.length){a.err(d.join("<br>"))}o("Fusion data from "+a.filename,[{text:l.map((e=>e.join("\t"))).join("\n")}])}function R(o,d){const f=[];for(const e of o.samples){for(const t of e.egglst){for(const e of t.lst){if(e.ismsg){const t=e.lst.map((e=>e.lst[0]));if(d){let e=false;for(const s of t){if(s.rating=="Major")e=true}if(e){f.push(t)}}else{f.push(t)}}else{for(const t of e.lst){for(const e of t.lst){if(d){if(e.rating=="Major")f.push([e])}else{f.push([e])}}}}}}}const h={},u=[],g=[],m=[];for(const c of f){if(c.length==1&&c[0].usepair){const l=c[0];if(l.isitd){if(!l.geneA){u.push(l.sample+" ITD ("+l.rating+"): no gene name??");continue}const s=l.usepair;const n=o.genome.isoformmatch(s.a.isoform,l.chrA,l.posA);if(!n){u.push(l.sample+" "+l.geneA+" ITD ("+l.rating+"): no gene model found for "+s.a.isoform);continue}const i=e(l.posA,n).rnapos;const r=e(l.posB,n).rnapos;if(i<=r){u.push(l.sample+" "+l.geneA+" ITD ("+l.rating+"): negative duplication length");continue}const p={dt:t,class:a,mname:"ITD",gene:l.geneA,sample:l.sample,isoform:s.a.isoform,rating:l.rating,score:l.score,functioneffect:l.functioneffect,rnaposition:r,rnaduplength:i-r+1,a:{chr:l.chrA,position:l.posA,strand:l.ortA,ratio:l.ratioA,chimericreads:l.readsA,totalreads:l.totalreadsA,match:l.matchA,repeat:l.repeatA},b:{chr:l.chrB,position:l.posB,strand:l.ortB,ratio:l.ratioB,chimericreads:l.readsB,totalreads:l.totalreadsB,match:l.matchB,repeat:l.repeatB}};let c=0,d=0;if(s.a.contigaa&&s.b.contigaa){c=s.b.contigaa-s.a.contigaa-1}if(s.a.contigbp&&s.b.contigbp){d=s.b.contigbp-s.a.contigbp-1}if(c>0){p.interstitial={aalen:c}}if(d>0){if(!p.interstitial)p.interstitial={};p.interstitial.bplen=d}if(!(l.geneA in h)){h[l.geneA]=[]}h[l.geneA].push(p);continue}if(l.isnloss){if(!l.geneB){g.push(l.sample+" NLoss ("+l.rating+"): no geneB");continue}const t=l.usepair.b;if(!t.isoform){g.push(l.sample+" "+l.geneB+" NLoss ("+l.rating+"): no isoform");continue}const n=o.genome.isoformmatch(t.isoform,l.chrB,l.posB);if(!n){g.push(l.sample+" "+l.geneB+" NLoss ("+l.rating+"): no gene model found for "+t.isoform);continue}const a=e(l.posB,n).rnapos;const r={dt:s,class:i,mname:"N-loss",gene:l.geneB,sample:l.sample,isoform:t.isoform,rating:l.rating,score:l.score,functioneffect:l.functioneffect,rnaposition:a,chr:l.chrB,position:l.posB,strand:l.ortB,ratio:l.ratioB,chimericreads:l.readsB,match:l.matchB,repeat:l.repeatB,partner:{chr:l.chrA,position:l.posA,strand:l.ortA,ratio:l.ratioA,chimericreads:l.readsA,match:l.matchA,repeat:l.repeatA}};if(l.geneA){r.partner.gene=l.geneA}if(l.usepair.a.isoform){r.partner.isoform=l.usepair.a.isoform}if(!(l.geneB in h)){h[l.geneB]=[]}h[l.geneB].push(r);continue}if(l.iscloss){if(!l.geneA){m.push(l.sample+" CLoss ("+l.rating+"): no geneA");continue}const t=l.usepair.a;if(!t.isoform){m.push(l.sample+" "+l.geneA+" CLoss ("+l.rating+"): no isoform");continue}const s=o.genome.isoformmatch(t.isoform,l.chrA,l.posA);if(!s){m.push(l.sample+" "+l.geneA+" CLoss ("+l.rating+"): no gene model found by "+t.isoform);continue}const a=e(l.posA,s).rnapos;const i={dt:n,class:r,mname:"C-loss",gene:l.geneA,sample:l.sample,isoform:t.isoform,rating:l.rating,score:l.score,functioneffect:l.functioneffect,rnaposition:a,chr:l.chrA,position:l.posA,strand:l.ortA,ratio:l.ratioA,chimericreads:l.readsA,match:l.matchA,repeat:l.repeatA,partner:{chr:l.chrB,position:l.posB,strand:l.ortB,ratio:l.ratioB,chimericreads:l.readsB,match:l.matchB,repeat:l.repeatB}};if(l.geneB){i.partner.gene=l.geneB}if(l.usepair.b.isoform){i.partner.isoform=l.usepair.b.isoform}if(!(l.geneA in h)){h[l.geneA]=[]}h[l.geneA].push(i);continue}}const d=new Map;const f=[];for(const e of c){if(e.geneA){if(!d.has(e.geneA))d.set(e.geneA,new Set);if(e.usepair){if(e.usepair.a.isoform)d.get(e.geneA).add(e.usepair.a.isoform)}}if(e.geneB){if(!d.has(e.geneB))d.set(e.geneB,new Set);if(e.usepair){if(e.usepair.b.isoform)d.get(e.geneB).add(e.usepair.b.isoform)}}const t={type:e.type,type2:e.type2,rating:e.rating,score:e.score,functioneffect:e.functioneffect,a:{name:e.geneA,chr:e.chrA,position:e.posA,strand:e.ortA,ratio:e.ratioA,feature:e.featureA,chimericreads:e.readsA,contiglen:e.matchA,repeatscore:e.repeatA},b:{name:e.geneB,chr:e.chrB,position:e.posB,strand:e.ortB,ratio:e.ratioB,feature:e.featureB,chimericreads:e.readsB,contiglen:e.matchB,repeatscore:e.repeatB}};if(e.usepair){const s=e.usepair;t.frame=s.frame;if(s.a.isoform){t.a.isoform=s.a.isoform}if(s.b.isoform){t.b.isoform=s.b.isoform}let n=0,o=0;if(s.a.contigaa&&s.b.contigaa){n=s.b.contigaa-s.a.contigaa-1}if(s.a.contigbp&&s.b.contigbp){o=s.b.contigbp-s.a.contigbp-1}if(n>0){t.interstitial={aalen:n}}if(o>0){if(!t.interstitial)t.interstitial={};t.interstitial.bplen=o}}f.push(t)}for(const[e,t]of d){for(const s of t){if(!(e in h)){h[e]=[]}const t={dt:l,class:p,sample:c[0].sample,isoform:s,pairlst:C(f)};for(const e of f){if(e.functioneffect){t.functioneffect=e.functioneffect}}h[e].push(t)}}}if(u.length){o.err(u.join("<br>"))}if(g.length){o.err(g.join("<br>"))}if(m.length){o.err(m.join("<br>"))}let b=0,x={};for(const e in h){b++;x[e.toUpperCase()]=h[e]}if(b==0){alert("No data can be added.");return}let y=null;for(const e in o.genome.datasets){if(o.genome.datasets[e].svmrid==o.id){y=o.genome.datasets[e];break}}if(y){y.bulkdata=x}else{y={label:o.filename,svmrid:o.id,bulkdata:x};o.genome.datasets[o.filename]=y}if(o.cohort){o.cohortpane.pane.remove()}else{o.cohort={name:o.filename,genome:o.genome,show_genetable:1,jwt:o.jwt,dsset:{}};o.cohort.dsset[o.filename]=y}const v=c({x:200,y:200});import("./tp.ui-9c2e9fc5.js").then((function(e){return e.t})).then((e=>{e.default(o.cohort,v.body,o.hostURL);o.cohortpane=v}))}function I(e,t){const s=[];const n=e.atlst.map((e=>e.label));n.push("transcript_nbr");n.push("breakpoint_nbr");n.push("functionalClass");for(const n of e.samples){const o=[];for(const e of n.egglst){for(const s of e.lst){if(s.ismsg){const e=s.lst.map((e=>e.lst[0]));if(t){let t=false;for(const s of e){if(s.rating=="Major")t=true}if(t){o.push(e)}}else{o.push(e)}}else{for(const e of s.lst){for(const s of e.lst){if(t){if(s.rating=="Major")o.push([s])}else{o.push([s])}}}}}}for(let t=0;t<o.length;t++){for(let n=0;n<o[t].length;n++){let a=o[t][n];const i=[],r=[],l=[],p=[],c=[],d=[],f=[],h=[],u=[],g=[],m=[],b=[],x=[];for(const e of a.pairs){i.push(e.frame);r.push(e.a.isoform);h.push(e.b.isoform);let t=e.a.codon;l.push(Number.isNaN(t)?"":t);t=e.b.codon;u.push(Number.isNaN(t)?"":t);t=e.a.exon;p.push(Number.isNaN(t)?"":t);t=e.b.exon;g.push(Number.isNaN(t)?"":t);c.push(e.a.anchor?e.a.anchor:"");m.push(e.b.anchor?e.b.anchor:"");t=e.a.contigaa;d.push(t==undefined?"":t);t=e.b.contigaa;b.push(t==undefined?"":t);t=e.a.contigbp;f.push(t==undefined?"":t);t=e.b.contigbp;x.push(t==undefined?"":t)}const y=[];for(const t of e.atlst){switch(t.key){case"lstframe":y.push(i.join(","));break;case"lstisoforma":y.push(r.join(","));break;case"lstisoformacodon":y.push(l.join(","));break;case"lstisoformaexon":y.push(p.join(","));break;case"lstisoformaanchor":y.push(c.join(","));break;case"lstcontigaaA":y.push(d.join(","));break;case"lstcontigbpA":y.push(f.join(","));break;case"lstisoformb":y.push(h.join(","));break;case"lstisoformbcodon":y.push(u.join(","));break;case"lstisoformbexon":y.push(g.join(","));break;case"lstisoformbanchor":y.push(m.join(","));break;case"lstcontigaaB":y.push(b.join(","));break;case"lstcontigbpB":y.push(x.join(","));break;default:y.push(a[t.key])}}y.push(t+1);y.push(n+1);y.push(a.functioneffect?a.functioneffect:"");s.push(y)}}}o("Fusion data from "+e.filename,[{text:n.join("\t")+"\n"+s.join("\n")}])}function C(e){const t=[];for(const s of e){const e={};for(const t in s)e[t]=s[t];e.a={};for(const t in s.a)e.a[t]=s.a[t];e.b={};for(const t in s.b)e.b[t]=s.b[t];if(s.interstitial){e.interstitial={};for(const t in s.interstitial)e.interstitial[t]=s.interstitial[t]}t.push(e)}return t}const T=1e4;const L="#A702C4";const M=new d;class F{constructor(e,t,s,n,o,a,i){window.svmr=this;this.hostURL=a;this.jwt=i;this.id=Math.random();this.items=s;this.genome=e;this.filename=n;this.atlst=t;this.cf_repeat=.7,this.cf_reads=2;this.cf_match=40;this.cf_ratio=.01;this.expression={};this.samples=[];this.genelst=[];this.elab2sample={};if(!o){const e=c({x:100,y:100,toshrink:true});e.header.append("span").style("color","#858585").style("font-size",".7em").html("Fusion Editor ");e.header.append("span").text(n);o=e.body}this.holder=o;this.errdiv=o.append("div").style("width","500px").style("margin","10px");const r=o.append("div").style("margin","20px").style("padding","0px");this.buttgene=r.append("button").text("Loading genes").on("click",(()=>{if(l.style("display")=="none"){f(l)}else{h(l)}}));this.buttsample=r.append("button").text("Loading samples").on("click",(()=>{if(this.ul.style("display")=="none"){f(this.ul)}else{h(this.ul)}}));r.append("button").text("Gene expression").on("click",(()=>{if(this.expression.div.style("display")=="none"){f(this.expression.div)}else{h(this.expression.div)}}));r.append("button").text("Parameter cutoff").on("click",(()=>{if(x.style("display")=="none"){f(x)}else{h(x)}}));r.append("button").text("Legend").on("click",(()=>{if(y.style("display")=="none"){f(y)}else{h(y)}}));r.append("button").style("margin-right","20px").text("Export data").on("click",(e=>{let t=0,s=0,n=0,o=0,a=0,i=0,r=0,l=0;for(const e of this.samples){for(const p of e.egglst){for(const e of p.lst){if(e.ismsg){let t=false;for(const s of e.lst){if(s.rating=="Major")t=true}if(t)s++;else o++}else{for(const s of e.lst){for(const e of s.lst){if(e.rating=="Major"){if(e.isitd)a++;else if(e.iscloss||e.isnloss)r++;else t++}else{if(e.isitd)i++;else if(e.iscloss||e.isnloss)l++;else n++}}}}}}}const p=M.clear().showunder(e.target).d.append("div");const c=p.append("table").style("border-spacing","10px").style("border-collapse","separate");let d=c.append("tr").style("color","#858585");d.append("td");d.append("td").text("2-gene fusion");d.append("td").text("Multi-gene fusion");d.append("td").text("ITD");d.append("td").text("Truncation");d=c.append("tr");d.append("td").text("Major").style("color","#858585").style("text-align","right");d.append("td").text(t);d.append("td").text(s);d.append("td").text(a);d.append("td").text(r);d=c.append("tr");d.append("td").text("not Major").style("color","#858585").style("text-align","right");d.append("td").text(n);d.append("td").text(o);d.append("td").text(i);d.append("td").text(l);let f=p.append("div").style("margin","10px").text('Export fusions labeled as "Major"');f.append("button").style("margin","10px").text("Tabular format").on("click",(()=>I(this,true)));f.append("button").style("margin","10px").text("JSON format").on("click",(()=>j(this,true)));f.append("button").style("margin","10px").text("View in ProteinPaint").on("click",(()=>R(this,true)));f=p.append("div").style("margin","10px").text("Export all fusions");f.append("button").style("margin","10px").text("Tabular format").on("click",(()=>I(this,false)));f.append("button").style("margin","10px").text("JSON format").on("click",(()=>j(this,false)));f.append("button").style("margin","10px").text("View in ProteinPaint").on("click",(()=>R(this,false)))}));r.append("a").attr("target","_blank").attr("href","https://docs.google.com/document/d/1DRVzE_WenG490eRYB7VGFOygtSqtF5L97rhK0HOUCNY/edit?usp=sharing").text("Help");this.expression.div=o.append("div").style("display","none").style("margin","20px").style("padding","20px").style("border","dashed 1px #bbb");this.expression.prediv=this.expression.div.append("div");this.expression.prediv.append("div").style("margin","5px").text("Load a file that includes gene expression data for current samples.");this.expression.prediv.append("div").style("margin","5px 5px 10px 5px").style("font-size","80%").text("The first 3 columns of the file should be: 1) gene name, 2) expression value, 3) sample name");this.expression.input=this.expression.prediv.append("input").attr("type","file").on("change",(e=>{q(this,e.target.files[0])}));this.expression.presays=this.expression.prediv.append("span").style("padding-left","20px");this.expression.afterdiv=this.expression.div.append("div").style("display","none");const l=o.append("div").style("display","none").style("margin","20px");let p=l.append("div").style("display","inline-block").style("border","dashed 1px #bbb");this.genefilter=p.append("div").style("background-color","#ededed").style("padding","10px 20px");let d=p.append("div").style("padding","10px 20px").style("overflow-y","scroll").style("resize","vertical").style("height","300px");d.append("div").style("margin","10px").style("font-size","70%").text("Not included: read-through and intergenic events (including one or both sides).");this.genetable=d.append("table");const x=o.append("div").style("display","none").style("margin","20px");p=x.append("div").style("display","inline-block").style("padding","20px").style("border","solid 1px #ededed");p.append("span").style("padding","0px 10px").text("Alert if:");d=p.append("span").style("padding","0px 10px");d.append("span").html("chimeric reads ≤ ");d.append("input").attr("size",3).property("value",this.cf_reads).on("change",(e=>{const t=Number.parseInt(e.target.value);if(Number.isNaN(t)){return}this.cf_reads=t}));d=p.append("span").style("padding","0px 10px");d.append("span").html("repeat score ≥ ");d.append("input").attr("size",3).property("value",this.cf_repeat).on("change",(e=>{const t=Number.parseFloat(e.target.value);if(Number.isNaN(t)){return}this.cf_repeat=t}));d=p.append("span").style("padding","0px 10px");d.append("span").html("contig bp length ≤ ");d.append("input").attr("size",3).property("value",this.cf_match).on("change",(e=>{const t=Number.parseInt(e.target.value);if(Number.isNaN(t)){return}this.cf_match=t}));d=p.append("span").style("padding","0px 10px");d.append("span").html("ratio ≤ ");d.append("input").attr("size",3).property("value",this.cf_ratio).on("change",(e=>{const t=Number.parseFloat(e.target.value);if(Number.isNaN(t)){return}this.cf_ratio=t}));const y=o.append("div").style("display","none").style("margin","20px");y.append("div").style("display","inline-block").style("padding","10px").style("border","solid 1px #ededed").html('<table style="margin:20px">'+'<tr><td><div style="display:inline-block;font-size:80%;color:white;background-color:'+u+';padding:2px 5px">IN</div></td><td>In-frame fusion</td></tr>'+'<tr><td><div style="display:inline-block;font-size:80%;color:white;background-color:'+g+';padding:2px 5px">O</div></td><td>Out-of-frame fusion</td></tr>'+'<tr><td><div style="display:inline-block;font-size:80%;color:black;border:solid 1px black;padding:1px 3px">?</div></td><td>Intergenic fusion, or gene isoform not specified</td></tr>'+"</table>"+'<table style="margin:20px">'+'<tr><td>chr5 <span style="border:solid 1px black;padding:0px 10px;"></span>'+"-"+'<span style="border:solid 1px black;padding:0px 10px;"></span> chr5</td>'+"<td>Intra-chromosomal breakpoints</td></tr>"+'<tr><td><span style="color:red">chr5</span> <span style="border:solid 1px black;padding:0px 10px;"></span>'+"-"+'<span style="border:solid 1px black;padding:0px 10px;"></span> <span style="color:red">chr10</span></td>'+"<td>Inter-chromosomal breakpoints</td></tr>"+"</tr></table>"+'<table style="margin:20px">'+'<tr><td><div style="display:inline-block;border:solid 1px black;padding:2px 10px;font-size:70%">geneA</div>'+"-"+'<div style="display:inline-block;border:solid 1px black;padding:2px 10px;font-size:70%">geneB</div>'+"</td><td>Neither geneA nor geneB is known fusion partner</td>"+"</tr>"+'<tr><td><div style="display:inline-block;border:solid 1px black;padding:2px 10px;font-size:70%;font-weight:bold;">geneA</div>'+"-"+'<div style="display:inline-block;border:solid 1px black;padding:2px 10px;font-size:70%">geneB</div>'+"</td><td>GeneA is a known fusion partner</td>"+"</tr>"+'<tr><td><div style="display:inline-block;border:solid 1px black;padding:2px 10px;font-size:70%;font-weight:bold;">geneA</div>'+"-"+'<div style="display:inline-block;border:solid 1px black;padding:2px 10px;font-size:70%;font-weight:bold;">geneB</div>'+"</td><td>Both genes are known fusion partners, but they do not make a known fusion product.</td>"+"</tr>"+'<tr><td><div style="display:inline-block;border:solid 1px black;padding:2px 10px;font-size:70%;font-weight:bold;color:'+L+'">geneA</div>'+"-"+'<div style="display:inline-block;border:solid 1px black;padding:2px 10px;font-size:70%;font-weight:bold;color:'+L+'">geneB</div>'+"</td><td>A known fusion product</td>"+"</tr>"+"</table>"+'<table style="margin:20px">'+'<tr><td><div style="width:40px;height:16px;position:relative;">'+'<div style="position:absolute;right:0px;top:0px;width:20px;height:16px;background-color:'+m+'"></div>'+'<div style="position:absolute;border:solid 1px black;width:100%;height:15px"></div>'+"</div>"+"</td>"+"<td>ratioA: for geneA, the ratio of chimeric reads over total reads</td></tr>"+'<tr><td><div style="width:40px;height:16px;position:relative;">'+'<div style="position:absolute;left:0px;top:0px;width:20px;height:16px;background-color:'+b+'"></div>'+'<div style="position:absolute;border:solid 1px black;width:100%;height:15px"></div>'+"</div>"+"</td>"+"<td>ratioB: for geneB, the ratio of chimeric reads over total reads</td></tr>"+'<tr><td><div style="width:40px;height:16px;border:solid 1px red;"></div></td><td>Antisense (reported strand is on the opposite of gene strand)</td></tr>'+"</table>");this.ul=o.append("ul");this.step_isoform(s)}err(e){x(this.errdiv,e)}step_isoform(e){const t=new Set;for(const s of e){for(const e of s.pairs){let s=e.a.isoform;if(s&&!this.genome.isoformcache.has(s.toUpperCase())){t.add(s)}s=e.b.isoform;if(s&&!this.genome.isoformcache.has(s.toUpperCase())){t.add(s)}}}if(t.size==0){this.step_eat(e);return}const s=[];for(const e of t){s.push(e)}const n=this.holder.append("div").style("margin","20px").text("Loading "+t.size+" isoforms ...");fetch(new Request(this.hostURL+"/isoformlst",{method:"POST",body:JSON.stringify({genome:this.genome.name,lst:s,jwt:this.jwt})})).then((e=>e.json())).then((s=>{if(s.error)throw{message:"Cannot load isoforms: "+s.error};n.remove();for(const e of s.lst){if(e[0]){this.genome.isoformcache.set(e[0].isoform,e)}}const o=[];for(const e of t){if(!this.genome.isoformcache.has(e.toUpperCase())){o.push(e)}}if(o.length){this.err(o.length+" invalid isoform"+(o.length>1?"s":"")+": "+o.join(", "))}this.step_eat(e)})).catch((e=>{this.err(e.message);if(e.stack)console.log(e.stack)}))}step_eat(t){for(const s of t){s.hook={};let t=null;for(const n of s.pairs){let o=this.genome.isoformmatch(n.a.isoform,s.chrA,s.posA);if(o){s.geneA=o.name;n.a.isdefault=o.isdefault;if(Number.isNaN(n.a.codon)||n.a.codon<0){n.a.codon=undefined;const t=e(s.posA,o);if(t.atupstream){n.a.atupstream=t.atupstream}else if(t.atdownstream){n.a.atdownstream=t.atdownstream}else if(t.atutr3){n.a.atutr3=t.atutr3}else if(t.atutr5){n.a.atutr5=t.atutr5}else{n.a.codon=t.codon}}}o=this.genome.isoformmatch(n.b.isoform,s.chrB,s.posB);if(o){s.geneB=o.name;n.b.isdefault=o.isdefault;if(Number.isNaN(n.b.codon)||n.b.codon<0){n.b.codon=undefined;const t=e(s.posB,o);if(t.atupstream){n.b.atupstream=t.atupstream}else if(t.atdownstream){n.b.atdownstream=t.atdownstream}else if(t.atutr3){n.b.atutr3=t.atutr3}else if(t.atutr5){n.b.atutr5=t.atutr5}else{n.b.codon=t.codon}}}if(n.a.isdefault&&n.b.isdefault){if(!t){t=n}if(n.inframe){t=n}}}if(t){s.usepair=t}else{s.notes.push("No preferred isoform pair");s.usepair=s.pairs[0]}if(s.usepair){s.usepair.inuse=true}s.eventlabel=(s.geneA?s.geneA:s.chrA)+"-"+(s.geneB?s.geneB:s.chrB)}const s={};const n={};let o=false;for(const e of t){let t=e.sample;if(t){if(!(t in s)){s[t]={}}if(!(e.eventlabel in s[t])){s[t][e.eventlabel]=[]}s[t][e.eventlabel].push(e)}else{o=true;if(!(e.eventlabel in n)){n[e.eventlabel]=[]}n[e.eventlabel].push(e)}}for(const e in s){this.samples.push({name:e,events:s[e]})}if(o){this.samples.push({name:"No name",events:n})}this.buttsample.text(this.samples.length+" sample"+(this.samples.length>1?"s":""));for(const e of this.samples){for(const t in e.events){if(!(t in this.elab2sample)){this.elab2sample[t]=[]}this.elab2sample[t].push(e)}}for(const e of this.samples){e.gene2events={};for(const t in e.events){for(const s of e.events[t]){const n=s.geneA;if(n){if(!(n in e.gene2events)){e.gene2events[n]={}}e.gene2events[n][t]=1}const o=s.geneB;if(o){if(!(o in e.gene2events)){e.gene2events[o]={}}e.gene2events[o][t]=1}}}}for(const e of this.samples){const t=[];for(const s in e.events){for(const n of e.events[s]){if(n.rating=="HQ")U(n,t)}}for(const s in e.events){for(const n of e.events[s]){if(n.rating=="LQ")U(n,t)}}for(const s in e.events){for(const n of e.events[s]){if(n.rating=="RT")U(n,t)}}for(const s in e.events){for(const n of e.events[s]){if(n.rating=="bad")U(n,t)}}let s=0;const n=[];for(const e of t){if(e.length>1){for(const t of e){t.msgid=s}s++;n.push(e)}}const o=[],i=[],r=[],l=[],p=[],c=[],d=[],f=[],h=[],g=[],m=[],b=[];for(const e of n){const t=[];let s=false,n=false,a=false,u=false,x=false,y=false,v=false,k=false,A=false,B=false,w=false,N=false;for(const o of e){t.push({label:o.eventlabel,lst:[o]});const e=o.usepair;if(o.rating=="HQ"){if(e){if(e.inframe)s=true;else n=true}else if(o.isnloss||o.iscloss){n=true}else{a=true}}else if(o.rating=="LQ"){if(e){if(e.inframe)u=true;else x=true}else if(o.isnloss||o.iscloss){x=true}else{y=true}}else if(o.rating=="RT"){if(e){if(e.inframe)v=true;else k=true}else if(o.isnloss||o.iscloss){k=true}else{A=true}}else{if(e){if(e.inframe)B=true;else w=true}else if(o.isnloss||o.iscloss){w=true}else{N=true}}}if(s){o.push({label:"",lst:t,ismsg:true})}else if(n){i.push({label:"",lst:t,ismsg:true})}else if(a){r.push({label:"",lst:t,ismsg:true})}else if(u){l.push({label:"",lst:t,ismsg:true})}else if(x){p.push({label:"",lst:t,ismsg:true})}else if(y){c.push({label:"",lst:t,ismsg:true})}else if(v){d.push({label:"",lst:t,ismsg:true})}else if(k){f.push({label:"",lst:t,ismsg:true})}else if(A){h.push({label:"",lst:t,ismsg:true})}else if(B){g.push({label:"",lst:t,ismsg:true})}else if(w){m.push({label:"",lst:t,ismsg:true})}else if(N){b.push({label:"",lst:t,ismsg:true})}else{console.log("multi-seg group unclassfied? "+key)}}const x={};for(const t in e.events){const s=[],n=[],u=[],y=[],v=[],k=[],A=[],B=[],w=[],N=[],z=[],_=[];for(const o of e.events[t]){if(o.msgid!=undefined){continue}if(o.geneA&&o.geneB){const e=o.geneA+"-"+o.geneB;let t=x[e];if(!t){const e=o.geneB+"-"+o.geneA;t=x[e]}if(t){if(!(e in t)){t[e]=[]}t[e].push(o)}else{x[e]={};x[e][e]=[o]}continue}var a=o.usepair;if(o.rating=="HQ"){if(a){if(a.inframe)s.push(o);else n.push(o)}else if(o.isnloss||o.iscloss){n.push(o)}else{u.push(o)}}else if(o.rating=="LQ"){if(a){if(a.inframe)y.push(o);else v.push(o)}else if(o.isnloss||o.iscloss){v.push(o)}else{k.push(o)}}else if(o.rating=="RT"){if(a){if(a.inframe)A.push(o);else B.push(o)}else if(o.isnloss||o.iscloss){B.push(o)}else{w.push(o)}}else{if(a){if(a.inframe)N.push(o);else z.push(o)}else if(o.isnloss||o.iscloss){z.push(o)}else{_.push(o)}}}if(s.length>0){o.push({label:t,lst:[{label:t,lst:s}]})}else if(n.length>0){i.push({label:t,lst:[{label:t,lst:n}]})}else if(u.length>0){r.push({label:t,lst:[{label:t,lst:u}]})}else if(y.length>0){l.push({label:t,lst:[{label:t,lst:y}]})}else if(v.length>0){p.push({label:t,lst:[{label:t,lst:v}]})}else if(k.length>0){c.push({label:t,lst:[{label:t,lst:k}]})}else if(A.length>0){d.push({label:t,lst:[{label:t,lst:A}]})}else if(B.length>0){f.push({label:t,lst:[{label:t,lst:B}]})}else if(w.length>0){h.push({label:t,lst:[{label:t,lst:w}]})}else if(N.length>0){g.push({label:t,lst:[{label:t,lst:N}]})}else if(z.length>0){m.push({label:t,lst:[{label:t,lst:z}]})}else if(_.length>0){b.push({label:t,lst:[{label:t,lst:_}]})}}for(const e in x){let t=false,s=false,n=false,a=false,u=false,y=false,v=false,k=false,A=false,B=false,w=false,N=false;const z=[];for(const o in x[e]){const i=x[e][o];if(i.length==1){if(i[0].msgid!=undefined){continue}}z.push({label:o,lst:i});for(const e of i){const o=e.usepair;if(e.rating=="HQ"){if(o){if(o.inframe)t=true;else s=true}else if(e.isnloss||e.iscloss){s=true}else{n=true}}else if(e.rating=="LQ"){if(o){if(o.inframe)a=true;else u=true}else if(e.isnloss||e.iscloss){u=true}else{y=true}}else if(e.rating=="RT"){if(o){if(o.inframe)v=true;else k=true}else if(e.isnloss||e.iscloss){k=true}else{A=true}}else{if(o){if(o.inframe)B=true;else w=true}else if(e.isnloss||e.iscloss){w=true}else{N=true}}}}if(t){o.push({label:e,lst:z})}else if(s){i.push({label:e,lst:z})}else if(n){r.push({label:e,lst:z})}else if(a){l.push({label:e,lst:z})}else if(u){p.push({label:e,lst:z})}else if(y){c.push({label:e,lst:z})}else if(v){d.push({label:e,lst:z})}else if(k){f.push({label:e,lst:z})}else if(A){h.push({label:e,lst:z})}else if(B){g.push({label:e,lst:z})}else if(w){m.push({label:e,lst:z})}else if(N){b.push({label:e,lst:z})}}e.egglst=[];e.hqincount=0;e.lqincount=0;if(o.length){e.egglst.push({htmlab:'HQ <span style="background-color:'+u+';color:white;padding:1px 3px;font-size:80%;">in-frame </span>',lst:o});e.hqincount=o.reduce(((e,t)=>e+t.lst.length),0)}if(i.length){e.egglst.push({htmlab:'HQ <span style="background-color:#E3C3C8;padding:1px 3px;font-size:80%;">truncation</span>',lst:i})}if(r.length){e.egglst.push({htmlab:'HQ <span style="background-color:#ccc;padding:1px 3px;font-size:80%;">others </span>',lst:r})}if(l.length){e.egglst.push({htmlab:'LQ <span style="background-color:'+u+';color:white;padding:1px 3px;font-size:80%;">in-frame </span>',lst:l});e.lqincount=l.reduce(((e,t)=>e+t),0)}if(p.length){e.egglst.push({htmlab:'LQ <span style="background-color:#E3C3C8;padding:1px 3px;font-size:80%;">truncation</span>',lst:p})}if(c.length){e.egglst.push({htmlab:'LQ <span style="background-color:#ccc;padding:1px 3px;font-size:80%;">others </span>',lst:c})}if(d.length){e.egglst.push({htmlab:'Read-through <span style="background-color:'+u+';color:white;padding:1px 3px;font-size:80%;">in-frame </span>',lst:d})}if(f.length){e.egglst.push({htmlab:'Read-through <span style="background-color:#E3C3C8;padding:1px 3px;font-size:80%;">truncation</span>',lst:f})}if(h.length){e.egglst.push({htmlab:'Read-through <span style="background-color:#ccc;padding:1px 3px;font-size:80%;">others </span>',lst:h})}if(g.length){e.egglst.push({htmlab:'Bad <span style="background-color:'+u+';color:white;padding:1px 3px;font-size:80%;">in-frame</span>',lst:g})}if(m.length){e.egglst.push({htmlab:'Bad <span style="background-color:#E3C3C8;padding:1px 3px;font-size:80%;">truncation</span>',lst:m})}if(b.length){e.egglst.push({htmlab:'Bad <span style="background-color:#ccc;padding:1px 3px;font-size:80%;">others </span>',lst:b})}}this.samples.sort(((e,t)=>{if(e.hqincount==t.hqincount){return t.lqincount-e.lqincount}return t.hqincount-e.hqincount}));for(const e of this.samples){for(const t of e.egglst){for(const e of t.lst){for(const t of e.lst){t.lst.sort(((e,t)=>{const s=e.usepair,n=t.usepair;if(s){if(n){if(s.inframe){if(!n.inframe){return-1}}else{if(n.inframe){return 1}}}else{return-1}}else{if(n){return 1}}return t.score-e.score}))}}t.lst.sort(((e,t)=>{if(e.lst.length!=t.lst.length){return t.lst.length-e.lst.length}let s=0;for(const t of e.lst){for(const e of t.lst){s=Math.max(s,e.score)}}let n=0;for(const e of t.lst){for(const t of e.lst){n=Math.max(n,t.score)}}return n-s}))}let t=1;for(const s of e.egglst){for(const e of s.lst){for(const s of e.lst){for(const e of s.lst){e.prodid=t++}}}}}this.step_gene();this.step_table()}dogenefilter(){let e=this.gui.inputa.property("value");let t=this.gui.inputb.property("value");if(e.length+t.length==0){this.gui.says.text("Showing "+(this.genelst.length>100?100:"all")+" of "+this.genelst.length+" pairs");this.geneshow(this.genelst.length>100?this.genelst.slice(0,100):this.genelst);return}e=e.length==0?null:e.toLowerCase();t=t.length==0?null:t.toLowerCase();const s=[];for(const n of this.genelst){if(e){if(!n.a)continue;if(n.a.toLowerCase().indexOf(e)==-1)continue}if(t){if(!n.b)continue;if(n.b.toLowerCase().indexOf(t)==-1)continue}s.push(n)}this.gui.says.text("Showing "+Math.min(100,s.length)+" of "+this.genelst.length+" pairs");this.geneshow(s.length>100?s.slice(0,100):s)}geneshow(e){this.genetable.selectAll("*").remove();const t=this.genetable.append("tr").style("background-color","#ededed").style("font-size",".8em");t.append("td").text("gene A");t.append("td").text("gene B");t.append("td").text("# sample");t.append("td").text("rating");for(const t of e){let e="black",n="black",o,a;if(t.ainter){e="#aaa";o="normal"}else{const s=t.samples[0].prodlst[0].hlgene;if(s==1||s==3||s==4)o="bold";if(s==4)e=L}if(t.binter){n="#aaa";a="normal"}else{const e=t.samples[0].prodlst[0].hlgene;if(e==2||e==3||e==4)a="bold";if(e==4)n=L}const i=this.genetable.append("tr").attr("class","sja_clb");i.append("td").text(t.a).style("color",e).style("font-weight",o);i.append("td").text(t.b).style("color",n).style("font-weight",a);i.append("td").text(t.samples.length);i.on("click",(()=>{const e=i.node().getBoundingClientRect();const s=c({x:e.left+e.width+10,y:e.top});s.header.text(t.a+" - "+t.b);const n=s.body.append("table");for(const e of t.samples){const t=n.append("tr");t.append("td").style("vertical-align","top").style("padding-top","5px").text(e.name);const s=t.append("td");for(const t of e.prodlst){const n=this.eventlogo([t],s);n.style("position","relative");n.append("div").style("position","absolute").style("width","100%").style("height","100%").style("top","0px").style("left","0px").on("mouseover",(s=>{const n=s.target.getBoundingClientRect();M.clear().show(n.left+n.width-2,n.top-30);this.showsvpairs({prodlst:[t],holder:M.d.append("div"),nodetail:true,sample:e,eglst:null,showothersample:false})})).on("click",(s=>{const n=s.target.getBoundingClientRect();const o=c({x:n.left+n.width+40,y:n.top-60});o.header.text(e.name);this.showsvpairs({prodlst:[t],holder:o.body})}))}}}));const r={};for(const e of t.samples){const t={};for(const s of e.prodlst){t[s.rating]=1}for(var s in t){if(!(s in r)){r[s]=0}r[s]++}}const l=[];for(const e of["HQ","LQ","RT","bad"]){if(r[e]){l.push('<span style="border-radius:6px;background-color:#ededed;padding:1px 6px;font-size:80%">'+e+(r[e]>1?' <span style="font-size:80%">'+r[e]+"</span>":"")+"</span>")}}i.append("td").html(l.join(" "))}}step_gene(){this.gui={};this.genefilter.append("span").text("Filter:");this.gui.inputa=this.genefilter.append("input").attr("size",7).attr("placeholder","gene A").style("margin-left","10px").on("keyup",(()=>this.dogenefilter()));this.gui.inputb=this.genefilter.append("input").attr("size",7).attr("placeholder","gene B").style("margin-left","10px").on("keyup",(()=>this.dogenefilter()));this.genefilter.append("button").style("margin-left","10px").text("Reset").on("click",(()=>{this.gui.inputa.property("value","");this.gui.inputb.property("value","");this.dogenefilter()}));this.gui.says=this.genefilter.append("span").style("padding-left","20px");const e={};const t=new Set;for(const s of this.samples){for(const n in s.events){for(const o of s.events[n]){if(!o.geneA||!o.geneB)continue;if(o.rating=="RT")continue;if(o.geneA){t.add(o.geneA)}if(o.geneB){t.add(o.geneB)}const n=(o.geneA?o.geneA:"<"+o.chrA)+" - "+(o.geneB?o.geneB:"<"+o.chrB);if(!(n in e)){e[n]={}}if(!(s.name in e[n])){e[n][s.name]=[]}e[n][s.name].push(o)}}}this.buttgene.text(t.size+" gene"+(t.size>1?"s":""));for(const t in e){const s=t.split(" - ");const n={samples:[]};if(s[0][0]=="<"){n.a=s[0].slice(1,s[0].length);n.ainter=true}else{n.a=s[0]}if(s[1][0]=="<"){n.b=s[1].slice(1,s[1].length);n.binter=true}else{n.b=s[1]}for(const s in e[t]){n.samples.push({name:s,prodlst:e[t][s]})}this.genelst.push(n)}this.genelst.sort(((e,t)=>{let s=0;for(const t of e.samples){for(const e of t.prodlst){if(e.rating=="HQ")s++}}let n=0;for(const e of t.samples){for(const t of e.prodlst){if(t.rating=="HQ")n++}}return n-s}));this.dogenefilter()}step_table(){this.eggbar=[];this.ul.selectAll("*").remove();for(const e of this.samples){this.ul.append("li").style("font-weight","bold").style("color","#545454").text(e.name);e.ul=this.ul.append("ul").style("margin-bottom","10px");this.showsample(e)}}showsample(e){e.ul.selectAll("*").remove();for(const t of e.egglst){const s=t.lst.reduce(((e,t)=>e+t.lst.length),0);const n=e.ul.append("li");const o=n.append("div").attr("class","sja_clb2").html(t.htmlab+" "+s);o.on("click",(()=>{for(const e of this.eggbar){e.style("background-color","")}o.style("background-color","yellow");const e=y(n.node().nextSibling);if(e.style("display")=="none"){f(e);t.isopen=true}else{h(e);t.isopen=false}}));this.eggbar.push(o);const a=e.ul.append("div").style("margin","10px");this.showevents(e,t.lst,a)}}showevents(e,t,s){const n=s.append("svg");let o=22,a=15,i=13,r=o-3,l=14,p=10,d=20,f=10,h=10,x=10,A=60,B=60,w=10,N=10,z=10,_=10,j=5,R=15,I=13,C=0,T=25,F=12,U=0,q=0,S=0,Q=0;for(const e of t){Q+=i;if(e.lst.length==1){Q+=o}else{Q+=h*2+(o+i)*e.lst.length+(a+i)*(e.lst.length-1)+x}for(const t of e.lst){t.svg={};const e=t.lst;const s=e[0];let o,a;if(s.geneA){const e=s.geneA.split(",");if(e.length>2){o=e[0]+","+e[1]+"..."}else{o=s.geneA}}else{o=""}if(s.geneB){const e=s.geneB.split(",");if(e.length>2){a=e[0]+","+e[1]+"..."}else{a=s.geneB}}else{a=""}n.append("text").text(o).attr("font-size",r).attr("font-family","Courier").each((function(){U=Math.max(U,this.getBBox().width)})).remove();n.append("text").text(a).attr("font-size",r).attr("font-family","Courier").each((function(){q=Math.max(q,this.getBBox().width)})).remove();n.append("text").text(s.rating).attr("font-size",r).attr("font-family","Courier").each((function(){t.svg.ratingw=this.getBBox().width})).remove();t.svg.framew=22;t.svg.typew=60;if(s.usepair){t.svg.frameword=s.usepair.inframe?"IN":"O"}else{t.svg.frameword="?"}n.append("text").text(s.featureA).attr("font-size",p).attr("font-family",v).each((function(){t.svg.featurew=this.getBBox().width})).remove();n.append("text").text(s.featureB).attr("font-size",p).attr("font-family",v).each((function(){t.svg.featurew=Math.max(t.svg.featurew,this.getBBox().width)})).remove();n.append("text").text(Math.floor(s.score)).attr("font-size",r).attr("font-family",v).each((function(){t.svg.scorew=this.getBBox().width})).remove();t.svg.logow=t.svg.ratingw+t.svg.framew+t.svg.typew+t.svg.featurew+t.svg.scorew+j*6;C=Math.max(C,t.svg.logow+(e.length>1?_+T:0));if(s.geneA&&s.geneB){const e=this.elab2sample[t.label];if(!e){t.svg.recurtext="Recurrence check error";t.svg.recurtextcolor="red"}else if(e.length==1){t.svg.recurtext="No recurrence";t.svg.recurtextcolor="#aaaaaa"}else{t.svg.hasrecurrence=true;t.svg.recurtext="In "+e.length+" samples";t.svg.recurtextcolor="black"}}else{t.svg.recurtext="Unknown recurrence";t.svg.recurtextcolor="#aaaaaa"}n.append("text").text(t.svg.recurtext).attr("font-size",r-4).attr("font-family",v).each((function(){t.svg.recurw=this.getBBox().width})).remove();S=Math.max(S,t.svg.recurw)}}U+=10;q+=10;Q+=i;let H=100;let O=A+w+o+I+U+F+N+F+q+I+o+w+B+z+C+R+S;n.attr("width",d*2+f*2+O+H).attr("height",Q);const D=n.append("g").attr("transform","translate("+d+",0)");let P=0;for(const d of t){P+=i;const Q=D.append("g").attr("transform","translate(0,"+P+")");const G=(o+i)*d.lst.length-i+(d.lst.length>1?h*2:0)+(d.lst.length>1?(a+i)*(d.lst.length-1):0);if(d.lst.length>1){Q.append("rect").attr("stroke","black").attr("stroke-dasharray",d.ismsg?"none":"2,3").attr("fill","none").attr("width",O+f*2).attr("height",G).attr("shape-rendering","crispEdges");if(d.ismsg){const a=Q.append("g").attr("transform","translate("+(O+f*2)+",0)");a.append("rect").attr("width",H).attr("height",o).attr("fill","#858585").attr("shape-rendering","crispEdges");a.append("text").text("multi-seg").attr("x",10).attr("y",o/2).attr("font-size",o-6).attr("font-family",v).attr("fill","white").attr("dominant-baseline","middle");a.append("rect").attr("width",H).attr("height",o).attr("fill","white").attr("fill-opacity",0).on("click",(o=>{const a=[];const i=[];for(const e of d.lst){const t=e.lst[0];i.push(t.prodid);const s={a:{chr:t.chrA,position:t.posA,strand:t.ortA,name:t.geneA?t.geneA:t.chrA,ratio:t.ratioA.toFixed(2),feature:t.featureA,contiglen:t.matchA,chimericreads:t.readsA,repeatscore:t.repeatA},b:{chr:t.chrB,position:t.posB,strand:t.ortB,name:t.geneB?t.geneB:t.chrB,ratio:t.ratioB.toFixed(2),feature:t.featureB,contiglen:t.matchB,chimericreads:t.readsB,repeatscore:t.repeatB},rating:t.rating,score:Math.ceil(t.score)};if(t.usepair){s.inframe=t.usepair.inframe;const e=t.usepair.a;s.a.gm=this.genome.isoformmatch(e.isoform,s.a.chr,s.a.position);s.a.codon=e.codon;s.a.exon=e.exon;s.a.atupstream=e.atupstream;s.a.atdownstream=e.atdownstream;s.a.atutr5=e.atutr5;s.a.atutr3=e.atutr3;const n=t.usepair.b;s.b.gm=this.genome.isoformmatch(n.isoform,s.b.chr,s.b.position);s.b.codon=n.codon;s.b.exon=n.exon;s.b.atupstream=n.atupstream;s.b.atdownstream=n.atdownstream;s.b.atutr5=n.atutr5;s.b.atutr3=n.atutr3;let o=0,a=0;if(e.contigaa&&n.contigaa){o=n.contigaa-e.contigaa-1}if(e.contigbp&&n.contigbp){a=n.contigbp-e.contigbp-1}if(o){s.interstitial={aalen:o}}if(a){if(!s.interstitial)s.interstitial={};s.interstitial.bplen=a}}a.push(s)}const r=o.target.getBoundingClientRect();const l=c({x:r.left+10,y:r.top+r.height+10});const p=l.body.append("div").style("margin","10px");p.append("span").style("padding-right","20px").text("Product id: "+i.join(", "));p.append("button").style("margin-right","10px").text("Break").on("click",(()=>{const o=d.lst.map((e=>e.lst[0].prodid));let a=0;for(;a<t.length;a++){const e=t[a];if(e.ismsg){const t=e.lst.map((e=>e.lst[0].prodid));if(t.join(",")==o.join(",")){break}}}delete d.ismsg;const i=d.lst;d.lst=[d.lst[0]];for(let e=1;e<i.length;e++){t.splice(a,0,{label:"",lst:[i[e]]})}n.remove();this.showevents(e,t,s);l.pane.remove()}));p.append("button").text("Edit").on("click",(s=>{const n=document.createElement("input");p.node().insertBefore(n,s.target);const o=document.createElement("button");p.node().insertBefore(o,s.target);p.node().removeChild(s.target);n.focus();const a=y(n);const r=y(o);a.attr("size",10).style("margin","0px 10px").property("value",i.join(","));r.text("Apply").on("click",(()=>{const s=n.value.trim().split(",");const o=[];for(const t of s){if(!t)continue;const s=Number.parseInt(t);if(Number.isNaN(s))return alert("invalid id: "+t);if(this.prodidisinvalid(s,e))return alert("invalid id "+s);o.push(s)}if(o.length<=1)return alert("must be at least 2 products");const a=[];for(const t of o){const s=this.extractprod(t,e);if(s){a.push({label:s.eventlabel,lst:[s]})}else{return alert("unknown product id "+t)}}if(a.length<=1)return alert("less than 2 products cannot make a group");t.unshift({lst:a,ismsg:true});this.showsample(e);l.pane.remove()}))}));E({samplelst:[{pairlst:a}],nosample:true,holder:l.body});const f={pairlst:a,genome:this.genome,holder:l.body,hostURL:this.hostURL,jwt:this.jwt};import("./svgraph-6fac8cbc.js").then((e=>{e.default(f)}))}))}}const J=Q.append("g").attr("transform","translate("+f+","+(d.lst.length>1?h:0)+")");let V=0;let Y=0;const W={};for(const e of d.lst){W[e.label]=1}const X={};for(const s of d.lst){const n=s.lst;const f=n[0];const h=f.usepair;if(d.lst.length>1&&Y>0){const e=J.append("g").attr("transform","translate("+(A+w+o+I+U+F+N/2)+","+V+")");const t=e.append("text").attr("fill","#858585").attr("font-size",a).attr("text-anchor","middle").attr("font-family",v).attr("y",a/2).attr("dominant-baseline","middle");if(d.ismsg){t.text(f.mswhat?f.mswhat:"No connection detail")}else{t.text("Reciprocal")}V+=a+i}const x=f.chrA==f.chrB?"black":k;const y=J.append("g").attr("transform","translate(0,"+V+")");y.append("text").text(f.chrA).attr("x",A).attr("y",o/2).attr("font-size",r-4).attr("text-anchor","end").attr("dominant-baseline","middle").attr("fill",x);const E={a:null,b:null};if(f.geneA){if(f.geneA in X){X[f.geneA]=1}else{const t=[];for(const s in e.gene2events[f.geneA]){if(!(s in W)){t.push(s)}}if(t.length>0){E.a={lst:t};E.a.circle=y.append("circle").attr("fill","white").attr("stroke","black").attr("cx",A+w+o/2).attr("cy",o/2).attr("r",o/2);if(t.length>1){E.a.text=y.append("text").text(t.length).attr("x",A+w+o/2).attr("y",o/2).attr("text-anchor","middle").attr("font-size",a).attr("dominant-baseline","middle").attr("fill","black")}y.append("line").attr("x1",A+w+o).attr("x2",A+w+o+I).attr("y1",o/2).attr("y2",o/2).attr("stroke","black").attr("shape-rendering","crispEdges")}}}y.append("rect").attr("fill",m).attr("x",A+w+o+I+(U+F)*(1-f.ratioA)).attr("width",(U+F)*f.ratioA).attr("height",o).attr("shape-rendering","crispEdges");let Q=false;if(h){const e=h.a.isoform;if(e){const t=this.genome.isoformmatch(e,f.chrA,f.posA);if(t&&t.strand!=f.ortA){Q=true}}}const H=y.append("rect").attr("fill","none").attr("stroke",Q?"red":"black").attr("shape-rendering","crispEdges").attr("x",A+w+o+I).attr("width",U+F).attr("height",o);let O;if(f.geneA){const e=f.geneA.split(",");if(e.length>2){O=e[0]+","+e[1]+"..."}else{O=f.geneA}}else{O=""}y.append("text").text(O).attr("x",A+w+o+I+U).attr("y",o/2).attr("font-size",r).attr("font-family","Courier").attr("font-weight",f.hlgene?f.hlgene==1||f.hlgene==3||f.hlgene==4?"bold":"normal":"normal").attr("fill",f.hlgene?f.hlgene==4?L:"#545454":"#545454").attr("text-anchor","end").attr("dominant-baseline","central");y.append("line").attr("x1",A+w+o+I+U+F).attr("x2",A+w+o+I+U+F+N).attr("y1",o/2).attr("y2",o/2).attr("shape-rendering","crispEdges").attr("stroke","black");y.append("rect").attr("fill",b).attr("x",A+w+o+I+U+F+N).attr("width",(F+q)*f.ratioB).attr("height",o).attr("shape-rendering","crispEdges");Q=false;if(h){const e=h.b.isoform;if(e){const t=this.genome.isoformmatch(e,f.chrB,f.posB);if(t&&t.strand!=f.ortB){Q=true}}}const D=y.append("rect").attr("fill","none").attr("stroke",Q?"red":"black").attr("shape-rendering","crispEdges").attr("x",A+w+o+I+U+F+N).attr("width",q+F).attr("height",o);let P;if(f.geneB){let e=f.geneB.split(",");if(e.length>2){P=e[0]+","+e[1]+"..."}else{P=f.geneB}}else{P=""}y.append("text").text(P).attr("x",A+w+o+I+U+F+N+F).attr("y",o/2).attr("font-size",r).attr("font-family","Courier").attr("font-weight",f.hlgene?f.hlgene==2||f.hlgene==3||f.hlgene==4?"bold":"normal":"normal").attr("fill",f.hlgene?f.hlgene==4?L:"#545454":"#545454").attr("dominant-baseline","central");if(f.geneB){if(f.geneB in X);else{X[f.geneB]=1;const t=[];for(const s in e.gene2events[f.geneB]){if(!(s in W)){t.push(s)}}if(t.length>0){E.b={lst:t};E.b.circle=y.append("circle").attr("fill","white").attr("stroke","black").attr("cx",A+w+o+I+U+F+N+F+q+I+o/2).attr("cy",o/2).attr("r",o/2);if(t.length>1){E.b.text=y.append("text").text(t.length).attr("x",A+w+o+I+U+F+N+F+q+I+o/2).attr("y",o/2).attr("text-anchor","middle").attr("font-size",a).attr("dominant-baseline","middle").attr("fill","black")}y.append("line").attr("x1",A+w+o+I+U+F+N+F+q).attr("x2",A+w+o+I+U+F+N+F+q+I).attr("y1",o/2).attr("y2",o/2).attr("stroke","black").attr("shape-rendering","crispEdges")}}}y.append("text").text(f.chrB).attr("x",A+w+o+I+U+F+N+F+q+I+o+w).attr("y",o/2).attr("font-size",r-4).attr("dominant-baseline","middle").attr("fill",x);let G=A+w+o+I+U+F+N+F+q+I+o+w+B+z;const K=G;const Z=y.append("rect").attr("fill","white").attr("stroke","#858585").attr("x",G).attr("y",-1.5).attr("width",s.svg.logow).attr("height",o+2).attr("rx",5).attr("ry",5);G+=j;f.hook.mainRating=y.append("text").text(f.rating).attr("font-size",r).attr("font-family",v).attr("fill","#858585").attr("x",G).attr("y",o/2).attr("dominant-baseline","middle");G+=s.svg.ratingw+j;f.hook.mainFrame={};f.hook.mainFrame.bg=y.append("rect").attr("x",G+1).attr("y",3).attr("width",s.svg.framew).attr("height",o-7).attr("shape-rendering","crispEdges");if(f.usepair){f.hook.mainFrame.bg.attr("fill",f.usepair.inframe?u:g)}else{f.hook.mainFrame.bg.attr("fill","none").attr("stroke","black")}f.hook.mainFrame.text=y.append("text").text(s.svg.frameword).attr("font-size",l).attr("font-family",v).attr("fill",f.usepair?"white":"black").attr("x",G+1+s.svg.framew/2).attr("text-anchor","middle").attr("y",o/2).attr("dominant-baseline","middle");G+=s.svg.framew+j;f.hook.mainType=y.append("text").text(f.type2).attr("font-size",r).attr("font-family",v).attr("fill","#858585").attr("x",G).attr("y",o/2).attr("dominant-baseline","middle");G+=s.svg.typew+j;y.append("text").text(f.featureA).attr("font-size",p).attr("font-family",v).attr("fill","black").attr("x",G).attr("y",o/4).attr("dominant-baseline","middle");y.append("text").text(f.featureB).attr("font-size",p).attr("font-family",v).attr("fill","black").attr("x",G).attr("y",o*3/4).attr("dominant-baseline","middle");G+=s.svg.featurew+j;y.append("text").text(Math.floor(f.score)).attr("font-size",r).attr("font-family",v).attr("fill","#858585").attr("x",G).attr("y",o/2).attr("dominant-baseline","middle");G+=s.svg.scorew+j+_;y.append("rect").attr("fill","white").attr("fill-opacity",0).attr("stroke","none").attr("x",K).attr("y",-1.5).attr("width",s.svg.logow).attr("height",o+2).on("mouseover",(()=>{Z.attr("stroke-width","2");const e=M.clear().showunder(Z.node()).d.append("div");this.prodstat(f,e)})).on("mouseout",(()=>{Z.attr("stroke-width","1");M.hide()}));if(n.length>1){const e=y.append("rect").attr("fill","none").attr("stroke","#858585").attr("x",G).attr("y",3.5).attr("width",T).attr("height",o-4).attr("rx",5).attr("ry",5);y.append("text").text(n.length-1).attr("fill","black").attr("font-size",p).attr("font-family",v).attr("x",G+T/2).attr("y",3.5+(o-3.5)/2).attr("text-anchor","middle").attr("dominant-baseline","middle");y.append("rect").attr("fill","white").attr("fill-opacity",0).attr("x",G).attr("y",3.5).attr("width",T).attr("height",o-4).on("mouseover",(t=>{e.attr("stroke-width","2");const s=M.clear().showunder(t.target).d.append("table").style("border-spacing","10px").style("border-collapse","separate");const o=s.append("tr");const a=s.append("tr");for(var i=1;i<n.length;i++){this.eventlogo([n[i]],o.append("td"));this.prodstat(n[i],a.append("td"))}})).on("mouseout",(()=>{e.attr("stroke-width","1");M.hide()}))}G=A+w+o+I+U+F+N+F+q+I+o+w+B+z+C+R;const $=y.append("text").text(s.svg.recurtext).attr("font-size",r-4).attr("font-family",v).attr("fill",s.svg.recurtextcolor).attr("x",G).attr("y",o/2).attr("dominant-baseline","middle");if(s.svg.hasrecurrence){$.attr("class","sja_svgtext2").on("mouseover",(t=>{const n=t.target.getBoundingClientRect();M.clear().show(n.left+n.width+10,n.top-15);const o=this.elab2sample[s.label];const a=M.d;a.append("div").style("margin","10px").style("color","#aaa").text("This fusion is recurrent in other samples:");const i=a.append("table").style("border-spacing","10px").style("border-collapse","separate");for(const t of o){if(t.name==e.name){continue}const n=i.append("tr");n.append("td").style("font-weight","bold").style("color","#858585").text(t.name);this.eventlogo(t.events[s.label],n.append("td"))}})).on("mouseout",(()=>M.hide()))}y.append("rect").attr("x",A+w+o+I).attr("width",U+F+N+F+q).attr("height",o).attr("fill","white").attr("fill-opacity",0).on("mouseover",(n=>{H.attr("stroke-width",2);D.attr("stroke-width",2);const o=n.target.getBoundingClientRect();M.clear().show(o.left+o.width+I/2,o.top-30);this.showsvpairs({prodlst:s.lst,holder:M.d,nodetail:true,sample:e,eglst:t,showothersample:true})})).on("mouseout",(()=>{M.hide();H.attr("stroke-width",1);D.attr("stroke-width",1)})).on("click",(e=>{if(s.inclick){return}s.inclick=true;const t=e.target.getBoundingClientRect();const n=c({x:t.left+t.width+I+o+w+B+z+C+R+S+5,y:t.top-100,close:function(){s.inclick=false;n.pane.remove()}});const a=s.lst[0];n.header.html('<span style="padding:2px 4px;background-color:'+m+';">'+(a.geneA?a.geneA:a.chrA)+"</span>"+'<span style="padding:2px 4px;background-color:'+b+';">'+(a.geneB?a.geneB:a.chrB)+"</span>");this.showsvpairs({prodlst:s.lst,holder:n.body})}));if(E.a){y.append("circle").attr("cx",A+w+o/2).attr("cy",o/2).attr("r",o/2).attr("fill","white").attr("fill-opacity",0).on("mouseover",(t=>this.extevt_mover(E.a,t.target,e))).on("mouseout",(()=>{this.extevt_mo(E.a);M.hide()})).on("click",(t=>{this.extevt_c(E.a,t.target,e)}))}if(E.b){y.append("circle").attr("cx",A+w+o+I+U+F+N+F+q+I+o/2).attr("cy",o/2).attr("r",o/2).attr("fill","white").attr("fill-opacity",0).on("mouseover",(t=>this.extevt_mover(E.b,t.target,e))).on("mouseout",(()=>{this.extevt_mo(E.b);M.hide()})).on("click",(t=>this.extevt_c(E.b,t.target,e)))}V+=o+i;Y++}P+=G+(d.lst.length>1?x:0)}s.style("display","none")}extevt_mover(e,t,s){e.circle.attr("fill","#858585");if(e.text){e.text.attr("fill","white")}M.clear().showunder(t);M.d.append("div").style("margin","10px").style("color","#aaa").text("Associated fusions from this sample:");this.extevt_table(e.lst,M.d,s)}extevt_mo(e){e.circle.attr("fill","white");if(e.text){e.text.attr("fill","black")}}extevt_c(e,t,s){const n=t.getBoundingClientRect();const o=c({x:n.left,y:n.top+n.height+10});this.extevt_table(e.lst,o.body,s)}extevt_table(e,t,s){const n=t.append("table").style("border-spacing","10px").style("border-collapse","separate");for(const t of e){const e=n.append("tr");const o=s.events[t];if(!o){e.append('<td colspan=2 style="color:red">No products found for '+t+"</td>");continue}const a=o[0];e.append("td").style("text-align","right").text(a.geneA?a.geneA:a.chrA);e.append("td").text(a.geneB?a.geneB:a.chrB);this.eventlogo(o,e.append("td"))}}eventlogo(e,t){const s=t.append("div");if(!e||e.length==0){s.style("color","red").text("No products")}else{const t=e[0];s.append("div").style("display","inline-block").style("padding","2px 4px").style("border","solid 1px #858585").style("border-radius","5px").html(t.rating+" "+'<span style="font-size:70%;vertical-align:2px;'+(t.usepair?t.usepair.inframe?"padding:2px 4px;background-color:"+u+';color:white;">IN':"padding:2px 4px;background-color:"+g+';color:white;">O':'padding:1px 3px;border:solid 1px black;background-color:white;color:black;">?')+"</span>"+' <span style="color:#858585">'+t.type2+"</span> "+'<div style="display:inline-block;font-size:70%;line-height:.9">'+t.featureA+"<br>"+t.featureB+"</div>"+" "+Math.floor(t.score));if(e.length>1){s.append("div").style("display","inline-block").style("margin-left","10px").style("padding","2px 4px").style("font-size",".7em").style("border","solid 1px #858585").style("border-radius",5).text(e.length-1)}}return s}prodstat(e,t){t.append("p").text("Product id: "+e.prodid);const s="#FFb3b3",n="#f1f1f1";const o=t.append("table").style("border-spacing","8px").style("border-collapse","separate");let a=o.append("tr");a.append("td");a.append("td").style("background-color",n).text(e.geneA?e.geneA:e.chrA);a.append("td").style("background-color",n).text(e.geneB?e.geneB:e.chrB);a=o.append("tr");a.append("td").style("font-size","80%").style("background-color",n).text("chimeric reads");a.append("td").style("padding","5px").style("background-color",e.readsA<=this.cf_reads?s:"").text(e.readsA);a.append("td").style("padding","5px").style("background-color",e.readsB<=this.cf_reads?s:"").text(e.readsB);a=o.append("tr");a.append("td").style("font-size","80%").style("background-color",n).text("ratio");a.append("td").style("padding","5px").style("background-color",e.ratioA<=this.cf_ratio?s:"").text(Math.ceil(e.ratioA*100)+"%");a.append("td").style("padding","5px").style("background-color",e.ratioB<=this.cf_ratio?s:"").text(Math.ceil(e.ratioB*100)+"%");a=o.append("tr");a.append("td").style("font-size","80%").style("background-color",n).text("contig length");a.append("td").style("padding","5px").style("background-color",e.matchA<=this.cf_match?s:"").text(e.matchA+" bp");a.append("td").style("padding","5px").style("background-color",e.matchB<=this.cf_match?s:"").text(e.matchB+" bp");a=o.append("tr");a.append("td").style("font-size","80%").style("background-color",n).text("repeat score");a.append("td").style("padding","5px").style("background-color",e.repeatA>=this.cf_repeat?s:"").text(e.repeatA);a.append("td").style("padding","5px").style("background-color",e.repeatB>=this.cf_repeat?s:"").text(e.repeatB)}showsvpairs(e){const t=e.holder.append("table").style("border-spacing","10px").style("border-collapse","separate");const s=t.append("tr");const n=t.append("tr");const o=n.append("td").attr("colspan",e.prodlst.length);const a=t.append("tr");const i=new Set;for(const t of e.prodlst){if(t.geneA){i.add(t.geneA)}if(t.geneB){i.add(t.geneB)}const n=s.append("td").style("vertical-align","top");if(e.nodetail){const s=n.append("div");s.append("span").style("padding-right","20px").text("Product id: "+t.prodid);const o=s.append("select").style("margin-right","5px").on("change",(e=>{const s=e.target;const n=s.options[s.selectedIndex].innerHTML;t.rating=n;if(t.hook.mainRating){t.hook.mainRating.text(n)}if(t.hook.lessRating){t.hook.lessRating.text(n)}}));const a=s.append("select").style("margin-right","5px").on("change",(e=>{const s=e.target;const n=s.options[s.selectedIndex].innerHTML=="in-frame";t.usepair.inframe=n;if(t.hook.mainFrame){t.hook.mainFrame.text.text(n?"IN":"O");t.hook.mainFrame.bg.attr("fill",n?u:g)}if(t.hook.lessFrame){t.hook.lessFrame.html(n?'<span style="background-color:'+u+';color:white;padding:2px 3px;font-size:80%;white-space:nowrap">In frame</span>':'<span style="background-color:'+g+';color:white;padding:2px 3px;font-size:80%;white-space:nowrap">Out of frame</span>')}}));const i=s.append("select").style("margin-right","5px").on("change",(e=>{const s=e.target;const n=s.selectedIndex;const o=s.options[n].innerHTML;t.type2=o;if(t.hook.mainType){t.hook.mainType.text(o)}t.iscloss=n==0;t.isnloss=n==1;t.isfusion=n==2;t.isitd=n==3;t.isuptss=n==4;t.isother=n==5}));const r=s.append("select").style("margin-right","5px").on("change",(e=>{const s=e.target;const n=s.options[s.selectedIndex].innerHTML;t.functioneffect=n}));s.append("button").text("Create group").on("click",(n=>{let o=document.createElement("div");s.node().insertBefore(o,n.target);y(n.target).remove();o=y(o);o.style("display","inline-block");if(!e.eglst){o.text("Cannot do it here: please go to sample "+e.sample.name);return}o.append("input").attr("size",10).property("value",t.prodid+",");o.append("button").style("margin","0px 10px").text("Apply").on("click",(t=>{const s=t.target.previousSibling.value.trim().split(",");const n=[];for(const t of s){const s=Number.parseInt(t);if(Number.isNaN(s))return alert("invalid id "+t);if(this.prodidisinvalid(s,e.sample))return alert("invalid id "+s);n.push(s)}if(n.length<=1)return alert("need at least 2 id");const o=[];for(const t of n){const s=this.extractprod(t,e.sample);if(s){o.push({label:s.eventlabel,lst:[s]})}else{return alert("invalid id "+t)}}if(o.length<=1)return alert("less than 2 products cannot make a group");e.eglst.unshift({lst:o,ismsg:true});this.showsample(e.sample);M.hide()}))}));o.append("option").text("HQ");o.append("option").text("LQ");o.append("option").text("RT");o.append("option").text("bad");o.append("option").text("Major");switch(t.rating){case"HQ":o.property("selectedindex",0);break;case"LQ":o.property("selectedIndex",1);break;case"RT":o.property("selectedIndex",2);break;case"bad":o.property("selectedIndex",3);break;case"Major":o.property("selectedIndex",4);break;default:alert("unknown rating: "+t.rating)}a.append("option").text("in-frame");a.append("option").text("out-of-frame");if(!t.usepair){a.attr("disabled",1)}else{a.property("selectedIndex",t.usepair.inframe?0:1)}i.append("option").text("CLoss");i.append("option").text("NLoss");i.append("option").text("Fusion");i.append("option").text("ITD");i.append("option").text("upTSS");i.append("option").text("other");if(t.iscloss){i.property("selectedIndex",0)}else if(t.isnloss){i.property("selectedIndex",1)}else if(t.isfusion){i.property("selectedIndex",2)}else if(t.isitd){i.property("selectedIndex",3)}else if(t.isuptss){i.property("selectedIndex",4)}else if(t.isother){i.property("selectedIndex",5)}else{alert("unknown type2: "+t.type2)}r.append("option").text("unknown effect");r.append("option").text("fusion gene");r.append("option").text("truncation, activated oncogene");r.append("option").text("truncation, loss-of-function");r.append("option").text("truncation, no consequence");r.append("option").text("ITD");switch(t.functioneffect){case undefined:r.property("selectedIndex",0);break;case"fusion gene":r.property("selectedIndex",1);break;case"truncation, activated oncogene":r.property("selectedIndex",2);break;case"truncation, loss-of-function":r.property("selectedIndex",3);break;case"truncation, no consequence":r.property("selectedIndex",4);break;case"ITD":r.property("selectedIndex",5);break}}const o={a:{chr:t.chrA,position:t.posA,strand:t.ortA,name:t.geneA?t.geneA:t.chrA,ratio:t.ratioA.toFixed(2),feature:t.featureA,contiglen:t.matchA,chimericreads:t.readsA,repeatscore:t.repeatA},b:{chr:t.chrB,position:t.posB,strand:t.ortB,name:t.geneB?t.geneB:t.chrB,ratio:t.ratioB.toFixed(2),feature:t.featureB,contiglen:t.matchB,chimericreads:t.readsB,repeatscore:t.repeatB},rating:t.rating,score:Math.ceil(t.score),originalprod:t};if(t.usepair){o.inframe=t.usepair.inframe;const e=t.usepair.a;o.a.gm=this.genome.isoformmatch(e.isoform,t.chrA,t.posA);o.a.codon=e.codon;o.a.exon=e.exon;o.a.atupstream=e.atupstream;o.a.atdownstream=e.atdownstream;o.a.atutr5=e.atutr5;o.a.atutr3=e.atutr3;const s=t.usepair.b;o.b.gm=this.genome.isoformmatch(s.isoform,t.chrB,t.posB);o.b.codon=s.codon;o.b.exon=s.exon;o.b.atupstream=s.atupstream;o.b.atdownstream=s.atdownstream;o.b.atutr5=s.atutr5;o.b.atutr3=s.atutr3;let n=0,a=0;if(e.contigaa&&s.contigaa){n=s.contigaa-e.contigaa-1}if(e.contigbp&&s.contigbp){a=s.contigbp-e.contigbp-1}if(n){o.interstitial={aalen:n}}if(a){if(!o.interstitial)o.interstitial={};o.interstitial.bplen=a}}E({samplelst:[{pairlst:[o]}],nosample:true,holder:n});const r={pairlst:[o],genome:this.genome,holder:n,quiet:true,hostURL:this.hostURL,jwt:this.jwt};import("./svgraph-6fac8cbc.js").then((e=>{e.default(r)}));if(!e.nodetail){const e=a.append("td").style("font-size",".8em").style("vertical-align","top");const s=[];for(const e of this.atlst){if(!e.custom)continue;const n=t[e.key];s.push({k:e.label,v:n==undefined?"":n})}A(e,s,25);t.pairs.sort(((e,t)=>{if(e.inuse)return-1;if(t.inuse)return 1;return 0}));const n=e.append("table");for(const e of t.pairs){const s=n.append("tr");s.append("td").html((e.inframe?"in-frame":"out-of-frame")+'<div style="font-size:70%">frame code: '+e.frame+"</div>");const o=s.append("td");const a=o.append("table").style("margin-bottom","20px").style("border",e.inuse?"solid 1px black":"").style("border-spacing","10px").style("border-collapse","separate");let i=a.append("tr").style("color","#858585").style("font-size",".7em");i.append("td").text("gene");i.append("td").text("isoform");i.append("td").text("gene position");i.append("td").text("exon");i.append("td").text("anchor");i.append("td").text("contig AA");i.append("td").text("contig bp");const r=a.append("tr");const l=a.append("tr");r.append("td").text(t.geneA?t.geneA:t.chrA);l.append("td").text(t.geneB?t.geneB:t.chrB);r.append("td").text(e.a.isoform?e.a.isoform:"");l.append("td").text(e.b.isoform?e.b.isoform:"");r.append("td").text(e.a.isoform?e.a.codon!=undefined?"codon: "+e.a.codon:e.a.atutr5?"5' UTR":e.a.atutr3?"3' UTR":e.a.atupstream?"upstream":"downstream":"");l.append("td").text(e.b.isoform?e.b.codon!=undefined?"codon: "+e.b.codon:e.b.atutr5?"5' UTR":e.b.atutr3?"3' UTR":e.b.atupstream?"upstream":"downstream":"");r.append("td").text(e.a.exon?e.a.exon:"");l.append("td").text(e.b.exon?e.b.exon:"");r.append("td").text(e.a.anchor?e.a.anchor:"");l.append("td").text(e.b.anchor?e.b.anchor:"");r.append("td").html(e.a.contigaa?'<span style="color:#858585;font-size:70%">ends at</span> '+e.a.contigaa:"?");l.append("td").html(e.b.contigaa?'<span style="color:#858585;font-size:70%">starts at</span> '+e.b.contigaa:"?");r.append("td").html(e.a.contigbp?'<span style="color:#858585;font-size:70%">ends at</span> '+e.a.contigbp:"?");l.append("td").html(e.b.contigbp?'<span style="color:#858585;font-size:70%">starts at</span> '+e.b.contigbp:"?")}}}if(!e.sample){return}const r=e.prodlst[0].eventlabel;const l=this.elab2sample[r];const p=[];if(l){for(const t of l){if(t.name!=e.sample.name)p.push(t)}}if(e.showothersample&&p.length>0){e.holder.append("button").style("display","block").style("margin","20px").text("Show in "+p.length+" other sample"+(p.length>1?"s":"")).on("click",(t=>{y(t.target).remove();for(const t of p){const s=t.events[r];if(!s){e.holder.append("div").style("margin","20px").style("color","red").text("Error: no products for this event in "+t.name);continue}const n=e.holder.append("table").style("margin-top","20px").style("border","solid 1px #ccc");const o=n.append("tr");o.append("td").text(t.name);const a=o.append("td");this.showsvpairs({prodlst:s,holder:a,nodetail:true,sample:t,eglst:null})}}))}if(this.expression.genes&&i.size>0){const t=o.append("table");const s=t.append("tr");for(const t of i){const n=this.expression.genes[t];if(n){const o=s.append("td").style("vertical-align","top").append("div").style("display","inline-block").style("margin-right","20px").style("border","solid 1px #ccc");o.append("div").style("background-color","#ededed").style("padding","10px").text(t);if(e.sample){for(const t of n){if(t.sample==e.sample.name){t.ishighlight=true;o.append("div").style("padding","10px").style("font-size","70%").html("Expression in "+e.sample.name+': <span style="font-size:150%">'+t.value+"</span>")}else{t.ishighlight=false}}}S({data:this.expression.genes[t],holder:o.append("div").style("margin","10px"),width:200,height:200,namename:"sample"})}else{s.append("td").style("vertical-align","top").text("No expression data for "+t+"</td>")}}}}prodidisinvalid(e,t){for(const s of t.egglst){for(const t of s.lst){for(const s of t.lst){for(const t of s.lst){if(t.prodid==e)return false}}}}return true}extractprod(e,t){let s=null;for(let n=0;n<t.egglst.length;n++){const o=t.egglst[n];for(let t=0;t<o.lst.length;t++){const n=o.lst[t];for(let t=0;t<n.lst.length;t++){const o=n.lst[t];for(let t=0;t<o.lst.length;t++){const n=o.lst[t];if(n.prodid==e){s=n;o.lst.splice(t,1);break}}if(s){if(o.lst.length==0){n.lst.splice(t,1)}break}}if(s){if(n.lst.length==0){o.lst.splice(t,1)}else{if(n.ismsg&&n.lst.length==1){delete n.ismsg}}break}}if(s){if(o.lst.length==0){t.egglst.splice(n,1)}break}}return s}}function U(e,t){if(e.isitd)return;if(e.sv_ort=="?")return;var s=true;var n=e.usepair;for(var o=0;o<t.length;o++){var a=t[o];var i=a[0];if(e.chrB==i.chrA&&e.ortB==i.ortA){if(h(e,i)){var r=i.usepair;if(n&&r&&n.b.isoform&&n.b.isoform==r.a.isoform){var l=n.b;var p=r.a;var c=false;if(l.atutr5){if(p.codon!=undefined){c=true;i.mswhat="5' UTR to coding region"}else if(p.atutr3){c=true;i.mswhat="5' UTR to 3' UTR"}else if(p.atutr5&&l.atutr5.off<p.atutr5.off){c=true;i.mswhat=p.atutr5.off-l.atutr5.off+" bp apart in 5' UTR"}}else if(l.atutr3){if(p.atutr3&&l.atutr3.off<p.atutr3.off){c=true;i.mswhat=p.atutr3.off-l.atutr3.off+" bp apart in 3' UTR"}}else if(l.codon!=undefined){if(p.codon!=undefined&&p.codon>l.codon){c=true;i.mswhat=p.codon-l.codon+" aa apart in protein"}else if(p.atutr3){c=true;i.mswhat="coding region to 3' UTR"}}if(c){a.unshift(e);s=false;break}}var d=i.posA-e.posB;if(e.ortB=="+"&&d>0&&d<T||e.ortB=="-"&&d<0&&-d<T){i.mswhat=Math.abs(d)+" bp apart on genome";a.unshift(e);s=false;break}}}i=a[a.length-1];if(e.chrA==i.chrB&&e.ortA==i.ortB){if(h(i,e)){var r=i.usepair;if(n&&r&&n.a.isoform&&n.a.isoform==r.b.isoform){var l=r.b;var p=n.a;var f=false;if(l.atutr5){if(p.codon!=undefined){f=true;e.mswhat="5' UTR to coding region"}else if(p.atutr3){f=true;e.mswhat="5' UTR to 3' UTR"}else if(p.atutr5&&l.atutr5.off<p.atutr5.off){f=true;e.mswhat=p.atutr5.off-l.atutr5.off+" bp apart in 5' UTR"}}else if(l.atutr3){if(p.atutr3&&l.atutr3.off<p.atutr3.off){f=true;e.mswhat=p.atutr3.off-l.atutr3.off+" bp apart in 3' UTR"}}else if(l.codon!=undefined){if(p.codon!=undefined&&p.codon>l.codon){f=true;e.mswhat=p.codon-l.codon+" aa apart in protein"}else if(p.atutr3){f=true;e.mswhat="coding region to 3' UTR"}}if(f){a.push(e);s=false;break}}var d=e.posA-i.posB;if(e.ortA=="+"&&d>0&&d<T&&(e.ortA=="-"&&d<0&&-d<T)){e.mswhat=Math.abs(d)+" bp apart on genome";a.push(e);s=false;break}}}}if(s){t.push([e])}function h(e,t){if(!e.usepair||!e.usepair.inframe)return false;if(!t.usepair||!t.usepair.inframe)return false;if(e.readsB==0||t.readsA==0)return false;var s=e.readsB/t.readsA;return s>=.2&&s<=5}}function E(e){const t=e.holder.append("table").style("border-spacing","10px").style("border-collapse","separate");const s=t.append("tr").style("font-size","70%").style("color","#858585");const n=[{label:"Feature",hide:true,get:e=>e.feature},{label:"Ratio",hide:true,get:e=>Math.ceil(e.ratio*100)+"%"},{label:"Chimeric<br>reads",hide:true,get:e=>e.chimericreads},{label:"Contig<br>length",hide:true,get:e=>e.contiglen},{label:"Repeat<br>score",hide:true,get:e=>e.repeatscore},{label:"Cicero<br>score",hide:true,atpair:true,get:e=>e.score},{label:"Cicero<br>rating",israting:true,hide:true,atpair:true,get:e=>e.rating}];for(const t of e.samplelst){for(const e of t.pairlst){if(e.a.feature||e.b.feature)n[0].hide=false;if(typeof e.a.ratio=="number"||typeof(e.b.ratio=="number"))n[1].hide=false;if(typeof e.a.chimericreads=="number"||typeof e.b.chimericreads=="number")n[2].hide=false;if(typeof e.a.contiglen=="number"||typeof e.b.contiglen=="number")n[3].hide=false;if(typeof e.a.repeatscore=="number"||typeof e.b.repeatscore=="number")n[4].hide=false;if(typeof e.score=="number")n[5].hide=false;if(e.rating)n[6].hide=false}}if(!e.nosample){s.append("td")}s.append("td");s.append("td");s.append("td").html("Genomic<br>position");s.append("td").html("Genomic<br>dist.");for(const e of n){if(e.hide)return;s.append("td").html(e.label)}for(const s of e.samplelst){let o=t.append("tr");if(!e.nosample){const e=o.append("td").text(s.sample);if(s.pairlst.length>1){e.attr("rowspan",s.pairlst.length)}}for(let e=0;e<s.pairlst.length;e++){if(e>0){o=t.append("tr")}const a=s.pairlst[e];o.append("td").style("text-align","right").html('<span style="background-color:'+m+';padding:2px 3px;font-size:80%">'+a.a.name+"</span>"+'<span style="background-color:'+b+';padding:2px 3px;font-size:80%">'+a.b.name+"</span>");const i=o.append("td");if(a.originalprod&&a.originalprod.hook.lessFrame){a.originalprod.hook.lessFrame=i}if(a.inframe){i.html('<span style="background-color:'+u+';color:white;padding:2px 3px;font-size:80%;white-space:nowrap">In frame</span>')}else{if(a.a.gm||a.b.gm){i.html('<span style="background-color:#858585;color:white;padding:2px 3px;font-size:80%;white-space:nowrap">Out of frame</span>')}else{i.html('<span style="border:solid 1px #858585;color:#858585;padding:1px 2px;font-size:80%;white-space:nowrap">no gene ?</span>')}}o.append("td").html('<div style="background-color:'+m+';padding:1px 3px;font-size:70%;white-space:nowrap">'+a.a.chr+":"+a.a.position+" "+a.a.strand+"</div>"+'<div style="background-color:'+b+';padding:1px 3px;font-size:70%;white-space:nowrap">'+a.b.chr+":"+a.b.position+" "+a.b.strand+"</div>");o.append("td").html(a.a.chr==a.b.chr?B(Math.abs(a.a.position-a.b.position)):'<span style="color:'+k+'">CTX</span>');for(const e of n){if(e.hide)continue;const t=o.append("td");if(e.israting&&a.originalprod&&a.originalprod.hook.lessRating){a.originalprod.hook.lessRating=t}if(e.atpair){t.text(e.get(a))}else{t.html('<span style="background-color:'+m+';padding:2px 3px;font-size:80%">'+e.get(a.a)+"</span>"+'<span style="background-color:'+b+';padding:2px 3px;font-size:80%">'+e.get(a.b)+"</span>")}}}}}function q(e,t){const s={};const n=e.expression;n.genes=s;const o=new FileReader;const a=4096;let i=[];let r=0;o.onloadend=e=>{if(e.target.readyState!=FileReader.DONE)return;const s=e.target.result;i.push(s);const l=r>=t.size;u(l);if(l){g()}else{r+=a;n.presays.text("Reading file: "+Math.ceil(r/t.size*100)+"%");o.readAsText(t.slice(r,r+a))}};o.readAsText(t.slice(0,a));const l={},p={};let c=0,d=0;function u(e){const t=i.join("").split("\n");for(let n=0;n<t.length-1-(e?0:1);n++){const e=t[n].split("\t");if(e.length==3){const t=Number.parseFloat(e[1]);if(Number.isNaN(t)){d++}else{c++;l[e[0]]=1;p[e[2]]=1;if(!(e[0]in s)){s[e[0]]=[]}s[e[0]].push({sample:e[2],value:t})}}else{d++}}if(!e){i=[t[t.length-1]]}}function g(){let t=0;for(const e in l)t++;let s=0;for(const e in p)s++;h(n.prediv);f(n.afterdiv);n.afterdiv.selectAll("*").remove();n.afterdiv.append("div").text("Expression data loaded for "+t+" genes, "+s+" samples, "+c+" data points"+(d>0?", "+d+" bad lines":""));n.afterdiv.append("button").text("Delete").style("margin","20px").on("click",(()=>{delete n.genes;n.prediv.node().removeChild(n.input.node());n.input=n.prediv.append("input").attr("type","file").on("change",(t=>{q(e,t.target.files[0])}));n.presays.text("");h(n.afterdiv);f(n.prediv)}))}}function S(e){const t="red";e.data.sort(((e,t)=>t.value-e.value));let s=e.width?e.width:400,n=e.height?e.height:400;let o=0;for(const t of e.data){o=Math.max(o,t.value)}let a;const i=w().domain([0,o]);const r=e.holder.append("svg");const l=r.append("g");const p=r.append("g");const c=p.selectAll().data(e.data).enter().append("g");const d=c.append("circle").attr("fill","white").attr("fill-opacity",0).attr("stroke",(e=>e.ishighlight?t:"black")).attr("stroke-opacity",(e=>e.ishighlight?.7:.2)).on("mouseover",((e,s)=>{e.target.setAttribute("transform","scale(1.5)");f.text((s.sample?s.sample:s.patient+" "+s.sampletype)+" "+s.value).attr("fill",s.ishighlight?t:"black")})).on("mouseout",((e,t)=>{e.target.setAttribute("transform","scale(1)");f.text("drag to resize").attr("fill","black")}));const f=r.append("text").text("drag to resize").attr("font-size",12).attr("class","sja_svgtext").attr("font-family",v).attr("text-anchor","end").on("mousedown",(e=>{e.preventDefault();const t=e.clientX,o=e.clientY,a=s,i=n;const r=y(document.body);r.on("mousemove",(()=>{s=a+e.clientX-t;n=i+e.clientY-o;h()})).on("mouseup",(()=>{r.on("mousemove",null).on("mouseup",null)}))}));function h(){a=Math.max(5,Math.min(s,n)/40);const t=Math.min(18,Math.max(12,a*2)),o=5,h=t+o+5,u=a+5,g=a*3;i.range([0,s]);r.attr("width",a*2+s+g).attr("height",h+u+n+a*2);N({axis:l.attr("transform","translate("+a*2+","+h+")").call(_().scale(i).ticks(Math.min(10,Math.ceil(s/50)))),fontsize:t,color:"black",showline:true});p.attr("transform","translate("+a*2+","+(h+u)+")");c.attr("transform",((t,s)=>"translate("+i(t.value)+","+n*s/e.data.length+")"));d.attr("r",(e=>a*(e.ishighlight?1.5:1)));f.attr("font-size",t).attr("x",a*2+s+g-5).attr("y",h+u+n+a*2-5)}h();return this}function Q(e,t,s,n,o,a){if(!e.dataname){e.dataname="Unnamed dataset"}if(e.input){const[i,r,l]=D(e.input,s);if(i){t("Fusion Editor input error: "+i);return}O(s,r,l,e.dataname,n,o,a);return}if(!e.urls){t('neither .input:"" or .urls:[] is provided for Fusion Editor');return}if(!Array.isArray(e.urls)){t("fusioneditor.urls[] should be an array of URL strings");return}if(e.urls.length==0){t("fusioneditor.urls[] is empty");return}const i=n.append("div").style("margin","20px").style("color","#aaa").style("font-size","1.5em").text("Loading fusion gene data ...");const r=[];e.urls.forEach((e=>{r.push(fetch(new Request(o+"/urltextfile",{method:"POST",body:JSON.stringify({url:e,jwt:a})})).then((e=>e.json())).then((t=>{if(t.error)throw{message:"Error with "+e+": "+t.error};return{data:t.text,url:e}})))}));Promise.all(r).then((r=>{i.remove();if(r.length==0){t("No data retrieved from fusioneditor.urls");return}const[l,p,c]=D(r[0].data,s);if(l){t("Error parsing fusion gene data in file "+r[0].url);return}for(let e=1;e<r.length;e++){const[n,o,a]=D(r[e].data,s);if(n){t("Error parsing fusion gene data in file "+r[e].url);return}for(const e of a){c.push(e)}for(const e of o){let t=true;for(const s of p){if(s.key==e.key){t=false;break}}if(t){p.push(e)}}}if(c.length==0){t("No fusion genes parsed from fusioneditor");return}O(s,p,c,e.dataname,n,o,a)})).catch((e=>{i.remove();t(e.message);if(e.stack)console.log(e.stack)}))}function H(e,t,s,n){const[o,a,i,r,l,p]=e;a.append("div").style("margin-top","20px").html("<p>Please upload CICERO output as a text file. "+"See <a href=https://docs.google.com/document/d/1jkVYRPIJpkWvA9vqtahRlNn63Hk5DehjHbF_BH9k7Rs/edit?usp=sharing target=_blank>file format</a>.</p>"+"<p>See <a href=https://docs.google.com/document/d/1DRVzE_WenG490eRYB7VGFOygtSqtF5L97rhK0HOUCNY/edit?usp=sharing target=_blank>function usage</a>.</p>");a.append("p").html("<a href=https://proteinpaint.stjude.org/ppdemo/hg19/fusion/cicero.output target=_blank>Example file</a>");function c(e,t){l.style("color",t?"red":"black").text(e)}const d=()=>{r.selectAll("*").remove();const e=r.append("input").attr("type","file").on("change",(e=>{const o=e.target.files[0];if(!o){d();return}if(!o.size){c("Invalid file "+o.name);d();return}const l=new FileReader;l.onload=e=>{const l=i.options[i.selectedIndex].innerHTML;const f=t[l];const[h,u,g]=D(e.target.result,f);if(h){c(h,1);d();return}O(f,u,g,o.name,p,s,n);r.remove();a.remove()};l.onerror=function(){c("Error reading file "+o.name,1);d();return};l.readAsText(o,"utf8")}));setTimeout((()=>e.node().focus()),1100)};d()}function O(e,t,s,n,o,a,i){new F(e,t,s,n,o,a,i)}function D(e,t){const s=e.trim().split("\n");const[n,o]=P(s[0]);if(n){return["File header error: "+n]}const a=s[0].split("\t")[0];const i=[];const r=[];for(let e=1;e<s.length;e++){const n=s[e];if(n=="")continue;if(n[0]=="#")continue;const l=n.trim().split("\t");if(l[0]==a)continue;const p={notes:[]};for(let e=0;e<o.length;e++){if(l[e]!==undefined&&l[e].includes('"'))return['Input file has invalid character " e.g. "NM_001007565"'];p[o[e].key]=l[e]}if(!p.rating){r.push([e,"rating unspecified",l]);continue}let c=p.rating;if(c.toLowerCase()=="major"){p.rating="HQ";c="HQ"}if(c!="HQ"&&c!="LQ"&&c!="RT"&&c!="bad"){r.push([e,"invalid rating: "+p.rating,l]);continue}if(!p.chrA){r.push([e,"missing chrA",l]);continue}if(!t.chrlookup[p.chrA.toUpperCase()]){r.push([e,"invalid chrA: "+p.chrA,l]);continue}if(!p.chrB){r.push([e,"missing chrB",l]);continue}if(!t.chrlookup[p.chrB.toUpperCase()]){r.push([e,"invalid chrB: "+p.chrB,l]);continue}c=p.posA;if(!c){r.push([e,"missing posA",l]);continue}let d=Number.parseInt(c);if(Number.isNaN(d)){r.push([e,"invalid posA: "+c,l]);continue}if(d<0||d>=t.chrlookup[p.chrA.toUpperCase()]){r.push([e,"invalid posA: "+c,l]);continue}p.posA=d;c=p.posB;if(!c){r.push([e,"missing posB",l]);continue}d=Number.parseInt(c);if(isNaN(d)){r.push([e,"invalid posB: "+c,l]);continue}if(d<0||d>=t.chrlookup[p.chrB.toUpperCase()]){r.push([e,"invalid posB: "+c,l]);continue}p.posB=d;if(!p.ratioA){r.push([e,"missing ratioA",l]);continue}d=Number.parseFloat(p.ratioA);if(Number.isNaN(d)){r.push([e,"invalid value for ratioA",l]);continue}if(d>1){r.push([e,"ratioA > 100%",l]);d=1}p.ratioA=d;if(!p.ratioB){r.push([e,"missing ratioB",l]);continue}d=Number.parseFloat(p.ratioB);if(Number.isNaN(d)){r.push([e,"invalid value for ratioB",l]);continue}if(d>1){r.push([e,"ratioB > 100%",l]);d=1}p.ratioB=d;if(!p.score){r.push([e,"missing score",l]);continue}d=Number.parseFloat(p.score);if(Number.isNaN(d)){r.push([e,"invalid value for score",l]);continue}p.score=d;if(!p.readsA){r.push([e,"readsA missing",l]);continue}d=Number.parseInt(p.readsA);if(Number.isNaN(d)){r.push([e,"invalid value for readsA",l]);continue}p.readsA=d;if(!p.readsB){r.push([e,"readsB missing",l]);continue}d=Number.parseInt(p.readsB);if(Number.isNaN(d)){r.push([e,"invalid value for readsB",l]);continue}p.readsB=d;if(!p.matchA){r.push([e,"matchA missing",l]);continue}d=Number.parseInt(p.matchA);if(Number.isNaN(d)){r.push([e,"invalid value for matchA",l]);continue}p.matchA=d;if(!p.matchB){r.push([e,"matchB missing",l]);continue}d=Number.parseInt(p.matchB);if(Number.isNaN(d)){r.push([e,"invalid value for matchB",l]);continue}p.matchB=d;if(!p.repeatA){r.push([e,"repeatA missing",l]);continue}d=Number.parseFloat(p.repeatA);if(Number.isNaN(d)){r.push([e,"invalid value for repeatA",l]);continue}p.repeatA=d;if(!p.repeatB){r.push([e,"repeatB missing",l]);continue}d=Number.parseFloat(p.repeatB);if(Number.isNaN(d)){r.push([e,"invalid value for repeatB",l]);continue}p.repeatB=d;if(p.type2){switch(p.type2.toLowerCase()){case"closs":p.iscloss=true;break;case"nloss":p.isnloss=true;break;case"fusion":p.isfusion=true;break;case"itd":p.isitd=true;break;case"other":p.isother=true;break;case"uptss":p.isuptss=true;break;default:r.push([e,"unknown type2: "+p.type2,l]);continue}}if(p.geneA==""||p.geneA=="NA"){p.geneA=null}if(p.geneB==""||p.geneB=="NA"){p.geneB=null}if(p.featureA=="intergenic")p.geneA=null;if(p.featureB=="intergenic")p.geneB=null;const f=p.lstisoforma?p.lstisoforma.toUpperCase().split(","):[],h=p.lstisoformb?p.lstisoformb.toUpperCase().split(","):[],u=p.lstisoformacodon?p.lstisoformacodon.split(","):[],g=p.lstisoformbcodon?p.lstisoformbcodon.split(","):[],m=p.lstframe?p.lstframe.split(","):[];let b=null,x=null,y=null,v=null,k=null,A=null,B=null,w=null;if(p.lstisoformaexon)b=p.lstisoformaexon.split(",");if(p.lstisoformbexon)x=p.lstisoformbexon.split(",");if(p.lstisoformaanchor)y=p.lstisoformaanchor.split(",");if(p.lstisoformbanchor)v=p.lstisoformbanchor.split(",");if(p.lstcontigaaA)k=p.lstcontigaaA.split(",");if(p.lstcontigaaB)A=p.lstcontigaaB.split(",");if(p.lstcontigbpA)B=p.lstcontigbpA.split(",");if(p.lstcontigbpB)w=p.lstcontigbpB.split(",");const N=Math.max(f.length,h.length,u.length,g.length,m.length);p.pairs=[];for(let e=0;e<N;e++){const t={a:{isoform:f[e]&&f[e].length>0?f[e]:null,exon:b?Number.parseInt(b[e]):NaN,codon:u[e]?Number.parseInt(u[e]):NaN,anchor:y?y[e]:undefined},b:{isoform:h[e]&&h[e].length>0?h[e]:null,exon:x?Number.parseInt(x[e]):NaN,codon:g[e]?Number.parseInt(g[e]):NaN,anchor:v?v[e]:undefined},frame:m[e],inframe:m[e]=="1"||m[e]=="2"};if(p.isuptss){t.inframe=true}let s=NaN,n=NaN,o=NaN,a=NaN;if(k&&k[e])s=Number.parseInt(k[e]);if(A&&A[e])n=Number.parseInt(A[e]);if(B&&B[e])o=Number.parseInt(B[e]);if(w&&w[e])a=Number.parseInt(w[e]);if(!Number.isNaN(s)&&!Number.isNaN(n)){t.a.contigaa=s;t.b.contigaa=n}if(!Number.isNaN(o)&&!Number.isNaN(a)){t.a.contigbp=o;t.b.contigbp=a}p.pairs.push(t)}if(p.exception){p.notes.push(p.exception)}if(p.hlgene){const t=Number.parseInt(p.hlgene);if(Number.isNaN(t)||t!=0&&t!=1&&t!=2&&t!=3&&t!=4){r.push([e,"invalid value for highlight gene flag: "+p.hlgene,l]);delete p.hlgene}else{p.hlgene=t}}i.push(p)}if(r.length>0){const e=o.map((e=>e.key));z(e,r)}if(i.length==0){return["No data loaded"]}return[null,o,i]}function P(e){const t=e.trim().split("\t");if(t.length<=1)return["invalid file header"];const s=[];const n=[];for(const e of t){n.push(e.toLowerCase());s.push({label:e,key:e.toLowerCase(),custom:true})}const o=(...e)=>{for(const t of e){const e=n.indexOf(t);if(e!=-1)return e}return-1};let a=o("genea");if(a==-1)return["geneA missing"];s[a].key="geneA";delete s[a].custom;a=o("chra");if(a==-1)return["chrA missing"];s[a].key="chrA";delete s[a].custom;a=o("posa");if(a==-1)return["posA missing"];s[a].key="posA";delete s[a].custom;a=o("orta");if(a==-1)return["ortA missing"];s[a].key="ortA";delete s[a].custom;a=o("featurea");if(a==-1)return["featureA missing"];s[a].key="featureA";delete s[a].custom;a=o("ratioa");if(a==-1)return["ratioA missing"];s[a].key="ratioA";delete s[a].custom;a=o("readsa");if(a==-1)return["readsA missing"];s[a].key="readsA";delete s[a].custom;a=o("sv_refseqa_aa_index");if(a!=-1){s[a].key="lstcontigaaA";delete s[a].custom}a=o("sv_refseqa_contig_index");if(a!=-1){s[a].key="lstcontigbpA";delete s[a].custom}a=o("total_readsa");if(a!=-1){s[a].key="totalreadsA";delete s[a].custom}a=o("geneb");if(a==-1)return["geneB missing"];s[a].key="geneB";delete s[a].custom;a=o("chrb");if(a==-1)return["chrB missing"];s[a].key="chrB";delete s[a].custom;a=o("posb");if(a==-1)return["posB missing"];s[a].key="posB";delete s[a].custom;a=o("ortb");if(a==-1)return["ortB missing"];s[a].key="ortB";delete s[a].custom;a=o("featureb");if(a==-1)return["featureB missing"];s[a].key="featureB";delete s[a].custom;a=o("ratiob");if(a==-1)return["ratioB missing"];s[a].key="ratioB";delete s[a].custom;a=o("readsb");if(a==-1)return["readsB missing"];s[a].key="readsB";delete s[a].custom;a=o("sv_refseqb_aa_index");if(a!=-1){s[a].key="lstcontigaaB";delete s[a].custom}a=o("sv_refseqb_contig_index");if(a!=-1){s[a].key="lstcontigbpB";delete s[a].custom}a=o("total_readsb");if(a!=-1){s[a].key="totalreadsB";delete s[a].custom}a=o("sv_inframe","frame");if(a==-1)return["sv_inframe missing"];s[a].key="lstframe";delete s[a].custom;a=o("sv_refseqa");if(a==-1)return["sv_refseqA missing"];s[a].key="lstisoforma";delete s[a].custom;a=o("sv_refseqa_codon");if(a!=-1){s[a].key="lstisoformacodon"}a=o("sv_refseqb_codon");if(a!=-1){s[a].key="lstisoformbcodon"}a=o("score");if(a==-1)return["score missing"];s[a].key="score";delete s[a].custom;a=o("sv_refseqb");if(a==-1)return["sv_refseqB missing"];s[a].key="lstisoformb";delete s[a].custom;a=o("rating");if(a==-1)return["rating missing"];s[a].key="rating";delete s[a].custom;a=o("matcha");if(a==-1)return["matchA missing"];s[a].key="matchA";delete s[a].custom;a=o("matchb");if(a==-1)return["matchB missing"];s[a].key="matchB";delete s[a].custom;a=o("repeata");if(a==-1)return["repeatA missing"];s[a].key="repeatA";delete s[a].custom;a=o("repeatb");if(a==-1)return["repeatB missing"];s[a].key="repeatB";delete s[a].custom;a=o("functional effect");if(a==-1)return["functional effect missing"];s[a].key="type2";delete s[a].custom;a=o("sample");if(a!=-1){s[a].key="sample";delete s[a].custom}a=o("sv_processing_exception");if(a!=-1){s[a].key="exception"}a=o("medal");if(a!=-1){s[a].key="hlgene"}a=o("sv_refseqa_exon");if(a!=-1){s[a].key="lstisoformaexon";delete s[a].custom}a=o("sv_refseqb_exon");if(a!=-1){s[a].key="lstisoformbexon";delete s[a].custom}a=o("sv_refseqa_anchor_type");if(a!=-1){s[a].key="lstisoformaanchor";delete s[a].custom}a=o("sv_refseqb_anchor_type");if(a!=-1){s[a].key="lstisoformbanchor";delete s[a].custom}return[null,s]}export{O as svmrlaunch,Q as svmrparseinput,D as svmrparseraw,H as svmrui};
|
|
1
|
+
import{aG as e,ar as t,aR as s,aQ as n,ab as o,an as a,bg as i,bh as r,at as l,bi as p,Z as c,M as d,p as f,ac as h,ba as u,b9 as g,bj as m,bk as b,j as x,d as y,ah as v,bl as k,a9 as A,ae as B,I as w,ag as N,bm as z}from"./app-2cd97738.js";import{c as _}from"./axis-747c801e.js";function j(a,i){var r=[];for(const e of a.samples){for(const t of e.egglst){for(const e of t.lst){if(e.ismsg){const t=e.lst.map((e=>e.lst[0]));if(i){let e=false;for(const s of t){if(s.rating=="Major")e=true}if(e){r.push(t)}}else{r.push(t)}}else{for(const t of e.lst){for(const e of t.lst){if(i){if(e.rating=="Major")r.push([e])}else{r.push([e])}}}}}}}const l=[],p=[],c=[],d=[];for(const o of r){if(o.length==1&&o[0].usepair){const i=o[0];if(i.isitd){const s=i.usepair;const n=a.genome.isoformmatch(s.a.isoform,i.chrA,i.posA);if(!n){p.push(i.sample+" "+i.geneA+" ITD ("+i.rating+"): no gene model found for "+s.a.isoform);continue}const o=e(i.posA,n).rnapos;const r=e(i.posB,n).rnapos;if(o<=r){p.push(i.sample+" "+i.geneA+" ITD ("+i.rating+"): negative duplication length");continue}const c={typecode:t,gene:i.geneA,isoform:s.a.isoform,rating:i.rating,score:i.score,functioneffect:i.functioneffect,rnaposition:r,rnaduplength:o-r+1,a:{chr:i.chrA,position:i.posA,strand:i.ortA,ratio:i.ratioA,chimericreads:i.readsA,totalreads:i.totalreadsA,match:i.matchA,repeat:i.repeatA},b:{chr:i.chrB,position:i.posB,strand:i.ortB,ratio:i.ratioB,chimericreads:i.readsB,totalreads:i.totalreadsB,match:i.matchB,repeat:i.repeatB}};let d=0,f=0;if(s.a.contigaa&&s.b.contigaa){d=s.b.contigaa-s.a.contigaa-1}if(s.a.contigbp&&s.b.contigbp){f=s.b.contigbp-s.a.contigbp-1}if(d>0){c.interstitial={aalen:d}}if(f>0){if(!c.interstitial)c.interstitial={};c.interstitial.bplen=f}l.push([i.sample,i.geneA,i.usepair.a.isoform,JSON.stringify(c)]);continue}if(i.isnloss){const t=i.usepair.b;if(!t.isoform){c.push(i.sample+" "+i.geneB+" NLoss ("+i.rating+"): no isoform");continue}const n=a.genome.isoformmatch(t.isoform,i.chrB,i.posB);if(!n){c.push(i.sample+" "+i.geneB+" NLoss ("+i.rating+"): no gene model found for "+t.isoform);continue}const o=e(i.posB,n).rnapos;const r={typecode:s,gene:i.geneB,isoform:t.isoform,rating:i.rating,score:i.score,functioneffect:i.functioneffect,rnaposition:o,chr:i.chrB,position:i.posB,strand:i.ortB,ratio:i.ratioB,chimericreads:i.readsB,match:i.matchB,repeat:i.repeatB,partner:{chr:i.chrA,position:i.posA,strand:i.ortA,ratio:i.ratioA,chimericreads:i.readsA,match:i.matchA,repeat:i.repeatA}};if(i.geneA){r.partner.gene=i.geneA}if(i.usepair.a.isoform){r.partner.isoform=i.usepair.a.isoform}l.push([i.sample,i.geneB,t.isoform,JSON.stringify(r)]);continue}if(i.iscloss){const t=i.usepair.a;if(!t.isoform){c.push(i.sample+" "+i.geneA+" CLoss ("+i.rating+"): no isoform");continue}const s=a.genome.isoformmatch(t.isoform,i.chrA,i.posA);if(!s){c.push(i.sample+" "+i.geneA+" CLoss ("+i.rating+"): no gene model found by "+t.isoform);continue}const o=e(i.posA,s).rnapos;const r={typecode:n,gene:i.geneA,isoform:t.isoform,rating:i.rating,score:i.score,functioneffect:i.functioneffect,rnaposition:o,chr:i.chrA,position:i.posA,strand:i.ortA,ratio:i.ratioA,chimericreads:i.readsA,match:i.matchA,repeat:i.repeatA,partner:{chr:i.chrB,position:i.posB,strand:i.ortB,ratio:i.ratioB,chimericreads:i.readsB,match:i.matchB,repeat:i.repeatB}};if(i.geneB){r.partner.gene=i.geneB}if(i.usepair.b.isoform){r.partner.isoform=i.usepair.b.isoform}l.push([i.sample,i.geneA,t.isoform,JSON.stringify(r)]);continue}}const i=new Set,r=new Set,d=[];for(const e of o){if(e.geneA)i.add(e.geneA);if(e.geneB)i.add(e.geneB);if(e.usepair){if(e.usepair.a.isoform)r.add(e.usepair.a.isoform);if(e.usepair.b.isoform)r.add(e.usepair.b.isoform)}const t={type:e.type,type2:e.type2,rating:e.rating,score:e.score,functioneffect:e.functioneffect,a:{name:e.geneA,chr:e.chrA,position:e.posA,strand:e.ortA,ratio:e.ratioA,feature:e.featureA,chimericreads:e.readsA,contiglen:e.matchA,repeatscore:e.repeatA},b:{name:e.geneB,chr:e.chrB,position:e.posB,strand:e.ortB,ratio:e.ratioB,feature:e.featureB,chimericreads:e.readsB,contiglen:e.matchB,repeatscore:e.repeatB}};if(e.usepair){const s=e.usepair;t.frame=s.frame;if(s.a.isoform){t.a.isoform=s.a.isoform}if(s.b.isoform){t.b.isoform=s.b.isoform}let n=0,o=0;if(s.a.contigaa&&s.b.contigaa){n=s.b.contigaa-s.a.contigaa-1}if(s.a.contigbp&&s.b.contigbp){o=s.b.contigbp-s.a.contigbp-1}if(n>0){t.interstitial={aalen:n}}if(o>0){if(!t.interstitial)t.interstitial={};t.interstitial.bplen=o}}d.push(t)}const f=[...i];const h=[...r];l.push([o[0].sample,f.length?f.join(","):"none",h.length?h.join(","):"none",JSON.stringify(d)])}if(p.length){a.err(p.join("<br>"))}if(c.length){a.err(c.join("<br>"))}if(d.length){a.err(d.join("<br>"))}o("Fusion data from "+a.filename,[{text:l.map((e=>e.join("\t"))).join("\n")}])}function R(o,d){const f=[];for(const e of o.samples){for(const t of e.egglst){for(const e of t.lst){if(e.ismsg){const t=e.lst.map((e=>e.lst[0]));if(d){let e=false;for(const s of t){if(s.rating=="Major")e=true}if(e){f.push(t)}}else{f.push(t)}}else{for(const t of e.lst){for(const e of t.lst){if(d){if(e.rating=="Major")f.push([e])}else{f.push([e])}}}}}}}const h={},u=[],g=[],m=[];for(const c of f){if(c.length==1&&c[0].usepair){const l=c[0];if(l.isitd){if(!l.geneA){u.push(l.sample+" ITD ("+l.rating+"): no gene name??");continue}const s=l.usepair;const n=o.genome.isoformmatch(s.a.isoform,l.chrA,l.posA);if(!n){u.push(l.sample+" "+l.geneA+" ITD ("+l.rating+"): no gene model found for "+s.a.isoform);continue}const i=e(l.posA,n).rnapos;const r=e(l.posB,n).rnapos;if(i<=r){u.push(l.sample+" "+l.geneA+" ITD ("+l.rating+"): negative duplication length");continue}const p={dt:t,class:a,mname:"ITD",gene:l.geneA,sample:l.sample,isoform:s.a.isoform,rating:l.rating,score:l.score,functioneffect:l.functioneffect,rnaposition:r,rnaduplength:i-r+1,a:{chr:l.chrA,position:l.posA,strand:l.ortA,ratio:l.ratioA,chimericreads:l.readsA,totalreads:l.totalreadsA,match:l.matchA,repeat:l.repeatA},b:{chr:l.chrB,position:l.posB,strand:l.ortB,ratio:l.ratioB,chimericreads:l.readsB,totalreads:l.totalreadsB,match:l.matchB,repeat:l.repeatB}};let c=0,d=0;if(s.a.contigaa&&s.b.contigaa){c=s.b.contigaa-s.a.contigaa-1}if(s.a.contigbp&&s.b.contigbp){d=s.b.contigbp-s.a.contigbp-1}if(c>0){p.interstitial={aalen:c}}if(d>0){if(!p.interstitial)p.interstitial={};p.interstitial.bplen=d}if(!(l.geneA in h)){h[l.geneA]=[]}h[l.geneA].push(p);continue}if(l.isnloss){if(!l.geneB){g.push(l.sample+" NLoss ("+l.rating+"): no geneB");continue}const t=l.usepair.b;if(!t.isoform){g.push(l.sample+" "+l.geneB+" NLoss ("+l.rating+"): no isoform");continue}const n=o.genome.isoformmatch(t.isoform,l.chrB,l.posB);if(!n){g.push(l.sample+" "+l.geneB+" NLoss ("+l.rating+"): no gene model found for "+t.isoform);continue}const a=e(l.posB,n).rnapos;const r={dt:s,class:i,mname:"N-loss",gene:l.geneB,sample:l.sample,isoform:t.isoform,rating:l.rating,score:l.score,functioneffect:l.functioneffect,rnaposition:a,chr:l.chrB,position:l.posB,strand:l.ortB,ratio:l.ratioB,chimericreads:l.readsB,match:l.matchB,repeat:l.repeatB,partner:{chr:l.chrA,position:l.posA,strand:l.ortA,ratio:l.ratioA,chimericreads:l.readsA,match:l.matchA,repeat:l.repeatA}};if(l.geneA){r.partner.gene=l.geneA}if(l.usepair.a.isoform){r.partner.isoform=l.usepair.a.isoform}if(!(l.geneB in h)){h[l.geneB]=[]}h[l.geneB].push(r);continue}if(l.iscloss){if(!l.geneA){m.push(l.sample+" CLoss ("+l.rating+"): no geneA");continue}const t=l.usepair.a;if(!t.isoform){m.push(l.sample+" "+l.geneA+" CLoss ("+l.rating+"): no isoform");continue}const s=o.genome.isoformmatch(t.isoform,l.chrA,l.posA);if(!s){m.push(l.sample+" "+l.geneA+" CLoss ("+l.rating+"): no gene model found by "+t.isoform);continue}const a=e(l.posA,s).rnapos;const i={dt:n,class:r,mname:"C-loss",gene:l.geneA,sample:l.sample,isoform:t.isoform,rating:l.rating,score:l.score,functioneffect:l.functioneffect,rnaposition:a,chr:l.chrA,position:l.posA,strand:l.ortA,ratio:l.ratioA,chimericreads:l.readsA,match:l.matchA,repeat:l.repeatA,partner:{chr:l.chrB,position:l.posB,strand:l.ortB,ratio:l.ratioB,chimericreads:l.readsB,match:l.matchB,repeat:l.repeatB}};if(l.geneB){i.partner.gene=l.geneB}if(l.usepair.b.isoform){i.partner.isoform=l.usepair.b.isoform}if(!(l.geneA in h)){h[l.geneA]=[]}h[l.geneA].push(i);continue}}const d=new Map;const f=[];for(const e of c){if(e.geneA){if(!d.has(e.geneA))d.set(e.geneA,new Set);if(e.usepair){if(e.usepair.a.isoform)d.get(e.geneA).add(e.usepair.a.isoform)}}if(e.geneB){if(!d.has(e.geneB))d.set(e.geneB,new Set);if(e.usepair){if(e.usepair.b.isoform)d.get(e.geneB).add(e.usepair.b.isoform)}}const t={type:e.type,type2:e.type2,rating:e.rating,score:e.score,functioneffect:e.functioneffect,a:{name:e.geneA,chr:e.chrA,position:e.posA,strand:e.ortA,ratio:e.ratioA,feature:e.featureA,chimericreads:e.readsA,contiglen:e.matchA,repeatscore:e.repeatA},b:{name:e.geneB,chr:e.chrB,position:e.posB,strand:e.ortB,ratio:e.ratioB,feature:e.featureB,chimericreads:e.readsB,contiglen:e.matchB,repeatscore:e.repeatB}};if(e.usepair){const s=e.usepair;t.frame=s.frame;if(s.a.isoform){t.a.isoform=s.a.isoform}if(s.b.isoform){t.b.isoform=s.b.isoform}let n=0,o=0;if(s.a.contigaa&&s.b.contigaa){n=s.b.contigaa-s.a.contigaa-1}if(s.a.contigbp&&s.b.contigbp){o=s.b.contigbp-s.a.contigbp-1}if(n>0){t.interstitial={aalen:n}}if(o>0){if(!t.interstitial)t.interstitial={};t.interstitial.bplen=o}}f.push(t)}for(const[e,t]of d){for(const s of t){if(!(e in h)){h[e]=[]}const t={dt:l,class:p,sample:c[0].sample,isoform:s,pairlst:C(f)};for(const e of f){if(e.functioneffect){t.functioneffect=e.functioneffect}}h[e].push(t)}}}if(u.length){o.err(u.join("<br>"))}if(g.length){o.err(g.join("<br>"))}if(m.length){o.err(m.join("<br>"))}let b=0,x={};for(const e in h){b++;x[e.toUpperCase()]=h[e]}if(b==0){alert("No data can be added.");return}let y=null;for(const e in o.genome.datasets){if(o.genome.datasets[e].svmrid==o.id){y=o.genome.datasets[e];break}}if(y){y.bulkdata=x}else{y={label:o.filename,svmrid:o.id,bulkdata:x};o.genome.datasets[o.filename]=y}if(o.cohort){o.cohortpane.pane.remove()}else{o.cohort={name:o.filename,genome:o.genome,show_genetable:1,jwt:o.jwt,dsset:{}};o.cohort.dsset[o.filename]=y}const v=c({x:200,y:200});import("./tp.ui-7b24f0ef.js").then((function(e){return e.t})).then((e=>{e.default(o.cohort,v.body,o.hostURL);o.cohortpane=v}))}function I(e,t){const s=[];const n=e.atlst.map((e=>e.label));n.push("transcript_nbr");n.push("breakpoint_nbr");n.push("functionalClass");for(const n of e.samples){const o=[];for(const e of n.egglst){for(const s of e.lst){if(s.ismsg){const e=s.lst.map((e=>e.lst[0]));if(t){let t=false;for(const s of e){if(s.rating=="Major")t=true}if(t){o.push(e)}}else{o.push(e)}}else{for(const e of s.lst){for(const s of e.lst){if(t){if(s.rating=="Major")o.push([s])}else{o.push([s])}}}}}}for(let t=0;t<o.length;t++){for(let n=0;n<o[t].length;n++){let a=o[t][n];const i=[],r=[],l=[],p=[],c=[],d=[],f=[],h=[],u=[],g=[],m=[],b=[],x=[];for(const e of a.pairs){i.push(e.frame);r.push(e.a.isoform);h.push(e.b.isoform);let t=e.a.codon;l.push(Number.isNaN(t)?"":t);t=e.b.codon;u.push(Number.isNaN(t)?"":t);t=e.a.exon;p.push(Number.isNaN(t)?"":t);t=e.b.exon;g.push(Number.isNaN(t)?"":t);c.push(e.a.anchor?e.a.anchor:"");m.push(e.b.anchor?e.b.anchor:"");t=e.a.contigaa;d.push(t==undefined?"":t);t=e.b.contigaa;b.push(t==undefined?"":t);t=e.a.contigbp;f.push(t==undefined?"":t);t=e.b.contigbp;x.push(t==undefined?"":t)}const y=[];for(const t of e.atlst){switch(t.key){case"lstframe":y.push(i.join(","));break;case"lstisoforma":y.push(r.join(","));break;case"lstisoformacodon":y.push(l.join(","));break;case"lstisoformaexon":y.push(p.join(","));break;case"lstisoformaanchor":y.push(c.join(","));break;case"lstcontigaaA":y.push(d.join(","));break;case"lstcontigbpA":y.push(f.join(","));break;case"lstisoformb":y.push(h.join(","));break;case"lstisoformbcodon":y.push(u.join(","));break;case"lstisoformbexon":y.push(g.join(","));break;case"lstisoformbanchor":y.push(m.join(","));break;case"lstcontigaaB":y.push(b.join(","));break;case"lstcontigbpB":y.push(x.join(","));break;default:y.push(a[t.key])}}y.push(t+1);y.push(n+1);y.push(a.functioneffect?a.functioneffect:"");s.push(y)}}}o("Fusion data from "+e.filename,[{text:n.join("\t")+"\n"+s.join("\n")}])}function C(e){const t=[];for(const s of e){const e={};for(const t in s)e[t]=s[t];e.a={};for(const t in s.a)e.a[t]=s.a[t];e.b={};for(const t in s.b)e.b[t]=s.b[t];if(s.interstitial){e.interstitial={};for(const t in s.interstitial)e.interstitial[t]=s.interstitial[t]}t.push(e)}return t}const T=1e4;const L="#A702C4";const M=new d;class F{constructor(e,t,s,n,o,a,i){window.svmr=this;this.hostURL=a;this.jwt=i;this.id=Math.random();this.items=s;this.genome=e;this.filename=n;this.atlst=t;this.cf_repeat=.7,this.cf_reads=2;this.cf_match=40;this.cf_ratio=.01;this.expression={};this.samples=[];this.genelst=[];this.elab2sample={};if(!o){const e=c({x:100,y:100,toshrink:true});e.header.append("span").style("color","#858585").style("font-size",".7em").html("Fusion Editor ");e.header.append("span").text(n);o=e.body}this.holder=o;this.errdiv=o.append("div").style("width","500px").style("margin","10px");const r=o.append("div").style("margin","20px").style("padding","0px");this.buttgene=r.append("button").text("Loading genes").on("click",(()=>{if(l.style("display")=="none"){f(l)}else{h(l)}}));this.buttsample=r.append("button").text("Loading samples").on("click",(()=>{if(this.ul.style("display")=="none"){f(this.ul)}else{h(this.ul)}}));r.append("button").text("Gene expression").on("click",(()=>{if(this.expression.div.style("display")=="none"){f(this.expression.div)}else{h(this.expression.div)}}));r.append("button").text("Parameter cutoff").on("click",(()=>{if(x.style("display")=="none"){f(x)}else{h(x)}}));r.append("button").text("Legend").on("click",(()=>{if(y.style("display")=="none"){f(y)}else{h(y)}}));r.append("button").style("margin-right","20px").text("Export data").on("click",(e=>{let t=0,s=0,n=0,o=0,a=0,i=0,r=0,l=0;for(const e of this.samples){for(const p of e.egglst){for(const e of p.lst){if(e.ismsg){let t=false;for(const s of e.lst){if(s.rating=="Major")t=true}if(t)s++;else o++}else{for(const s of e.lst){for(const e of s.lst){if(e.rating=="Major"){if(e.isitd)a++;else if(e.iscloss||e.isnloss)r++;else t++}else{if(e.isitd)i++;else if(e.iscloss||e.isnloss)l++;else n++}}}}}}}const p=M.clear().showunder(e.target).d.append("div");const c=p.append("table").style("border-spacing","10px").style("border-collapse","separate");let d=c.append("tr").style("color","#858585");d.append("td");d.append("td").text("2-gene fusion");d.append("td").text("Multi-gene fusion");d.append("td").text("ITD");d.append("td").text("Truncation");d=c.append("tr");d.append("td").text("Major").style("color","#858585").style("text-align","right");d.append("td").text(t);d.append("td").text(s);d.append("td").text(a);d.append("td").text(r);d=c.append("tr");d.append("td").text("not Major").style("color","#858585").style("text-align","right");d.append("td").text(n);d.append("td").text(o);d.append("td").text(i);d.append("td").text(l);let f=p.append("div").style("margin","10px").text('Export fusions labeled as "Major"');f.append("button").style("margin","10px").text("Tabular format").on("click",(()=>I(this,true)));f.append("button").style("margin","10px").text("JSON format").on("click",(()=>j(this,true)));f.append("button").style("margin","10px").text("View in ProteinPaint").on("click",(()=>R(this,true)));f=p.append("div").style("margin","10px").text("Export all fusions");f.append("button").style("margin","10px").text("Tabular format").on("click",(()=>I(this,false)));f.append("button").style("margin","10px").text("JSON format").on("click",(()=>j(this,false)));f.append("button").style("margin","10px").text("View in ProteinPaint").on("click",(()=>R(this,false)))}));r.append("a").attr("target","_blank").attr("href","https://docs.google.com/document/d/1DRVzE_WenG490eRYB7VGFOygtSqtF5L97rhK0HOUCNY/edit?usp=sharing").text("Help");this.expression.div=o.append("div").style("display","none").style("margin","20px").style("padding","20px").style("border","dashed 1px #bbb");this.expression.prediv=this.expression.div.append("div");this.expression.prediv.append("div").style("margin","5px").text("Load a file that includes gene expression data for current samples.");this.expression.prediv.append("div").style("margin","5px 5px 10px 5px").style("font-size","80%").text("The first 3 columns of the file should be: 1) gene name, 2) expression value, 3) sample name");this.expression.input=this.expression.prediv.append("input").attr("type","file").on("change",(e=>{q(this,e.target.files[0])}));this.expression.presays=this.expression.prediv.append("span").style("padding-left","20px");this.expression.afterdiv=this.expression.div.append("div").style("display","none");const l=o.append("div").style("display","none").style("margin","20px");let p=l.append("div").style("display","inline-block").style("border","dashed 1px #bbb");this.genefilter=p.append("div").style("background-color","#ededed").style("padding","10px 20px");let d=p.append("div").style("padding","10px 20px").style("overflow-y","scroll").style("resize","vertical").style("height","300px");d.append("div").style("margin","10px").style("font-size","70%").text("Not included: read-through and intergenic events (including one or both sides).");this.genetable=d.append("table");const x=o.append("div").style("display","none").style("margin","20px");p=x.append("div").style("display","inline-block").style("padding","20px").style("border","solid 1px #ededed");p.append("span").style("padding","0px 10px").text("Alert if:");d=p.append("span").style("padding","0px 10px");d.append("span").html("chimeric reads ≤ ");d.append("input").attr("size",3).property("value",this.cf_reads).on("change",(e=>{const t=Number.parseInt(e.target.value);if(Number.isNaN(t)){return}this.cf_reads=t}));d=p.append("span").style("padding","0px 10px");d.append("span").html("repeat score ≥ ");d.append("input").attr("size",3).property("value",this.cf_repeat).on("change",(e=>{const t=Number.parseFloat(e.target.value);if(Number.isNaN(t)){return}this.cf_repeat=t}));d=p.append("span").style("padding","0px 10px");d.append("span").html("contig bp length ≤ ");d.append("input").attr("size",3).property("value",this.cf_match).on("change",(e=>{const t=Number.parseInt(e.target.value);if(Number.isNaN(t)){return}this.cf_match=t}));d=p.append("span").style("padding","0px 10px");d.append("span").html("ratio ≤ ");d.append("input").attr("size",3).property("value",this.cf_ratio).on("change",(e=>{const t=Number.parseFloat(e.target.value);if(Number.isNaN(t)){return}this.cf_ratio=t}));const y=o.append("div").style("display","none").style("margin","20px");y.append("div").style("display","inline-block").style("padding","10px").style("border","solid 1px #ededed").html('<table style="margin:20px">'+'<tr><td><div style="display:inline-block;font-size:80%;color:white;background-color:'+u+';padding:2px 5px">IN</div></td><td>In-frame fusion</td></tr>'+'<tr><td><div style="display:inline-block;font-size:80%;color:white;background-color:'+g+';padding:2px 5px">O</div></td><td>Out-of-frame fusion</td></tr>'+'<tr><td><div style="display:inline-block;font-size:80%;color:black;border:solid 1px black;padding:1px 3px">?</div></td><td>Intergenic fusion, or gene isoform not specified</td></tr>'+"</table>"+'<table style="margin:20px">'+'<tr><td>chr5 <span style="border:solid 1px black;padding:0px 10px;"></span>'+"-"+'<span style="border:solid 1px black;padding:0px 10px;"></span> chr5</td>'+"<td>Intra-chromosomal breakpoints</td></tr>"+'<tr><td><span style="color:red">chr5</span> <span style="border:solid 1px black;padding:0px 10px;"></span>'+"-"+'<span style="border:solid 1px black;padding:0px 10px;"></span> <span style="color:red">chr10</span></td>'+"<td>Inter-chromosomal breakpoints</td></tr>"+"</tr></table>"+'<table style="margin:20px">'+'<tr><td><div style="display:inline-block;border:solid 1px black;padding:2px 10px;font-size:70%">geneA</div>'+"-"+'<div style="display:inline-block;border:solid 1px black;padding:2px 10px;font-size:70%">geneB</div>'+"</td><td>Neither geneA nor geneB is known fusion partner</td>"+"</tr>"+'<tr><td><div style="display:inline-block;border:solid 1px black;padding:2px 10px;font-size:70%;font-weight:bold;">geneA</div>'+"-"+'<div style="display:inline-block;border:solid 1px black;padding:2px 10px;font-size:70%">geneB</div>'+"</td><td>GeneA is a known fusion partner</td>"+"</tr>"+'<tr><td><div style="display:inline-block;border:solid 1px black;padding:2px 10px;font-size:70%;font-weight:bold;">geneA</div>'+"-"+'<div style="display:inline-block;border:solid 1px black;padding:2px 10px;font-size:70%;font-weight:bold;">geneB</div>'+"</td><td>Both genes are known fusion partners, but they do not make a known fusion product.</td>"+"</tr>"+'<tr><td><div style="display:inline-block;border:solid 1px black;padding:2px 10px;font-size:70%;font-weight:bold;color:'+L+'">geneA</div>'+"-"+'<div style="display:inline-block;border:solid 1px black;padding:2px 10px;font-size:70%;font-weight:bold;color:'+L+'">geneB</div>'+"</td><td>A known fusion product</td>"+"</tr>"+"</table>"+'<table style="margin:20px">'+'<tr><td><div style="width:40px;height:16px;position:relative;">'+'<div style="position:absolute;right:0px;top:0px;width:20px;height:16px;background-color:'+m+'"></div>'+'<div style="position:absolute;border:solid 1px black;width:100%;height:15px"></div>'+"</div>"+"</td>"+"<td>ratioA: for geneA, the ratio of chimeric reads over total reads</td></tr>"+'<tr><td><div style="width:40px;height:16px;position:relative;">'+'<div style="position:absolute;left:0px;top:0px;width:20px;height:16px;background-color:'+b+'"></div>'+'<div style="position:absolute;border:solid 1px black;width:100%;height:15px"></div>'+"</div>"+"</td>"+"<td>ratioB: for geneB, the ratio of chimeric reads over total reads</td></tr>"+'<tr><td><div style="width:40px;height:16px;border:solid 1px red;"></div></td><td>Antisense (reported strand is on the opposite of gene strand)</td></tr>'+"</table>");this.ul=o.append("ul");this.step_isoform(s)}err(e){x(this.errdiv,e)}step_isoform(e){const t=new Set;for(const s of e){for(const e of s.pairs){let s=e.a.isoform;if(s&&!this.genome.isoformcache.has(s.toUpperCase())){t.add(s)}s=e.b.isoform;if(s&&!this.genome.isoformcache.has(s.toUpperCase())){t.add(s)}}}if(t.size==0){this.step_eat(e);return}const s=[];for(const e of t){s.push(e)}const n=this.holder.append("div").style("margin","20px").text("Loading "+t.size+" isoforms ...");fetch(new Request(this.hostURL+"/isoformlst",{method:"POST",body:JSON.stringify({genome:this.genome.name,lst:s,jwt:this.jwt})})).then((e=>e.json())).then((s=>{if(s.error)throw{message:"Cannot load isoforms: "+s.error};n.remove();for(const e of s.lst){if(e[0]){this.genome.isoformcache.set(e[0].isoform,e)}}const o=[];for(const e of t){if(!this.genome.isoformcache.has(e.toUpperCase())){o.push(e)}}if(o.length){this.err(o.length+" invalid isoform"+(o.length>1?"s":"")+": "+o.join(", "))}this.step_eat(e)})).catch((e=>{this.err(e.message);if(e.stack)console.log(e.stack)}))}step_eat(t){for(const s of t){s.hook={};let t=null;for(const n of s.pairs){let o=this.genome.isoformmatch(n.a.isoform,s.chrA,s.posA);if(o){s.geneA=o.name;n.a.isdefault=o.isdefault;if(Number.isNaN(n.a.codon)||n.a.codon<0){n.a.codon=undefined;const t=e(s.posA,o);if(t.atupstream){n.a.atupstream=t.atupstream}else if(t.atdownstream){n.a.atdownstream=t.atdownstream}else if(t.atutr3){n.a.atutr3=t.atutr3}else if(t.atutr5){n.a.atutr5=t.atutr5}else{n.a.codon=t.codon}}}o=this.genome.isoformmatch(n.b.isoform,s.chrB,s.posB);if(o){s.geneB=o.name;n.b.isdefault=o.isdefault;if(Number.isNaN(n.b.codon)||n.b.codon<0){n.b.codon=undefined;const t=e(s.posB,o);if(t.atupstream){n.b.atupstream=t.atupstream}else if(t.atdownstream){n.b.atdownstream=t.atdownstream}else if(t.atutr3){n.b.atutr3=t.atutr3}else if(t.atutr5){n.b.atutr5=t.atutr5}else{n.b.codon=t.codon}}}if(n.a.isdefault&&n.b.isdefault){if(!t){t=n}if(n.inframe){t=n}}}if(t){s.usepair=t}else{s.notes.push("No preferred isoform pair");s.usepair=s.pairs[0]}if(s.usepair){s.usepair.inuse=true}s.eventlabel=(s.geneA?s.geneA:s.chrA)+"-"+(s.geneB?s.geneB:s.chrB)}const s={};const n={};let o=false;for(const e of t){let t=e.sample;if(t){if(!(t in s)){s[t]={}}if(!(e.eventlabel in s[t])){s[t][e.eventlabel]=[]}s[t][e.eventlabel].push(e)}else{o=true;if(!(e.eventlabel in n)){n[e.eventlabel]=[]}n[e.eventlabel].push(e)}}for(const e in s){this.samples.push({name:e,events:s[e]})}if(o){this.samples.push({name:"No name",events:n})}this.buttsample.text(this.samples.length+" sample"+(this.samples.length>1?"s":""));for(const e of this.samples){for(const t in e.events){if(!(t in this.elab2sample)){this.elab2sample[t]=[]}this.elab2sample[t].push(e)}}for(const e of this.samples){e.gene2events={};for(const t in e.events){for(const s of e.events[t]){const n=s.geneA;if(n){if(!(n in e.gene2events)){e.gene2events[n]={}}e.gene2events[n][t]=1}const o=s.geneB;if(o){if(!(o in e.gene2events)){e.gene2events[o]={}}e.gene2events[o][t]=1}}}}for(const e of this.samples){const t=[];for(const s in e.events){for(const n of e.events[s]){if(n.rating=="HQ")U(n,t)}}for(const s in e.events){for(const n of e.events[s]){if(n.rating=="LQ")U(n,t)}}for(const s in e.events){for(const n of e.events[s]){if(n.rating=="RT")U(n,t)}}for(const s in e.events){for(const n of e.events[s]){if(n.rating=="bad")U(n,t)}}let s=0;const n=[];for(const e of t){if(e.length>1){for(const t of e){t.msgid=s}s++;n.push(e)}}const o=[],i=[],r=[],l=[],p=[],c=[],d=[],f=[],h=[],g=[],m=[],b=[];for(const e of n){const t=[];let s=false,n=false,a=false,u=false,x=false,y=false,v=false,k=false,A=false,B=false,w=false,N=false;for(const o of e){t.push({label:o.eventlabel,lst:[o]});const e=o.usepair;if(o.rating=="HQ"){if(e){if(e.inframe)s=true;else n=true}else if(o.isnloss||o.iscloss){n=true}else{a=true}}else if(o.rating=="LQ"){if(e){if(e.inframe)u=true;else x=true}else if(o.isnloss||o.iscloss){x=true}else{y=true}}else if(o.rating=="RT"){if(e){if(e.inframe)v=true;else k=true}else if(o.isnloss||o.iscloss){k=true}else{A=true}}else{if(e){if(e.inframe)B=true;else w=true}else if(o.isnloss||o.iscloss){w=true}else{N=true}}}if(s){o.push({label:"",lst:t,ismsg:true})}else if(n){i.push({label:"",lst:t,ismsg:true})}else if(a){r.push({label:"",lst:t,ismsg:true})}else if(u){l.push({label:"",lst:t,ismsg:true})}else if(x){p.push({label:"",lst:t,ismsg:true})}else if(y){c.push({label:"",lst:t,ismsg:true})}else if(v){d.push({label:"",lst:t,ismsg:true})}else if(k){f.push({label:"",lst:t,ismsg:true})}else if(A){h.push({label:"",lst:t,ismsg:true})}else if(B){g.push({label:"",lst:t,ismsg:true})}else if(w){m.push({label:"",lst:t,ismsg:true})}else if(N){b.push({label:"",lst:t,ismsg:true})}else{console.log("multi-seg group unclassfied? "+key)}}const x={};for(const t in e.events){const s=[],n=[],u=[],y=[],v=[],k=[],A=[],B=[],w=[],N=[],z=[],_=[];for(const o of e.events[t]){if(o.msgid!=undefined){continue}if(o.geneA&&o.geneB){const e=o.geneA+"-"+o.geneB;let t=x[e];if(!t){const e=o.geneB+"-"+o.geneA;t=x[e]}if(t){if(!(e in t)){t[e]=[]}t[e].push(o)}else{x[e]={};x[e][e]=[o]}continue}var a=o.usepair;if(o.rating=="HQ"){if(a){if(a.inframe)s.push(o);else n.push(o)}else if(o.isnloss||o.iscloss){n.push(o)}else{u.push(o)}}else if(o.rating=="LQ"){if(a){if(a.inframe)y.push(o);else v.push(o)}else if(o.isnloss||o.iscloss){v.push(o)}else{k.push(o)}}else if(o.rating=="RT"){if(a){if(a.inframe)A.push(o);else B.push(o)}else if(o.isnloss||o.iscloss){B.push(o)}else{w.push(o)}}else{if(a){if(a.inframe)N.push(o);else z.push(o)}else if(o.isnloss||o.iscloss){z.push(o)}else{_.push(o)}}}if(s.length>0){o.push({label:t,lst:[{label:t,lst:s}]})}else if(n.length>0){i.push({label:t,lst:[{label:t,lst:n}]})}else if(u.length>0){r.push({label:t,lst:[{label:t,lst:u}]})}else if(y.length>0){l.push({label:t,lst:[{label:t,lst:y}]})}else if(v.length>0){p.push({label:t,lst:[{label:t,lst:v}]})}else if(k.length>0){c.push({label:t,lst:[{label:t,lst:k}]})}else if(A.length>0){d.push({label:t,lst:[{label:t,lst:A}]})}else if(B.length>0){f.push({label:t,lst:[{label:t,lst:B}]})}else if(w.length>0){h.push({label:t,lst:[{label:t,lst:w}]})}else if(N.length>0){g.push({label:t,lst:[{label:t,lst:N}]})}else if(z.length>0){m.push({label:t,lst:[{label:t,lst:z}]})}else if(_.length>0){b.push({label:t,lst:[{label:t,lst:_}]})}}for(const e in x){let t=false,s=false,n=false,a=false,u=false,y=false,v=false,k=false,A=false,B=false,w=false,N=false;const z=[];for(const o in x[e]){const i=x[e][o];if(i.length==1){if(i[0].msgid!=undefined){continue}}z.push({label:o,lst:i});for(const e of i){const o=e.usepair;if(e.rating=="HQ"){if(o){if(o.inframe)t=true;else s=true}else if(e.isnloss||e.iscloss){s=true}else{n=true}}else if(e.rating=="LQ"){if(o){if(o.inframe)a=true;else u=true}else if(e.isnloss||e.iscloss){u=true}else{y=true}}else if(e.rating=="RT"){if(o){if(o.inframe)v=true;else k=true}else if(e.isnloss||e.iscloss){k=true}else{A=true}}else{if(o){if(o.inframe)B=true;else w=true}else if(e.isnloss||e.iscloss){w=true}else{N=true}}}}if(t){o.push({label:e,lst:z})}else if(s){i.push({label:e,lst:z})}else if(n){r.push({label:e,lst:z})}else if(a){l.push({label:e,lst:z})}else if(u){p.push({label:e,lst:z})}else if(y){c.push({label:e,lst:z})}else if(v){d.push({label:e,lst:z})}else if(k){f.push({label:e,lst:z})}else if(A){h.push({label:e,lst:z})}else if(B){g.push({label:e,lst:z})}else if(w){m.push({label:e,lst:z})}else if(N){b.push({label:e,lst:z})}}e.egglst=[];e.hqincount=0;e.lqincount=0;if(o.length){e.egglst.push({htmlab:'HQ <span style="background-color:'+u+';color:white;padding:1px 3px;font-size:80%;">in-frame </span>',lst:o});e.hqincount=o.reduce(((e,t)=>e+t.lst.length),0)}if(i.length){e.egglst.push({htmlab:'HQ <span style="background-color:#E3C3C8;padding:1px 3px;font-size:80%;">truncation</span>',lst:i})}if(r.length){e.egglst.push({htmlab:'HQ <span style="background-color:#ccc;padding:1px 3px;font-size:80%;">others </span>',lst:r})}if(l.length){e.egglst.push({htmlab:'LQ <span style="background-color:'+u+';color:white;padding:1px 3px;font-size:80%;">in-frame </span>',lst:l});e.lqincount=l.reduce(((e,t)=>e+t),0)}if(p.length){e.egglst.push({htmlab:'LQ <span style="background-color:#E3C3C8;padding:1px 3px;font-size:80%;">truncation</span>',lst:p})}if(c.length){e.egglst.push({htmlab:'LQ <span style="background-color:#ccc;padding:1px 3px;font-size:80%;">others </span>',lst:c})}if(d.length){e.egglst.push({htmlab:'Read-through <span style="background-color:'+u+';color:white;padding:1px 3px;font-size:80%;">in-frame </span>',lst:d})}if(f.length){e.egglst.push({htmlab:'Read-through <span style="background-color:#E3C3C8;padding:1px 3px;font-size:80%;">truncation</span>',lst:f})}if(h.length){e.egglst.push({htmlab:'Read-through <span style="background-color:#ccc;padding:1px 3px;font-size:80%;">others </span>',lst:h})}if(g.length){e.egglst.push({htmlab:'Bad <span style="background-color:'+u+';color:white;padding:1px 3px;font-size:80%;">in-frame</span>',lst:g})}if(m.length){e.egglst.push({htmlab:'Bad <span style="background-color:#E3C3C8;padding:1px 3px;font-size:80%;">truncation</span>',lst:m})}if(b.length){e.egglst.push({htmlab:'Bad <span style="background-color:#ccc;padding:1px 3px;font-size:80%;">others </span>',lst:b})}}this.samples.sort(((e,t)=>{if(e.hqincount==t.hqincount){return t.lqincount-e.lqincount}return t.hqincount-e.hqincount}));for(const e of this.samples){for(const t of e.egglst){for(const e of t.lst){for(const t of e.lst){t.lst.sort(((e,t)=>{const s=e.usepair,n=t.usepair;if(s){if(n){if(s.inframe){if(!n.inframe){return-1}}else{if(n.inframe){return 1}}}else{return-1}}else{if(n){return 1}}return t.score-e.score}))}}t.lst.sort(((e,t)=>{if(e.lst.length!=t.lst.length){return t.lst.length-e.lst.length}let s=0;for(const t of e.lst){for(const e of t.lst){s=Math.max(s,e.score)}}let n=0;for(const e of t.lst){for(const t of e.lst){n=Math.max(n,t.score)}}return n-s}))}let t=1;for(const s of e.egglst){for(const e of s.lst){for(const s of e.lst){for(const e of s.lst){e.prodid=t++}}}}}this.step_gene();this.step_table()}dogenefilter(){let e=this.gui.inputa.property("value");let t=this.gui.inputb.property("value");if(e.length+t.length==0){this.gui.says.text("Showing "+(this.genelst.length>100?100:"all")+" of "+this.genelst.length+" pairs");this.geneshow(this.genelst.length>100?this.genelst.slice(0,100):this.genelst);return}e=e.length==0?null:e.toLowerCase();t=t.length==0?null:t.toLowerCase();const s=[];for(const n of this.genelst){if(e){if(!n.a)continue;if(n.a.toLowerCase().indexOf(e)==-1)continue}if(t){if(!n.b)continue;if(n.b.toLowerCase().indexOf(t)==-1)continue}s.push(n)}this.gui.says.text("Showing "+Math.min(100,s.length)+" of "+this.genelst.length+" pairs");this.geneshow(s.length>100?s.slice(0,100):s)}geneshow(e){this.genetable.selectAll("*").remove();const t=this.genetable.append("tr").style("background-color","#ededed").style("font-size",".8em");t.append("td").text("gene A");t.append("td").text("gene B");t.append("td").text("# sample");t.append("td").text("rating");for(const t of e){let e="black",n="black",o,a;if(t.ainter){e="#aaa";o="normal"}else{const s=t.samples[0].prodlst[0].hlgene;if(s==1||s==3||s==4)o="bold";if(s==4)e=L}if(t.binter){n="#aaa";a="normal"}else{const e=t.samples[0].prodlst[0].hlgene;if(e==2||e==3||e==4)a="bold";if(e==4)n=L}const i=this.genetable.append("tr").attr("class","sja_clb");i.append("td").text(t.a).style("color",e).style("font-weight",o);i.append("td").text(t.b).style("color",n).style("font-weight",a);i.append("td").text(t.samples.length);i.on("click",(()=>{const e=i.node().getBoundingClientRect();const s=c({x:e.left+e.width+10,y:e.top});s.header.text(t.a+" - "+t.b);const n=s.body.append("table");for(const e of t.samples){const t=n.append("tr");t.append("td").style("vertical-align","top").style("padding-top","5px").text(e.name);const s=t.append("td");for(const t of e.prodlst){const n=this.eventlogo([t],s);n.style("position","relative");n.append("div").style("position","absolute").style("width","100%").style("height","100%").style("top","0px").style("left","0px").on("mouseover",(s=>{const n=s.target.getBoundingClientRect();M.clear().show(n.left+n.width-2,n.top-30);this.showsvpairs({prodlst:[t],holder:M.d.append("div"),nodetail:true,sample:e,eglst:null,showothersample:false})})).on("click",(s=>{const n=s.target.getBoundingClientRect();const o=c({x:n.left+n.width+40,y:n.top-60});o.header.text(e.name);this.showsvpairs({prodlst:[t],holder:o.body})}))}}}));const r={};for(const e of t.samples){const t={};for(const s of e.prodlst){t[s.rating]=1}for(var s in t){if(!(s in r)){r[s]=0}r[s]++}}const l=[];for(const e of["HQ","LQ","RT","bad"]){if(r[e]){l.push('<span style="border-radius:6px;background-color:#ededed;padding:1px 6px;font-size:80%">'+e+(r[e]>1?' <span style="font-size:80%">'+r[e]+"</span>":"")+"</span>")}}i.append("td").html(l.join(" "))}}step_gene(){this.gui={};this.genefilter.append("span").text("Filter:");this.gui.inputa=this.genefilter.append("input").attr("size",7).attr("placeholder","gene A").style("margin-left","10px").on("keyup",(()=>this.dogenefilter()));this.gui.inputb=this.genefilter.append("input").attr("size",7).attr("placeholder","gene B").style("margin-left","10px").on("keyup",(()=>this.dogenefilter()));this.genefilter.append("button").style("margin-left","10px").text("Reset").on("click",(()=>{this.gui.inputa.property("value","");this.gui.inputb.property("value","");this.dogenefilter()}));this.gui.says=this.genefilter.append("span").style("padding-left","20px");const e={};const t=new Set;for(const s of this.samples){for(const n in s.events){for(const o of s.events[n]){if(!o.geneA||!o.geneB)continue;if(o.rating=="RT")continue;if(o.geneA){t.add(o.geneA)}if(o.geneB){t.add(o.geneB)}const n=(o.geneA?o.geneA:"<"+o.chrA)+" - "+(o.geneB?o.geneB:"<"+o.chrB);if(!(n in e)){e[n]={}}if(!(s.name in e[n])){e[n][s.name]=[]}e[n][s.name].push(o)}}}this.buttgene.text(t.size+" gene"+(t.size>1?"s":""));for(const t in e){const s=t.split(" - ");const n={samples:[]};if(s[0][0]=="<"){n.a=s[0].slice(1,s[0].length);n.ainter=true}else{n.a=s[0]}if(s[1][0]=="<"){n.b=s[1].slice(1,s[1].length);n.binter=true}else{n.b=s[1]}for(const s in e[t]){n.samples.push({name:s,prodlst:e[t][s]})}this.genelst.push(n)}this.genelst.sort(((e,t)=>{let s=0;for(const t of e.samples){for(const e of t.prodlst){if(e.rating=="HQ")s++}}let n=0;for(const e of t.samples){for(const t of e.prodlst){if(t.rating=="HQ")n++}}return n-s}));this.dogenefilter()}step_table(){this.eggbar=[];this.ul.selectAll("*").remove();for(const e of this.samples){this.ul.append("li").style("font-weight","bold").style("color","#545454").text(e.name);e.ul=this.ul.append("ul").style("margin-bottom","10px");this.showsample(e)}}showsample(e){e.ul.selectAll("*").remove();for(const t of e.egglst){const s=t.lst.reduce(((e,t)=>e+t.lst.length),0);const n=e.ul.append("li");const o=n.append("div").attr("class","sja_clb2").html(t.htmlab+" "+s);o.on("click",(()=>{for(const e of this.eggbar){e.style("background-color","")}o.style("background-color","yellow");const e=y(n.node().nextSibling);if(e.style("display")=="none"){f(e);t.isopen=true}else{h(e);t.isopen=false}}));this.eggbar.push(o);const a=e.ul.append("div").style("margin","10px");this.showevents(e,t.lst,a)}}showevents(e,t,s){const n=s.append("svg");let o=22,a=15,i=13,r=o-3,l=14,p=10,d=20,f=10,h=10,x=10,A=60,B=60,w=10,N=10,z=10,_=10,j=5,R=15,I=13,C=0,T=25,F=12,U=0,q=0,S=0,Q=0;for(const e of t){Q+=i;if(e.lst.length==1){Q+=o}else{Q+=h*2+(o+i)*e.lst.length+(a+i)*(e.lst.length-1)+x}for(const t of e.lst){t.svg={};const e=t.lst;const s=e[0];let o,a;if(s.geneA){const e=s.geneA.split(",");if(e.length>2){o=e[0]+","+e[1]+"..."}else{o=s.geneA}}else{o=""}if(s.geneB){const e=s.geneB.split(",");if(e.length>2){a=e[0]+","+e[1]+"..."}else{a=s.geneB}}else{a=""}n.append("text").text(o).attr("font-size",r).attr("font-family","Courier").each((function(){U=Math.max(U,this.getBBox().width)})).remove();n.append("text").text(a).attr("font-size",r).attr("font-family","Courier").each((function(){q=Math.max(q,this.getBBox().width)})).remove();n.append("text").text(s.rating).attr("font-size",r).attr("font-family","Courier").each((function(){t.svg.ratingw=this.getBBox().width})).remove();t.svg.framew=22;t.svg.typew=60;if(s.usepair){t.svg.frameword=s.usepair.inframe?"IN":"O"}else{t.svg.frameword="?"}n.append("text").text(s.featureA).attr("font-size",p).attr("font-family",v).each((function(){t.svg.featurew=this.getBBox().width})).remove();n.append("text").text(s.featureB).attr("font-size",p).attr("font-family",v).each((function(){t.svg.featurew=Math.max(t.svg.featurew,this.getBBox().width)})).remove();n.append("text").text(Math.floor(s.score)).attr("font-size",r).attr("font-family",v).each((function(){t.svg.scorew=this.getBBox().width})).remove();t.svg.logow=t.svg.ratingw+t.svg.framew+t.svg.typew+t.svg.featurew+t.svg.scorew+j*6;C=Math.max(C,t.svg.logow+(e.length>1?_+T:0));if(s.geneA&&s.geneB){const e=this.elab2sample[t.label];if(!e){t.svg.recurtext="Recurrence check error";t.svg.recurtextcolor="red"}else if(e.length==1){t.svg.recurtext="No recurrence";t.svg.recurtextcolor="#aaaaaa"}else{t.svg.hasrecurrence=true;t.svg.recurtext="In "+e.length+" samples";t.svg.recurtextcolor="black"}}else{t.svg.recurtext="Unknown recurrence";t.svg.recurtextcolor="#aaaaaa"}n.append("text").text(t.svg.recurtext).attr("font-size",r-4).attr("font-family",v).each((function(){t.svg.recurw=this.getBBox().width})).remove();S=Math.max(S,t.svg.recurw)}}U+=10;q+=10;Q+=i;let H=100;let O=A+w+o+I+U+F+N+F+q+I+o+w+B+z+C+R+S;n.attr("width",d*2+f*2+O+H).attr("height",Q);const D=n.append("g").attr("transform","translate("+d+",0)");let P=0;for(const d of t){P+=i;const Q=D.append("g").attr("transform","translate(0,"+P+")");const G=(o+i)*d.lst.length-i+(d.lst.length>1?h*2:0)+(d.lst.length>1?(a+i)*(d.lst.length-1):0);if(d.lst.length>1){Q.append("rect").attr("stroke","black").attr("stroke-dasharray",d.ismsg?"none":"2,3").attr("fill","none").attr("width",O+f*2).attr("height",G).attr("shape-rendering","crispEdges");if(d.ismsg){const a=Q.append("g").attr("transform","translate("+(O+f*2)+",0)");a.append("rect").attr("width",H).attr("height",o).attr("fill","#858585").attr("shape-rendering","crispEdges");a.append("text").text("multi-seg").attr("x",10).attr("y",o/2).attr("font-size",o-6).attr("font-family",v).attr("fill","white").attr("dominant-baseline","middle");a.append("rect").attr("width",H).attr("height",o).attr("fill","white").attr("fill-opacity",0).on("click",(o=>{const a=[];const i=[];for(const e of d.lst){const t=e.lst[0];i.push(t.prodid);const s={a:{chr:t.chrA,position:t.posA,strand:t.ortA,name:t.geneA?t.geneA:t.chrA,ratio:t.ratioA.toFixed(2),feature:t.featureA,contiglen:t.matchA,chimericreads:t.readsA,repeatscore:t.repeatA},b:{chr:t.chrB,position:t.posB,strand:t.ortB,name:t.geneB?t.geneB:t.chrB,ratio:t.ratioB.toFixed(2),feature:t.featureB,contiglen:t.matchB,chimericreads:t.readsB,repeatscore:t.repeatB},rating:t.rating,score:Math.ceil(t.score)};if(t.usepair){s.inframe=t.usepair.inframe;const e=t.usepair.a;s.a.gm=this.genome.isoformmatch(e.isoform,s.a.chr,s.a.position);s.a.codon=e.codon;s.a.exon=e.exon;s.a.atupstream=e.atupstream;s.a.atdownstream=e.atdownstream;s.a.atutr5=e.atutr5;s.a.atutr3=e.atutr3;const n=t.usepair.b;s.b.gm=this.genome.isoformmatch(n.isoform,s.b.chr,s.b.position);s.b.codon=n.codon;s.b.exon=n.exon;s.b.atupstream=n.atupstream;s.b.atdownstream=n.atdownstream;s.b.atutr5=n.atutr5;s.b.atutr3=n.atutr3;let o=0,a=0;if(e.contigaa&&n.contigaa){o=n.contigaa-e.contigaa-1}if(e.contigbp&&n.contigbp){a=n.contigbp-e.contigbp-1}if(o){s.interstitial={aalen:o}}if(a){if(!s.interstitial)s.interstitial={};s.interstitial.bplen=a}}a.push(s)}const r=o.target.getBoundingClientRect();const l=c({x:r.left+10,y:r.top+r.height+10});const p=l.body.append("div").style("margin","10px");p.append("span").style("padding-right","20px").text("Product id: "+i.join(", "));p.append("button").style("margin-right","10px").text("Break").on("click",(()=>{const o=d.lst.map((e=>e.lst[0].prodid));let a=0;for(;a<t.length;a++){const e=t[a];if(e.ismsg){const t=e.lst.map((e=>e.lst[0].prodid));if(t.join(",")==o.join(",")){break}}}delete d.ismsg;const i=d.lst;d.lst=[d.lst[0]];for(let e=1;e<i.length;e++){t.splice(a,0,{label:"",lst:[i[e]]})}n.remove();this.showevents(e,t,s);l.pane.remove()}));p.append("button").text("Edit").on("click",(s=>{const n=document.createElement("input");p.node().insertBefore(n,s.target);const o=document.createElement("button");p.node().insertBefore(o,s.target);p.node().removeChild(s.target);n.focus();const a=y(n);const r=y(o);a.attr("size",10).style("margin","0px 10px").property("value",i.join(","));r.text("Apply").on("click",(()=>{const s=n.value.trim().split(",");const o=[];for(const t of s){if(!t)continue;const s=Number.parseInt(t);if(Number.isNaN(s))return alert("invalid id: "+t);if(this.prodidisinvalid(s,e))return alert("invalid id "+s);o.push(s)}if(o.length<=1)return alert("must be at least 2 products");const a=[];for(const t of o){const s=this.extractprod(t,e);if(s){a.push({label:s.eventlabel,lst:[s]})}else{return alert("unknown product id "+t)}}if(a.length<=1)return alert("less than 2 products cannot make a group");t.unshift({lst:a,ismsg:true});this.showsample(e);l.pane.remove()}))}));E({samplelst:[{pairlst:a}],nosample:true,holder:l.body});const f={pairlst:a,genome:this.genome,holder:l.body,hostURL:this.hostURL,jwt:this.jwt};import("./svgraph-6ab3011b.js").then((e=>{e.default(f)}))}))}}const J=Q.append("g").attr("transform","translate("+f+","+(d.lst.length>1?h:0)+")");let V=0;let Y=0;const W={};for(const e of d.lst){W[e.label]=1}const X={};for(const s of d.lst){const n=s.lst;const f=n[0];const h=f.usepair;if(d.lst.length>1&&Y>0){const e=J.append("g").attr("transform","translate("+(A+w+o+I+U+F+N/2)+","+V+")");const t=e.append("text").attr("fill","#858585").attr("font-size",a).attr("text-anchor","middle").attr("font-family",v).attr("y",a/2).attr("dominant-baseline","middle");if(d.ismsg){t.text(f.mswhat?f.mswhat:"No connection detail")}else{t.text("Reciprocal")}V+=a+i}const x=f.chrA==f.chrB?"black":k;const y=J.append("g").attr("transform","translate(0,"+V+")");y.append("text").text(f.chrA).attr("x",A).attr("y",o/2).attr("font-size",r-4).attr("text-anchor","end").attr("dominant-baseline","middle").attr("fill",x);const E={a:null,b:null};if(f.geneA){if(f.geneA in X){X[f.geneA]=1}else{const t=[];for(const s in e.gene2events[f.geneA]){if(!(s in W)){t.push(s)}}if(t.length>0){E.a={lst:t};E.a.circle=y.append("circle").attr("fill","white").attr("stroke","black").attr("cx",A+w+o/2).attr("cy",o/2).attr("r",o/2);if(t.length>1){E.a.text=y.append("text").text(t.length).attr("x",A+w+o/2).attr("y",o/2).attr("text-anchor","middle").attr("font-size",a).attr("dominant-baseline","middle").attr("fill","black")}y.append("line").attr("x1",A+w+o).attr("x2",A+w+o+I).attr("y1",o/2).attr("y2",o/2).attr("stroke","black").attr("shape-rendering","crispEdges")}}}y.append("rect").attr("fill",m).attr("x",A+w+o+I+(U+F)*(1-f.ratioA)).attr("width",(U+F)*f.ratioA).attr("height",o).attr("shape-rendering","crispEdges");let Q=false;if(h){const e=h.a.isoform;if(e){const t=this.genome.isoformmatch(e,f.chrA,f.posA);if(t&&t.strand!=f.ortA){Q=true}}}const H=y.append("rect").attr("fill","none").attr("stroke",Q?"red":"black").attr("shape-rendering","crispEdges").attr("x",A+w+o+I).attr("width",U+F).attr("height",o);let O;if(f.geneA){const e=f.geneA.split(",");if(e.length>2){O=e[0]+","+e[1]+"..."}else{O=f.geneA}}else{O=""}y.append("text").text(O).attr("x",A+w+o+I+U).attr("y",o/2).attr("font-size",r).attr("font-family","Courier").attr("font-weight",f.hlgene?f.hlgene==1||f.hlgene==3||f.hlgene==4?"bold":"normal":"normal").attr("fill",f.hlgene?f.hlgene==4?L:"#545454":"#545454").attr("text-anchor","end").attr("dominant-baseline","central");y.append("line").attr("x1",A+w+o+I+U+F).attr("x2",A+w+o+I+U+F+N).attr("y1",o/2).attr("y2",o/2).attr("shape-rendering","crispEdges").attr("stroke","black");y.append("rect").attr("fill",b).attr("x",A+w+o+I+U+F+N).attr("width",(F+q)*f.ratioB).attr("height",o).attr("shape-rendering","crispEdges");Q=false;if(h){const e=h.b.isoform;if(e){const t=this.genome.isoformmatch(e,f.chrB,f.posB);if(t&&t.strand!=f.ortB){Q=true}}}const D=y.append("rect").attr("fill","none").attr("stroke",Q?"red":"black").attr("shape-rendering","crispEdges").attr("x",A+w+o+I+U+F+N).attr("width",q+F).attr("height",o);let P;if(f.geneB){let e=f.geneB.split(",");if(e.length>2){P=e[0]+","+e[1]+"..."}else{P=f.geneB}}else{P=""}y.append("text").text(P).attr("x",A+w+o+I+U+F+N+F).attr("y",o/2).attr("font-size",r).attr("font-family","Courier").attr("font-weight",f.hlgene?f.hlgene==2||f.hlgene==3||f.hlgene==4?"bold":"normal":"normal").attr("fill",f.hlgene?f.hlgene==4?L:"#545454":"#545454").attr("dominant-baseline","central");if(f.geneB){if(f.geneB in X);else{X[f.geneB]=1;const t=[];for(const s in e.gene2events[f.geneB]){if(!(s in W)){t.push(s)}}if(t.length>0){E.b={lst:t};E.b.circle=y.append("circle").attr("fill","white").attr("stroke","black").attr("cx",A+w+o+I+U+F+N+F+q+I+o/2).attr("cy",o/2).attr("r",o/2);if(t.length>1){E.b.text=y.append("text").text(t.length).attr("x",A+w+o+I+U+F+N+F+q+I+o/2).attr("y",o/2).attr("text-anchor","middle").attr("font-size",a).attr("dominant-baseline","middle").attr("fill","black")}y.append("line").attr("x1",A+w+o+I+U+F+N+F+q).attr("x2",A+w+o+I+U+F+N+F+q+I).attr("y1",o/2).attr("y2",o/2).attr("stroke","black").attr("shape-rendering","crispEdges")}}}y.append("text").text(f.chrB).attr("x",A+w+o+I+U+F+N+F+q+I+o+w).attr("y",o/2).attr("font-size",r-4).attr("dominant-baseline","middle").attr("fill",x);let G=A+w+o+I+U+F+N+F+q+I+o+w+B+z;const K=G;const Z=y.append("rect").attr("fill","white").attr("stroke","#858585").attr("x",G).attr("y",-1.5).attr("width",s.svg.logow).attr("height",o+2).attr("rx",5).attr("ry",5);G+=j;f.hook.mainRating=y.append("text").text(f.rating).attr("font-size",r).attr("font-family",v).attr("fill","#858585").attr("x",G).attr("y",o/2).attr("dominant-baseline","middle");G+=s.svg.ratingw+j;f.hook.mainFrame={};f.hook.mainFrame.bg=y.append("rect").attr("x",G+1).attr("y",3).attr("width",s.svg.framew).attr("height",o-7).attr("shape-rendering","crispEdges");if(f.usepair){f.hook.mainFrame.bg.attr("fill",f.usepair.inframe?u:g)}else{f.hook.mainFrame.bg.attr("fill","none").attr("stroke","black")}f.hook.mainFrame.text=y.append("text").text(s.svg.frameword).attr("font-size",l).attr("font-family",v).attr("fill",f.usepair?"white":"black").attr("x",G+1+s.svg.framew/2).attr("text-anchor","middle").attr("y",o/2).attr("dominant-baseline","middle");G+=s.svg.framew+j;f.hook.mainType=y.append("text").text(f.type2).attr("font-size",r).attr("font-family",v).attr("fill","#858585").attr("x",G).attr("y",o/2).attr("dominant-baseline","middle");G+=s.svg.typew+j;y.append("text").text(f.featureA).attr("font-size",p).attr("font-family",v).attr("fill","black").attr("x",G).attr("y",o/4).attr("dominant-baseline","middle");y.append("text").text(f.featureB).attr("font-size",p).attr("font-family",v).attr("fill","black").attr("x",G).attr("y",o*3/4).attr("dominant-baseline","middle");G+=s.svg.featurew+j;y.append("text").text(Math.floor(f.score)).attr("font-size",r).attr("font-family",v).attr("fill","#858585").attr("x",G).attr("y",o/2).attr("dominant-baseline","middle");G+=s.svg.scorew+j+_;y.append("rect").attr("fill","white").attr("fill-opacity",0).attr("stroke","none").attr("x",K).attr("y",-1.5).attr("width",s.svg.logow).attr("height",o+2).on("mouseover",(()=>{Z.attr("stroke-width","2");const e=M.clear().showunder(Z.node()).d.append("div");this.prodstat(f,e)})).on("mouseout",(()=>{Z.attr("stroke-width","1");M.hide()}));if(n.length>1){const e=y.append("rect").attr("fill","none").attr("stroke","#858585").attr("x",G).attr("y",3.5).attr("width",T).attr("height",o-4).attr("rx",5).attr("ry",5);y.append("text").text(n.length-1).attr("fill","black").attr("font-size",p).attr("font-family",v).attr("x",G+T/2).attr("y",3.5+(o-3.5)/2).attr("text-anchor","middle").attr("dominant-baseline","middle");y.append("rect").attr("fill","white").attr("fill-opacity",0).attr("x",G).attr("y",3.5).attr("width",T).attr("height",o-4).on("mouseover",(t=>{e.attr("stroke-width","2");const s=M.clear().showunder(t.target).d.append("table").style("border-spacing","10px").style("border-collapse","separate");const o=s.append("tr");const a=s.append("tr");for(var i=1;i<n.length;i++){this.eventlogo([n[i]],o.append("td"));this.prodstat(n[i],a.append("td"))}})).on("mouseout",(()=>{e.attr("stroke-width","1");M.hide()}))}G=A+w+o+I+U+F+N+F+q+I+o+w+B+z+C+R;const $=y.append("text").text(s.svg.recurtext).attr("font-size",r-4).attr("font-family",v).attr("fill",s.svg.recurtextcolor).attr("x",G).attr("y",o/2).attr("dominant-baseline","middle");if(s.svg.hasrecurrence){$.attr("class","sja_svgtext2").on("mouseover",(t=>{const n=t.target.getBoundingClientRect();M.clear().show(n.left+n.width+10,n.top-15);const o=this.elab2sample[s.label];const a=M.d;a.append("div").style("margin","10px").style("color","#aaa").text("This fusion is recurrent in other samples:");const i=a.append("table").style("border-spacing","10px").style("border-collapse","separate");for(const t of o){if(t.name==e.name){continue}const n=i.append("tr");n.append("td").style("font-weight","bold").style("color","#858585").text(t.name);this.eventlogo(t.events[s.label],n.append("td"))}})).on("mouseout",(()=>M.hide()))}y.append("rect").attr("x",A+w+o+I).attr("width",U+F+N+F+q).attr("height",o).attr("fill","white").attr("fill-opacity",0).on("mouseover",(n=>{H.attr("stroke-width",2);D.attr("stroke-width",2);const o=n.target.getBoundingClientRect();M.clear().show(o.left+o.width+I/2,o.top-30);this.showsvpairs({prodlst:s.lst,holder:M.d,nodetail:true,sample:e,eglst:t,showothersample:true})})).on("mouseout",(()=>{M.hide();H.attr("stroke-width",1);D.attr("stroke-width",1)})).on("click",(e=>{if(s.inclick){return}s.inclick=true;const t=e.target.getBoundingClientRect();const n=c({x:t.left+t.width+I+o+w+B+z+C+R+S+5,y:t.top-100,close:function(){s.inclick=false;n.pane.remove()}});const a=s.lst[0];n.header.html('<span style="padding:2px 4px;background-color:'+m+';">'+(a.geneA?a.geneA:a.chrA)+"</span>"+'<span style="padding:2px 4px;background-color:'+b+';">'+(a.geneB?a.geneB:a.chrB)+"</span>");this.showsvpairs({prodlst:s.lst,holder:n.body})}));if(E.a){y.append("circle").attr("cx",A+w+o/2).attr("cy",o/2).attr("r",o/2).attr("fill","white").attr("fill-opacity",0).on("mouseover",(t=>this.extevt_mover(E.a,t.target,e))).on("mouseout",(()=>{this.extevt_mo(E.a);M.hide()})).on("click",(t=>{this.extevt_c(E.a,t.target,e)}))}if(E.b){y.append("circle").attr("cx",A+w+o+I+U+F+N+F+q+I+o/2).attr("cy",o/2).attr("r",o/2).attr("fill","white").attr("fill-opacity",0).on("mouseover",(t=>this.extevt_mover(E.b,t.target,e))).on("mouseout",(()=>{this.extevt_mo(E.b);M.hide()})).on("click",(t=>this.extevt_c(E.b,t.target,e)))}V+=o+i;Y++}P+=G+(d.lst.length>1?x:0)}s.style("display","none")}extevt_mover(e,t,s){e.circle.attr("fill","#858585");if(e.text){e.text.attr("fill","white")}M.clear().showunder(t);M.d.append("div").style("margin","10px").style("color","#aaa").text("Associated fusions from this sample:");this.extevt_table(e.lst,M.d,s)}extevt_mo(e){e.circle.attr("fill","white");if(e.text){e.text.attr("fill","black")}}extevt_c(e,t,s){const n=t.getBoundingClientRect();const o=c({x:n.left,y:n.top+n.height+10});this.extevt_table(e.lst,o.body,s)}extevt_table(e,t,s){const n=t.append("table").style("border-spacing","10px").style("border-collapse","separate");for(const t of e){const e=n.append("tr");const o=s.events[t];if(!o){e.append('<td colspan=2 style="color:red">No products found for '+t+"</td>");continue}const a=o[0];e.append("td").style("text-align","right").text(a.geneA?a.geneA:a.chrA);e.append("td").text(a.geneB?a.geneB:a.chrB);this.eventlogo(o,e.append("td"))}}eventlogo(e,t){const s=t.append("div");if(!e||e.length==0){s.style("color","red").text("No products")}else{const t=e[0];s.append("div").style("display","inline-block").style("padding","2px 4px").style("border","solid 1px #858585").style("border-radius","5px").html(t.rating+" "+'<span style="font-size:70%;vertical-align:2px;'+(t.usepair?t.usepair.inframe?"padding:2px 4px;background-color:"+u+';color:white;">IN':"padding:2px 4px;background-color:"+g+';color:white;">O':'padding:1px 3px;border:solid 1px black;background-color:white;color:black;">?')+"</span>"+' <span style="color:#858585">'+t.type2+"</span> "+'<div style="display:inline-block;font-size:70%;line-height:.9">'+t.featureA+"<br>"+t.featureB+"</div>"+" "+Math.floor(t.score));if(e.length>1){s.append("div").style("display","inline-block").style("margin-left","10px").style("padding","2px 4px").style("font-size",".7em").style("border","solid 1px #858585").style("border-radius",5).text(e.length-1)}}return s}prodstat(e,t){t.append("p").text("Product id: "+e.prodid);const s="#FFb3b3",n="#f1f1f1";const o=t.append("table").style("border-spacing","8px").style("border-collapse","separate");let a=o.append("tr");a.append("td");a.append("td").style("background-color",n).text(e.geneA?e.geneA:e.chrA);a.append("td").style("background-color",n).text(e.geneB?e.geneB:e.chrB);a=o.append("tr");a.append("td").style("font-size","80%").style("background-color",n).text("chimeric reads");a.append("td").style("padding","5px").style("background-color",e.readsA<=this.cf_reads?s:"").text(e.readsA);a.append("td").style("padding","5px").style("background-color",e.readsB<=this.cf_reads?s:"").text(e.readsB);a=o.append("tr");a.append("td").style("font-size","80%").style("background-color",n).text("ratio");a.append("td").style("padding","5px").style("background-color",e.ratioA<=this.cf_ratio?s:"").text(Math.ceil(e.ratioA*100)+"%");a.append("td").style("padding","5px").style("background-color",e.ratioB<=this.cf_ratio?s:"").text(Math.ceil(e.ratioB*100)+"%");a=o.append("tr");a.append("td").style("font-size","80%").style("background-color",n).text("contig length");a.append("td").style("padding","5px").style("background-color",e.matchA<=this.cf_match?s:"").text(e.matchA+" bp");a.append("td").style("padding","5px").style("background-color",e.matchB<=this.cf_match?s:"").text(e.matchB+" bp");a=o.append("tr");a.append("td").style("font-size","80%").style("background-color",n).text("repeat score");a.append("td").style("padding","5px").style("background-color",e.repeatA>=this.cf_repeat?s:"").text(e.repeatA);a.append("td").style("padding","5px").style("background-color",e.repeatB>=this.cf_repeat?s:"").text(e.repeatB)}showsvpairs(e){const t=e.holder.append("table").style("border-spacing","10px").style("border-collapse","separate");const s=t.append("tr");const n=t.append("tr");const o=n.append("td").attr("colspan",e.prodlst.length);const a=t.append("tr");const i=new Set;for(const t of e.prodlst){if(t.geneA){i.add(t.geneA)}if(t.geneB){i.add(t.geneB)}const n=s.append("td").style("vertical-align","top");if(e.nodetail){const s=n.append("div");s.append("span").style("padding-right","20px").text("Product id: "+t.prodid);const o=s.append("select").style("margin-right","5px").on("change",(e=>{const s=e.target;const n=s.options[s.selectedIndex].innerHTML;t.rating=n;if(t.hook.mainRating){t.hook.mainRating.text(n)}if(t.hook.lessRating){t.hook.lessRating.text(n)}}));const a=s.append("select").style("margin-right","5px").on("change",(e=>{const s=e.target;const n=s.options[s.selectedIndex].innerHTML=="in-frame";t.usepair.inframe=n;if(t.hook.mainFrame){t.hook.mainFrame.text.text(n?"IN":"O");t.hook.mainFrame.bg.attr("fill",n?u:g)}if(t.hook.lessFrame){t.hook.lessFrame.html(n?'<span style="background-color:'+u+';color:white;padding:2px 3px;font-size:80%;white-space:nowrap">In frame</span>':'<span style="background-color:'+g+';color:white;padding:2px 3px;font-size:80%;white-space:nowrap">Out of frame</span>')}}));const i=s.append("select").style("margin-right","5px").on("change",(e=>{const s=e.target;const n=s.selectedIndex;const o=s.options[n].innerHTML;t.type2=o;if(t.hook.mainType){t.hook.mainType.text(o)}t.iscloss=n==0;t.isnloss=n==1;t.isfusion=n==2;t.isitd=n==3;t.isuptss=n==4;t.isother=n==5}));const r=s.append("select").style("margin-right","5px").on("change",(e=>{const s=e.target;const n=s.options[s.selectedIndex].innerHTML;t.functioneffect=n}));s.append("button").text("Create group").on("click",(n=>{let o=document.createElement("div");s.node().insertBefore(o,n.target);y(n.target).remove();o=y(o);o.style("display","inline-block");if(!e.eglst){o.text("Cannot do it here: please go to sample "+e.sample.name);return}o.append("input").attr("size",10).property("value",t.prodid+",");o.append("button").style("margin","0px 10px").text("Apply").on("click",(t=>{const s=t.target.previousSibling.value.trim().split(",");const n=[];for(const t of s){const s=Number.parseInt(t);if(Number.isNaN(s))return alert("invalid id "+t);if(this.prodidisinvalid(s,e.sample))return alert("invalid id "+s);n.push(s)}if(n.length<=1)return alert("need at least 2 id");const o=[];for(const t of n){const s=this.extractprod(t,e.sample);if(s){o.push({label:s.eventlabel,lst:[s]})}else{return alert("invalid id "+t)}}if(o.length<=1)return alert("less than 2 products cannot make a group");e.eglst.unshift({lst:o,ismsg:true});this.showsample(e.sample);M.hide()}))}));o.append("option").text("HQ");o.append("option").text("LQ");o.append("option").text("RT");o.append("option").text("bad");o.append("option").text("Major");switch(t.rating){case"HQ":o.property("selectedindex",0);break;case"LQ":o.property("selectedIndex",1);break;case"RT":o.property("selectedIndex",2);break;case"bad":o.property("selectedIndex",3);break;case"Major":o.property("selectedIndex",4);break;default:alert("unknown rating: "+t.rating)}a.append("option").text("in-frame");a.append("option").text("out-of-frame");if(!t.usepair){a.attr("disabled",1)}else{a.property("selectedIndex",t.usepair.inframe?0:1)}i.append("option").text("CLoss");i.append("option").text("NLoss");i.append("option").text("Fusion");i.append("option").text("ITD");i.append("option").text("upTSS");i.append("option").text("other");if(t.iscloss){i.property("selectedIndex",0)}else if(t.isnloss){i.property("selectedIndex",1)}else if(t.isfusion){i.property("selectedIndex",2)}else if(t.isitd){i.property("selectedIndex",3)}else if(t.isuptss){i.property("selectedIndex",4)}else if(t.isother){i.property("selectedIndex",5)}else{alert("unknown type2: "+t.type2)}r.append("option").text("unknown effect");r.append("option").text("fusion gene");r.append("option").text("truncation, activated oncogene");r.append("option").text("truncation, loss-of-function");r.append("option").text("truncation, no consequence");r.append("option").text("ITD");switch(t.functioneffect){case undefined:r.property("selectedIndex",0);break;case"fusion gene":r.property("selectedIndex",1);break;case"truncation, activated oncogene":r.property("selectedIndex",2);break;case"truncation, loss-of-function":r.property("selectedIndex",3);break;case"truncation, no consequence":r.property("selectedIndex",4);break;case"ITD":r.property("selectedIndex",5);break}}const o={a:{chr:t.chrA,position:t.posA,strand:t.ortA,name:t.geneA?t.geneA:t.chrA,ratio:t.ratioA.toFixed(2),feature:t.featureA,contiglen:t.matchA,chimericreads:t.readsA,repeatscore:t.repeatA},b:{chr:t.chrB,position:t.posB,strand:t.ortB,name:t.geneB?t.geneB:t.chrB,ratio:t.ratioB.toFixed(2),feature:t.featureB,contiglen:t.matchB,chimericreads:t.readsB,repeatscore:t.repeatB},rating:t.rating,score:Math.ceil(t.score),originalprod:t};if(t.usepair){o.inframe=t.usepair.inframe;const e=t.usepair.a;o.a.gm=this.genome.isoformmatch(e.isoform,t.chrA,t.posA);o.a.codon=e.codon;o.a.exon=e.exon;o.a.atupstream=e.atupstream;o.a.atdownstream=e.atdownstream;o.a.atutr5=e.atutr5;o.a.atutr3=e.atutr3;const s=t.usepair.b;o.b.gm=this.genome.isoformmatch(s.isoform,t.chrB,t.posB);o.b.codon=s.codon;o.b.exon=s.exon;o.b.atupstream=s.atupstream;o.b.atdownstream=s.atdownstream;o.b.atutr5=s.atutr5;o.b.atutr3=s.atutr3;let n=0,a=0;if(e.contigaa&&s.contigaa){n=s.contigaa-e.contigaa-1}if(e.contigbp&&s.contigbp){a=s.contigbp-e.contigbp-1}if(n){o.interstitial={aalen:n}}if(a){if(!o.interstitial)o.interstitial={};o.interstitial.bplen=a}}E({samplelst:[{pairlst:[o]}],nosample:true,holder:n});const r={pairlst:[o],genome:this.genome,holder:n,quiet:true,hostURL:this.hostURL,jwt:this.jwt};import("./svgraph-6ab3011b.js").then((e=>{e.default(r)}));if(!e.nodetail){const e=a.append("td").style("font-size",".8em").style("vertical-align","top");const s=[];for(const e of this.atlst){if(!e.custom)continue;const n=t[e.key];s.push({k:e.label,v:n==undefined?"":n})}A(e,s,25);t.pairs.sort(((e,t)=>{if(e.inuse)return-1;if(t.inuse)return 1;return 0}));const n=e.append("table");for(const e of t.pairs){const s=n.append("tr");s.append("td").html((e.inframe?"in-frame":"out-of-frame")+'<div style="font-size:70%">frame code: '+e.frame+"</div>");const o=s.append("td");const a=o.append("table").style("margin-bottom","20px").style("border",e.inuse?"solid 1px black":"").style("border-spacing","10px").style("border-collapse","separate");let i=a.append("tr").style("color","#858585").style("font-size",".7em");i.append("td").text("gene");i.append("td").text("isoform");i.append("td").text("gene position");i.append("td").text("exon");i.append("td").text("anchor");i.append("td").text("contig AA");i.append("td").text("contig bp");const r=a.append("tr");const l=a.append("tr");r.append("td").text(t.geneA?t.geneA:t.chrA);l.append("td").text(t.geneB?t.geneB:t.chrB);r.append("td").text(e.a.isoform?e.a.isoform:"");l.append("td").text(e.b.isoform?e.b.isoform:"");r.append("td").text(e.a.isoform?e.a.codon!=undefined?"codon: "+e.a.codon:e.a.atutr5?"5' UTR":e.a.atutr3?"3' UTR":e.a.atupstream?"upstream":"downstream":"");l.append("td").text(e.b.isoform?e.b.codon!=undefined?"codon: "+e.b.codon:e.b.atutr5?"5' UTR":e.b.atutr3?"3' UTR":e.b.atupstream?"upstream":"downstream":"");r.append("td").text(e.a.exon?e.a.exon:"");l.append("td").text(e.b.exon?e.b.exon:"");r.append("td").text(e.a.anchor?e.a.anchor:"");l.append("td").text(e.b.anchor?e.b.anchor:"");r.append("td").html(e.a.contigaa?'<span style="color:#858585;font-size:70%">ends at</span> '+e.a.contigaa:"?");l.append("td").html(e.b.contigaa?'<span style="color:#858585;font-size:70%">starts at</span> '+e.b.contigaa:"?");r.append("td").html(e.a.contigbp?'<span style="color:#858585;font-size:70%">ends at</span> '+e.a.contigbp:"?");l.append("td").html(e.b.contigbp?'<span style="color:#858585;font-size:70%">starts at</span> '+e.b.contigbp:"?")}}}if(!e.sample){return}const r=e.prodlst[0].eventlabel;const l=this.elab2sample[r];const p=[];if(l){for(const t of l){if(t.name!=e.sample.name)p.push(t)}}if(e.showothersample&&p.length>0){e.holder.append("button").style("display","block").style("margin","20px").text("Show in "+p.length+" other sample"+(p.length>1?"s":"")).on("click",(t=>{y(t.target).remove();for(const t of p){const s=t.events[r];if(!s){e.holder.append("div").style("margin","20px").style("color","red").text("Error: no products for this event in "+t.name);continue}const n=e.holder.append("table").style("margin-top","20px").style("border","solid 1px #ccc");const o=n.append("tr");o.append("td").text(t.name);const a=o.append("td");this.showsvpairs({prodlst:s,holder:a,nodetail:true,sample:t,eglst:null})}}))}if(this.expression.genes&&i.size>0){const t=o.append("table");const s=t.append("tr");for(const t of i){const n=this.expression.genes[t];if(n){const o=s.append("td").style("vertical-align","top").append("div").style("display","inline-block").style("margin-right","20px").style("border","solid 1px #ccc");o.append("div").style("background-color","#ededed").style("padding","10px").text(t);if(e.sample){for(const t of n){if(t.sample==e.sample.name){t.ishighlight=true;o.append("div").style("padding","10px").style("font-size","70%").html("Expression in "+e.sample.name+': <span style="font-size:150%">'+t.value+"</span>")}else{t.ishighlight=false}}}S({data:this.expression.genes[t],holder:o.append("div").style("margin","10px"),width:200,height:200,namename:"sample"})}else{s.append("td").style("vertical-align","top").text("No expression data for "+t+"</td>")}}}}prodidisinvalid(e,t){for(const s of t.egglst){for(const t of s.lst){for(const s of t.lst){for(const t of s.lst){if(t.prodid==e)return false}}}}return true}extractprod(e,t){let s=null;for(let n=0;n<t.egglst.length;n++){const o=t.egglst[n];for(let t=0;t<o.lst.length;t++){const n=o.lst[t];for(let t=0;t<n.lst.length;t++){const o=n.lst[t];for(let t=0;t<o.lst.length;t++){const n=o.lst[t];if(n.prodid==e){s=n;o.lst.splice(t,1);break}}if(s){if(o.lst.length==0){n.lst.splice(t,1)}break}}if(s){if(n.lst.length==0){o.lst.splice(t,1)}else{if(n.ismsg&&n.lst.length==1){delete n.ismsg}}break}}if(s){if(o.lst.length==0){t.egglst.splice(n,1)}break}}return s}}function U(e,t){if(e.isitd)return;if(e.sv_ort=="?")return;var s=true;var n=e.usepair;for(var o=0;o<t.length;o++){var a=t[o];var i=a[0];if(e.chrB==i.chrA&&e.ortB==i.ortA){if(h(e,i)){var r=i.usepair;if(n&&r&&n.b.isoform&&n.b.isoform==r.a.isoform){var l=n.b;var p=r.a;var c=false;if(l.atutr5){if(p.codon!=undefined){c=true;i.mswhat="5' UTR to coding region"}else if(p.atutr3){c=true;i.mswhat="5' UTR to 3' UTR"}else if(p.atutr5&&l.atutr5.off<p.atutr5.off){c=true;i.mswhat=p.atutr5.off-l.atutr5.off+" bp apart in 5' UTR"}}else if(l.atutr3){if(p.atutr3&&l.atutr3.off<p.atutr3.off){c=true;i.mswhat=p.atutr3.off-l.atutr3.off+" bp apart in 3' UTR"}}else if(l.codon!=undefined){if(p.codon!=undefined&&p.codon>l.codon){c=true;i.mswhat=p.codon-l.codon+" aa apart in protein"}else if(p.atutr3){c=true;i.mswhat="coding region to 3' UTR"}}if(c){a.unshift(e);s=false;break}}var d=i.posA-e.posB;if(e.ortB=="+"&&d>0&&d<T||e.ortB=="-"&&d<0&&-d<T){i.mswhat=Math.abs(d)+" bp apart on genome";a.unshift(e);s=false;break}}}i=a[a.length-1];if(e.chrA==i.chrB&&e.ortA==i.ortB){if(h(i,e)){var r=i.usepair;if(n&&r&&n.a.isoform&&n.a.isoform==r.b.isoform){var l=r.b;var p=n.a;var f=false;if(l.atutr5){if(p.codon!=undefined){f=true;e.mswhat="5' UTR to coding region"}else if(p.atutr3){f=true;e.mswhat="5' UTR to 3' UTR"}else if(p.atutr5&&l.atutr5.off<p.atutr5.off){f=true;e.mswhat=p.atutr5.off-l.atutr5.off+" bp apart in 5' UTR"}}else if(l.atutr3){if(p.atutr3&&l.atutr3.off<p.atutr3.off){f=true;e.mswhat=p.atutr3.off-l.atutr3.off+" bp apart in 3' UTR"}}else if(l.codon!=undefined){if(p.codon!=undefined&&p.codon>l.codon){f=true;e.mswhat=p.codon-l.codon+" aa apart in protein"}else if(p.atutr3){f=true;e.mswhat="coding region to 3' UTR"}}if(f){a.push(e);s=false;break}}var d=e.posA-i.posB;if(e.ortA=="+"&&d>0&&d<T&&(e.ortA=="-"&&d<0&&-d<T)){e.mswhat=Math.abs(d)+" bp apart on genome";a.push(e);s=false;break}}}}if(s){t.push([e])}function h(e,t){if(!e.usepair||!e.usepair.inframe)return false;if(!t.usepair||!t.usepair.inframe)return false;if(e.readsB==0||t.readsA==0)return false;var s=e.readsB/t.readsA;return s>=.2&&s<=5}}function E(e){const t=e.holder.append("table").style("border-spacing","10px").style("border-collapse","separate");const s=t.append("tr").style("font-size","70%").style("color","#858585");const n=[{label:"Feature",hide:true,get:e=>e.feature},{label:"Ratio",hide:true,get:e=>Math.ceil(e.ratio*100)+"%"},{label:"Chimeric<br>reads",hide:true,get:e=>e.chimericreads},{label:"Contig<br>length",hide:true,get:e=>e.contiglen},{label:"Repeat<br>score",hide:true,get:e=>e.repeatscore},{label:"Cicero<br>score",hide:true,atpair:true,get:e=>e.score},{label:"Cicero<br>rating",israting:true,hide:true,atpair:true,get:e=>e.rating}];for(const t of e.samplelst){for(const e of t.pairlst){if(e.a.feature||e.b.feature)n[0].hide=false;if(typeof e.a.ratio=="number"||typeof(e.b.ratio=="number"))n[1].hide=false;if(typeof e.a.chimericreads=="number"||typeof e.b.chimericreads=="number")n[2].hide=false;if(typeof e.a.contiglen=="number"||typeof e.b.contiglen=="number")n[3].hide=false;if(typeof e.a.repeatscore=="number"||typeof e.b.repeatscore=="number")n[4].hide=false;if(typeof e.score=="number")n[5].hide=false;if(e.rating)n[6].hide=false}}if(!e.nosample){s.append("td")}s.append("td");s.append("td");s.append("td").html("Genomic<br>position");s.append("td").html("Genomic<br>dist.");for(const e of n){if(e.hide)return;s.append("td").html(e.label)}for(const s of e.samplelst){let o=t.append("tr");if(!e.nosample){const e=o.append("td").text(s.sample);if(s.pairlst.length>1){e.attr("rowspan",s.pairlst.length)}}for(let e=0;e<s.pairlst.length;e++){if(e>0){o=t.append("tr")}const a=s.pairlst[e];o.append("td").style("text-align","right").html('<span style="background-color:'+m+';padding:2px 3px;font-size:80%">'+a.a.name+"</span>"+'<span style="background-color:'+b+';padding:2px 3px;font-size:80%">'+a.b.name+"</span>");const i=o.append("td");if(a.originalprod&&a.originalprod.hook.lessFrame){a.originalprod.hook.lessFrame=i}if(a.inframe){i.html('<span style="background-color:'+u+';color:white;padding:2px 3px;font-size:80%;white-space:nowrap">In frame</span>')}else{if(a.a.gm||a.b.gm){i.html('<span style="background-color:#858585;color:white;padding:2px 3px;font-size:80%;white-space:nowrap">Out of frame</span>')}else{i.html('<span style="border:solid 1px #858585;color:#858585;padding:1px 2px;font-size:80%;white-space:nowrap">no gene ?</span>')}}o.append("td").html('<div style="background-color:'+m+';padding:1px 3px;font-size:70%;white-space:nowrap">'+a.a.chr+":"+a.a.position+" "+a.a.strand+"</div>"+'<div style="background-color:'+b+';padding:1px 3px;font-size:70%;white-space:nowrap">'+a.b.chr+":"+a.b.position+" "+a.b.strand+"</div>");o.append("td").html(a.a.chr==a.b.chr?B(Math.abs(a.a.position-a.b.position)):'<span style="color:'+k+'">CTX</span>');for(const e of n){if(e.hide)continue;const t=o.append("td");if(e.israting&&a.originalprod&&a.originalprod.hook.lessRating){a.originalprod.hook.lessRating=t}if(e.atpair){t.text(e.get(a))}else{t.html('<span style="background-color:'+m+';padding:2px 3px;font-size:80%">'+e.get(a.a)+"</span>"+'<span style="background-color:'+b+';padding:2px 3px;font-size:80%">'+e.get(a.b)+"</span>")}}}}}function q(e,t){const s={};const n=e.expression;n.genes=s;const o=new FileReader;const a=4096;let i=[];let r=0;o.onloadend=e=>{if(e.target.readyState!=FileReader.DONE)return;const s=e.target.result;i.push(s);const l=r>=t.size;u(l);if(l){g()}else{r+=a;n.presays.text("Reading file: "+Math.ceil(r/t.size*100)+"%");o.readAsText(t.slice(r,r+a))}};o.readAsText(t.slice(0,a));const l={},p={};let c=0,d=0;function u(e){const t=i.join("").split("\n");for(let n=0;n<t.length-1-(e?0:1);n++){const e=t[n].split("\t");if(e.length==3){const t=Number.parseFloat(e[1]);if(Number.isNaN(t)){d++}else{c++;l[e[0]]=1;p[e[2]]=1;if(!(e[0]in s)){s[e[0]]=[]}s[e[0]].push({sample:e[2],value:t})}}else{d++}}if(!e){i=[t[t.length-1]]}}function g(){let t=0;for(const e in l)t++;let s=0;for(const e in p)s++;h(n.prediv);f(n.afterdiv);n.afterdiv.selectAll("*").remove();n.afterdiv.append("div").text("Expression data loaded for "+t+" genes, "+s+" samples, "+c+" data points"+(d>0?", "+d+" bad lines":""));n.afterdiv.append("button").text("Delete").style("margin","20px").on("click",(()=>{delete n.genes;n.prediv.node().removeChild(n.input.node());n.input=n.prediv.append("input").attr("type","file").on("change",(t=>{q(e,t.target.files[0])}));n.presays.text("");h(n.afterdiv);f(n.prediv)}))}}function S(e){const t="red";e.data.sort(((e,t)=>t.value-e.value));let s=e.width?e.width:400,n=e.height?e.height:400;let o=0;for(const t of e.data){o=Math.max(o,t.value)}let a;const i=w().domain([0,o]);const r=e.holder.append("svg");const l=r.append("g");const p=r.append("g");const c=p.selectAll().data(e.data).enter().append("g");const d=c.append("circle").attr("fill","white").attr("fill-opacity",0).attr("stroke",(e=>e.ishighlight?t:"black")).attr("stroke-opacity",(e=>e.ishighlight?.7:.2)).on("mouseover",((e,s)=>{e.target.setAttribute("transform","scale(1.5)");f.text((s.sample?s.sample:s.patient+" "+s.sampletype)+" "+s.value).attr("fill",s.ishighlight?t:"black")})).on("mouseout",((e,t)=>{e.target.setAttribute("transform","scale(1)");f.text("drag to resize").attr("fill","black")}));const f=r.append("text").text("drag to resize").attr("font-size",12).attr("class","sja_svgtext").attr("font-family",v).attr("text-anchor","end").on("mousedown",(e=>{e.preventDefault();const t=e.clientX,o=e.clientY,a=s,i=n;const r=y(document.body);r.on("mousemove",(()=>{s=a+e.clientX-t;n=i+e.clientY-o;h()})).on("mouseup",(()=>{r.on("mousemove",null).on("mouseup",null)}))}));function h(){a=Math.max(5,Math.min(s,n)/40);const t=Math.min(18,Math.max(12,a*2)),o=5,h=t+o+5,u=a+5,g=a*3;i.range([0,s]);r.attr("width",a*2+s+g).attr("height",h+u+n+a*2);N({axis:l.attr("transform","translate("+a*2+","+h+")").call(_().scale(i).ticks(Math.min(10,Math.ceil(s/50)))),fontsize:t,color:"black",showline:true});p.attr("transform","translate("+a*2+","+(h+u)+")");c.attr("transform",((t,s)=>"translate("+i(t.value)+","+n*s/e.data.length+")"));d.attr("r",(e=>a*(e.ishighlight?1.5:1)));f.attr("font-size",t).attr("x",a*2+s+g-5).attr("y",h+u+n+a*2-5)}h();return this}function Q(e,t,s,n,o,a){if(!e.dataname){e.dataname="Unnamed dataset"}if(e.input){const[i,r,l]=D(e.input,s);if(i){t("Fusion Editor input error: "+i);return}O(s,r,l,e.dataname,n,o,a);return}if(!e.urls){t('neither .input:"" or .urls:[] is provided for Fusion Editor');return}if(!Array.isArray(e.urls)){t("fusioneditor.urls[] should be an array of URL strings");return}if(e.urls.length==0){t("fusioneditor.urls[] is empty");return}const i=n.append("div").style("margin","20px").style("color","#aaa").style("font-size","1.5em").text("Loading fusion gene data ...");const r=[];e.urls.forEach((e=>{r.push(fetch(new Request(o+"/urltextfile",{method:"POST",body:JSON.stringify({url:e,jwt:a})})).then((e=>e.json())).then((t=>{if(t.error)throw{message:"Error with "+e+": "+t.error};return{data:t.text,url:e}})))}));Promise.all(r).then((r=>{i.remove();if(r.length==0){t("No data retrieved from fusioneditor.urls");return}const[l,p,c]=D(r[0].data,s);if(l){t("Error parsing fusion gene data in file "+r[0].url);return}for(let e=1;e<r.length;e++){const[n,o,a]=D(r[e].data,s);if(n){t("Error parsing fusion gene data in file "+r[e].url);return}for(const e of a){c.push(e)}for(const e of o){let t=true;for(const s of p){if(s.key==e.key){t=false;break}}if(t){p.push(e)}}}if(c.length==0){t("No fusion genes parsed from fusioneditor");return}O(s,p,c,e.dataname,n,o,a)})).catch((e=>{i.remove();t(e.message);if(e.stack)console.log(e.stack)}))}function H(e,t,s,n){const[o,a,i,r,l,p]=e;a.append("div").style("margin-top","20px").html("<p>Please upload CICERO output as a text file. "+"See <a href=https://docs.google.com/document/d/1jkVYRPIJpkWvA9vqtahRlNn63Hk5DehjHbF_BH9k7Rs/edit?usp=sharing target=_blank>file format</a>.</p>"+"<p>See <a href=https://docs.google.com/document/d/1DRVzE_WenG490eRYB7VGFOygtSqtF5L97rhK0HOUCNY/edit?usp=sharing target=_blank>function usage</a>.</p>");a.append("p").html("<a href=https://proteinpaint.stjude.org/ppdemo/hg19/fusion/cicero.output target=_blank>Example file</a>");function c(e,t){l.style("color",t?"red":"black").text(e)}const d=()=>{r.selectAll("*").remove();const e=r.append("input").attr("type","file").on("change",(e=>{const o=e.target.files[0];if(!o){d();return}if(!o.size){c("Invalid file "+o.name);d();return}const l=new FileReader;l.onload=e=>{const l=i.options[i.selectedIndex].innerHTML;const f=t[l];const[h,u,g]=D(e.target.result,f);if(h){c(h,1);d();return}O(f,u,g,o.name,p,s,n);r.remove();a.remove()};l.onerror=function(){c("Error reading file "+o.name,1);d();return};l.readAsText(o,"utf8")}));setTimeout((()=>e.node().focus()),1100)};d()}function O(e,t,s,n,o,a,i){new F(e,t,s,n,o,a,i)}function D(e,t){const s=e.trim().split("\n");const[n,o]=P(s[0]);if(n){return["File header error: "+n]}const a=s[0].split("\t")[0];const i=[];const r=[];for(let e=1;e<s.length;e++){const n=s[e];if(n=="")continue;if(n[0]=="#")continue;const l=n.trim().split("\t");if(l[0]==a)continue;const p={notes:[]};for(let e=0;e<o.length;e++){if(l[e]!==undefined&&l[e].includes('"'))return['Input file has invalid character " e.g. "NM_001007565"'];p[o[e].key]=l[e]}if(!p.rating){r.push([e,"rating unspecified",l]);continue}let c=p.rating;if(c.toLowerCase()=="major"){p.rating="HQ";c="HQ"}if(c!="HQ"&&c!="LQ"&&c!="RT"&&c!="bad"){r.push([e,"invalid rating: "+p.rating,l]);continue}if(!p.chrA){r.push([e,"missing chrA",l]);continue}if(!t.chrlookup[p.chrA.toUpperCase()]){r.push([e,"invalid chrA: "+p.chrA,l]);continue}if(!p.chrB){r.push([e,"missing chrB",l]);continue}if(!t.chrlookup[p.chrB.toUpperCase()]){r.push([e,"invalid chrB: "+p.chrB,l]);continue}c=p.posA;if(!c){r.push([e,"missing posA",l]);continue}let d=Number.parseInt(c);if(Number.isNaN(d)){r.push([e,"invalid posA: "+c,l]);continue}if(d<0||d>=t.chrlookup[p.chrA.toUpperCase()]){r.push([e,"invalid posA: "+c,l]);continue}p.posA=d;c=p.posB;if(!c){r.push([e,"missing posB",l]);continue}d=Number.parseInt(c);if(isNaN(d)){r.push([e,"invalid posB: "+c,l]);continue}if(d<0||d>=t.chrlookup[p.chrB.toUpperCase()]){r.push([e,"invalid posB: "+c,l]);continue}p.posB=d;if(!p.ratioA){r.push([e,"missing ratioA",l]);continue}d=Number.parseFloat(p.ratioA);if(Number.isNaN(d)){r.push([e,"invalid value for ratioA",l]);continue}if(d>1){r.push([e,"ratioA > 100%",l]);d=1}p.ratioA=d;if(!p.ratioB){r.push([e,"missing ratioB",l]);continue}d=Number.parseFloat(p.ratioB);if(Number.isNaN(d)){r.push([e,"invalid value for ratioB",l]);continue}if(d>1){r.push([e,"ratioB > 100%",l]);d=1}p.ratioB=d;if(!p.score){r.push([e,"missing score",l]);continue}d=Number.parseFloat(p.score);if(Number.isNaN(d)){r.push([e,"invalid value for score",l]);continue}p.score=d;if(!p.readsA){r.push([e,"readsA missing",l]);continue}d=Number.parseInt(p.readsA);if(Number.isNaN(d)){r.push([e,"invalid value for readsA",l]);continue}p.readsA=d;if(!p.readsB){r.push([e,"readsB missing",l]);continue}d=Number.parseInt(p.readsB);if(Number.isNaN(d)){r.push([e,"invalid value for readsB",l]);continue}p.readsB=d;if(!p.matchA){r.push([e,"matchA missing",l]);continue}d=Number.parseInt(p.matchA);if(Number.isNaN(d)){r.push([e,"invalid value for matchA",l]);continue}p.matchA=d;if(!p.matchB){r.push([e,"matchB missing",l]);continue}d=Number.parseInt(p.matchB);if(Number.isNaN(d)){r.push([e,"invalid value for matchB",l]);continue}p.matchB=d;if(!p.repeatA){r.push([e,"repeatA missing",l]);continue}d=Number.parseFloat(p.repeatA);if(Number.isNaN(d)){r.push([e,"invalid value for repeatA",l]);continue}p.repeatA=d;if(!p.repeatB){r.push([e,"repeatB missing",l]);continue}d=Number.parseFloat(p.repeatB);if(Number.isNaN(d)){r.push([e,"invalid value for repeatB",l]);continue}p.repeatB=d;if(p.type2){switch(p.type2.toLowerCase()){case"closs":p.iscloss=true;break;case"nloss":p.isnloss=true;break;case"fusion":p.isfusion=true;break;case"itd":p.isitd=true;break;case"other":p.isother=true;break;case"uptss":p.isuptss=true;break;default:r.push([e,"unknown type2: "+p.type2,l]);continue}}if(p.geneA==""||p.geneA=="NA"){p.geneA=null}if(p.geneB==""||p.geneB=="NA"){p.geneB=null}if(p.featureA=="intergenic")p.geneA=null;if(p.featureB=="intergenic")p.geneB=null;const f=p.lstisoforma?p.lstisoforma.toUpperCase().split(","):[],h=p.lstisoformb?p.lstisoformb.toUpperCase().split(","):[],u=p.lstisoformacodon?p.lstisoformacodon.split(","):[],g=p.lstisoformbcodon?p.lstisoformbcodon.split(","):[],m=p.lstframe?p.lstframe.split(","):[];let b=null,x=null,y=null,v=null,k=null,A=null,B=null,w=null;if(p.lstisoformaexon)b=p.lstisoformaexon.split(",");if(p.lstisoformbexon)x=p.lstisoformbexon.split(",");if(p.lstisoformaanchor)y=p.lstisoformaanchor.split(",");if(p.lstisoformbanchor)v=p.lstisoformbanchor.split(",");if(p.lstcontigaaA)k=p.lstcontigaaA.split(",");if(p.lstcontigaaB)A=p.lstcontigaaB.split(",");if(p.lstcontigbpA)B=p.lstcontigbpA.split(",");if(p.lstcontigbpB)w=p.lstcontigbpB.split(",");const N=Math.max(f.length,h.length,u.length,g.length,m.length);p.pairs=[];for(let e=0;e<N;e++){const t={a:{isoform:f[e]&&f[e].length>0?f[e]:null,exon:b?Number.parseInt(b[e]):NaN,codon:u[e]?Number.parseInt(u[e]):NaN,anchor:y?y[e]:undefined},b:{isoform:h[e]&&h[e].length>0?h[e]:null,exon:x?Number.parseInt(x[e]):NaN,codon:g[e]?Number.parseInt(g[e]):NaN,anchor:v?v[e]:undefined},frame:m[e],inframe:m[e]=="1"||m[e]=="2"};if(p.isuptss){t.inframe=true}let s=NaN,n=NaN,o=NaN,a=NaN;if(k&&k[e])s=Number.parseInt(k[e]);if(A&&A[e])n=Number.parseInt(A[e]);if(B&&B[e])o=Number.parseInt(B[e]);if(w&&w[e])a=Number.parseInt(w[e]);if(!Number.isNaN(s)&&!Number.isNaN(n)){t.a.contigaa=s;t.b.contigaa=n}if(!Number.isNaN(o)&&!Number.isNaN(a)){t.a.contigbp=o;t.b.contigbp=a}p.pairs.push(t)}if(p.exception){p.notes.push(p.exception)}if(p.hlgene){const t=Number.parseInt(p.hlgene);if(Number.isNaN(t)||t!=0&&t!=1&&t!=2&&t!=3&&t!=4){r.push([e,"invalid value for highlight gene flag: "+p.hlgene,l]);delete p.hlgene}else{p.hlgene=t}}i.push(p)}if(r.length>0){const e=o.map((e=>e.key));z(e,r)}if(i.length==0){return["No data loaded"]}return[null,o,i]}function P(e){const t=e.trim().split("\t");if(t.length<=1)return["invalid file header"];const s=[];const n=[];for(const e of t){n.push(e.toLowerCase());s.push({label:e,key:e.toLowerCase(),custom:true})}const o=(...e)=>{for(const t of e){const e=n.indexOf(t);if(e!=-1)return e}return-1};let a=o("genea");if(a==-1)return["geneA missing"];s[a].key="geneA";delete s[a].custom;a=o("chra");if(a==-1)return["chrA missing"];s[a].key="chrA";delete s[a].custom;a=o("posa");if(a==-1)return["posA missing"];s[a].key="posA";delete s[a].custom;a=o("orta");if(a==-1)return["ortA missing"];s[a].key="ortA";delete s[a].custom;a=o("featurea");if(a==-1)return["featureA missing"];s[a].key="featureA";delete s[a].custom;a=o("ratioa");if(a==-1)return["ratioA missing"];s[a].key="ratioA";delete s[a].custom;a=o("readsa");if(a==-1)return["readsA missing"];s[a].key="readsA";delete s[a].custom;a=o("sv_refseqa_aa_index");if(a!=-1){s[a].key="lstcontigaaA";delete s[a].custom}a=o("sv_refseqa_contig_index");if(a!=-1){s[a].key="lstcontigbpA";delete s[a].custom}a=o("total_readsa");if(a!=-1){s[a].key="totalreadsA";delete s[a].custom}a=o("geneb");if(a==-1)return["geneB missing"];s[a].key="geneB";delete s[a].custom;a=o("chrb");if(a==-1)return["chrB missing"];s[a].key="chrB";delete s[a].custom;a=o("posb");if(a==-1)return["posB missing"];s[a].key="posB";delete s[a].custom;a=o("ortb");if(a==-1)return["ortB missing"];s[a].key="ortB";delete s[a].custom;a=o("featureb");if(a==-1)return["featureB missing"];s[a].key="featureB";delete s[a].custom;a=o("ratiob");if(a==-1)return["ratioB missing"];s[a].key="ratioB";delete s[a].custom;a=o("readsb");if(a==-1)return["readsB missing"];s[a].key="readsB";delete s[a].custom;a=o("sv_refseqb_aa_index");if(a!=-1){s[a].key="lstcontigaaB";delete s[a].custom}a=o("sv_refseqb_contig_index");if(a!=-1){s[a].key="lstcontigbpB";delete s[a].custom}a=o("total_readsb");if(a!=-1){s[a].key="totalreadsB";delete s[a].custom}a=o("sv_inframe","frame");if(a==-1)return["sv_inframe missing"];s[a].key="lstframe";delete s[a].custom;a=o("sv_refseqa");if(a==-1)return["sv_refseqA missing"];s[a].key="lstisoforma";delete s[a].custom;a=o("sv_refseqa_codon");if(a!=-1){s[a].key="lstisoformacodon"}a=o("sv_refseqb_codon");if(a!=-1){s[a].key="lstisoformbcodon"}a=o("score");if(a==-1)return["score missing"];s[a].key="score";delete s[a].custom;a=o("sv_refseqb");if(a==-1)return["sv_refseqB missing"];s[a].key="lstisoformb";delete s[a].custom;a=o("rating");if(a==-1)return["rating missing"];s[a].key="rating";delete s[a].custom;a=o("matcha");if(a==-1)return["matchA missing"];s[a].key="matchA";delete s[a].custom;a=o("matchb");if(a==-1)return["matchB missing"];s[a].key="matchB";delete s[a].custom;a=o("repeata");if(a==-1)return["repeatA missing"];s[a].key="repeatA";delete s[a].custom;a=o("repeatb");if(a==-1)return["repeatB missing"];s[a].key="repeatB";delete s[a].custom;a=o("functional effect");if(a==-1)return["functional effect missing"];s[a].key="type2";delete s[a].custom;a=o("sample");if(a!=-1){s[a].key="sample";delete s[a].custom}a=o("sv_processing_exception");if(a!=-1){s[a].key="exception"}a=o("medal");if(a!=-1){s[a].key="hlgene"}a=o("sv_refseqa_exon");if(a!=-1){s[a].key="lstisoformaexon";delete s[a].custom}a=o("sv_refseqb_exon");if(a!=-1){s[a].key="lstisoformbexon";delete s[a].custom}a=o("sv_refseqa_anchor_type");if(a!=-1){s[a].key="lstisoformaanchor";delete s[a].custom}a=o("sv_refseqb_anchor_type");if(a!=-1){s[a].key="lstisoformbanchor";delete s[a].custom}return[null,s]}export{O as svmrlaunch,Q as svmrparseinput,D as svmrparseraw,H as svmrui};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{controlsInit as t}from"./controls-
|
|
1
|
+
import{controlsInit as t}from"./controls-3c1691d7.js";import{h as e,d as s}from"./app-2cd97738.js";import"./controls.btns-5b1240c8.js";import"./controls.config-81cd5749.js";import"./termsetting-ad8c4f3a.js";import"./tslib.es6-c3c2d88f.js";import"path";class o{constructor(t){this.type="table"}async init(){const t=this.opts;const e=t.controls?null:t.holder.append("div");const s=t.controls?t.holder:t.holder.append("div");this.dom={header:t.header,controls:e,holder:s,div:s.style("margin","10px 0px").style("display","none"),inputs:["term1","overlay"]};if(this.dom.header)this.dom.header.html("Crosstab");i(this);l(this);await this.setControls()}async setControls(){if(this.opts.controls){this.opts.controls.on("downloadClick.boxplot",this.download)}else{this.dom.holder.attr("class","pp-termdb-plot-viz").style("display","inline-block").style("min-width","300px").style("margin-left","50px");this.components={controls:await t({app:this.app,id:this.id,holder:this.dom.controls.attr("class","pp-termdb-plot-controls").style("display","inline-block")})};this.components.controls.on("downloadClick.boxplot",this.download)}}getState(t,e){const s=t.plots.find((t=>t.id===this.id));if(!s){throw`No plot with id='${this.id}' found. Did you set this.id before this.api = getComponentApi(this)?`}return{activeCohort:t.activeCohort,termfilter:t.termfilter,config:{term:s.term,term2:s.term2,settings:{common:s.settings.common,table:s.settings.table}}}}async main(){try{this.config=structuredClone(this.state.config);if(!this.config.term2){this.dom.div.style("display","none");throw"term2 is required for table view"}const t=this.state.config;if(this.dom.header)this.dom.header.html(t.term.term.name+" vs "+t.term2.term.name);const e=this.getDataRequestOpts();this.data=await this.app.vocabApi.getNestedChartSeriesData(e);this.app.vocabApi.syncTermData(this.state.config,this.data);const[s,o]=this.processData(this.data);this.render(s,o)}catch(t){throw t}}getDataRequestOpts(){const t=this.config;const e={term:t.term,filter:this.state.termfilter.filter};if(t.term2)e.term2=t.term2;if(t.term0)e.term0=t.term0;if(this.state.ssid)e.ssid=this.state.ssid;return e}processData(t){const e=this.config.term2.term;const s=t.refs.rows.map((t=>{const s=e.values&&t in e.values?e.values[t].label:t;return{key:t,label:s}}));const o=t.refs.rows;const i=this.config.term.term;const l=t.refs.cols.map((e=>{const s=t.charts[0].serieses.find((t=>t.seriesId==e));const l=i.values&&e in i.values?i.values[e].label:e;return{label:l,lst:!s?[]:s.data.slice().sort(((t,e)=>o.indexOf(t.dataId)-o.indexOf(e.dataId))).map((t=>({label:t.dataId,value:t.total})))}}));return[s,l]}}function i(t){t.download=()=>{if(!t.state||!t.state.isVisible)return;const e=[];t.dom.div.selectAll("tr").each((function(){const t=[];s(this).selectAll("th, td").each((function(){t.push(s(this).text())}));e.push(t)}));const o=e.map((t=>t.join("\t"))).join("\n");const i=document.createElement("a");document.body.appendChild(i);i.addEventListener("click",(function(){i.download=t.config.term.term.name+" table.txt";i.href=URL.createObjectURL(new Blob([o],{type:"text/tab-separated-values"}));document.body.removeChild(i)}),false);i.click()}}function l(t){t.render=function e(s,o){t.dom.div.style("display","inline-block").selectAll("*").remove();const i=t.dom.div.append("table").style("margin-right","20px").style("border-spacing","3px").style("border-collapse","collapse").style("border","1px solid black");const l=i.append("tr").style("white-space","normal").style("background-color","#ececec");l.append("td");for(const t of s){const e=t.label;l.append("th").text(e.length>20?e.slice(0,16)+"...":e).attr("aria-label",e).style("border","1px solid black").style("padding","3px").style("text-align","center").style("min-width","80px").style("max-width","150px").style("word-break",e.length>12?"break-word":"normal").style("vertical-align","top")}let a=0;for(const t of o){const e=i.append("tr").style("background-color",a++%2==0?"#fff":"#ececec");e.append("th").text(t.label.length>20?t.label.slice(0,20)+"...":t.label).attr("aria-label",t.label).style("border","1px solid black").style("padding","3px").style("word-break",t.label.length>12?"break-all":"normal");const o=s.map((t=>t.key));for(const s of o){const o=e.append("td").style("border","1px solid black").style("padding","3px 5px").style("text-align","center");const i=t.lst.find((t=>t.label==s));if(i){o.html(i.value)}}}}}const a=e(o);export{a as tableInit};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{_ as t}from"./tslib.es6-c3c2d88f.js";import{d as e}from"./app-
|
|
1
|
+
import{_ as t}from"./tslib.es6-c3c2d88f.js";import{d as e}from"./app-2cd97738.js";function n({columns:t,rows:n,div:o,columnButtons:s,buttons:l,noButtonCallback:a,singleMode:i=false,noRadioBtn:c=false,showLines:d=true,striped:r=true,showHeader:p=true,maxWidth:f="90vw",maxHeight:h="40vh",selectedRows:u=[],selectAll:b=false,resize:y=false,selectedRowStyle:g={},inputName:w=null,dataTestId:m=null}){v();let k=g;function v(){if(!t||(t===null||t===void 0?void 0:t.length)==0)throw`Missing columns data`;if(!n)throw`Missing rows data`;if(!o)throw`Missing div argument`;const e=[];for(const[o,s]of n.entries()){if(s.length!=t.length)e.push(o+1)}if(e.length>0)throw`Num of row objects != num of cols. Line num(s) = ${e}`;if(l){for(const[t,e]of l.entries()){if(!e.text)throw`Missing button.text in buttons, line #${t+1}`;if(!e.callback)throw`Missing button.callback in buttons, line #${t+1}`}}}const x=w||"select"+Math.random();const _=o.append("div").style("background-color","white");if(y){if(n.length>10)_.style("height",h);_.style("max-width",f);_.style("resize","both")}else{_.style("max-height",h).style("max-width",f);if(t.length>2)_.style("resize","horizontal")}_.attr("class","sjpp_show_scrollbar");const j=_.append("table").style("width","100%");if(m){j.attr("data-testid",m)}const C=j.append("thead").style("position","sticky").style("top","0").style("background-color","white").style("padding","5px");const A=C.append("tr");if(d)A.append("td").style("width","1vw");if(l||a){const t=A.append("td").attr("class","sjpp_table_header").style("width","1.5vw");if(!i){const e=t.append("input").attr("id","checkboxHeader").attr("type","checkbox").on("change",(()=>{const t=M.selectAll("input").nodes();M.selectAll("input").property("checked",e.node().checked);if(l)I();if(a)for(const[e,n]of t.entries())a(e,n)}));e.node().checked=b;if(!p)A.append("th").text("Check/Uncheck All").attr("class","sjpp_table_header sjpp_table_item")}}if(s&&s.length>0){A.append("th").text("Actions").attr("class","sjpp_table_item sjpp_table_header")}if(p)for(const e of t){const t=A.append("th").text(e.label).attr("class","sjpp_table_item sjpp_table_header");if(e.width)t.style("width",e.width)}const M=j.append("tbody");for(const[e,o]of n.entries()){let n;const p=M.append("tr").attr("class","sjpp_row_wrapper");if(r&&e%2==1)p.style("background-color","rgb(245,245,245)");if(l||a)p.on("click",(t=>{if(t.target!==n.node()){if(i)n.node().checked=true;else n.node().checked=!n.node().checked;n.dispatch("change")}}));if(d){p.append("td").text(e+1).style("text-align","center").style("width","1vw").style("font-size","0.8rem")}if(l||a){const t=p.append("td").style("width","1.5vw").style("float","center");if(c){t.style("display","none")}n=t.append("input").attr("type",i?"radio":"checkbox").attr("name",x).attr("value",e).property("checked",b||u.includes(e)).on("change",(()=>{if(l)I();else a(e,n.node());const t=n.property("checked");for(const e in k){p.style(e,t?k[e]:"")}}));const o=n.property("checked");for(const t in g){p.style(t,o?g[t]:"")}}if(s&&s.length>0){const t=p.append("td").attr("class","sjpp_table_item");for(const n of s){n.button=t.append("button").style("white-space","normal").text(n.text).on("click",(t=>n.callback(t,e)));if(n.dataTestId){n.button.attr("data-testid",n.dataTestId)}if("disabled"in n)n.button.node().disabled=n.disabled(e)}}for(const[n,s]of o.entries()){const o=p.append("td").attr("class","sjpp_table_item");s.__td=o;const l=t[n];if(l.editCallback&&s.value){o.on("click",(t=>{t.stopImmediatePropagation();const n=o.select("input").empty();if(!n)return;o.html("");const a=o.append("input").attr("value",s.value).on("change",(()=>{const t=a.node().value;s.value=t;o.text(s.value);l.editCallback(e,s)}));a.node().focus();a.node().select()}))}if(l.width)o.style("width",l.width);if(l.align)o.style("text-align",l.align);if(l.nowrap)o.style("white-space","nowrap");if(s.url){o.append("a").text(s.value||s.value==0?s.value:s.url).attr("href",s.url).attr("target","_blank")}else if(s.html)o.html(s.html);else if("value"in s){o.text(s.value);if(s.color)o.style("color",s.color)}else if(s.color){if(s.disabled){o.style("background-color",s.color)}else{const t=o.append("input").attr("type","color").attr("value",s.color).on("change",(()=>{const n=t.node().value;s.color=n;if(l.editCallback)l.editCallback(e,s)}))}}}}if(l){const t=o.append("div").insert("div").style("display","inline-block").style("float","right").style("padding-bottom","5px");for(const e of l){e.button=t.append("button").text(e.text).style("margin","10px 10px 0 0").on("click",(()=>{e.callback(R(),e.button.node())}));if(e.class)e.button.attr("class",e.class);e.button.node().disabled=u.length==0&&!b}I()}function I(){if(!l)return;const t=R();for(const e of l){e.button.node().disabled=t.length==0;if(e.onChange)e.onChange(t,e.button.node())}}function R(){const t=M.selectAll("input:checked");const e=[];if(!t.empty()){t.each(((t,n,o)=>{const s=o[n];e.push(Number.parseInt(s.value))}))}return e}const z={update(t){if(t.selectedRowStyle){k=t.selectedRowStyle;const n=M.selectAll("tr");for(const t in k){n.style(t,(function(){return e(this).select("td input").property("checked")?k[t]:""}))}}}};return z}function o(e,n){return t(this,void 0,void 0,(function*(){const t=`table.tsv`;let o="";for(const t of n){o+=`${t.label}\t`}o+="\n";for(const t of e){for(const e of t){let t="";if(e.value)t=e.value;else if(e.url)t=e.url;else if(e.color)t=e.color;o+=`${t}\t`}o+="\n"}const s="data:text/tsv;charset=utf-8,"+encodeURIComponent(o);const l=document.createElement("a");l.setAttribute("href",s);l.setAttribute("download",t);document.body.appendChild(l);l.click();l.remove()}))}export{o as d,n as r};
|