@jbrowse/plugin-canvas 4.1.1 → 4.1.4
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/esm/CanvasFeatureRenderer/configSchema.d.ts +4 -4
- package/esm/CanvasFeatureRenderer/configSchema2.d.ts +4 -4
- package/esm/CanvasFeatureRenderer/drawChevrons.d.ts +1 -1
- package/esm/CanvasFeatureRenderer/drawChevrons.js +4 -1
- package/esm/CanvasFeatureRenderer/floatingLabels.js +6 -21
- package/esm/CanvasFeatureRenderer/glyphs/box.js +2 -2
- package/esm/CanvasFeatureRenderer/glyphs/cds.js +2 -2
- package/esm/CanvasFeatureRenderer/glyphs/glyphUtils.js +3 -3
- package/esm/CanvasFeatureRenderer/glyphs/matureProteinRegion.js +2 -2
- package/esm/CanvasFeatureRenderer/glyphs/processed.js +2 -2
- package/esm/CanvasFeatureRenderer/glyphs/repeatRegion.js +2 -2
- package/esm/CanvasFeatureRenderer/glyphs/segments.js +2 -2
- package/esm/CanvasFeatureRenderer/glyphs/subfeatures.js +2 -2
- package/esm/CanvasFeatureRenderer/layout/layoutFeatures.js +15 -9
- package/esm/CanvasFeatureRenderer/layout/layoutUtils.js +0 -1
- package/esm/CanvasFeatureRenderer/makeImageData.js +6 -5
- package/esm/CanvasFeatureRenderer/peptides/peptideUtils.d.ts +1 -0
- package/esm/CanvasFeatureRenderer/peptides/peptideUtils.js +6 -1
- package/esm/CanvasFeatureRenderer/renderConfig.d.ts +3 -0
- package/esm/CanvasFeatureRenderer/renderConfig.js +9 -0
- package/esm/CanvasFeatureRenderer/types.d.ts +2 -3
- package/package.json +4 -4
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
declare const CanvasFeatureRenderer: import("
|
|
1
|
+
declare const CanvasFeatureRenderer: import("@jbrowse/core/configuration/configurationSchema").ConfigurationSchemaType<{
|
|
2
2
|
color1: {
|
|
3
3
|
type: string;
|
|
4
4
|
description: string;
|
|
@@ -55,7 +55,7 @@ declare const CanvasFeatureRenderer: import("node_modules/@jbrowse/core/src/conf
|
|
|
55
55
|
defaultValue: string;
|
|
56
56
|
contextVariable: string[];
|
|
57
57
|
};
|
|
58
|
-
labels: import("
|
|
58
|
+
labels: import("@jbrowse/core/configuration/configurationSchema").ConfigurationSchemaType<{
|
|
59
59
|
name: {
|
|
60
60
|
type: string;
|
|
61
61
|
description: string;
|
|
@@ -86,7 +86,7 @@ declare const CanvasFeatureRenderer: import("node_modules/@jbrowse/core/src/conf
|
|
|
86
86
|
defaultValue: number;
|
|
87
87
|
contextVariable: string[];
|
|
88
88
|
};
|
|
89
|
-
}, import("
|
|
89
|
+
}, import("@jbrowse/core/configuration/configurationSchema").ConfigurationSchemaOptions<undefined, undefined>>;
|
|
90
90
|
displayMode: {
|
|
91
91
|
type: string;
|
|
92
92
|
model: import("@jbrowse/mobx-state-tree").ISimpleType<string>;
|
|
@@ -132,5 +132,5 @@ declare const CanvasFeatureRenderer: import("node_modules/@jbrowse/core/src/conf
|
|
|
132
132
|
description: string;
|
|
133
133
|
defaultValue: boolean;
|
|
134
134
|
};
|
|
135
|
-
}, import("
|
|
135
|
+
}, import("@jbrowse/core/configuration/configurationSchema").ConfigurationSchemaOptions<undefined, undefined>>;
|
|
136
136
|
export default CanvasFeatureRenderer;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
declare const SvgFeatureRenderer: import("
|
|
1
|
+
declare const SvgFeatureRenderer: import("@jbrowse/core/configuration/configurationSchema").ConfigurationSchemaType<{}, import("@jbrowse/core/configuration/configurationSchema").ConfigurationSchemaOptions<import("@jbrowse/core/configuration/configurationSchema").ConfigurationSchemaType<{
|
|
2
2
|
color1: {
|
|
3
3
|
type: string;
|
|
4
4
|
description: string;
|
|
@@ -55,7 +55,7 @@ declare const SvgFeatureRenderer: import("node_modules/@jbrowse/core/src/configu
|
|
|
55
55
|
defaultValue: string;
|
|
56
56
|
contextVariable: string[];
|
|
57
57
|
};
|
|
58
|
-
labels: import("
|
|
58
|
+
labels: import("@jbrowse/core/configuration/configurationSchema").ConfigurationSchemaType<{
|
|
59
59
|
name: {
|
|
60
60
|
type: string;
|
|
61
61
|
description: string;
|
|
@@ -86,7 +86,7 @@ declare const SvgFeatureRenderer: import("node_modules/@jbrowse/core/src/configu
|
|
|
86
86
|
defaultValue: number;
|
|
87
87
|
contextVariable: string[];
|
|
88
88
|
};
|
|
89
|
-
}, import("
|
|
89
|
+
}, import("@jbrowse/core/configuration/configurationSchema").ConfigurationSchemaOptions<undefined, undefined>>;
|
|
90
90
|
displayMode: {
|
|
91
91
|
type: string;
|
|
92
92
|
model: import("@jbrowse/mobx-state-tree").ISimpleType<string>;
|
|
@@ -132,5 +132,5 @@ declare const SvgFeatureRenderer: import("node_modules/@jbrowse/core/src/configu
|
|
|
132
132
|
description: string;
|
|
133
133
|
defaultValue: boolean;
|
|
134
134
|
};
|
|
135
|
-
}, import("
|
|
135
|
+
}, import("@jbrowse/core/configuration/configurationSchema").ConfigurationSchemaOptions<undefined, undefined>>, undefined>>;
|
|
136
136
|
export default SvgFeatureRenderer;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare function drawChevrons(ctx: CanvasRenderingContext2D, x: number, y: number, width: number, strand: number, color: string, spacing?: number, size?: number): void;
|
|
1
|
+
export declare function drawChevrons(ctx: CanvasRenderingContext2D, x: number, y: number, width: number, strand: number, color: string, canvasWidth: number, spacing?: number, size?: number): void;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export function drawChevrons(ctx, x, y, width, strand, color, spacing = 40, size = 4) {
|
|
1
|
+
export function drawChevrons(ctx, x, y, width, strand, color, canvasWidth, spacing = 40, size = 4) {
|
|
2
2
|
if (strand === 0 || width < spacing) {
|
|
3
3
|
return;
|
|
4
4
|
}
|
|
@@ -10,6 +10,9 @@ export function drawChevrons(ctx, x, y, width, strand, color, spacing = 40, size
|
|
|
10
10
|
const startOffset = (width - numChevrons * spacing) / 2 + spacing / 2;
|
|
11
11
|
for (let i = 0; i < numChevrons; i++) {
|
|
12
12
|
const cx = x + startOffset + i * spacing;
|
|
13
|
+
if (cx + halfSize < 0 || cx - halfSize > canvasWidth) {
|
|
14
|
+
continue;
|
|
15
|
+
}
|
|
13
16
|
if (strand === 1) {
|
|
14
17
|
ctx.moveTo(cx - halfSize, y - halfSize);
|
|
15
18
|
ctx.lineTo(cx + halfSize, y);
|
|
@@ -8,36 +8,21 @@ export function createFeatureFloatingLabels({ feature, config, configContext, na
|
|
|
8
8
|
const description = truncateLabel(rawDescription);
|
|
9
9
|
const shouldShowLabel = /\S/.test(name) && showLabels;
|
|
10
10
|
const shouldShowDescription = /\S/.test(description) && showDescriptions;
|
|
11
|
-
if (!shouldShowLabel && !shouldShowDescription) {
|
|
12
|
-
return [];
|
|
13
|
-
}
|
|
14
|
-
const actualFontHeight = readCachedConfig(fontHeight, config, ['labels', 'fontSize'], feature);
|
|
15
11
|
const floatingLabels = [];
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
text: name,
|
|
19
|
-
relativeY: 0,
|
|
20
|
-
color: nameColor,
|
|
21
|
-
textWidth: measureText(name, FLOATING_LABEL_FONT_SIZE),
|
|
22
|
-
}, {
|
|
23
|
-
text: description,
|
|
24
|
-
relativeY: actualFontHeight,
|
|
25
|
-
color: descriptionColor,
|
|
26
|
-
textWidth: measureText(description, FLOATING_LABEL_FONT_SIZE),
|
|
27
|
-
});
|
|
28
|
-
}
|
|
29
|
-
else if (shouldShowLabel) {
|
|
12
|
+
let currentY = 0;
|
|
13
|
+
if (shouldShowLabel) {
|
|
30
14
|
floatingLabels.push({
|
|
31
15
|
text: name,
|
|
32
|
-
relativeY:
|
|
16
|
+
relativeY: currentY,
|
|
33
17
|
color: nameColor,
|
|
34
18
|
textWidth: measureText(name, FLOATING_LABEL_FONT_SIZE),
|
|
35
19
|
});
|
|
20
|
+
currentY += readCachedConfig(fontHeight, config, ['labels', 'fontSize'], feature);
|
|
36
21
|
}
|
|
37
|
-
|
|
22
|
+
if (shouldShowDescription) {
|
|
38
23
|
floatingLabels.push({
|
|
39
24
|
text: description,
|
|
40
|
-
relativeY:
|
|
25
|
+
relativeY: currentY,
|
|
41
26
|
color: descriptionColor,
|
|
42
27
|
textWidth: measureText(description, FLOATING_LABEL_FONT_SIZE),
|
|
43
28
|
});
|
|
@@ -14,9 +14,9 @@ export const boxGlyph = {
|
|
|
14
14
|
},
|
|
15
15
|
layout(args) {
|
|
16
16
|
const { feature, bpPerPx, reversed, configContext } = args;
|
|
17
|
-
const { config,
|
|
17
|
+
const { config, featureHeight, heightMultiplier } = configContext;
|
|
18
18
|
const height = readCachedConfig(featureHeight, config, 'height', feature);
|
|
19
|
-
const baseHeight =
|
|
19
|
+
const baseHeight = height * heightMultiplier;
|
|
20
20
|
const width = (feature.get('end') - feature.get('start')) / bpPerPx;
|
|
21
21
|
const isTopLevel = !feature.parent?.();
|
|
22
22
|
const strand = feature.get('strand');
|
|
@@ -12,9 +12,9 @@ export const cdsGlyph = {
|
|
|
12
12
|
},
|
|
13
13
|
layout(args) {
|
|
14
14
|
const { feature, bpPerPx, configContext } = args;
|
|
15
|
-
const { config,
|
|
15
|
+
const { config, featureHeight, heightMultiplier } = configContext;
|
|
16
16
|
const height = readCachedConfig(featureHeight, config, 'height', feature);
|
|
17
|
-
const baseHeight =
|
|
17
|
+
const baseHeight = height * heightMultiplier;
|
|
18
18
|
const width = (feature.get('end') - feature.get('start')) / bpPerPx;
|
|
19
19
|
return {
|
|
20
20
|
feature,
|
|
@@ -14,9 +14,9 @@ export function getStrandArrowPadding(strand, reversed) {
|
|
|
14
14
|
}
|
|
15
15
|
export function layoutChild(child, parentFeature, args, glyphType = 'Box') {
|
|
16
16
|
const { bpPerPx, reversed, configContext } = args;
|
|
17
|
-
const { config,
|
|
17
|
+
const { config, featureHeight, heightMultiplier } = configContext;
|
|
18
18
|
const heightPx = readCachedConfig(featureHeight, config, 'height', child);
|
|
19
|
-
const baseHeightPx =
|
|
19
|
+
const baseHeightPx = heightPx * heightMultiplier;
|
|
20
20
|
const childStart = child.get('start');
|
|
21
21
|
const childEnd = child.get('end');
|
|
22
22
|
const parentStart = parentFeature.get('start');
|
|
@@ -110,7 +110,7 @@ export function drawSegmentedFeature(ctx, layout, dc, boxGlyph, cdsGlyph) {
|
|
|
110
110
|
const strand = feature.get('strand');
|
|
111
111
|
if (strand) {
|
|
112
112
|
const effectiveStrand = reversed ? -strand : strand;
|
|
113
|
-
drawChevrons(ctx, left, top + height / 2, width, effectiveStrand, strokeColor);
|
|
113
|
+
drawChevrons(ctx, left, top + height / 2, width, effectiveStrand, strokeColor, canvasWidth);
|
|
114
114
|
}
|
|
115
115
|
}
|
|
116
116
|
for (const childLayout of children) {
|
|
@@ -56,11 +56,11 @@ export const matureProteinRegionGlyph = {
|
|
|
56
56
|
},
|
|
57
57
|
layout(args) {
|
|
58
58
|
const { feature, bpPerPx, configContext } = args;
|
|
59
|
-
const { config,
|
|
59
|
+
const { config, featureHeight, heightMultiplier, subfeatureLabels } = configContext;
|
|
60
60
|
const start = feature.get('start');
|
|
61
61
|
const end = feature.get('end');
|
|
62
62
|
const heightPx = readCachedConfig(featureHeight, config, 'height', feature);
|
|
63
|
-
const baseHeightPx =
|
|
63
|
+
const baseHeightPx = heightPx * heightMultiplier;
|
|
64
64
|
const widthPx = (end - start) / bpPerPx;
|
|
65
65
|
const matureProteins = getMatureProteinChildren(feature);
|
|
66
66
|
const children = matureProteins.map(child => layoutChild(child, feature, args));
|
|
@@ -20,11 +20,11 @@ export const processedTranscriptGlyph = {
|
|
|
20
20
|
},
|
|
21
21
|
layout(args) {
|
|
22
22
|
const { feature, bpPerPx, reversed, configContext } = args;
|
|
23
|
-
const { config,
|
|
23
|
+
const { config, featureHeight, heightMultiplier } = configContext;
|
|
24
24
|
const start = feature.get('start');
|
|
25
25
|
const end = feature.get('end');
|
|
26
26
|
const heightPx = readCachedConfig(featureHeight, config, 'height', feature);
|
|
27
|
-
const baseHeightPx =
|
|
27
|
+
const baseHeightPx = heightPx * heightMultiplier;
|
|
28
28
|
const widthPx = (end - start) / bpPerPx;
|
|
29
29
|
const strand = feature.get('strand');
|
|
30
30
|
const arrowPadding = getStrandArrowPadding(strand, reversed);
|
|
@@ -33,11 +33,11 @@ export const repeatRegionGlyph = {
|
|
|
33
33
|
},
|
|
34
34
|
layout(args) {
|
|
35
35
|
const { feature, bpPerPx, reversed, configContext } = args;
|
|
36
|
-
const { config,
|
|
36
|
+
const { config, featureHeight, heightMultiplier } = configContext;
|
|
37
37
|
const start = feature.get('start');
|
|
38
38
|
const end = feature.get('end');
|
|
39
39
|
const heightPx = readCachedConfig(featureHeight, config, 'height', feature);
|
|
40
|
-
const baseHeightPx =
|
|
40
|
+
const baseHeightPx = heightPx * heightMultiplier;
|
|
41
41
|
const widthPx = (end - start) / bpPerPx;
|
|
42
42
|
const strand = feature.get('strand');
|
|
43
43
|
const arrowPadding = getStrandArrowPadding(strand, reversed);
|
|
@@ -32,11 +32,11 @@ export const segmentsGlyph = {
|
|
|
32
32
|
},
|
|
33
33
|
layout(args) {
|
|
34
34
|
const { feature, bpPerPx, reversed, configContext } = args;
|
|
35
|
-
const { config,
|
|
35
|
+
const { config, featureHeight, heightMultiplier } = configContext;
|
|
36
36
|
const start = feature.get('start');
|
|
37
37
|
const end = feature.get('end');
|
|
38
38
|
const heightPx = readCachedConfig(featureHeight, config, 'height', feature);
|
|
39
|
-
const baseHeightPx =
|
|
39
|
+
const baseHeightPx = heightPx * heightMultiplier;
|
|
40
40
|
const widthPx = (end - start) / bpPerPx;
|
|
41
41
|
const strand = feature.get('strand');
|
|
42
42
|
const arrowPadding = getStrandArrowPadding(strand, reversed);
|
|
@@ -41,13 +41,13 @@ export const subfeaturesGlyph = {
|
|
|
41
41
|
},
|
|
42
42
|
layout(args) {
|
|
43
43
|
const { feature, bpPerPx, reversed, configContext } = args;
|
|
44
|
-
const { config,
|
|
44
|
+
const { config, featureHeight, heightMultiplier, geneGlyphMode, transcriptTypes, } = configContext;
|
|
45
45
|
const featureBp = {
|
|
46
46
|
start: feature.get('start'),
|
|
47
47
|
end: feature.get('end'),
|
|
48
48
|
};
|
|
49
49
|
const heightPx = readCachedConfig(featureHeight, config, 'height', feature);
|
|
50
|
-
const baseHeightPx =
|
|
50
|
+
const baseHeightPx = heightPx * heightMultiplier;
|
|
51
51
|
const widthPx = (featureBp.end - featureBp.start) / bpPerPx;
|
|
52
52
|
let subfeatures = [...(feature.get('subfeatures') || [])];
|
|
53
53
|
const codingStatus = new Map(subfeatures.map(f => [f.id(), hasCodingSubfeature(f)]));
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { readConfObject } from '@jbrowse/core/configuration';
|
|
2
2
|
import { createFeatureFloatingLabels } from "../floatingLabels.js";
|
|
3
3
|
import { layoutFeature } from "./layoutFeature.js";
|
|
4
|
+
import { readCachedConfig } from "../renderConfig.js";
|
|
4
5
|
const yPadding = 5;
|
|
5
6
|
export function layoutFeatures({ features, bpPerPx, region, configContext, layout, pluginManager, }) {
|
|
6
7
|
const reversed = region.reversed || false;
|
|
@@ -18,12 +19,14 @@ export function layoutFeatures({ features, bpPerPx, region, configContext, layou
|
|
|
18
19
|
const totalLayoutHeight = featureLayout.totalLayoutHeight;
|
|
19
20
|
const name = String(readConfObject(config, ['labels', 'name'], { feature }) || '');
|
|
20
21
|
const description = String(readConfObject(config, ['labels', 'description'], { feature }) || '');
|
|
22
|
+
const { nameColor, descriptionColor } = configContext;
|
|
23
|
+
const resolvedNameColor = readCachedConfig(nameColor, config, ['labels', 'nameColor'], feature);
|
|
21
24
|
const floatingLabels = createFeatureFloatingLabels({
|
|
22
25
|
feature,
|
|
23
26
|
config,
|
|
24
27
|
configContext,
|
|
25
|
-
nameColor: 'black',
|
|
26
|
-
descriptionColor: '
|
|
28
|
+
nameColor: resolvedNameColor === '#f0f' ? 'black' : resolvedNameColor,
|
|
29
|
+
descriptionColor: readCachedConfig(descriptionColor, config, ['labels', 'descriptionColor'], feature),
|
|
27
30
|
name,
|
|
28
31
|
description,
|
|
29
32
|
});
|
|
@@ -32,15 +35,20 @@ export function layoutFeatures({ features, bpPerPx, region, configContext, layou
|
|
|
32
35
|
const leftPaddingBp = featureLayout.leftPadding * bpPerPx;
|
|
33
36
|
const rightPaddingBp = (totalLayoutWidth - featureLayout.width - featureLayout.leftPadding) *
|
|
34
37
|
bpPerPx;
|
|
35
|
-
|
|
36
|
-
|
|
38
|
+
let layoutStart;
|
|
39
|
+
let layoutEnd;
|
|
40
|
+
if (reversed) {
|
|
41
|
+
layoutStart = featureStart - rightPaddingBp;
|
|
42
|
+
layoutEnd = featureEnd + leftPaddingBp;
|
|
43
|
+
}
|
|
44
|
+
else {
|
|
45
|
+
layoutStart = featureStart - leftPaddingBp;
|
|
46
|
+
layoutEnd = featureEnd + rightPaddingBp;
|
|
47
|
+
}
|
|
37
48
|
const topPx = layout.addRect(feature.id(), layoutStart, layoutEnd, totalLayoutHeight + yPadding, feature, {
|
|
38
|
-
label: name,
|
|
39
|
-
description,
|
|
40
49
|
refName: feature.get('refName'),
|
|
41
50
|
floatingLabels,
|
|
42
51
|
totalFeatureHeight: featureLayout.height,
|
|
43
|
-
totalLayoutWidth,
|
|
44
52
|
featureWidth: featureLayout.width,
|
|
45
53
|
featureStartBp: featureStart,
|
|
46
54
|
featureEndBp: featureEnd,
|
|
@@ -50,8 +58,6 @@ export function layoutFeatures({ features, bpPerPx, region, configContext, layou
|
|
|
50
58
|
feature,
|
|
51
59
|
layout: featureLayout,
|
|
52
60
|
topPx,
|
|
53
|
-
label: name,
|
|
54
|
-
description,
|
|
55
61
|
});
|
|
56
62
|
}
|
|
57
63
|
}
|
|
@@ -102,7 +102,6 @@ function addChildrenRecursive({ layout, featureLayout, subfeatureCoords, subfeat
|
|
|
102
102
|
refName: childFeature.get('refName'),
|
|
103
103
|
floatingLabels,
|
|
104
104
|
totalFeatureHeight: child.height,
|
|
105
|
-
totalLayoutWidth: child.totalLayoutWidth,
|
|
106
105
|
actualTopPx: topPx,
|
|
107
106
|
featureWidth: child.width,
|
|
108
107
|
featureStartBp: childStart,
|
|
@@ -2,7 +2,7 @@ import { readConfObject } from '@jbrowse/core/configuration';
|
|
|
2
2
|
import { createJBrowseTheme } from '@jbrowse/core/ui';
|
|
3
3
|
import { bpToPx } from '@jbrowse/core/util';
|
|
4
4
|
import Flatbush from '@jbrowse/core/util/flatbush';
|
|
5
|
-
import { checkStopToken2
|
|
5
|
+
import { checkStopToken2 } from '@jbrowse/core/util/stopToken';
|
|
6
6
|
import { drawFeature } from "./drawFeature.js";
|
|
7
7
|
import { buildChildrenIndex, convertToCanvasCoords, } from "./layout/layoutUtils.js";
|
|
8
8
|
function buildFlatbush(coords, count) {
|
|
@@ -19,7 +19,7 @@ function buildFlatbush(coords, count) {
|
|
|
19
19
|
return fb;
|
|
20
20
|
}
|
|
21
21
|
export function makeImageData({ ctx, layoutRecords, canvasWidth, renderArgs, configContext, }) {
|
|
22
|
-
const { bpPerPx, regions, theme: configTheme,
|
|
22
|
+
const { bpPerPx, regions, theme: configTheme, stopTokenCheck, layout, peptideDataMap, colorByCDS, pluginManager, } = renderArgs;
|
|
23
23
|
const region = regions[0];
|
|
24
24
|
const theme = createJBrowseTheme(configTheme);
|
|
25
25
|
const drawContext = {
|
|
@@ -38,9 +38,8 @@ export function makeImageData({ ctx, layoutRecords, canvasWidth, renderArgs, con
|
|
|
38
38
|
ctx.textBaseline = 'top';
|
|
39
39
|
ctx.textAlign = 'left';
|
|
40
40
|
const { subfeatureLabels, transcriptTypes, config } = configContext;
|
|
41
|
-
const lastCheck = createStopTokenChecker(stopToken);
|
|
42
41
|
for (const record of layoutRecords) {
|
|
43
|
-
const { feature, layout: featureLayout, topPx: recordTopPx
|
|
42
|
+
const { feature, layout: featureLayout, topPx: recordTopPx } = record;
|
|
44
43
|
const featureStartBp = feature.get(region.reversed ? 'end' : 'start');
|
|
45
44
|
const startPx = bpToPx(featureStartBp, region, bpPerPx);
|
|
46
45
|
const canvasLayout = convertToCanvasCoords(featureLayout, startPx, recordTopPx);
|
|
@@ -51,6 +50,8 @@ export function makeImageData({ ctx, layoutRecords, canvasWidth, renderArgs, con
|
|
|
51
50
|
top: canvasLayout.y,
|
|
52
51
|
bottom: canvasLayout.y + canvasLayout.totalLayoutHeight,
|
|
53
52
|
};
|
|
53
|
+
const label = String(readConfObject(config, ['labels', 'name'], { feature }) || '');
|
|
54
|
+
const description = String(readConfObject(config, ['labels', 'description'], { feature }) || '');
|
|
54
55
|
const tooltip = String(readConfObject(config, 'mouseover', { feature, label, description }) ||
|
|
55
56
|
'');
|
|
56
57
|
coords.push(bounds.left, bounds.top, bounds.right, bounds.bottom);
|
|
@@ -78,7 +79,7 @@ export function makeImageData({ ctx, layoutRecords, canvasWidth, renderArgs, con
|
|
|
78
79
|
labelColor: theme.palette.text.primary,
|
|
79
80
|
parentTooltip: tooltip,
|
|
80
81
|
});
|
|
81
|
-
checkStopToken2(
|
|
82
|
+
checkStopToken2(stopTokenCheck);
|
|
82
83
|
}
|
|
83
84
|
return {
|
|
84
85
|
flatbush: buildFlatbush(coords, items.length).data,
|
|
@@ -2,4 +2,5 @@ import type { PeptideData } from '../types.ts';
|
|
|
2
2
|
import type PluginManager from '@jbrowse/core/PluginManager';
|
|
3
3
|
import type { RenderArgsDeserialized } from '@jbrowse/core/pluggableElementTypes/renderers/BoxRendererType';
|
|
4
4
|
import type { Feature } from '@jbrowse/core/util';
|
|
5
|
+
export declare function findTranscriptsWithCDS(features: Map<string, Feature>): Feature[];
|
|
5
6
|
export declare function fetchPeptideData(pluginManager: PluginManager, renderProps: RenderArgsDeserialized, features: Map<string, Feature>): Promise<Map<string, PeptideData>>;
|
|
@@ -37,18 +37,23 @@ function hasCDSSubfeatures(feature) {
|
|
|
37
37
|
const subfeatures = feature.get('subfeatures');
|
|
38
38
|
return subfeatures?.some((sub) => sub.get('type') === 'CDS') ?? false;
|
|
39
39
|
}
|
|
40
|
-
function findTranscriptsWithCDS(features) {
|
|
40
|
+
export function findTranscriptsWithCDS(features) {
|
|
41
41
|
const transcripts = [];
|
|
42
42
|
for (const feature of features.values()) {
|
|
43
43
|
const type = feature.get('type');
|
|
44
44
|
const subfeatures = feature.get('subfeatures');
|
|
45
45
|
if (type === 'gene' && subfeatures?.length) {
|
|
46
|
+
let hasTranscriptWithCDS = false;
|
|
46
47
|
for (const subfeature of subfeatures) {
|
|
47
48
|
const subType = subfeature.get('type');
|
|
48
49
|
if (isTranscriptType(subType) && hasCDSSubfeatures(subfeature)) {
|
|
49
50
|
transcripts.push(subfeature);
|
|
51
|
+
hasTranscriptWithCDS = true;
|
|
50
52
|
}
|
|
51
53
|
}
|
|
54
|
+
if (!hasTranscriptWithCDS && hasCDSSubfeatures(feature)) {
|
|
55
|
+
transcripts.push(feature);
|
|
56
|
+
}
|
|
52
57
|
}
|
|
53
58
|
else if (isTranscriptType(type) && hasCDSSubfeatures(feature)) {
|
|
54
59
|
transcripts.push(feature);
|
|
@@ -19,8 +19,11 @@ export interface RenderConfigContext {
|
|
|
19
19
|
outline: CachedConfig<string>;
|
|
20
20
|
featureHeight: CachedConfig<number>;
|
|
21
21
|
fontHeight: CachedConfig<number>;
|
|
22
|
+
nameColor: CachedConfig<string>;
|
|
23
|
+
descriptionColor: CachedConfig<string>;
|
|
22
24
|
labelAllowed: boolean;
|
|
23
25
|
geneGlyphMode: string;
|
|
24
26
|
displayDirectionalChevrons: boolean;
|
|
27
|
+
heightMultiplier: number;
|
|
25
28
|
}
|
|
26
29
|
export declare function createRenderConfigContext(config: AnyConfigurationModel): RenderConfigContext;
|
|
@@ -12,6 +12,12 @@ function createCachedConfig(config, key, defaultValue) {
|
|
|
12
12
|
const value = isCallback ? defaultValue : readConfObject(config, key);
|
|
13
13
|
return { value, isCallback };
|
|
14
14
|
}
|
|
15
|
+
function getHeightMultiplier(displayMode) {
|
|
16
|
+
if (displayMode === 'compact') {
|
|
17
|
+
return 0.5;
|
|
18
|
+
}
|
|
19
|
+
return 1;
|
|
20
|
+
}
|
|
15
21
|
export function createRenderConfigContext(config) {
|
|
16
22
|
const displayMode = readConfObject(config, 'displayMode');
|
|
17
23
|
return {
|
|
@@ -30,6 +36,9 @@ export function createRenderConfigContext(config) {
|
|
|
30
36
|
outline: createCachedConfig(config, 'outline', ''),
|
|
31
37
|
featureHeight: createCachedConfig(config, 'height', 10),
|
|
32
38
|
fontHeight: createCachedConfig(config, ['labels', 'fontSize'], 12),
|
|
39
|
+
nameColor: createCachedConfig(config, ['labels', 'nameColor'], 'black'),
|
|
40
|
+
descriptionColor: createCachedConfig(config, ['labels', 'descriptionColor'], 'blue'),
|
|
33
41
|
labelAllowed: displayMode !== 'collapse',
|
|
42
|
+
heightMultiplier: getHeightMultiplier(displayMode),
|
|
34
43
|
};
|
|
35
44
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { RenderConfigContext } from './renderConfig.ts';
|
|
2
2
|
import type PluginManager from '@jbrowse/core/PluginManager';
|
|
3
3
|
import type { AnyConfigurationModel } from '@jbrowse/core/configuration';
|
|
4
|
-
import type { Feature, Region } from '@jbrowse/core/util';
|
|
4
|
+
import type { Feature, LastStopTokenCheck, Region } from '@jbrowse/core/util';
|
|
5
5
|
import type { BaseLayout } from '@jbrowse/core/util/layouts';
|
|
6
6
|
import type { Theme } from '@mui/material';
|
|
7
7
|
export interface SequenceData {
|
|
@@ -56,8 +56,6 @@ export interface LayoutRecord {
|
|
|
56
56
|
feature: Feature;
|
|
57
57
|
layout: FeatureLayout;
|
|
58
58
|
topPx: number;
|
|
59
|
-
label: string;
|
|
60
|
-
description: string;
|
|
61
59
|
}
|
|
62
60
|
export interface FlatbushItem {
|
|
63
61
|
featureId: string;
|
|
@@ -90,6 +88,7 @@ export interface RenderArgs {
|
|
|
90
88
|
theme: Record<string, any>;
|
|
91
89
|
highResolutionScaling?: number;
|
|
92
90
|
stopToken?: string;
|
|
91
|
+
stopTokenCheck?: LastStopTokenCheck;
|
|
93
92
|
peptideDataMap?: Map<string, PeptideData>;
|
|
94
93
|
colorByCDS?: boolean;
|
|
95
94
|
pluginManager?: PluginManager;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@jbrowse/plugin-canvas",
|
|
3
|
-
"version": "4.1.
|
|
3
|
+
"version": "4.1.4",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "JBrowse 2 plugin for canvas features",
|
|
6
6
|
"keywords": [
|
|
@@ -22,13 +22,13 @@
|
|
|
22
22
|
],
|
|
23
23
|
"dependencies": {
|
|
24
24
|
"@jbrowse/mobx-state-tree": "^5.5.0",
|
|
25
|
-
"@mui/material": "^7.3.
|
|
25
|
+
"@mui/material": "^7.3.8",
|
|
26
26
|
"g2p_mapper": "^2.0.0",
|
|
27
27
|
"mobx": "^6.15.0",
|
|
28
28
|
"mobx-react": "^9.2.1",
|
|
29
29
|
"rxjs": "^7.8.2",
|
|
30
|
-
"@jbrowse/plugin-linear-genome-view": "^4.1.
|
|
31
|
-
"@jbrowse/core": "^4.1.
|
|
30
|
+
"@jbrowse/plugin-linear-genome-view": "^4.1.4",
|
|
31
|
+
"@jbrowse/core": "^4.1.4"
|
|
32
32
|
},
|
|
33
33
|
"peerDependencies": {
|
|
34
34
|
"react": ">=18.0.0"
|