Skip to content

Commit 2353d78

Browse files
committed
Updated highlight coloring and Ligysis button text
1 parent 7aa12a3 commit 2353d78

File tree

1 file changed

+36
-2
lines changed

1 file changed

+36
-2
lines changed

src/components/structure/StructureViewer.tsx

Lines changed: 36 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import 'molstar/lib/mol-plugin-ui/skin/light.scss';
99
import { useSafetyWindowsHighlighting } from '../../hooks/useSafetyWindowsHighlighting';
1010
import { mapUniProtToKegg } from '../../utils/api/uniprotUtils';
1111
import './StructureViewer.css';
12+
import { Color } from 'molstar/lib/mol-util/color';
1213

1314
interface StructureViewerProps {
1415
/** PDB ID to load (e.g., '1crn') */
@@ -43,6 +44,8 @@ interface StructureViewerProps {
4344
}>;
4445
/** Enable safety window highlighting */
4546
enableSafetyWindowHighlighting?: boolean;
47+
/** Custom colors for cartoon representation (hex color codes) */
48+
cartoonColors?: string[]; // Array of up to 8 hex colors like ['#FF0000', '#00FF00', ...]
4649
}
4750

4851
export const StructureViewer: React.FC<StructureViewerProps> = ({
@@ -57,7 +60,8 @@ export const StructureViewer: React.FC<StructureViewerProps> = ({
5760
onStructureLoaded,
5861
onError,
5962
safetyWindows = [],
60-
enableSafetyWindowHighlighting = false
63+
enableSafetyWindowHighlighting = false,
64+
cartoonColors = ['#FF0000', '#00FF00', '#0000FF', '#FFFF00', '#FF00FF', '#00FFFF', '#000000', '#FFFFFF'] // Default to 8 colors
6165
}) => {
6266
const containerRef = useRef<HTMLDivElement>(null);
6367
const pluginRef = useRef<any>(null);
@@ -77,6 +81,23 @@ export const StructureViewer: React.FC<StructureViewerProps> = ({
7781
const getPluginSpec = (): PluginUISpec => {
7882
const spec = DefaultPluginUISpec();
7983

84+
// Configure Canvas3D rendering and colors
85+
spec.canvas3d = {
86+
...DefaultPluginUISpec().canvas3d,
87+
renderer: {
88+
...DefaultPluginUISpec().canvas3d?.renderer,
89+
backgroundColor: Color(0xffffff), // white background
90+
selectColor: Color(0xff6699), // pink higlight
91+
},
92+
// Customize highlight/selection colors
93+
marking: {
94+
enabled: true,
95+
selectEdgeColor: Color(0xff6699), // pink higlight
96+
highlightEdgeColor: Color(0xff6699), // pink highlight
97+
98+
}
99+
};
100+
80101
// Enable sequence viewer and ensure it's visible
81102
spec.layout = {
82103
initial: {
@@ -279,6 +300,19 @@ export const StructureViewer: React.FC<StructureViewerProps> = ({
279300
type: 'cartoon',
280301
color: 'chain-id',
281302
size: 'uniform',
303+
params: {
304+
// Custom color configuration
305+
colors: cartoonColors?.length ? {
306+
name: 'custom',
307+
params: {
308+
colors: cartoonColors.map(hex => {
309+
// Convert hex to Mol* Color format
310+
const num = parseInt(hex.replace('#', ''), 16);
311+
return Color(num);
312+
})
313+
}
314+
} : undefined
315+
}
282316
}
283317
);
284318
} catch (reprError) {
@@ -662,7 +696,7 @@ export const StructureViewer: React.FC<StructureViewerProps> = ({
662696
className="external-link-button external-link-ligsys"
663697
title={`View ${uniprotId} in LIGSYS Database`}
664698
>
665-
💊 LIGSYS
699+
💊 LIGYSIS
666700
</button>
667701
)}
668702
</div>

0 commit comments

Comments
 (0)