@jbrowse/plugin-canvas 4.1.3 → 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/floatingLabels.js +6 -21
- package/esm/CanvasFeatureRenderer/layout/layoutFeatures.js +15 -9
- package/esm/CanvasFeatureRenderer/layout/layoutUtils.js +0 -1
- package/esm/CanvasFeatureRenderer/makeImageData.js +3 -1
- package/esm/CanvasFeatureRenderer/peptides/peptideUtils.d.ts +1 -0
- package/esm/CanvasFeatureRenderer/peptides/peptideUtils.js +6 -1
- package/esm/CanvasFeatureRenderer/renderConfig.d.ts +2 -0
- package/esm/CanvasFeatureRenderer/renderConfig.js +2 -0
- package/esm/CanvasFeatureRenderer/types.d.ts +0 -2
- 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;
|
|
@@ -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
|
});
|
|
@@ -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,
|
|
@@ -39,7 +39,7 @@ export function makeImageData({ ctx, layoutRecords, canvasWidth, renderArgs, con
|
|
|
39
39
|
ctx.textAlign = 'left';
|
|
40
40
|
const { subfeatureLabels, transcriptTypes, config } = configContext;
|
|
41
41
|
for (const record of layoutRecords) {
|
|
42
|
-
const { feature, layout: featureLayout, topPx: recordTopPx
|
|
42
|
+
const { feature, layout: featureLayout, topPx: recordTopPx } = record;
|
|
43
43
|
const featureStartBp = feature.get(region.reversed ? 'end' : 'start');
|
|
44
44
|
const startPx = bpToPx(featureStartBp, region, bpPerPx);
|
|
45
45
|
const canvasLayout = convertToCanvasCoords(featureLayout, startPx, recordTopPx);
|
|
@@ -50,6 +50,8 @@ export function makeImageData({ ctx, layoutRecords, canvasWidth, renderArgs, con
|
|
|
50
50
|
top: canvasLayout.y,
|
|
51
51
|
bottom: canvasLayout.y + canvasLayout.totalLayoutHeight,
|
|
52
52
|
};
|
|
53
|
+
const label = String(readConfObject(config, ['labels', 'name'], { feature }) || '');
|
|
54
|
+
const description = String(readConfObject(config, ['labels', 'description'], { feature }) || '');
|
|
53
55
|
const tooltip = String(readConfObject(config, 'mouseover', { feature, label, description }) ||
|
|
54
56
|
'');
|
|
55
57
|
coords.push(bounds.left, bounds.top, bounds.right, bounds.bottom);
|
|
@@ -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,6 +19,8 @@ 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;
|
|
@@ -36,6 +36,8 @@ export function createRenderConfigContext(config) {
|
|
|
36
36
|
outline: createCachedConfig(config, 'outline', ''),
|
|
37
37
|
featureHeight: createCachedConfig(config, 'height', 10),
|
|
38
38
|
fontHeight: createCachedConfig(config, ['labels', 'fontSize'], 12),
|
|
39
|
+
nameColor: createCachedConfig(config, ['labels', 'nameColor'], 'black'),
|
|
40
|
+
descriptionColor: createCachedConfig(config, ['labels', 'descriptionColor'], 'blue'),
|
|
39
41
|
labelAllowed: displayMode !== 'collapse',
|
|
40
42
|
heightMultiplier: getHeightMultiplier(displayMode),
|
|
41
43
|
};
|
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/
|
|
31
|
-
"@jbrowse/
|
|
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"
|