@genome-spy/core 0.51.0 → 0.53.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/bundle/{index-C8lYPtq_.js → index-B5cesONJ.js} +21 -21
- package/dist/bundle/index-BJLu48Hz.js +274 -0
- package/dist/bundle/{index-Sk-Wtwdn.js → index-BywMLhhd.js} +963 -989
- package/dist/bundle/{index-BwFvhduA.js → index-CSayoXbw.js} +7 -9
- package/dist/bundle/{index-CkI3Kd2P.js → index-DAJ8JQLE.js} +6 -5
- package/dist/bundle/{index-BtRKzKhM.js → index-_tI-fMQF.js} +414 -415
- package/dist/bundle/{index-CmBp-spD.js → index-e0oKgZbZ.js} +36 -36
- package/dist/bundle/{index-Z7JiNsFI.js → index-oqw_s02W.js} +10 -11
- package/dist/bundle/{index-mihmTLo-.js → index-uO0O4Uv-.js} +22 -22
- package/dist/bundle/index.es.js +4088 -4006
- package/dist/bundle/index.js +233 -112
- package/dist/bundle/{long-CYrAUkxh.js → long-D4tVjLLz.js} +5 -5
- package/dist/bundle/remoteFile-BkTxwFub.js +90 -0
- package/dist/schema.json +53 -12
- package/dist/src/data/sources/dataUtils.d.ts +5 -0
- package/dist/src/data/sources/dataUtils.d.ts.map +1 -1
- package/dist/src/data/sources/dataUtils.js +9 -0
- package/dist/src/data/sources/lazy/axisTickSource.js +1 -1
- package/dist/src/data/sources/lazy/bamSource.d.ts.map +1 -1
- package/dist/src/data/sources/lazy/bigBedSource.d.ts.map +1 -1
- package/dist/src/data/sources/lazy/bigWigSource.js +1 -1
- package/dist/src/data/sources/lazy/singleAxisLazySource.d.ts +4 -6
- package/dist/src/data/sources/lazy/singleAxisLazySource.d.ts.map +1 -1
- package/dist/src/data/sources/lazy/singleAxisLazySource.js +4 -18
- package/dist/src/data/sources/urlSource.d.ts.map +1 -1
- package/dist/src/data/sources/urlSource.js +12 -7
- package/dist/src/data/transforms/clone.d.ts +1 -2
- package/dist/src/data/transforms/clone.d.ts.map +1 -1
- package/dist/src/data/transforms/clone.js +19 -4
- package/dist/src/data/transforms/filterScoredLabels.d.ts.map +1 -1
- package/dist/src/data/transforms/filterScoredLabels.js +1 -4
- package/dist/src/data/transforms/transformFactory.d.ts.map +1 -1
- package/dist/src/encoder/encoder.d.ts +1 -1
- package/dist/src/encoder/encoder.d.ts.map +1 -1
- package/dist/src/fonts/bmFontMetrics.d.ts.map +1 -1
- package/dist/src/genome/genome.d.ts +24 -2
- package/dist/src/genome/genome.d.ts.map +1 -1
- package/dist/src/genome/genome.js +66 -28
- package/dist/src/genome/genome.test.js +43 -1
- package/dist/src/genome/genomes.d.ts +8 -0
- package/dist/src/genome/genomes.d.ts.map +1 -0
- package/dist/src/genome/genomes.js +164 -0
- package/dist/src/genome/genomes.test.d.ts +2 -0
- package/dist/src/genome/genomes.test.d.ts.map +1 -0
- package/dist/src/genome/genomes.test.js +8 -0
- package/dist/src/genomeSpy.d.ts.map +1 -1
- package/dist/src/gl/dataToVertices.d.ts.map +1 -1
- package/dist/src/gl/glslScaleGenerator.d.ts.map +1 -1
- package/dist/src/spec/axis.d.ts +0 -2
- package/dist/src/spec/genome.d.ts +19 -6
- package/dist/src/spec/scale.d.ts +1 -1
- package/dist/src/utils/addBaseUrl.d.ts +6 -0
- package/dist/src/utils/addBaseUrl.d.ts.map +1 -1
- package/dist/src/utils/addBaseUrl.js +18 -0
- package/dist/src/utils/addBaseUrl.test.js +9 -1
- package/dist/src/utils/cloner.d.ts +8 -2
- package/dist/src/utils/cloner.d.ts.map +1 -1
- package/dist/src/utils/cloner.js +19 -2
- package/dist/src/utils/cloner.test.js +16 -5
- package/dist/src/utils/expression.d.ts.map +1 -1
- package/dist/src/utils/ui/tooltip.d.ts +1 -1
- package/dist/src/utils/ui/tooltip.d.ts.map +1 -1
- package/dist/src/view/layerView.d.ts.map +1 -1
- package/dist/src/view/layerView.js +4 -1
- package/dist/src/view/paramMediator.d.ts +8 -3
- package/dist/src/view/paramMediator.d.ts.map +1 -1
- package/dist/src/view/paramMediator.js +3 -1
- package/dist/src/view/scaleResolution.d.ts +9 -0
- package/dist/src/view/scaleResolution.d.ts.map +1 -1
- package/dist/src/view/scaleResolution.js +30 -0
- package/dist/src/view/view.d.ts +20 -3
- package/dist/src/view/view.d.ts.map +1 -1
- package/dist/src/view/view.js +30 -2
- package/dist/src/view/view.test.js +15 -5
- package/dist/src/view/zoom.d.ts.map +1 -1
- package/package.json +2 -2
- package/dist/bundle/index-Dixm7K89.js +0 -279
- package/dist/bundle/remoteFile-1_eCK3VV.js +0 -96
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tooltip.d.ts","sourceRoot":"","sources":["../../../../src/utils/ui/tooltip.js"],"names":[],"mappings":"AAIA,gEAAiE;AAEjE;IACI;;OAEG;IACH,uBAFW,WAAW,EAsBrB;IAnBG,uBAA0B;IAE1B,wBAA4C;IAE5C,kBAAoB;IAGpB,kBAAkB;IAClB,uBADW,GAAG,CACwB;IAEtC,wBAA0B;IAE1B,sBAAsB;IACtB,+BAA+B;IAC/B,aADW,CAAC,MAAM,EAAE,MAAM,CAAC,CACC;IAE5B,sBAAsB;IAK1B;;OAEG;IACH,
|
|
1
|
+
{"version":3,"file":"tooltip.d.ts","sourceRoot":"","sources":["../../../../src/utils/ui/tooltip.js"],"names":[],"mappings":"AAIA,gEAAiE;AAEjE;IACI;;OAEG;IACH,uBAFW,WAAW,EAsBrB;IAnBG,uBAA0B;IAE1B,wBAA4C;IAE5C,kBAAoB;IAGpB,kBAAkB;IAClB,uBADW,GAAG,CACwB;IAEtC,wBAA0B;IAE1B,sBAAsB;IACtB,+BAA+B;IAC/B,aADW,CAAC,MAAM,EAAE,MAAM,CAAC,CACC;IAE5B,sBAAsB;IAK1B;;OAEG;IACH,8BAKC;IAED,uBAEC;IAED,uBAEC;IAED;;OAEG;IACH,0BAFW,OAAO,QAOjB;IAED,wBAEC;IAED;;OAEG;IACH,4BAFW,UAAU,QAkCpB;IA/BG,8BAA0D;IAiC9D,wBAiBC;IAED;;OAEG;IACH,oBAFW,MAAM,GAAG,OAAO,KAAK,EAAE,cAAc,GAAG,WAAW,QAiB7D;IAED,cAGC;IAED;;;;;;;OAOG;IACH,sDAHuB,QAAQ,MAAM,GAAG,WAAW,GAAG,OAAO,KAAK,EAAE,cAAc,CAAC,QAmBlF;IAED,sBAEC;CACJ"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"layerView.d.ts","sourceRoot":"","sources":["../../../src/view/layerView.js"],"names":[],"mappings":"AAIA;IAQI;;;;;;;;OAQG;IACH,kBAPW,OAAO,iBAAiB,EAAE,SAAS,WACnC,OAAO,yBAAyB,EAAE,OAAO,gBACzC,aAAa,cACb,OAAO,WAAW,EAAE,OAAO,QAC3B,MAAM,YACN,OAAO,WAAW,EAAE,WAAW,
|
|
1
|
+
{"version":3,"file":"layerView.d.ts","sourceRoot":"","sources":["../../../src/view/layerView.js"],"names":[],"mappings":"AAIA;IAQI;;;;;;;;OAQG;IACH,kBAPW,OAAO,iBAAiB,EAAE,SAAS,WACnC,OAAO,yBAAyB,EAAE,OAAO,gBACzC,aAAa,cACb,OAAO,WAAW,EAAE,OAAO,QAC3B,MAAM,YACN,OAAO,WAAW,EAAE,WAAW,EAWzC;IAHG,0CAAgB;IAoCpB,gEAEC;;CA6CJ;0BA7GyB,oBAAoB"}
|
|
@@ -20,7 +20,10 @@ export default class LayerView extends ContainerView {
|
|
|
20
20
|
* @param {import("./view.js").ViewOptions} [options]
|
|
21
21
|
*/
|
|
22
22
|
constructor(spec, context, layoutParent, dataParent, name, options) {
|
|
23
|
-
super(spec, context, layoutParent, dataParent, name,
|
|
23
|
+
super(spec, context, layoutParent, dataParent, name, {
|
|
24
|
+
layersChildren: true,
|
|
25
|
+
...options,
|
|
26
|
+
});
|
|
24
27
|
|
|
25
28
|
this.spec = spec;
|
|
26
29
|
|
|
@@ -55,6 +55,9 @@ export function makeConstantExprRef(value: any): ExprRefFunction;
|
|
|
55
55
|
* A class that manages parameters and expressions.
|
|
56
56
|
* Supports nesting and scoped parameters.
|
|
57
57
|
*
|
|
58
|
+
* TODO: The proposed JavaScript signals may provide a better way to implement this.
|
|
59
|
+
* https://github.com/proposal-signals/proposal-signals
|
|
60
|
+
*
|
|
58
61
|
* @typedef {import("../utils/expression.js").ExpressionFunction & { addListener: (listener: () => void) => void, invalidate: () => void, identifier: () => string}} ExprRefFunction
|
|
59
62
|
*/
|
|
60
63
|
export default class ParamMediator {
|
|
@@ -107,9 +110,8 @@ export default class ParamMediator {
|
|
|
107
110
|
*
|
|
108
111
|
* @param {string} paramName
|
|
109
112
|
* @returns {ParamMediator}
|
|
110
|
-
* @protected
|
|
111
113
|
*/
|
|
112
|
-
|
|
114
|
+
findMediatorForParam(paramName: string): ParamMediator;
|
|
113
115
|
/**
|
|
114
116
|
* Parse expr and return a function that returns the value of the parameter.
|
|
115
117
|
*
|
|
@@ -134,8 +136,11 @@ export default class ParamMediator {
|
|
|
134
136
|
/**
|
|
135
137
|
* A class that manages parameters and expressions.
|
|
136
138
|
* Supports nesting and scoped parameters.
|
|
139
|
+
*
|
|
140
|
+
* TODO: The proposed JavaScript signals may provide a better way to implement this.
|
|
141
|
+
* https://github.com/proposal-signals/proposal-signals
|
|
137
142
|
*/
|
|
138
|
-
export type ExprRefFunction =
|
|
143
|
+
export type ExprRefFunction = import("../utils/expression.js").ExpressionFunction & {
|
|
139
144
|
addListener: (listener: () => void) => void;
|
|
140
145
|
invalidate: () => void;
|
|
141
146
|
identifier: () => string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"paramMediator.d.ts","sourceRoot":"","sources":["../../../src/view/paramMediator.js"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"paramMediator.d.ts","sourceRoot":"","sources":["../../../src/view/paramMediator.js"],"names":[],"mappings":"AAoUA;;;GAGG;AACH,6BAHW,GAAG,+CAKb;AAED;;;;;;;GAOG;AACH,oFASC;AAED;;;GAGG;AACH,gJAEC;AAED;;;GAGG;AACH,gMAEC;AAED;;;;;;;;;;GAUG;AACH,mFANW,aAAa,+CAEW,IAAI,KAwCtC;AAED;;;;;;GAMG;AACH,4CAHW,MAAM,GACJ,MAAM,CAUlB;AAED;;;;;;;GAOG;AACH,2CAHW,GAAG,GACD,eAAe,CAW3B;AA9bD;;;;;;;;GAQG;AACH;IA2BI;;;;;OAKG;IACH,2BALW,MAAM,aAAa,EAU7B;IA7BD;;;OAGG;IACH,0BAHU,IAAI,MAAM,EAAE,IAAI,MAAM,IAAI,CAAC,CAAC,CAGvB;IA2Bf;;;OAGG;IACH,wEAzCqB,GAAG,KAAK,IAAI,CAmGhC;IAED;;;;;;;OAOG;IACH,6BANW,MAAM,6BAEN,OAAO,iBACS,IAAI,CAgC9B;IAED;;;OAGG;IACH,qBAFW,MAAM,WAlIc,GAAG,KAAK,IAAI,CA0I1C;IAED;;;OAGG;IACH,oBAFW,MAAM,OAIhB;IAED;;;OAGG;IACH,qBAFW,MAAM,OAKhB;IAED;;OAEG;IACH,kFAIC;IAED;;;;OAIG;IACH,gCAHW,MAAM,GACJ,aAAa,CAQzB;IAID;;;;OAIG;IACH,uBAFW,MAAM,mBA4EhB;IAED;;;;OAIG;IACH,qBAFW,MAAM,OAKhB;IAED;;;;;OAKG;IACH,sBAFa,OAAO,CAiBnB;;CACJ;;;;;;;;8BAvTY,OAAO,wBAAwB,EAAE,kBAAkB,GAAG;IAAE,WAAW,EAAE,CAAC,QAAQ,EAAE,MAAM,IAAI,KAAK,IAAI,CAAC;IAAC,UAAU,EAAE,MAAM,IAAI,CAAC;IAAC,UAAU,EAAE,MAAM,MAAM,CAAA;CAAC"}
|
|
@@ -6,6 +6,9 @@ import { createSinglePointSelection } from "../selection/selection.js";
|
|
|
6
6
|
* A class that manages parameters and expressions.
|
|
7
7
|
* Supports nesting and scoped parameters.
|
|
8
8
|
*
|
|
9
|
+
* TODO: The proposed JavaScript signals may provide a better way to implement this.
|
|
10
|
+
* https://github.com/proposal-signals/proposal-signals
|
|
11
|
+
*
|
|
9
12
|
* @typedef {import("../utils/expression.js").ExpressionFunction & { addListener: (listener: () => void) => void, invalidate: () => void, identifier: () => string}} ExprRefFunction
|
|
10
13
|
*/
|
|
11
14
|
export default class ParamMediator {
|
|
@@ -193,7 +196,6 @@ export default class ParamMediator {
|
|
|
193
196
|
*
|
|
194
197
|
* @param {string} paramName
|
|
195
198
|
* @returns {ParamMediator}
|
|
196
|
-
* @protected
|
|
197
199
|
*/
|
|
198
200
|
findMediatorForParam(paramName) {
|
|
199
201
|
if (this.#paramValues.has(paramName)) {
|
|
@@ -126,6 +126,15 @@ export default class ScaleResolution implements ScaleResolutionApi {
|
|
|
126
126
|
* be generalized to other quantitative channels such as color, opacity, size, etc.
|
|
127
127
|
*/
|
|
128
128
|
getZoomLevel(): number;
|
|
129
|
+
/**
|
|
130
|
+
* Returns the length of the axis in pixels. Chooses the smallest of the views.
|
|
131
|
+
* They should all be the same, but some exotic configuration might break that assumption.
|
|
132
|
+
*
|
|
133
|
+
* This method is needed because positional channels have unit ranges and the
|
|
134
|
+
* length of the axis is not directly available from the scale. Ideally, ranges would
|
|
135
|
+
* be configured as pixels, but that is yet to be materialized.
|
|
136
|
+
*/
|
|
137
|
+
getAxisLength(): number;
|
|
129
138
|
/**
|
|
130
139
|
*
|
|
131
140
|
* @returns {import("../genome/genome.js").default}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"scaleResolution.d.ts","sourceRoot":"","sources":["../../../src/view/scaleResolution.js"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"scaleResolution.d.ts","sourceRoot":"","sources":["../../../src/view/scaleResolution.js"],"names":[],"mappings":"AA88BA;;;;;;;;;;GAUG;AACH,6CAFW,OAAO,WAAW,EAAE,OAAO,GAAG,OAAO,WAAW,EAAE,OAAO,EAAE,QA4BrE;AAt8BD,0CAA2C;AAC3C,gCAAiC;AACjC,gCAAiC;AACjC,4BAA6B;AAC7B,4BAA6B;AAE7B;;;;;;;;GAQG;AACH;;;;;;;GAOG;AACH;IAyCI;;OAEG;IACH,2DASC;IARG,8CAAsB;IACtB,yDAAyD;IACzD,SADW,qBAAqB,EAAE,CACjB;IACjB,0FAA0F;IAC1F,MADW,OAAO,oBAAoB,EAAE,IAAI,CAC5B;IAEhB,iEAAiE;IACjE,MADW,MAAM,CACI;IAWzB;;;;;;;OAOG;IACH,4KAEC;IAED;;;OAGG;IACH,+KAEC;IAcD;;;;;OAKG;IACH,qBAFW,qBAAqB,QA4B/B;IA8MD;;;;OAIG;IACH,+DAOC;IAED;;OAEG;IACH,oBAyCC;IAED;;OAEG;IACH;eA5XkC,OAAO,kBAAkB,EAAE,KAAK;MAwajE;IAED,mBAEC;IAED;;OAEG;IACH,oBAFa,mFAA6B,CAOzC;IAED;;;;OAIG;IACH,oBAKC;IAED;;OAEG;IACH,sBAGC;IAUD;;;;;;;OAOG;IACH,kBALW,MAAM,eACN,MAAM,OACN,MAAM,GACJ,OAAO,CAwEnB;IAED;;;;;;OAMG;IACH,eAJW,mFAA6B,aAC7B,OAAO,GAAG,MAAM,iBA0D1B;IAED;;;;OAIG;IACH,qBAcC;IAED;;;;;OAKG;IACH,uBAOC;IAED;;;;;;;OAOG;IACH,wBAoBC;IA8DD;;;OAGG;IACH,aAFa,OAAO,qBAAqB,EAAE,OAAO,CAajD;IAID;;;;;OAKG;IACH,uBAFW,MAAM,yDAUhB;IAED;;OAEG;IACH,iBAFW,MAAM,yDAKhB;IAED;;;OAGG;IACH,6EAFa,MAAM,CAQlB;IAED;;;OAGG;IACH,mHAFa,MAAM,EAAE,CAOpB;;CACJ;;;;;UAh0BS,OAAO,eAAe,EAAE,OAAO;aAC/B,CAAC;gBACD,OAAO,oBAAoB,EAAE,mBAAmB;qFACd,OAAO,oBAAoB,EAAE,IAAI"}
|
|
@@ -730,6 +730,36 @@ export default class ScaleResolution {
|
|
|
730
730
|
return 1.0;
|
|
731
731
|
}
|
|
732
732
|
|
|
733
|
+
/**
|
|
734
|
+
* Returns the length of the axis in pixels. Chooses the smallest of the views.
|
|
735
|
+
* They should all be the same, but some exotic configuration might break that assumption.
|
|
736
|
+
*
|
|
737
|
+
* This method is needed because positional channels have unit ranges and the
|
|
738
|
+
* length of the axis is not directly available from the scale. Ideally, ranges would
|
|
739
|
+
* be configured as pixels, but that is yet to be materialized.
|
|
740
|
+
*/
|
|
741
|
+
getAxisLength() {
|
|
742
|
+
if (this.channel !== "x" && this.channel !== "y") {
|
|
743
|
+
throw new Error(
|
|
744
|
+
"Axis length is only defined for x and y channels!"
|
|
745
|
+
);
|
|
746
|
+
}
|
|
747
|
+
|
|
748
|
+
// Here's a problem: if the view has been hidden, it may have stale coords.
|
|
749
|
+
// TODO: They should be cleared when the layout is invalidated.
|
|
750
|
+
// Alternatively, scale ranges could be set in pixels.
|
|
751
|
+
const lengths = this.members
|
|
752
|
+
.map(
|
|
753
|
+
(m) =>
|
|
754
|
+
m.view.coords?.[this.channel === "x" ? "width" : "height"]
|
|
755
|
+
)
|
|
756
|
+
.filter((len) => len > 0);
|
|
757
|
+
|
|
758
|
+
return lengths.length
|
|
759
|
+
? lengths.reduce((a, b) => Math.min(a, b), 10000)
|
|
760
|
+
: 0;
|
|
761
|
+
}
|
|
762
|
+
|
|
733
763
|
#getZoomExtent() {
|
|
734
764
|
const props = this.scale.props;
|
|
735
765
|
const zoom = props.zoom;
|
package/dist/src/view/view.d.ts
CHANGED
|
@@ -28,7 +28,11 @@ export const VISIT_STOP: "VISIT_STOP";
|
|
|
28
28
|
* @prop {boolean} [blockEncodingInheritance]
|
|
29
29
|
* Don't inherit encodings from parent. Default: false.
|
|
30
30
|
* @prop {boolean} [contributesToScaleDomain]
|
|
31
|
-
* Whether ScaleResolution should include this view or its children in the
|
|
31
|
+
* Whether ScaleResolution should include this view or its children in the
|
|
32
|
+
* domain. Default: true
|
|
33
|
+
* @prop {boolean} [layersChildren]
|
|
34
|
+
* View's children are layered on top of each other and they have the same
|
|
35
|
+
* coordinates as their parent.
|
|
32
36
|
*/
|
|
33
37
|
export default class View {
|
|
34
38
|
/**
|
|
@@ -76,12 +80,19 @@ export default class View {
|
|
|
76
80
|
*/
|
|
77
81
|
blockEncodingInheritance: boolean;
|
|
78
82
|
/**
|
|
79
|
-
* Whether ScaleResolution should include this view or its children in the
|
|
83
|
+
* Whether ScaleResolution should include this view or its children in the
|
|
84
|
+
* domain. Default: true
|
|
80
85
|
*/
|
|
81
86
|
contributesToScaleDomain: boolean;
|
|
87
|
+
/**
|
|
88
|
+
* View's children are layered on top of each other and they have the same
|
|
89
|
+
* coordinates as their parent.
|
|
90
|
+
*/
|
|
91
|
+
layersChildren?: boolean;
|
|
82
92
|
};
|
|
83
93
|
/**
|
|
84
94
|
* Whether GridView or equivalent should draw axis and grid lines for this view.
|
|
95
|
+
* TODO: Use view options for this.
|
|
85
96
|
* @type {Record<import("../spec/channel.js").PrimaryPositionalChannel, boolean>}
|
|
86
97
|
*/
|
|
87
98
|
needsAxes: Record<import("../spec/channel.js").PrimaryPositionalChannel, boolean>;
|
|
@@ -328,9 +339,15 @@ export type ViewOptions = {
|
|
|
328
339
|
*/
|
|
329
340
|
blockEncodingInheritance?: boolean;
|
|
330
341
|
/**
|
|
331
|
-
* Whether ScaleResolution should include this view or its children in the
|
|
342
|
+
* Whether ScaleResolution should include this view or its children in the
|
|
343
|
+
* domain. Default: true
|
|
332
344
|
*/
|
|
333
345
|
contributesToScaleDomain?: boolean;
|
|
346
|
+
/**
|
|
347
|
+
* View's children are layered on top of each other and they have the same
|
|
348
|
+
* coordinates as their parent.
|
|
349
|
+
*/
|
|
350
|
+
layersChildren?: boolean;
|
|
334
351
|
};
|
|
335
352
|
import ParamMediator from "./paramMediator.js";
|
|
336
353
|
import Padding from "./layout/padding.js";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"view.d.ts","sourceRoot":"","sources":["../../../src/view/view.js"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"view.d.ts","sourceRoot":"","sources":["../../../src/view/view.js"],"names":[],"mappings":"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"}
|
package/dist/src/view/view.js
CHANGED
|
@@ -18,6 +18,7 @@ import { peek } from "../utils/arrayUtils.js";
|
|
|
18
18
|
import ViewError from "./viewError.js";
|
|
19
19
|
import ParamMediator, { isExprRef } from "./paramMediator.js";
|
|
20
20
|
import { InternMap } from "internmap";
|
|
21
|
+
import { endWithSlash } from "../utils/addBaseUrl.js";
|
|
21
22
|
|
|
22
23
|
// TODO: View classes have too many responsibilities. Come up with a way
|
|
23
24
|
// to separate the concerns. However, most concerns are tightly tied to
|
|
@@ -58,7 +59,11 @@ const defaultOpacityFunction = (parentOpacity) => parentOpacity;
|
|
|
58
59
|
* @prop {boolean} [blockEncodingInheritance]
|
|
59
60
|
* Don't inherit encodings from parent. Default: false.
|
|
60
61
|
* @prop {boolean} [contributesToScaleDomain]
|
|
61
|
-
* Whether ScaleResolution should include this view or its children in the
|
|
62
|
+
* Whether ScaleResolution should include this view or its children in the
|
|
63
|
+
* domain. Default: true
|
|
64
|
+
* @prop {boolean} [layersChildren]
|
|
65
|
+
* View's children are layered on top of each other and they have the same
|
|
66
|
+
* coordinates as their parent.
|
|
62
67
|
*/
|
|
63
68
|
export default class View {
|
|
64
69
|
/** @type {Record<string, (function(BroadcastMessage):void)[]>} */
|
|
@@ -70,6 +75,12 @@ export default class View {
|
|
|
70
75
|
/** @type {Record<string, InteractionEventListener[]>} */
|
|
71
76
|
#nonCapturingInteractionEventListeners = {};
|
|
72
77
|
|
|
78
|
+
/** @type {(value: number) => void} */
|
|
79
|
+
#widthSetter;
|
|
80
|
+
|
|
81
|
+
/** @type {(value: number) => void} */
|
|
82
|
+
#heightSetter;
|
|
83
|
+
|
|
73
84
|
/**
|
|
74
85
|
* @type {function(number):number}
|
|
75
86
|
*/
|
|
@@ -127,6 +138,7 @@ export default class View {
|
|
|
127
138
|
|
|
128
139
|
/**
|
|
129
140
|
* Whether GridView or equivalent should draw axis and grid lines for this view.
|
|
141
|
+
* TODO: Use view options for this.
|
|
130
142
|
* @type {Record<import("../spec/channel.js").PrimaryPositionalChannel, boolean>}
|
|
131
143
|
*/
|
|
132
144
|
this.needsAxes = { x: false, y: false };
|
|
@@ -141,6 +153,19 @@ export default class View {
|
|
|
141
153
|
this.paramMediator.registerParam(param);
|
|
142
154
|
}
|
|
143
155
|
}
|
|
156
|
+
|
|
157
|
+
// All descendants of a layer view have the same coordinates - no need to redefine.
|
|
158
|
+
if (!this.layoutParent?.options.layeredChildren) {
|
|
159
|
+
// Width and height can be overriden by the view spec. Typically it
|
|
160
|
+
// doesn't make much sense, but it's used in the App's SampleView
|
|
161
|
+
// to set the height to sample facets' height.
|
|
162
|
+
const allocateIfFree = (/** @type {string} */ name) =>
|
|
163
|
+
this.paramMediator.findMediatorForParam(name)
|
|
164
|
+
? undefined
|
|
165
|
+
: this.paramMediator.allocateSetter(name, 0);
|
|
166
|
+
this.#heightSetter = allocateIfFree("height");
|
|
167
|
+
this.#widthSetter = allocateIfFree("width");
|
|
168
|
+
}
|
|
144
169
|
}
|
|
145
170
|
|
|
146
171
|
/**
|
|
@@ -503,6 +528,9 @@ export default class View {
|
|
|
503
528
|
options.clipRect ? coords.intersect(options.clipRect) : coords
|
|
504
529
|
);
|
|
505
530
|
|
|
531
|
+
this.#widthSetter?.(coords.width);
|
|
532
|
+
this.#heightSetter?.(coords.height);
|
|
533
|
+
|
|
506
534
|
// override
|
|
507
535
|
}
|
|
508
536
|
|
|
@@ -647,7 +675,7 @@ export default class View {
|
|
|
647
675
|
getBaseUrl() {
|
|
648
676
|
return concatUrl(
|
|
649
677
|
() => this.dataParent?.getBaseUrl(),
|
|
650
|
-
this.spec.baseUrl
|
|
678
|
+
endWithSlash(this.spec.baseUrl)
|
|
651
679
|
);
|
|
652
680
|
}
|
|
653
681
|
|
|
@@ -164,7 +164,15 @@ describe("Utility methods", () => {
|
|
|
164
164
|
layer: [],
|
|
165
165
|
},
|
|
166
166
|
LayerView
|
|
167
|
-
).then((view) => expect(view.getBaseUrl()).toEqual("blaa"));
|
|
167
|
+
).then((view) => expect(view.getBaseUrl()).toEqual("blaa/"));
|
|
168
|
+
|
|
169
|
+
await createAndInitialize(
|
|
170
|
+
{
|
|
171
|
+
baseUrl: "blaa/",
|
|
172
|
+
layer: [],
|
|
173
|
+
},
|
|
174
|
+
LayerView
|
|
175
|
+
).then((view) => expect(view.getBaseUrl()).toEqual("blaa/"));
|
|
168
176
|
|
|
169
177
|
await createAndInitialize(
|
|
170
178
|
{
|
|
@@ -172,7 +180,9 @@ describe("Utility methods", () => {
|
|
|
172
180
|
layer: [],
|
|
173
181
|
},
|
|
174
182
|
LayerView
|
|
175
|
-
).then((view) =>
|
|
183
|
+
).then((view) =>
|
|
184
|
+
expect(view.getBaseUrl()).toEqual("https://site.com/")
|
|
185
|
+
);
|
|
176
186
|
|
|
177
187
|
await createAndInitialize(
|
|
178
188
|
{
|
|
@@ -187,7 +197,7 @@ describe("Utility methods", () => {
|
|
|
187
197
|
LayerView
|
|
188
198
|
).then((view) =>
|
|
189
199
|
expect(view.children[0].getBaseUrl()).toEqual(
|
|
190
|
-
"https://site.com/blaa"
|
|
200
|
+
"https://site.com/blaa/"
|
|
191
201
|
)
|
|
192
202
|
);
|
|
193
203
|
|
|
@@ -204,7 +214,7 @@ describe("Utility methods", () => {
|
|
|
204
214
|
LayerView
|
|
205
215
|
).then((view) =>
|
|
206
216
|
expect(view.children[0].getBaseUrl()).toEqual(
|
|
207
|
-
"https://another-site.com"
|
|
217
|
+
"https://another-site.com/"
|
|
208
218
|
)
|
|
209
219
|
);
|
|
210
220
|
|
|
@@ -226,7 +236,7 @@ describe("Utility methods", () => {
|
|
|
226
236
|
).then((view) =>
|
|
227
237
|
// @ts-ignore
|
|
228
238
|
expect(view.children[0].children[0].getBaseUrl()).toEqual(
|
|
229
|
-
"https://site.com/blaa"
|
|
239
|
+
"https://site.com/blaa/"
|
|
230
240
|
)
|
|
231
241
|
);
|
|
232
242
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"zoom.d.ts","sourceRoot":"","sources":["../../../src/view/zoom.js"],"names":[],"mappings":"AAkBA,0CAGC;AAgBD;;;;;;GAMG;AACH,yCANW,OAAO,8BAA8B,EAAE,OAAO,UAC9C,OAAO,uBAAuB,EAAE,OAAO,
|
|
1
|
+
{"version":3,"file":"zoom.d.ts","sourceRoot":"","sources":["../../../src/view/zoom.js"],"names":[],"mappings":"AAkBA,0CAGC;AAgBD;;;;;;GAMG;AACH,yCANW,OAAO,8BAA8B,EAAE,OAAO,UAC9C,OAAO,uBAAuB,EAAE,OAAO,cACvC,CAAC,SAAS,EAAE,SAAS,KAAK,IAAI,UAC9B,OAAO,yBAAyB,EAAE,KAAK,aACvC,OAAO,sBAAsB,EAAE,OAAO,QAkJhD;;OA1LS,MAAM;OACN,MAAM;YACN,MAAM;YACN,MAAM;YACN,MAAM"}
|
package/package.json
CHANGED
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
},
|
|
8
8
|
"contributors": [],
|
|
9
9
|
"license": "MIT",
|
|
10
|
-
"version": "0.
|
|
10
|
+
"version": "0.53.0",
|
|
11
11
|
"jsdelivr": "dist/bundle/index.js",
|
|
12
12
|
"unpkg": "dist/bundle/index.js",
|
|
13
13
|
"browser": "dist/bundle/index.js",
|
|
@@ -67,5 +67,5 @@
|
|
|
67
67
|
"devDependencies": {
|
|
68
68
|
"@types/long": "^4.0.1"
|
|
69
69
|
},
|
|
70
|
-
"gitHead": "
|
|
70
|
+
"gitHead": "38a9a0467a93cb99fa62346da85adb367f48ea48"
|
|
71
71
|
}
|
|
@@ -1,279 +0,0 @@
|
|
|
1
|
-
import { L as g } from "./__vite-browser-external-C--ziKoh.js";
|
|
2
|
-
import { b as w } from "./index-C8lYPtq_.js";
|
|
3
|
-
import { L as x, u as E } from "./long-CYrAUkxh.js";
|
|
4
|
-
import "./_commonjsHelpers-BIiJCwQW.js";
|
|
5
|
-
const m = 1;
|
|
6
|
-
class _ {
|
|
7
|
-
constructor({ filehandle: e, path: t }) {
|
|
8
|
-
if (e)
|
|
9
|
-
this.filehandle = e;
|
|
10
|
-
else if (t)
|
|
11
|
-
this.filehandle = new g(t);
|
|
12
|
-
else
|
|
13
|
-
throw new TypeError("either filehandle or path must be defined");
|
|
14
|
-
}
|
|
15
|
-
_readLongWithOverflow(e, t = 0, i = !0) {
|
|
16
|
-
const n = x.fromBytesLE(e.slice(t, t + 8), i);
|
|
17
|
-
if (n.greaterThan(Number.MAX_SAFE_INTEGER) || n.lessThan(Number.MIN_SAFE_INTEGER))
|
|
18
|
-
throw new TypeError("integer overflow");
|
|
19
|
-
return n.toNumber();
|
|
20
|
-
}
|
|
21
|
-
_getIndex() {
|
|
22
|
-
return this.index || (this.index = this._readIndex()), this.index;
|
|
23
|
-
}
|
|
24
|
-
async _readIndex() {
|
|
25
|
-
let e = w.Buffer.allocUnsafe(8);
|
|
26
|
-
await this.filehandle.read(e, 0, 8, 0);
|
|
27
|
-
const t = this._readLongWithOverflow(e, 0, !0);
|
|
28
|
-
if (!t)
|
|
29
|
-
return [[0, 0]];
|
|
30
|
-
const i = new Array(t + 1);
|
|
31
|
-
i[0] = [0, 0];
|
|
32
|
-
const n = 8 * 2 * t;
|
|
33
|
-
if (n > Number.MAX_SAFE_INTEGER)
|
|
34
|
-
throw new TypeError("integer overflow");
|
|
35
|
-
e = w.Buffer.allocUnsafe(n), await this.filehandle.read(e, 0, n, 8);
|
|
36
|
-
for (let s = 0; s < t; s += 1) {
|
|
37
|
-
const r = this._readLongWithOverflow(e, s * 16), a = this._readLongWithOverflow(e, s * 16 + 8);
|
|
38
|
-
i[s + 1] = [r, a];
|
|
39
|
-
}
|
|
40
|
-
return i;
|
|
41
|
-
}
|
|
42
|
-
async getLastBlock() {
|
|
43
|
-
const e = await this._getIndex();
|
|
44
|
-
if (e.length)
|
|
45
|
-
return e[e.length - 1];
|
|
46
|
-
}
|
|
47
|
-
async getRelevantBlocksForRead(e, t) {
|
|
48
|
-
const i = t + e;
|
|
49
|
-
if (e === 0)
|
|
50
|
-
return [];
|
|
51
|
-
const n = await this._getIndex(), s = [], r = (h, u) => {
|
|
52
|
-
const p = h[m], b = u ? u[m] : 1 / 0;
|
|
53
|
-
return p <= t && b > t ? 0 : p < t ? -1 : 1;
|
|
54
|
-
};
|
|
55
|
-
let a = 0, f = n.length - 1, o = Math.floor(n.length / 2), d = r(n[o], n[o + 1]);
|
|
56
|
-
for (; d !== 0; )
|
|
57
|
-
d > 0 ? f = o - 1 : d < 0 && (a = o + 1), o = Math.ceil((f - a) / 2) + a, d = r(n[o], n[o + 1]);
|
|
58
|
-
s.push(n[o]);
|
|
59
|
-
let c = o + 1;
|
|
60
|
-
for (; c < n.length && (s.push(n[c]), !(n[c][m] >= i)); c += 1)
|
|
61
|
-
;
|
|
62
|
-
return s[s.length - 1][m] < i && s.push([]), s;
|
|
63
|
-
}
|
|
64
|
-
}
|
|
65
|
-
class y {
|
|
66
|
-
constructor({ filehandle: e, path: t, gziFilehandle: i, gziPath: n }) {
|
|
67
|
-
if (e)
|
|
68
|
-
this.filehandle = e;
|
|
69
|
-
else if (t)
|
|
70
|
-
this.filehandle = new g(t);
|
|
71
|
-
else
|
|
72
|
-
throw new TypeError("either filehandle or path must be defined");
|
|
73
|
-
if (!i && !n && !t)
|
|
74
|
-
throw new TypeError("either gziFilehandle or gziPath must be defined");
|
|
75
|
-
this.gzi = new _({
|
|
76
|
-
filehandle: i,
|
|
77
|
-
path: !i && !n && t ? n : `${t}.gzi`
|
|
78
|
-
});
|
|
79
|
-
}
|
|
80
|
-
async stat() {
|
|
81
|
-
const e = await this.filehandle.stat();
|
|
82
|
-
return Object.assign(e, {
|
|
83
|
-
size: await this.getUncompressedFileSize(),
|
|
84
|
-
blocks: void 0,
|
|
85
|
-
blksize: void 0
|
|
86
|
-
});
|
|
87
|
-
}
|
|
88
|
-
async getUncompressedFileSize() {
|
|
89
|
-
const [, e] = await this.gzi.getLastBlock(), { size: t } = await this.filehandle.stat(), i = w.Buffer.allocUnsafe(4), { bytesRead: n } = await this.filehandle.read(i, 0, 4, t - 28 - 4);
|
|
90
|
-
if (n !== 4)
|
|
91
|
-
throw new Error("read error");
|
|
92
|
-
const s = i.readUInt32LE(0);
|
|
93
|
-
return e + s;
|
|
94
|
-
}
|
|
95
|
-
async _readAndUncompressBlock(e, [t], [i]) {
|
|
96
|
-
let n = i;
|
|
97
|
-
n || (n = (await this.filehandle.stat()).size);
|
|
98
|
-
const s = n - t;
|
|
99
|
-
return await this.filehandle.read(e, 0, s, t), await E(e.slice(0, s));
|
|
100
|
-
}
|
|
101
|
-
async read(e, t, i, n) {
|
|
102
|
-
const s = await this.gzi.getRelevantBlocksForRead(i, n), r = w.Buffer.allocUnsafe(32768 * 2);
|
|
103
|
-
let a = t, f = 0;
|
|
104
|
-
for (let o = 0; o < s.length - 1; o += 1) {
|
|
105
|
-
const d = await this._readAndUncompressBlock(r, s[o], s[o + 1]), [, c] = s[o], h = c >= n ? 0 : n - c, u = Math.min(n + i, c + d.length) - c;
|
|
106
|
-
h >= 0 && h < d.length && (d.copy(e, a, h, u), a += u - h, f += u - h);
|
|
107
|
-
}
|
|
108
|
-
return { bytesRead: f, buffer: e };
|
|
109
|
-
}
|
|
110
|
-
}
|
|
111
|
-
function S(l, e) {
|
|
112
|
-
return l.offset + l.lineBytes * Math.floor(e / l.lineLength) + e % l.lineLength;
|
|
113
|
-
}
|
|
114
|
-
async function I(l, e) {
|
|
115
|
-
const t = await l.readFile(e);
|
|
116
|
-
if (!(t && t.length))
|
|
117
|
-
throw new Error("No data read from FASTA index (FAI) file");
|
|
118
|
-
let i = 0, n;
|
|
119
|
-
const s = t.toString("utf8").split(/\r?\n/).filter((r) => /\S/.test(r)).map((r) => r.split(" ")).filter((r) => r[0] !== "").map((r) => ((!n || n.name !== r[0]) && (n = { name: r[0], id: i }, i += 1), {
|
|
120
|
-
id: n.id,
|
|
121
|
-
name: r[0],
|
|
122
|
-
length: +r[1],
|
|
123
|
-
start: 0,
|
|
124
|
-
end: +r[1],
|
|
125
|
-
offset: +r[2],
|
|
126
|
-
lineLength: +r[3],
|
|
127
|
-
lineBytes: +r[4]
|
|
128
|
-
}));
|
|
129
|
-
return {
|
|
130
|
-
name: Object.fromEntries(s.map((r) => [r.name, r])),
|
|
131
|
-
id: Object.fromEntries(s.map((r) => [r.id, r]))
|
|
132
|
-
};
|
|
133
|
-
}
|
|
134
|
-
class B {
|
|
135
|
-
constructor({ fasta: e, fai: t, path: i, faiPath: n, chunkSizeLimit: s = 1e6 }) {
|
|
136
|
-
if (e)
|
|
137
|
-
this.fasta = e;
|
|
138
|
-
else if (i)
|
|
139
|
-
this.fasta = new g(i);
|
|
140
|
-
else
|
|
141
|
-
throw new Error("Need to pass filehandle for fasta or path to localfile");
|
|
142
|
-
if (t)
|
|
143
|
-
this.fai = t;
|
|
144
|
-
else if (n)
|
|
145
|
-
this.fai = new g(n);
|
|
146
|
-
else if (i)
|
|
147
|
-
this.fai = new g(`${i}.fai`);
|
|
148
|
-
else
|
|
149
|
-
throw new Error("Need to pass filehandle for or path to localfile");
|
|
150
|
-
this.chunkSizeLimit = s;
|
|
151
|
-
}
|
|
152
|
-
async _getIndexes(e) {
|
|
153
|
-
return this.indexes || (this.indexes = I(this.fai, e)), this.indexes;
|
|
154
|
-
}
|
|
155
|
-
/**
|
|
156
|
-
* @returns {array[string]} array of string sequence
|
|
157
|
-
* names that are present in the index, in which the
|
|
158
|
-
* array index indicates the sequence ID, and the value
|
|
159
|
-
* is the sequence name
|
|
160
|
-
*/
|
|
161
|
-
async getSequenceNames(e) {
|
|
162
|
-
return Object.keys((await this._getIndexes(e)).name);
|
|
163
|
-
}
|
|
164
|
-
/**
|
|
165
|
-
* @returns {array[string]} array of string sequence
|
|
166
|
-
* names that are present in the index, in which the
|
|
167
|
-
* array index indicates the sequence ID, and the value
|
|
168
|
-
* is the sequence name
|
|
169
|
-
*/
|
|
170
|
-
async getSequenceSizes(e) {
|
|
171
|
-
const t = {}, i = await this._getIndexes(e), n = Object.values(i.id);
|
|
172
|
-
for (let s = 0; s < n.length; s += 1)
|
|
173
|
-
t[n[s].name] = n[s].length;
|
|
174
|
-
return t;
|
|
175
|
-
}
|
|
176
|
-
/**
|
|
177
|
-
* @returns {array[string]} array of string sequence
|
|
178
|
-
* names that are present in the index, in which the
|
|
179
|
-
* array index indicates the sequence ID, and the value
|
|
180
|
-
* is the sequence name
|
|
181
|
-
*/
|
|
182
|
-
async getSequenceSize(e, t) {
|
|
183
|
-
var i;
|
|
184
|
-
return (i = (await this._getIndexes(t)).name[e]) === null || i === void 0 ? void 0 : i.length;
|
|
185
|
-
}
|
|
186
|
-
/**
|
|
187
|
-
*
|
|
188
|
-
* @param {string} name
|
|
189
|
-
* @returns {Promise[boolean]} true if the file contains the given reference sequence name
|
|
190
|
-
*/
|
|
191
|
-
async hasReferenceSequence(e, t) {
|
|
192
|
-
return !!(await this._getIndexes(t)).name[e];
|
|
193
|
-
}
|
|
194
|
-
/**
|
|
195
|
-
*
|
|
196
|
-
* @param {number} seqId
|
|
197
|
-
* @param {number} min
|
|
198
|
-
* @param {number} max
|
|
199
|
-
*/
|
|
200
|
-
async getResiduesById(e, t, i, n) {
|
|
201
|
-
const s = (await this._getIndexes(n)).id[e];
|
|
202
|
-
if (s)
|
|
203
|
-
return this._fetchFromIndexEntry(s, t, i, n);
|
|
204
|
-
}
|
|
205
|
-
/**
|
|
206
|
-
* @param {string} seqName
|
|
207
|
-
* @param {number} min
|
|
208
|
-
* @param {number} max
|
|
209
|
-
*/
|
|
210
|
-
async getResiduesByName(e, t, i, n) {
|
|
211
|
-
const s = (await this._getIndexes(n)).name[e];
|
|
212
|
-
if (s)
|
|
213
|
-
return this._fetchFromIndexEntry(s, t, i, n);
|
|
214
|
-
}
|
|
215
|
-
//alias for getResiduesByName
|
|
216
|
-
async getSequence(e, t, i, n) {
|
|
217
|
-
return this.getResiduesByName(e, t, i, n);
|
|
218
|
-
}
|
|
219
|
-
async _fetchFromIndexEntry(e, t = 0, i, n) {
|
|
220
|
-
let s = i;
|
|
221
|
-
if (t < 0)
|
|
222
|
-
throw new TypeError("regionStart cannot be less than 0");
|
|
223
|
-
if ((s === void 0 || s > e.length) && (s = e.length), t >= s)
|
|
224
|
-
return "";
|
|
225
|
-
const r = S(e, t), a = S(e, s) - r;
|
|
226
|
-
if (a > this.chunkSizeLimit)
|
|
227
|
-
throw new Error(`data size of ${a.toLocaleString()} bytes exceeded chunk size limit of ${this.chunkSizeLimit.toLocaleString()} bytes`);
|
|
228
|
-
const f = Buffer.allocUnsafe(a);
|
|
229
|
-
return await this.fasta.read(f, 0, a, r, n), f.toString("utf8").replace(/\s+/g, "");
|
|
230
|
-
}
|
|
231
|
-
}
|
|
232
|
-
class O extends B {
|
|
233
|
-
constructor({ fasta: e, path: t, fai: i, faiPath: n, gzi: s, gziPath: r, chunkSizeLimit: a }) {
|
|
234
|
-
super({ fasta: e, path: t, fai: i, faiPath: n, chunkSizeLimit: a }), e && s ? this.fasta = new y({
|
|
235
|
-
filehandle: e,
|
|
236
|
-
gziFilehandle: s
|
|
237
|
-
}) : t && r && (this.fasta = new y({ path: t, gziPath: r }));
|
|
238
|
-
}
|
|
239
|
-
}
|
|
240
|
-
function L(l) {
|
|
241
|
-
return l.split(">").filter((e) => /\S/.test(e)).map((e) => {
|
|
242
|
-
const [t, ...i] = e.split(`
|
|
243
|
-
`), [n, ...s] = t.split(" "), r = i.join("").replace(/\s/g, "");
|
|
244
|
-
return {
|
|
245
|
-
id: n,
|
|
246
|
-
description: s.join(" "),
|
|
247
|
-
sequence: r
|
|
248
|
-
};
|
|
249
|
-
});
|
|
250
|
-
}
|
|
251
|
-
class v {
|
|
252
|
-
constructor({ fasta: e, path: t }) {
|
|
253
|
-
if (e)
|
|
254
|
-
this.fasta = e;
|
|
255
|
-
else if (t)
|
|
256
|
-
this.fasta = new g(t);
|
|
257
|
-
else
|
|
258
|
-
throw new Error("Need to pass fasta or path");
|
|
259
|
-
this.data = this.fasta.readFile().then((i) => {
|
|
260
|
-
const n = i.toString("utf8");
|
|
261
|
-
return L(n);
|
|
262
|
-
});
|
|
263
|
-
}
|
|
264
|
-
async fetch(e, t, i) {
|
|
265
|
-
const s = (await this.data).find((a) => a.id === e), r = i - t;
|
|
266
|
-
if (!s)
|
|
267
|
-
throw new Error(`no sequence with id ${e} exists`);
|
|
268
|
-
return s.sequence.substr(t, r);
|
|
269
|
-
}
|
|
270
|
-
async getSequenceNames() {
|
|
271
|
-
return (await this.data).map((t) => t.id);
|
|
272
|
-
}
|
|
273
|
-
}
|
|
274
|
-
export {
|
|
275
|
-
O as BgzipIndexedFasta,
|
|
276
|
-
v as FetchableSmallFasta,
|
|
277
|
-
B as IndexedFasta,
|
|
278
|
-
L as parseSmallFasta
|
|
279
|
-
};
|