@genome-spy/core 0.36.1 → 0.37.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/README.md +1 -0
- package/dist/{index.es.js → bundle/index.es.js} +2253 -2115
- package/dist/{index.js → bundle/index.js} +180 -44
- package/dist/src/data/collector.d.ts +36 -0
- package/dist/src/data/collector.d.ts.map +1 -0
- package/dist/src/data/collector.js +184 -0
- package/dist/src/data/collector.test.js +84 -0
- package/dist/src/data/dataFlow.d.ts +65 -0
- package/dist/src/data/dataFlow.d.ts.map +1 -0
- package/dist/src/data/dataFlow.js +142 -0
- package/dist/src/data/dataFlow.test.js +5 -0
- package/dist/src/data/facetNode.d.ts +17 -0
- package/dist/src/data/facetNode.d.ts.map +1 -0
- package/dist/src/data/facetNode.js +17 -0
- package/dist/src/data/flow.test.js +72 -0
- package/dist/src/data/flowNode.d.ts +136 -0
- package/dist/src/data/flowNode.d.ts.map +1 -0
- package/dist/src/data/flowNode.js +286 -0
- package/dist/src/data/flowNode.test.js +50 -0
- package/dist/src/data/flowOptimizer.d.ts +27 -0
- package/dist/src/data/flowOptimizer.d.ts.map +1 -0
- package/dist/src/data/flowOptimizer.js +133 -0
- package/dist/src/data/flowOptimizer.test.js +193 -0
- package/dist/src/data/flowTestUtils.d.ts +30 -0
- package/dist/src/data/flowTestUtils.d.ts.map +1 -0
- package/dist/src/data/flowTestUtils.js +63 -0
- package/dist/src/data/formats/fasta.d.ts +20 -0
- package/dist/src/data/formats/fasta.d.ts.map +1 -0
- package/dist/src/data/formats/fasta.js +32 -0
- package/dist/src/data/formats/fasta.test.js +27 -0
- package/dist/src/data/sources/dataSource.d.ts +12 -0
- package/dist/src/data/sources/dataSource.d.ts.map +1 -0
- package/dist/src/data/sources/dataSource.js +25 -0
- package/dist/src/data/sources/dataSourceFactory.d.ts +16 -0
- package/dist/src/data/sources/dataSourceFactory.d.ts.map +1 -0
- package/dist/src/data/sources/dataSourceFactory.js +127 -0
- package/dist/src/data/sources/dataUtils.d.ts +50 -0
- package/dist/src/data/sources/dataUtils.d.ts.map +1 -0
- package/dist/src/data/sources/dataUtils.js +83 -0
- package/dist/src/data/sources/dynamic/README.md +3 -0
- package/dist/src/data/sources/dynamic/axisGenomeSource.d.ts +13 -0
- package/dist/src/data/sources/dynamic/axisGenomeSource.d.ts.map +1 -0
- package/dist/src/data/sources/dynamic/axisGenomeSource.js +19 -0
- package/dist/src/data/sources/dynamic/axisTickSource.d.ts +18 -0
- package/dist/src/data/sources/dynamic/axisTickSource.d.ts.map +1 -0
- package/dist/src/data/sources/dynamic/axisTickSource.js +73 -0
- package/dist/src/data/sources/dynamic/bamSource.d.ts +46 -0
- package/dist/src/data/sources/dynamic/bamSource.d.ts.map +1 -0
- package/dist/src/data/sources/dynamic/bamSource.js +115 -0
- package/dist/src/data/sources/dynamic/bigBedSource.d.ts +51 -0
- package/dist/src/data/sources/dynamic/bigBedSource.d.ts.map +1 -0
- package/dist/src/data/sources/dynamic/bigBedSource.js +128 -0
- package/dist/src/data/sources/dynamic/bigWigSource.d.ts +58 -0
- package/dist/src/data/sources/dynamic/bigWigSource.d.ts.map +1 -0
- package/dist/src/data/sources/dynamic/bigWigSource.js +166 -0
- package/dist/src/data/sources/dynamic/gff3Source.d.ts +8 -0
- package/dist/src/data/sources/dynamic/gff3Source.d.ts.map +1 -0
- package/dist/src/data/sources/dynamic/gff3Source.js +19 -0
- package/dist/src/data/sources/dynamic/indexedFastaSource.d.ts +30 -0
- package/dist/src/data/sources/dynamic/indexedFastaSource.d.ts.map +1 -0
- package/dist/src/data/sources/dynamic/indexedFastaSource.js +86 -0
- package/dist/src/data/sources/dynamic/singleAxisLazySource.d.ts +42 -0
- package/dist/src/data/sources/dynamic/singleAxisLazySource.d.ts.map +1 -0
- package/dist/src/data/sources/dynamic/singleAxisLazySource.js +129 -0
- package/dist/src/data/sources/dynamic/tabixSource.d.ts +54 -0
- package/dist/src/data/sources/dynamic/tabixSource.d.ts.map +1 -0
- package/dist/src/data/sources/dynamic/tabixSource.js +140 -0
- package/dist/src/data/sources/dynamic/windowedMixin.d.ts +32 -0
- package/dist/src/data/sources/dynamic/windowedMixin.d.ts.map +1 -0
- package/dist/src/data/sources/dynamic/windowedMixin.js +53 -0
- package/dist/src/data/sources/inlineSource.d.ts +16 -0
- package/dist/src/data/sources/inlineSource.d.ts.map +1 -0
- package/dist/src/data/sources/inlineSource.js +68 -0
- package/dist/src/data/sources/inlineSource.test.js +56 -0
- package/dist/src/data/sources/namedSource.d.ts +25 -0
- package/dist/src/data/sources/namedSource.d.ts.map +1 -0
- package/dist/src/data/sources/namedSource.js +80 -0
- package/dist/src/data/sources/sequenceSource.d.ts +17 -0
- package/dist/src/data/sources/sequenceSource.d.ts.map +1 -0
- package/dist/src/data/sources/sequenceSource.js +47 -0
- package/dist/src/data/sources/sequenceSource.test.js +46 -0
- package/dist/src/data/sources/urlSource.d.ts +16 -0
- package/dist/src/data/sources/urlSource.d.ts.map +1 -0
- package/dist/src/data/sources/urlSource.js +74 -0
- package/dist/src/data/transforms/aggregate.d.ts +18 -0
- package/dist/src/data/transforms/aggregate.d.ts.map +1 -0
- package/dist/src/data/transforms/aggregate.js +67 -0
- package/dist/src/data/transforms/clone.d.ts +15 -0
- package/dist/src/data/transforms/clone.d.ts.map +1 -0
- package/dist/src/data/transforms/clone.js +40 -0
- package/dist/src/data/transforms/clone.test.js +11 -0
- package/dist/src/data/transforms/coverage.d.ts +30 -0
- package/dist/src/data/transforms/coverage.d.ts.map +1 -0
- package/dist/src/data/transforms/coverage.js +183 -0
- package/dist/src/data/transforms/coverage.test.js +123 -0
- package/dist/src/data/transforms/filter.d.ts +12 -0
- package/dist/src/data/transforms/filter.d.ts.map +1 -0
- package/dist/src/data/transforms/filter.js +33 -0
- package/dist/src/data/transforms/filter.test.js +18 -0
- package/dist/src/data/transforms/filterScoredLabels.d.ts +29 -0
- package/dist/src/data/transforms/filterScoredLabels.d.ts.map +1 -0
- package/dist/src/data/transforms/filterScoredLabels.js +134 -0
- package/dist/src/data/transforms/flatten.d.ts +10 -0
- package/dist/src/data/transforms/flatten.d.ts.map +1 -0
- package/dist/src/data/transforms/flatten.js +68 -0
- package/dist/src/data/transforms/flatten.test.js +93 -0
- package/dist/src/data/transforms/flattenCompressedExons.d.ts +19 -0
- package/dist/src/data/transforms/flattenCompressedExons.d.ts.map +1 -0
- package/dist/src/data/transforms/flattenCompressedExons.js +53 -0
- package/dist/src/data/transforms/flattenDelimited.d.ts +10 -0
- package/dist/src/data/transforms/flattenDelimited.d.ts.map +1 -0
- package/dist/src/data/transforms/flattenDelimited.js +66 -0
- package/dist/src/data/transforms/flattenDelimited.test.js +87 -0
- package/dist/src/data/transforms/flattenSequence.d.ts +11 -0
- package/dist/src/data/transforms/flattenSequence.d.ts.map +1 -0
- package/dist/src/data/transforms/flattenSequence.js +35 -0
- package/dist/src/data/transforms/flattenSequence.test.js +34 -0
- package/dist/src/data/transforms/formula.d.ts +13 -0
- package/dist/src/data/transforms/formula.d.ts.map +1 -0
- package/dist/src/data/transforms/formula.js +35 -0
- package/dist/src/data/transforms/formula.test.js +19 -0
- package/dist/src/data/transforms/identifier.d.ts +40 -0
- package/dist/src/data/transforms/identifier.d.ts.map +1 -0
- package/dist/src/data/transforms/identifier.js +106 -0
- package/dist/src/data/transforms/identifier.test.js +83 -0
- package/dist/src/data/transforms/linearizeGenomicCoordinate.d.ts +10 -0
- package/dist/src/data/transforms/linearizeGenomicCoordinate.d.ts.map +1 -0
- package/dist/src/data/transforms/linearizeGenomicCoordinate.js +97 -0
- package/dist/src/data/transforms/measureText.d.ts +18 -0
- package/dist/src/data/transforms/measureText.d.ts.map +1 -0
- package/dist/src/data/transforms/measureText.js +42 -0
- package/dist/src/data/transforms/pileup.d.ts +10 -0
- package/dist/src/data/transforms/pileup.d.ts.map +1 -0
- package/dist/src/data/transforms/pileup.js +126 -0
- package/dist/src/data/transforms/pileup.test.js +70 -0
- package/dist/src/data/transforms/project.d.ts +13 -0
- package/dist/src/data/transforms/project.d.ts.map +1 -0
- package/dist/src/data/transforms/project.js +38 -0
- package/dist/src/data/transforms/project.test.js +32 -0
- package/dist/src/data/transforms/regexExtract.d.ts +13 -0
- package/dist/src/data/transforms/regexExtract.d.ts.map +1 -0
- package/dist/src/data/transforms/regexExtract.js +57 -0
- package/dist/src/data/transforms/regexExtract.test.js +67 -0
- package/dist/src/data/transforms/regexFold.d.ts +14 -0
- package/dist/src/data/transforms/regexFold.d.ts.map +1 -0
- package/dist/src/data/transforms/regexFold.js +139 -0
- package/dist/src/data/transforms/regexFold.test.js +160 -0
- package/dist/src/data/transforms/sample.d.ts +42 -0
- package/dist/src/data/transforms/sample.d.ts.map +1 -0
- package/dist/src/data/transforms/sample.js +99 -0
- package/dist/src/data/transforms/sample.test.js +38 -0
- package/dist/src/data/transforms/stack.d.ts +11 -0
- package/dist/src/data/transforms/stack.d.ts.map +1 -0
- package/dist/src/data/transforms/stack.js +134 -0
- package/dist/src/data/transforms/stack.test.js +91 -0
- package/dist/src/data/transforms/transformFactory.d.ts +12 -0
- package/dist/src/data/transforms/transformFactory.d.ts.map +1 -0
- package/dist/src/data/transforms/transformFactory.js +59 -0
- package/dist/src/encoder/accessor.d.ts +15 -0
- package/dist/src/encoder/accessor.d.ts.map +1 -0
- package/dist/src/encoder/accessor.js +76 -0
- package/dist/src/encoder/accessor.test.js +47 -0
- package/dist/src/encoder/encoder.d.ts +144 -0
- package/dist/src/encoder/encoder.d.ts.map +1 -0
- package/dist/src/encoder/encoder.js +400 -0
- package/dist/src/encoder/encoder.test.js +98 -0
- package/dist/src/fonts/Lato-Regular.json +1267 -0
- package/dist/src/fonts/Lato-Regular.png +0 -0
- package/dist/src/fonts/OFL.txt +93 -0
- package/dist/src/fonts/README.md +3 -0
- package/dist/src/fonts/bmFontManager.d.ts +182 -0
- package/dist/src/fonts/bmFontManager.d.ts.map +1 -0
- package/dist/src/fonts/bmFontManager.js +359 -0
- package/dist/src/fonts/bmFontMetrics.d.ts +45 -0
- package/dist/src/fonts/bmFontMetrics.d.ts.map +1 -0
- package/dist/src/fonts/bmFontMetrics.js +108 -0
- package/dist/src/genome/genome.d.ts +172 -0
- package/dist/src/genome/genome.d.ts.map +1 -0
- package/dist/src/genome/genome.js +379 -0
- package/dist/src/genome/genome.test.js +226 -0
- package/dist/src/genome/genomeStore.d.ts +20 -0
- package/dist/src/genome/genomeStore.d.ts.map +1 -0
- package/dist/src/genome/genomeStore.js +54 -0
- package/dist/src/genome/locusFormat.d.ts +14 -0
- package/dist/src/genome/locusFormat.d.ts.map +1 -0
- package/dist/src/genome/locusFormat.js +37 -0
- package/dist/src/genome/scaleIndex.d.ts +6 -0
- package/dist/src/genome/scaleIndex.d.ts.map +1 -0
- package/dist/src/genome/scaleIndex.js +165 -0
- package/dist/src/genome/scaleIndex.test.js +78 -0
- package/dist/src/genome/scaleLocus.d.ts +3 -0
- package/dist/src/genome/scaleLocus.d.ts.map +1 -0
- package/dist/src/genome/scaleLocus.js +101 -0
- package/dist/src/genome/scaleLocus.test.js +4 -0
- package/dist/src/genomeSpy.d.ts +141 -0
- package/dist/src/genomeSpy.d.ts.map +1 -0
- package/dist/src/genomeSpy.js +788 -0
- package/dist/src/gl/arrayBuilder.d.ts +71 -0
- package/dist/src/gl/arrayBuilder.d.ts.map +1 -0
- package/dist/src/gl/arrayBuilder.js +199 -0
- package/dist/src/gl/dataToVertices.d.ts +194 -0
- package/dist/src/gl/dataToVertices.d.ts.map +1 -0
- package/dist/src/gl/dataToVertices.js +639 -0
- package/dist/src/gl/includes/common.glsl.js +2 -0
- package/dist/src/gl/includes/picking.fragment.glsl.js +2 -0
- package/dist/src/gl/includes/picking.vertex.glsl.js +2 -0
- package/dist/src/gl/includes/sampleFacet.glsl.js +2 -0
- package/dist/src/gl/includes/scales.glsl.js +2 -0
- package/dist/src/gl/link.fragment.glsl.js +2 -0
- package/dist/src/gl/link.vertex.glsl.js +2 -0
- package/dist/src/gl/point.fragment.glsl.js +2 -0
- package/dist/src/gl/point.vertex.glsl.js +2 -0
- package/dist/src/gl/rect.fragment.glsl.js +2 -0
- package/dist/src/gl/rect.vertex.glsl.js +2 -0
- package/dist/src/gl/rule.fragment.glsl.js +2 -0
- package/dist/src/gl/rule.vertex.glsl.js +2 -0
- package/dist/src/gl/text.fragment.glsl.js +2 -0
- package/dist/src/gl/text.vertex.glsl.js +2 -0
- package/dist/src/gl/webGLHelper.d.ts +118 -0
- package/dist/src/gl/webGLHelper.d.ts.map +1 -0
- package/dist/src/gl/webGLHelper.js +513 -0
- package/dist/src/img/bowtie.svg +1 -0
- package/dist/src/img/genomespy-favicon.svg +34 -0
- package/dist/src/index.d.ts +15 -0
- package/dist/src/index.d.ts.map +1 -0
- package/dist/src/index.html +11 -0
- package/dist/src/index.js +129 -0
- package/dist/src/marks/link.d.ts +11 -0
- package/dist/src/marks/link.d.ts.map +1 -0
- package/dist/src/marks/link.js +175 -0
- package/dist/src/marks/mark.d.ts +226 -0
- package/dist/src/marks/mark.d.ts.map +1 -0
- package/dist/src/marks/mark.js +1004 -0
- package/dist/src/marks/markUtils.d.ts +23 -0
- package/dist/src/marks/markUtils.d.ts.map +1 -0
- package/dist/src/marks/markUtils.js +125 -0
- package/dist/src/marks/pointMark.d.ts +11 -0
- package/dist/src/marks/pointMark.d.ts.map +1 -0
- package/dist/src/marks/pointMark.js +251 -0
- package/dist/src/marks/rectMark.d.ts +18 -0
- package/dist/src/marks/rectMark.d.ts.map +1 -0
- package/dist/src/marks/rectMark.js +255 -0
- package/dist/src/marks/rule.d.ts +6 -0
- package/dist/src/marks/rule.d.ts.map +1 -0
- package/dist/src/marks/rule.js +250 -0
- package/dist/src/marks/text.d.ts +13 -0
- package/dist/src/marks/text.d.ts.map +1 -0
- package/dist/src/marks/text.js +279 -0
- package/dist/src/scale/colorUtils.d.ts +34 -0
- package/dist/src/scale/colorUtils.d.ts.map +1 -0
- package/dist/src/scale/colorUtils.js +184 -0
- package/dist/src/scale/glslScaleGenerator.d.ts +45 -0
- package/dist/src/scale/glslScaleGenerator.d.ts.map +1 -0
- package/dist/src/scale/glslScaleGenerator.js +506 -0
- package/dist/src/scale/scale.d.ts +10 -0
- package/dist/src/scale/scale.d.ts.map +1 -0
- package/dist/src/scale/scale.js +456 -0
- package/dist/src/scale/scale.test.js +324 -0
- package/dist/src/scale/ticks.d.ts +47 -0
- package/dist/src/scale/ticks.d.ts.map +1 -0
- package/dist/src/scale/ticks.js +203 -0
- package/dist/src/scale/ticks.test.js +40 -0
- package/dist/src/singlePageApp.d.ts +2 -0
- package/dist/src/singlePageApp.d.ts.map +1 -0
- package/dist/src/singlePageApp.js +13 -0
- package/dist/src/spec/axis.d.ts +402 -0
- package/dist/src/spec/channel.d.ts +440 -0
- package/dist/src/spec/data.d.ts +370 -0
- package/dist/src/spec/font.d.ts +15 -0
- package/dist/src/spec/genome.d.ts +35 -0
- package/dist/src/spec/mark.d.ts +435 -0
- package/dist/src/spec/root.d.ts +22 -0
- package/dist/src/spec/sampleView.d.ts +185 -0
- package/dist/src/spec/scale.d.ts +273 -0
- package/dist/src/spec/title.d.ts +102 -0
- package/dist/src/spec/tooltip.d.ts +9 -0
- package/dist/src/spec/transform.d.ts +504 -0
- package/dist/src/spec/view.d.ts +214 -0
- package/dist/src/styles/genome-spy.css.d.ts +3 -0
- package/dist/src/styles/genome-spy.css.d.ts.map +1 -0
- package/dist/src/styles/genome-spy.css.js +114 -0
- package/dist/src/styles/genome-spy.scss +153 -0
- package/dist/src/tooltip/dataTooltipHandler.d.ts +2 -0
- package/dist/src/tooltip/dataTooltipHandler.d.ts.map +1 -0
- package/dist/src/tooltip/dataTooltipHandler.js +64 -0
- package/dist/src/tooltip/refseqGeneTooltipHandler.d.ts +2 -0
- package/dist/src/tooltip/refseqGeneTooltipHandler.d.ts.map +1 -0
- package/dist/src/tooltip/refseqGeneTooltipHandler.js +78 -0
- package/dist/src/tooltip/tooltipHandler.d.ts +9 -0
- package/dist/src/tooltip/tooltipHandler.d.ts.map +1 -0
- package/dist/src/tooltip/tooltipHandler.ts +12 -0
- package/dist/src/types/bmFont.d.ts +58 -0
- package/dist/src/types/embedApi.d.ts +67 -0
- package/dist/src/types/encoder.d.ts +84 -0
- package/dist/src/types/flowBatch.d.ts +40 -0
- package/dist/src/types/rendering.d.ts +65 -0
- package/dist/src/types/scaleResolutionApi.d.ts +40 -0
- package/dist/src/types/viewContext.d.ts +85 -0
- package/dist/src/utils/addBaseUrl.d.ts +6 -0
- package/dist/src/utils/addBaseUrl.d.ts.map +1 -0
- package/dist/src/utils/addBaseUrl.js +19 -0
- package/dist/src/utils/addBaseUrl.test.js +22 -0
- package/dist/src/utils/animator.d.ts +41 -0
- package/dist/src/utils/animator.d.ts.map +1 -0
- package/dist/src/utils/animator.js +83 -0
- package/dist/src/utils/arrayUtils.d.ts +34 -0
- package/dist/src/utils/arrayUtils.d.ts.map +1 -0
- package/dist/src/utils/arrayUtils.js +61 -0
- package/dist/src/utils/binnedIndex.d.ts +23 -0
- package/dist/src/utils/binnedIndex.d.ts.map +1 -0
- package/dist/src/utils/binnedIndex.js +167 -0
- package/dist/src/utils/binnedIndex.test.js +155 -0
- package/dist/src/utils/clamp.d.ts +7 -0
- package/dist/src/utils/clamp.d.ts.map +1 -0
- package/dist/src/utils/clamp.js +8 -0
- package/dist/src/utils/cloner.d.ts +16 -0
- package/dist/src/utils/cloner.d.ts.map +1 -0
- package/dist/src/utils/cloner.js +34 -0
- package/dist/src/utils/cloner.test.js +24 -0
- package/dist/src/utils/coalesce.d.ts +6 -0
- package/dist/src/utils/coalesce.d.ts.map +1 -0
- package/dist/src/utils/coalesce.js +11 -0
- package/dist/src/utils/coalesce.test.js +16 -0
- package/dist/src/utils/concatIterables.d.ts +8 -0
- package/dist/src/utils/concatIterables.d.ts.map +1 -0
- package/dist/src/utils/concatIterables.js +26 -0
- package/dist/src/utils/concatIterables.test.js +8 -0
- package/dist/src/utils/debounce.d.ts +8 -0
- package/dist/src/utils/debounce.d.ts.map +1 -0
- package/dist/src/utils/debounce.js +37 -0
- package/dist/src/utils/domainArray.d.ts +61 -0
- package/dist/src/utils/domainArray.d.ts.map +1 -0
- package/dist/src/utils/domainArray.js +216 -0
- package/dist/src/utils/domainArray.test.js +130 -0
- package/dist/src/utils/eerp.d.ts +12 -0
- package/dist/src/utils/eerp.d.ts.map +1 -0
- package/dist/src/utils/eerp.js +13 -0
- package/dist/src/utils/expression.d.ts +9 -0
- package/dist/src/utils/expression.d.ts.map +1 -0
- package/dist/src/utils/expression.js +32 -0
- package/dist/src/utils/field.d.ts +17 -0
- package/dist/src/utils/field.d.ts.map +1 -0
- package/dist/src/utils/field.js +28 -0
- package/dist/src/utils/formatObject.d.ts +7 -0
- package/dist/src/utils/formatObject.d.ts.map +1 -0
- package/dist/src/utils/formatObject.js +37 -0
- package/dist/src/utils/indexer.d.ts +16 -0
- package/dist/src/utils/indexer.d.ts.map +1 -0
- package/dist/src/utils/indexer.js +43 -0
- package/dist/src/utils/indexer.test.js +47 -0
- package/dist/src/utils/inertia.d.ts +42 -0
- package/dist/src/utils/inertia.d.ts.map +1 -0
- package/dist/src/utils/inertia.js +124 -0
- package/dist/src/utils/interactionEvent.d.ts +26 -0
- package/dist/src/utils/interactionEvent.d.ts.map +1 -0
- package/dist/src/utils/interactionEvent.js +33 -0
- package/dist/src/utils/iterateNestedMaps.d.ts +11 -0
- package/dist/src/utils/iterateNestedMaps.d.ts.map +1 -0
- package/dist/src/utils/iterateNestedMaps.js +21 -0
- package/dist/src/utils/iterateNestedMaps.test.js +33 -0
- package/dist/src/utils/kWayMerge.d.ts +9 -0
- package/dist/src/utils/kWayMerge.d.ts.map +1 -0
- package/dist/src/utils/kWayMerge.js +42 -0
- package/dist/src/utils/kWayMerge.test.js +26 -0
- package/dist/src/utils/layout/flexLayout.d.ts +182 -0
- package/dist/src/utils/layout/flexLayout.d.ts.map +1 -0
- package/dist/src/utils/layout/flexLayout.js +381 -0
- package/dist/src/utils/layout/flexLayout.test.js +323 -0
- package/dist/src/utils/layout/grid.d.ts +29 -0
- package/dist/src/utils/layout/grid.d.ts.map +1 -0
- package/dist/src/utils/layout/grid.js +95 -0
- package/dist/src/utils/layout/grid.test.js +71 -0
- package/dist/src/utils/layout/padding.d.ts +83 -0
- package/dist/src/utils/layout/padding.d.ts.map +1 -0
- package/dist/src/utils/layout/padding.js +155 -0
- package/dist/src/utils/layout/point.d.ts +16 -0
- package/dist/src/utils/layout/point.d.ts.map +1 -0
- package/dist/src/utils/layout/point.js +23 -0
- package/dist/src/utils/layout/rectangle.d.ts +142 -0
- package/dist/src/utils/layout/rectangle.d.ts.map +1 -0
- package/dist/src/utils/layout/rectangle.js +296 -0
- package/dist/src/utils/layout/rectangle.test.js +172 -0
- package/dist/src/utils/mergeObjects.d.ts +15 -0
- package/dist/src/utils/mergeObjects.d.ts.map +1 -0
- package/dist/src/utils/mergeObjects.js +99 -0
- package/dist/src/utils/mergeObjects.test.js +42 -0
- package/dist/src/utils/numberExtractor.d.ts +9 -0
- package/dist/src/utils/numberExtractor.d.ts.map +1 -0
- package/dist/src/utils/numberExtractor.js +24 -0
- package/dist/src/utils/numberExtractor.test.js +6 -0
- package/dist/src/utils/point.d.ts +9 -0
- package/dist/src/utils/point.d.ts.map +1 -0
- package/dist/src/utils/point.js +14 -0
- package/dist/src/utils/propertyCacher.d.ts +30 -0
- package/dist/src/utils/propertyCacher.d.ts.map +1 -0
- package/dist/src/utils/propertyCacher.js +70 -0
- package/dist/src/utils/propertyCacher.test.js +85 -0
- package/dist/src/utils/propertyCoalescer.d.ts +15 -0
- package/dist/src/utils/propertyCoalescer.d.ts.map +1 -0
- package/dist/src/utils/propertyCoalescer.js +42 -0
- package/dist/src/utils/propertyCoalescer.test.js +22 -0
- package/dist/src/utils/reservationMap.d.ts +42 -0
- package/dist/src/utils/reservationMap.d.ts.map +1 -0
- package/dist/src/utils/reservationMap.js +103 -0
- package/dist/src/utils/reservationMap.test.js +20 -0
- package/dist/src/utils/scaleNull.d.ts +13 -0
- package/dist/src/utils/scaleNull.d.ts.map +1 -0
- package/dist/src/utils/scaleNull.js +21 -0
- package/dist/src/utils/setOperations.d.ts +31 -0
- package/dist/src/utils/setOperations.d.ts.map +1 -0
- package/dist/src/utils/setOperations.js +75 -0
- package/dist/src/utils/smoothstep.d.ts +7 -0
- package/dist/src/utils/smoothstep.d.ts.map +1 -0
- package/dist/src/utils/smoothstep.js +10 -0
- package/dist/src/utils/throttle.d.ts +8 -0
- package/dist/src/utils/throttle.d.ts.map +1 -0
- package/dist/src/utils/throttle.js +34 -0
- package/dist/src/utils/topK.d.ts +22 -0
- package/dist/src/utils/topK.d.ts.map +1 -0
- package/dist/src/utils/topK.js +76 -0
- package/dist/src/utils/topK.test.js +64 -0
- package/dist/src/utils/transition.d.ts +44 -0
- package/dist/src/utils/transition.d.ts.map +1 -0
- package/dist/src/utils/transition.js +74 -0
- package/dist/src/utils/trees.d.ts +56 -0
- package/dist/src/utils/trees.d.ts.map +1 -0
- package/dist/src/utils/trees.js +92 -0
- package/dist/src/utils/trees.test.js +130 -0
- package/dist/src/utils/ui/tooltip.d.ts +50 -0
- package/dist/src/utils/ui/tooltip.d.ts.map +1 -0
- package/dist/src/utils/ui/tooltip.js +189 -0
- package/dist/src/utils/url.d.ts +9 -0
- package/dist/src/utils/url.d.ts.map +1 -0
- package/dist/src/utils/url.js +22 -0
- package/dist/src/utils/variableTools.d.ts +14 -0
- package/dist/src/utils/variableTools.d.ts.map +1 -0
- package/dist/src/utils/variableTools.js +24 -0
- package/dist/src/utils/variableTools.test.js +13 -0
- package/dist/src/view/axisGridView.d.ts +39 -0
- package/dist/src/view/axisGridView.d.ts.map +1 -0
- package/dist/src/view/axisGridView.js +246 -0
- package/dist/src/view/axisResolution.d.ts +24 -0
- package/dist/src/view/axisResolution.d.ts.map +1 -0
- package/dist/src/view/axisResolution.js +141 -0
- package/dist/src/view/axisResolution.test.js +201 -0
- package/dist/src/view/axisView.d.ts +49 -0
- package/dist/src/view/axisView.d.ts.map +1 -0
- package/dist/src/view/axisView.js +629 -0
- package/dist/src/view/concatView.d.ts +16 -0
- package/dist/src/view/concatView.d.ts.map +1 -0
- package/dist/src/view/concatView.js +84 -0
- package/dist/src/view/containerView.d.ts +43 -0
- package/dist/src/view/containerView.d.ts.map +1 -0
- package/dist/src/view/containerView.js +137 -0
- package/dist/src/view/facetView.d.ts +71 -0
- package/dist/src/view/facetView.d.ts.map +1 -0
- package/dist/src/view/facetView.js +492 -0
- package/dist/src/view/flowBuilder.d.ts +37 -0
- package/dist/src/view/flowBuilder.d.ts.map +1 -0
- package/dist/src/view/flowBuilder.js +383 -0
- package/dist/src/view/flowBuilder.test.js +125 -0
- package/dist/src/view/gridView.d.ts +111 -0
- package/dist/src/view/gridView.d.ts.map +1 -0
- package/dist/src/view/gridView.js +1086 -0
- package/dist/src/view/implicitRootView.d.ts +9 -0
- package/dist/src/view/implicitRootView.d.ts.map +1 -0
- package/dist/src/view/implicitRootView.js +23 -0
- package/dist/src/view/importView.d.ts +17 -0
- package/dist/src/view/importView.d.ts.map +1 -0
- package/dist/src/view/importView.js +22 -0
- package/dist/src/view/layerView.d.ts +25 -0
- package/dist/src/view/layerView.d.ts.map +1 -0
- package/dist/src/view/layerView.js +77 -0
- package/dist/src/view/renderingContext/bufferedViewRenderingContext.d.ts +30 -0
- package/dist/src/view/renderingContext/bufferedViewRenderingContext.d.ts.map +1 -0
- package/dist/src/view/renderingContext/bufferedViewRenderingContext.js +175 -0
- package/dist/src/view/renderingContext/compositeViewRenderingContext.d.ts +14 -0
- package/dist/src/view/renderingContext/compositeViewRenderingContext.d.ts.map +1 -0
- package/dist/src/view/renderingContext/compositeViewRenderingContext.js +51 -0
- package/dist/src/view/renderingContext/debuggingViewRenderingContext.d.ts +51 -0
- package/dist/src/view/renderingContext/debuggingViewRenderingContext.d.ts.map +1 -0
- package/dist/src/view/renderingContext/debuggingViewRenderingContext.js +94 -0
- package/dist/src/view/renderingContext/layoutRecorderViewRenderingContext.d.ts +60 -0
- package/dist/src/view/renderingContext/layoutRecorderViewRenderingContext.d.ts.map +1 -0
- package/dist/src/view/renderingContext/layoutRecorderViewRenderingContext.js +128 -0
- package/dist/src/view/renderingContext/simpleViewRenderingContext.d.ts +19 -0
- package/dist/src/view/renderingContext/simpleViewRenderingContext.d.ts.map +1 -0
- package/dist/src/view/renderingContext/simpleViewRenderingContext.js +64 -0
- package/dist/src/view/renderingContext/svgViewRenderingContext.d.ts +22 -0
- package/dist/src/view/renderingContext/svgViewRenderingContext.d.ts.map +1 -0
- package/dist/src/view/renderingContext/svgViewRenderingContext.js +125 -0
- package/dist/src/view/renderingContext/viewRenderingContext.d.ts +33 -0
- package/dist/src/view/renderingContext/viewRenderingContext.d.ts.map +1 -0
- package/dist/src/view/renderingContext/viewRenderingContext.js +41 -0
- package/dist/src/view/scaleResolution.d.ts +170 -0
- package/dist/src/view/scaleResolution.d.ts.map +1 -0
- package/dist/src/view/scaleResolution.js +874 -0
- package/dist/src/view/scaleResolution.test.js +658 -0
- package/dist/src/view/testUtils.d.ts +30 -0
- package/dist/src/view/testUtils.d.ts.map +1 -0
- package/dist/src/view/testUtils.js +101 -0
- package/dist/src/view/title.d.ts +6 -0
- package/dist/src/view/title.d.ts.map +1 -0
- package/dist/src/view/title.js +165 -0
- package/dist/src/view/unitView.d.ts +93 -0
- package/dist/src/view/unitView.d.ts.map +1 -0
- package/dist/src/view/unitView.js +345 -0
- package/dist/src/view/view.d.ts +291 -0
- package/dist/src/view/view.d.ts.map +1 -0
- package/dist/src/view/view.js +691 -0
- package/dist/src/view/view.test.js +214 -0
- package/dist/src/view/viewFactory.d.ts +76 -0
- package/dist/src/view/viewFactory.d.ts.map +1 -0
- package/dist/src/view/viewFactory.js +178 -0
- package/dist/src/view/viewFactory.test.js +17 -0
- package/dist/src/view/viewUtils.d.ts +90 -0
- package/dist/src/view/viewUtils.d.ts.map +1 -0
- package/dist/src/view/viewUtils.js +326 -0
- package/dist/src/view/zoom.d.ts +23 -0
- package/dist/src/view/zoom.d.ts.map +1 -0
- package/dist/src/view/zoom.js +89 -0
- package/package.json +17 -12
- package/dist/style.css +0 -1
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
import { bisector } from "d3-array";
|
|
2
|
+
import FlowNode, { BEHAVIOR_COLLECTS } from "../flowNode";
|
|
3
|
+
import { topKSlice } from "../../utils/topK";
|
|
4
|
+
import ReservationMap from "../../utils/reservationMap";
|
|
5
|
+
import { field } from "../../utils/field";
|
|
6
|
+
|
|
7
|
+
export default class FilterScoredLabelsTransform extends FlowNode {
|
|
8
|
+
get behavior() {
|
|
9
|
+
return BEHAVIOR_COLLECTS;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
*
|
|
14
|
+
* @param {import("../../spec/transform").FilterScoredLabelsParams} params
|
|
15
|
+
* @param {import("../../view/view").default} view
|
|
16
|
+
*/
|
|
17
|
+
constructor(params, view) {
|
|
18
|
+
super();
|
|
19
|
+
|
|
20
|
+
this.params = params;
|
|
21
|
+
|
|
22
|
+
/** @type {any[]} */
|
|
23
|
+
this._data = [];
|
|
24
|
+
|
|
25
|
+
this.channel = params.channel ?? "x";
|
|
26
|
+
|
|
27
|
+
if (!["x", "y"].includes(this.channel)) {
|
|
28
|
+
throw new Error("Invalid channel: " + this.channel);
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
this.posAccessor = field(this.params.pos);
|
|
32
|
+
this.posBisector = bisector(this.posAccessor);
|
|
33
|
+
this.scoreAccessor = field(this.params.score);
|
|
34
|
+
this.widthAccessor = field(this.params.width);
|
|
35
|
+
/** @type {function(any):any} */
|
|
36
|
+
this.laneAccessor = this.params.lane
|
|
37
|
+
? field(this.params.lane)
|
|
38
|
+
: (d) => 0;
|
|
39
|
+
this.padding = this.params.padding ?? 0;
|
|
40
|
+
|
|
41
|
+
/** @type {Map<any, ReservationMap>} */
|
|
42
|
+
this.reservationMaps = new Map();
|
|
43
|
+
|
|
44
|
+
this.resolution = view.getScaleResolution(this.channel);
|
|
45
|
+
|
|
46
|
+
// Synchronize propagation with rendering because we need both the domain and the range (length of the axis).
|
|
47
|
+
const callback = () => this._filterAndPropagate();
|
|
48
|
+
this.schedule = () => view.context.animator.requestTransition(callback);
|
|
49
|
+
|
|
50
|
+
// Propagate when the domain changes
|
|
51
|
+
this.resolution.addEventListener("domain", (scale) => this.schedule());
|
|
52
|
+
|
|
53
|
+
// Propagate when layout changes. Abusing a "private" method.
|
|
54
|
+
// TODO: Provide another attachment point, in view context for example
|
|
55
|
+
view._addBroadcastHandler("layoutComputed", () => this.schedule());
|
|
56
|
+
|
|
57
|
+
// TODO: Remove observers when this FlowNode is thrown away.
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
complete() {
|
|
61
|
+
const posAccessor = this.posAccessor;
|
|
62
|
+
this._data.sort((a, b) => posAccessor(a) - posAccessor(b));
|
|
63
|
+
|
|
64
|
+
this._scores = this._data.map(this.scoreAccessor);
|
|
65
|
+
|
|
66
|
+
for (const lane of new Set(this._data.map(this.laneAccessor))) {
|
|
67
|
+
this.reservationMaps.set(lane, new ReservationMap(200));
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
this.schedule();
|
|
71
|
+
|
|
72
|
+
super.complete();
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
_filterAndPropagate() {
|
|
76
|
+
super.reset();
|
|
77
|
+
|
|
78
|
+
const scale = this.resolution.getScale();
|
|
79
|
+
const rangeSpan =
|
|
80
|
+
this.resolution.members[0].view.coords?.[
|
|
81
|
+
this.channel == "x" ? "width" : "height"
|
|
82
|
+
];
|
|
83
|
+
if (!rangeSpan) {
|
|
84
|
+
// The view size is not (yet) available
|
|
85
|
+
return;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
for (const reservationMap of this.reservationMaps.values()) {
|
|
89
|
+
reservationMap.reset();
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
const domain = scale.domain();
|
|
93
|
+
const k = 70; // TODO: Configurable
|
|
94
|
+
|
|
95
|
+
// Find the maximum of k elements from the visible domain in priority order
|
|
96
|
+
const topIndices = topKSlice(
|
|
97
|
+
this._scores,
|
|
98
|
+
k,
|
|
99
|
+
this.posBisector.left(this._data, domain[0]),
|
|
100
|
+
this.posBisector.right(this._data, domain[1])
|
|
101
|
+
);
|
|
102
|
+
|
|
103
|
+
// Try to fit the elements on the available lanes and propagate if there was room
|
|
104
|
+
for (const i of topIndices) {
|
|
105
|
+
const datum = this._data[i];
|
|
106
|
+
const pos = scale(this.posAccessor(datum)) * rangeSpan;
|
|
107
|
+
const halfWidth = this.widthAccessor(datum) / 2 + this.padding;
|
|
108
|
+
|
|
109
|
+
if (
|
|
110
|
+
this.reservationMaps
|
|
111
|
+
.get(this.laneAccessor(datum))
|
|
112
|
+
.reserve(pos - halfWidth, pos + halfWidth)
|
|
113
|
+
) {
|
|
114
|
+
this._propagate(datum);
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
super.complete();
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
reset() {
|
|
122
|
+
super.reset();
|
|
123
|
+
this._data = [];
|
|
124
|
+
this.groups = new Map();
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
/**
|
|
128
|
+
*
|
|
129
|
+
* @param {import("../flowNode").Datum} datum
|
|
130
|
+
*/
|
|
131
|
+
handle(datum) {
|
|
132
|
+
this._data.push(datum);
|
|
133
|
+
}
|
|
134
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export default class FlattenTransform extends FlowNode {
|
|
2
|
+
/**
|
|
3
|
+
* @param {import("../../spec/transform").FlattenParams} params
|
|
4
|
+
*/
|
|
5
|
+
constructor(params: import("../../spec/transform").FlattenParams);
|
|
6
|
+
/** @param {any[]} datum */
|
|
7
|
+
handle: (datum: any[]) => void;
|
|
8
|
+
}
|
|
9
|
+
import FlowNode from "../flowNode";
|
|
10
|
+
//# sourceMappingURL=flatten.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"flatten.d.ts","sourceRoot":"","sources":["../../../../src/data/transforms/flatten.js"],"names":[],"mappings":"AAIA;IAKI;;OAEG;IACH,oBAFW,OAAO,sBAAsB,EAAE,aAAa,EAwDtD;IAvCO,2BAA2B;IAC3B,gBADY,GAAG,EAAE,UAwBhB;CAgBZ;qBAjEyC,aAAa"}
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import { asArray } from "../../utils/arrayUtils";
|
|
2
|
+
import { field } from "../../utils/field";
|
|
3
|
+
import FlowNode, { BEHAVIOR_CLONES } from "../flowNode";
|
|
4
|
+
|
|
5
|
+
export default class FlattenTransform extends FlowNode {
|
|
6
|
+
get behavior() {
|
|
7
|
+
return BEHAVIOR_CLONES;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* @param {import("../../spec/transform").FlattenParams} params
|
|
12
|
+
*/
|
|
13
|
+
constructor(params) {
|
|
14
|
+
super();
|
|
15
|
+
|
|
16
|
+
const indexField = params.index;
|
|
17
|
+
|
|
18
|
+
if (params.fields) {
|
|
19
|
+
const accessors = asArray(params.fields).map((f) => field(f));
|
|
20
|
+
const as = asArray(params.as || params.fields);
|
|
21
|
+
|
|
22
|
+
if (accessors.length !== as.length) {
|
|
23
|
+
throw new Error(
|
|
24
|
+
`Lengths of "fields" (${accessors.length}), and "as" (${as.length}) do not match!`
|
|
25
|
+
);
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
/** @param {any[]} datum */
|
|
29
|
+
this.handle = (datum) => {
|
|
30
|
+
// TODO: Check that the field contains an array
|
|
31
|
+
const accessedFields = accessors.map(
|
|
32
|
+
(accessor, i) => accessor(datum) ?? []
|
|
33
|
+
);
|
|
34
|
+
|
|
35
|
+
const maxLen = accessedFields[0].length;
|
|
36
|
+
|
|
37
|
+
for (let ri = 0; ri < maxLen; ri++) {
|
|
38
|
+
// TODO: use objectCloner for extra performance
|
|
39
|
+
/** @type {import("../flowNode").Datum} */
|
|
40
|
+
const newRow = Object.assign({}, datum);
|
|
41
|
+
for (let fi = 0; fi < accessors.length; fi++) {
|
|
42
|
+
newRow[as[fi]] =
|
|
43
|
+
ri < accessedFields[fi].length
|
|
44
|
+
? accessedFields[fi][ri]
|
|
45
|
+
: null;
|
|
46
|
+
}
|
|
47
|
+
if (indexField) {
|
|
48
|
+
newRow[indexField] = ri;
|
|
49
|
+
}
|
|
50
|
+
this._propagate(newRow);
|
|
51
|
+
}
|
|
52
|
+
};
|
|
53
|
+
} else {
|
|
54
|
+
/** @param {any[]} datum */
|
|
55
|
+
this.handle = (datum) => {
|
|
56
|
+
// TODO: Check that the object is an array
|
|
57
|
+
for (let i = 0; i < datum.length; i++) {
|
|
58
|
+
/** @type {import("../flowNode").Datum} */
|
|
59
|
+
const newRow = Object.assign({}, datum[i]);
|
|
60
|
+
if (indexField) {
|
|
61
|
+
newRow[indexField] = i;
|
|
62
|
+
}
|
|
63
|
+
this._propagate(newRow);
|
|
64
|
+
}
|
|
65
|
+
};
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
}
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
import { describe, expect, test } from "vitest";
|
|
2
|
+
import { processData } from "../flowTestUtils";
|
|
3
|
+
import FlattenTransform from "./flatten";
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* @param {import("./flatten").FlattenParams} params
|
|
7
|
+
* @param {any[]} data
|
|
8
|
+
*/
|
|
9
|
+
function transform(params, data) {
|
|
10
|
+
return processData(new FlattenTransform(params), data);
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
describe("Flatten transform", () => {
|
|
14
|
+
test("With a single field", () => {
|
|
15
|
+
/** @type {import("./flattenDelimited").FlattenParams} */
|
|
16
|
+
const params = { type: "flatten", fields: ["foo"] };
|
|
17
|
+
|
|
18
|
+
const input = [
|
|
19
|
+
{ name: "alpha", data: 123, foo: [1, 2] },
|
|
20
|
+
{ name: "beta", data: 456, foo: [3, 4, 5] },
|
|
21
|
+
];
|
|
22
|
+
|
|
23
|
+
expect(transform(params, input)).toEqual([
|
|
24
|
+
{ name: "alpha", data: 123, foo: 1 },
|
|
25
|
+
{ name: "alpha", data: 123, foo: 2 },
|
|
26
|
+
{ name: "beta", data: 456, foo: 3 },
|
|
27
|
+
{ name: "beta", data: 456, foo: 4 },
|
|
28
|
+
{ name: "beta", data: 456, foo: 5 },
|
|
29
|
+
]);
|
|
30
|
+
});
|
|
31
|
+
|
|
32
|
+
test("With an index field", () => {
|
|
33
|
+
/** @type {import("./flattenDelimited").FlattenParams} */
|
|
34
|
+
const params = { type: "flatten", fields: ["foo"], index: "idx" };
|
|
35
|
+
|
|
36
|
+
const input = [
|
|
37
|
+
{ name: "alpha", data: 123, foo: [1, 2] },
|
|
38
|
+
{ name: "beta", data: 456, foo: [3, 4, 5] },
|
|
39
|
+
];
|
|
40
|
+
|
|
41
|
+
expect(transform(params, input)).toEqual([
|
|
42
|
+
{ name: "alpha", data: 123, foo: 1, idx: 0 },
|
|
43
|
+
{ name: "alpha", data: 123, foo: 2, idx: 1 },
|
|
44
|
+
{ name: "beta", data: 456, foo: 3, idx: 0 },
|
|
45
|
+
{ name: "beta", data: 456, foo: 4, idx: 1 },
|
|
46
|
+
{ name: "beta", data: 456, foo: 5, idx: 2 },
|
|
47
|
+
]);
|
|
48
|
+
});
|
|
49
|
+
|
|
50
|
+
test("With multiple fields", () => {
|
|
51
|
+
/** @type {import("./flattenDelimited").FlattenParams} */
|
|
52
|
+
const params = { type: "flatten", fields: ["foo", "bar"] };
|
|
53
|
+
|
|
54
|
+
const input = [
|
|
55
|
+
{ key: "alpha", foo: [1, 2], bar: ["A", "B"] },
|
|
56
|
+
{ key: "beta", foo: [3, 4, 5], bar: ["C", "D"] },
|
|
57
|
+
];
|
|
58
|
+
|
|
59
|
+
expect(transform(params, input)).toEqual([
|
|
60
|
+
{ key: "alpha", foo: 1, bar: "A" },
|
|
61
|
+
{ key: "alpha", foo: 2, bar: "B" },
|
|
62
|
+
{ key: "beta", foo: 3, bar: "C" },
|
|
63
|
+
{ key: "beta", foo: 4, bar: "D" },
|
|
64
|
+
{ key: "beta", foo: 5, bar: null },
|
|
65
|
+
]);
|
|
66
|
+
});
|
|
67
|
+
|
|
68
|
+
test("Throws on mismatching spec lengths", () => {
|
|
69
|
+
/** @type {import("./flattenDelimited").FlattenParams} */
|
|
70
|
+
const params = {
|
|
71
|
+
type: "flatten",
|
|
72
|
+
fields: ["a", "b"],
|
|
73
|
+
as: ["a"],
|
|
74
|
+
};
|
|
75
|
+
|
|
76
|
+
expect(() => transform(params, sampleData)).toThrow();
|
|
77
|
+
});
|
|
78
|
+
|
|
79
|
+
test("Missing fields property treats the input object as an array", () => {
|
|
80
|
+
/** @type {import("./flattenDelimited").FlattenParams} */
|
|
81
|
+
const params = {
|
|
82
|
+
type: "flatten",
|
|
83
|
+
};
|
|
84
|
+
|
|
85
|
+
const input = [[{ a: 1 }], [{ a: 2 }, { a: 3 }]];
|
|
86
|
+
|
|
87
|
+
expect(transform(params, input)).toEqual([
|
|
88
|
+
{ a: 1 },
|
|
89
|
+
{ a: 2 },
|
|
90
|
+
{ a: 3 },
|
|
91
|
+
]);
|
|
92
|
+
});
|
|
93
|
+
});
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Flattens "run-length encoded" exons. The transforms inputs the start
|
|
3
|
+
* coordinate of the gene body and a comma-delimited string of alternating
|
|
4
|
+
* intron and exon lengths. A new datum is created for each exon.
|
|
5
|
+
*/
|
|
6
|
+
export default class FlattenCompressedExonsTransform extends FlowNode {
|
|
7
|
+
/**
|
|
8
|
+
*
|
|
9
|
+
* @param {import("../../spec/transform").FlattenCompressedExonsParams} params
|
|
10
|
+
*/
|
|
11
|
+
constructor(params: import("../../spec/transform").FlattenCompressedExonsParams);
|
|
12
|
+
/**
|
|
13
|
+
*
|
|
14
|
+
* @param {any} datum
|
|
15
|
+
*/
|
|
16
|
+
handle: (datum: any) => void;
|
|
17
|
+
}
|
|
18
|
+
import FlowNode from "../flowNode";
|
|
19
|
+
//# sourceMappingURL=flattenCompressedExons.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"flattenCompressedExons.d.ts","sourceRoot":"","sources":["../../../../src/data/transforms/flattenCompressedExons.js"],"names":[],"mappings":"AAIA;;;;GAIG;AACH;IAKI;;;OAGG;IACH,oBAFW,OAAO,sBAAsB,EAAE,4BAA4B,EAmCrE;IA1BG;;;OAGG;IACH,gBAFW,GAAG,UAuBb;CAER;qBAlDyC,aAAa"}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { field } from "../../utils/field";
|
|
2
|
+
import numberExtractor from "../../utils/numberExtractor";
|
|
3
|
+
import FlowNode, { BEHAVIOR_CLONES } from "../flowNode";
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Flattens "run-length encoded" exons. The transforms inputs the start
|
|
7
|
+
* coordinate of the gene body and a comma-delimited string of alternating
|
|
8
|
+
* intron and exon lengths. A new datum is created for each exon.
|
|
9
|
+
*/
|
|
10
|
+
export default class FlattenCompressedExonsTransform extends FlowNode {
|
|
11
|
+
get behavior() {
|
|
12
|
+
return BEHAVIOR_CLONES;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
*
|
|
17
|
+
* @param {import("../../spec/transform").FlattenCompressedExonsParams} params
|
|
18
|
+
*/
|
|
19
|
+
constructor(params) {
|
|
20
|
+
super();
|
|
21
|
+
|
|
22
|
+
const exonsAccessor = field(params.exons ?? "exons");
|
|
23
|
+
const startAccessor = field(params.start ?? "start");
|
|
24
|
+
const [exonStart, exonEnd] = params.as || ["exonStart", "exonEnd"];
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
*
|
|
28
|
+
* @param {any} datum
|
|
29
|
+
*/
|
|
30
|
+
this.handle = (datum) => {
|
|
31
|
+
let upper = startAccessor(datum);
|
|
32
|
+
let lower = upper;
|
|
33
|
+
|
|
34
|
+
let inExon = true;
|
|
35
|
+
const exons = exonsAccessor(datum);
|
|
36
|
+
for (const token of numberExtractor(exons)) {
|
|
37
|
+
if (inExon) {
|
|
38
|
+
lower = upper + token;
|
|
39
|
+
} else {
|
|
40
|
+
upper = lower + token;
|
|
41
|
+
|
|
42
|
+
const newRow = Object.assign({}, datum);
|
|
43
|
+
newRow[exonStart] = lower;
|
|
44
|
+
newRow[exonEnd] = upper;
|
|
45
|
+
|
|
46
|
+
this._propagate(newRow);
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
inExon = !inExon;
|
|
50
|
+
}
|
|
51
|
+
};
|
|
52
|
+
}
|
|
53
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export default class FlattenDelimitedTransform extends FlowNode {
|
|
2
|
+
/**
|
|
3
|
+
* @param {import("../../spec/transform").FlattenDelimitedParams} params
|
|
4
|
+
*/
|
|
5
|
+
constructor(params: import("../../spec/transform").FlattenDelimitedParams);
|
|
6
|
+
/** @param {any[]} datum */
|
|
7
|
+
handle: (datum: any[]) => void;
|
|
8
|
+
}
|
|
9
|
+
import FlowNode from "../flowNode";
|
|
10
|
+
//# sourceMappingURL=flattenDelimited.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"flattenDelimited.d.ts","sourceRoot":"","sources":["../../../../src/data/transforms/flattenDelimited.js"],"names":[],"mappings":"AAIA;IAKI;;OAEG;IACH,oBAFW,OAAO,sBAAsB,EAAE,sBAAsB,EAuC/D;IAnBG,2BAA2B;IAC3B,gBADY,GAAG,EAAE,UAkBhB;CAER;qBAhDyC,aAAa"}
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import { asArray } from "../../utils/arrayUtils";
|
|
2
|
+
import { field } from "../../utils/field";
|
|
3
|
+
import FlowNode, { BEHAVIOR_CLONES } from "../flowNode";
|
|
4
|
+
|
|
5
|
+
export default class FlattenDelimitedTransform extends FlowNode {
|
|
6
|
+
get behavior() {
|
|
7
|
+
return BEHAVIOR_CLONES;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* @param {import("../../spec/transform").FlattenDelimitedParams} params
|
|
12
|
+
*/
|
|
13
|
+
constructor(params) {
|
|
14
|
+
super();
|
|
15
|
+
|
|
16
|
+
// TODO: Validate config. string elements, etc...
|
|
17
|
+
|
|
18
|
+
const accessors = asArray(params.field).map((f) => field(f));
|
|
19
|
+
const separators = asArray(params.separator);
|
|
20
|
+
const as = asArray(params.as || params.field);
|
|
21
|
+
|
|
22
|
+
if (
|
|
23
|
+
accessors.length !== separators.length ||
|
|
24
|
+
accessors.length !== as.length
|
|
25
|
+
) {
|
|
26
|
+
throw new Error(
|
|
27
|
+
`Lengths of "separator" (${separators.length}), "fields" (${accessors.length}), and "as" (${as.length}) do not match!`
|
|
28
|
+
);
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
/** @param {any[]} datum */
|
|
32
|
+
this.handle = (datum) => {
|
|
33
|
+
if (accessors.some((a) => !a(datum))) return;
|
|
34
|
+
|
|
35
|
+
const splitFields = accessors.map((accessor, i) =>
|
|
36
|
+
accessor(datum).split(separators[i])
|
|
37
|
+
);
|
|
38
|
+
validateSplit(splitFields, datum);
|
|
39
|
+
const flatLen = splitFields[0].length;
|
|
40
|
+
|
|
41
|
+
for (let ri = 0; ri < flatLen; ri++) {
|
|
42
|
+
/** @type {import("../flowNode").Datum} */
|
|
43
|
+
const newRow = Object.assign({}, datum);
|
|
44
|
+
for (let fi = 0; fi < accessors.length; fi++) {
|
|
45
|
+
newRow[as[fi]] = splitFields[fi][ri];
|
|
46
|
+
}
|
|
47
|
+
this._propagate(newRow);
|
|
48
|
+
}
|
|
49
|
+
};
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
/**
|
|
54
|
+
*
|
|
55
|
+
* @param {any[]} splitFields
|
|
56
|
+
* @param {unknown} row
|
|
57
|
+
*/
|
|
58
|
+
function validateSplit(splitFields, row) {
|
|
59
|
+
const splitLengths = splitFields.map((f) => f.length);
|
|
60
|
+
if (!splitLengths.every((x) => x == splitLengths[0])) {
|
|
61
|
+
throw new Error(
|
|
62
|
+
"Mismatching number of elements in the fields to be split: " +
|
|
63
|
+
JSON.stringify(row)
|
|
64
|
+
);
|
|
65
|
+
}
|
|
66
|
+
}
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
import { describe, expect, test } from "vitest";
|
|
2
|
+
import { processData } from "../flowTestUtils";
|
|
3
|
+
import FlattenDelimitedTransform from "./flattenDelimited";
|
|
4
|
+
|
|
5
|
+
const sampleData = [
|
|
6
|
+
{ id: 1, a: "q, w, e", b: "a-s-d" },
|
|
7
|
+
{ id: 2, a: "r, t, y", b: "f-g-h" },
|
|
8
|
+
{ id: 3, a: "u", b: "j" },
|
|
9
|
+
];
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* @param {import("./flattenDelimited").FlattenDelimitedParams} params
|
|
13
|
+
* @param {any[]} data
|
|
14
|
+
*/
|
|
15
|
+
function transform(params, data) {
|
|
16
|
+
return processData(new FlattenDelimitedTransform(params), data);
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
describe("FlattenDelimited transform", () => {
|
|
20
|
+
test("With a single field", () => {
|
|
21
|
+
/** @type {import("./flattenDelimited").FlattenDelimitedParams} */
|
|
22
|
+
const config = {
|
|
23
|
+
type: "flattenDelimited",
|
|
24
|
+
field: "a",
|
|
25
|
+
separator: ", ",
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
expect(transform(config, sampleData)).toEqual([
|
|
29
|
+
{ id: 1, a: "q", b: "a-s-d" },
|
|
30
|
+
{ id: 1, a: "w", b: "a-s-d" },
|
|
31
|
+
{ id: 1, a: "e", b: "a-s-d" },
|
|
32
|
+
{ id: 2, a: "r", b: "f-g-h" },
|
|
33
|
+
{ id: 2, a: "t", b: "f-g-h" },
|
|
34
|
+
{ id: 2, a: "y", b: "f-g-h" },
|
|
35
|
+
{ id: 3, a: "u", b: "j" },
|
|
36
|
+
]);
|
|
37
|
+
});
|
|
38
|
+
|
|
39
|
+
test("With two fields", () => {
|
|
40
|
+
/** @type {import("./flattenDelimited").FlattenDelimitedParams} */
|
|
41
|
+
const config = {
|
|
42
|
+
type: "flattenDelimited",
|
|
43
|
+
field: ["a", "b"],
|
|
44
|
+
as: ["a", "c"],
|
|
45
|
+
separator: [", ", "-"],
|
|
46
|
+
};
|
|
47
|
+
|
|
48
|
+
expect(transform(config, sampleData)).toEqual([
|
|
49
|
+
{ id: 1, a: "q", b: "a-s-d", c: "a" },
|
|
50
|
+
{ id: 1, a: "w", b: "a-s-d", c: "s" },
|
|
51
|
+
{ id: 1, a: "e", b: "a-s-d", c: "d" },
|
|
52
|
+
{ id: 2, a: "r", b: "f-g-h", c: "f" },
|
|
53
|
+
{ id: 2, a: "t", b: "f-g-h", c: "g" },
|
|
54
|
+
{ id: 2, a: "y", b: "f-g-h", c: "h" },
|
|
55
|
+
{ id: 3, a: "u", b: "j", c: "j" },
|
|
56
|
+
]);
|
|
57
|
+
});
|
|
58
|
+
|
|
59
|
+
test("Throws on differing field lengths", () => {
|
|
60
|
+
const data = [
|
|
61
|
+
{
|
|
62
|
+
a: "1-2",
|
|
63
|
+
b: "1-2-3",
|
|
64
|
+
},
|
|
65
|
+
];
|
|
66
|
+
|
|
67
|
+
/** @type {import("./flattenDelimited").FlattenDelimitedParams} */
|
|
68
|
+
const config = {
|
|
69
|
+
type: "flattenDelimited",
|
|
70
|
+
field: ["a", "b"],
|
|
71
|
+
separator: ["-", "-"],
|
|
72
|
+
};
|
|
73
|
+
|
|
74
|
+
expect(() => transform(config, data)).toThrow();
|
|
75
|
+
});
|
|
76
|
+
|
|
77
|
+
test("Throws on mismatching spec lengths", () => {
|
|
78
|
+
/** @type {import("./flattenDelimited").FlattenDelimitedParams} */
|
|
79
|
+
const config = {
|
|
80
|
+
type: "flattenDelimited",
|
|
81
|
+
field: ["a", "b"],
|
|
82
|
+
separator: ["a"],
|
|
83
|
+
};
|
|
84
|
+
|
|
85
|
+
expect(() => transform(config, sampleData)).toThrow();
|
|
86
|
+
});
|
|
87
|
+
});
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export default class FlattenSequenceTransform extends FlowNode {
|
|
2
|
+
/**
|
|
3
|
+
*
|
|
4
|
+
* @param {import("../../spec/transform").FlattenSequenceParams} params
|
|
5
|
+
*/
|
|
6
|
+
constructor(params: import("../../spec/transform").FlattenSequenceParams);
|
|
7
|
+
/** @param {any[]} datum */
|
|
8
|
+
handle: (datum: any[]) => void;
|
|
9
|
+
}
|
|
10
|
+
import FlowNode from "../flowNode";
|
|
11
|
+
//# sourceMappingURL=flattenSequence.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"flattenSequence.d.ts","sourceRoot":"","sources":["../../../../src/data/transforms/flattenSequence.js"],"names":[],"mappings":"AAGA;IAKI;;;OAGG;IACH,oBAFW,OAAO,sBAAsB,EAAE,qBAAqB,EAuB9D;IAfG,2BAA2B;IAC3B,gBADY,GAAG,EAAE,UAchB;CAER;qBAjCyC,aAAa"}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { field } from "../../utils/field";
|
|
2
|
+
import FlowNode, { BEHAVIOR_CLONES } from "../flowNode";
|
|
3
|
+
|
|
4
|
+
export default class FlattenSequenceTransform extends FlowNode {
|
|
5
|
+
get behavior() {
|
|
6
|
+
return BEHAVIOR_CLONES;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
*
|
|
11
|
+
* @param {import("../../spec/transform").FlattenSequenceParams} params
|
|
12
|
+
*/
|
|
13
|
+
constructor(params) {
|
|
14
|
+
super();
|
|
15
|
+
|
|
16
|
+
const accessor = field(params.field ?? "sequence");
|
|
17
|
+
const [asPos, asSequence] = params.as ?? ["pos", "sequence"];
|
|
18
|
+
|
|
19
|
+
/** @param {any[]} datum */
|
|
20
|
+
this.handle = (datum) => {
|
|
21
|
+
// TODO: Use code generation
|
|
22
|
+
const template = Object.assign({}, datum, {
|
|
23
|
+
[asSequence]: "",
|
|
24
|
+
[asPos]: 0,
|
|
25
|
+
});
|
|
26
|
+
const sequence = /** @type {string} */ (accessor(datum));
|
|
27
|
+
for (let i = 0; i < sequence.length; i++) {
|
|
28
|
+
const newObject = Object.assign({}, template);
|
|
29
|
+
newObject[asPos] = i;
|
|
30
|
+
newObject[asSequence] = sequence.charAt(i);
|
|
31
|
+
this._propagate(newObject);
|
|
32
|
+
}
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { expect, test } from "vitest";
|
|
2
|
+
import { processData } from "../flowTestUtils";
|
|
3
|
+
import FlattenSequenceTransform from "./flattenSequence";
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* @param {import("./flattenSequence").FlattenSequenceParams} params
|
|
7
|
+
* @param {any[]} data
|
|
8
|
+
*/
|
|
9
|
+
function transform(params, data) {
|
|
10
|
+
return processData(new FlattenSequenceTransform(params), data);
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
test("FlattenSequenece", () => {
|
|
14
|
+
expect(
|
|
15
|
+
transform(
|
|
16
|
+
{
|
|
17
|
+
type: "flattenSequence",
|
|
18
|
+
field: "seq",
|
|
19
|
+
as: ["p", "seq"],
|
|
20
|
+
},
|
|
21
|
+
[
|
|
22
|
+
{ identifier: "A", seq: "TCG" },
|
|
23
|
+
{ identifier: "B", seq: "AAT" },
|
|
24
|
+
]
|
|
25
|
+
)
|
|
26
|
+
).toEqual([
|
|
27
|
+
{ identifier: "A", seq: "T", p: 0 },
|
|
28
|
+
{ identifier: "A", seq: "C", p: 1 },
|
|
29
|
+
{ identifier: "A", seq: "G", p: 2 },
|
|
30
|
+
{ identifier: "B", seq: "A", p: 0 },
|
|
31
|
+
{ identifier: "B", seq: "A", p: 1 },
|
|
32
|
+
{ identifier: "B", seq: "T", p: 2 },
|
|
33
|
+
]);
|
|
34
|
+
});
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export default class FormulaTransform extends FlowNode {
|
|
2
|
+
/**
|
|
3
|
+
*
|
|
4
|
+
* @param {import("../../spec/transform").FormulaParams} params
|
|
5
|
+
*/
|
|
6
|
+
constructor(params: import("../../spec/transform").FormulaParams);
|
|
7
|
+
params: import("../../spec/transform").FormulaParams;
|
|
8
|
+
as: string;
|
|
9
|
+
/** @type {(datum: any) => any} */
|
|
10
|
+
fn: (datum: any) => any;
|
|
11
|
+
}
|
|
12
|
+
import FlowNode from "../flowNode";
|
|
13
|
+
//# sourceMappingURL=formula.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"formula.d.ts","sourceRoot":"","sources":["../../../../src/data/transforms/formula.js"],"names":[],"mappings":"AAGA;IAKI;;;OAGG;IACH,oBAFW,OAAO,sBAAsB,EAAE,aAAa,EAUtD;IANG,qDAAoB;IAEpB,WAAmB;IAEnB,kCAAkC;IAClC,YADmB,GAAG,KAAK,GAAG,CACX;CAe1B;qBAjC2C,aAAa"}
|