Skip to content

Commit 8426e19

Browse files
AmirMohammad CheraghaliAmirMohammad Cheraghali
authored andcommitted
Fix: Charge coloring using explicit multi-representation approach with hex colors
1 parent e3c52b7 commit 8426e19

1 file changed

Lines changed: 17 additions & 13 deletions

File tree

src/components/ProteinViewer.tsx

Lines changed: 17 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1310,21 +1310,25 @@ export const ProteinViewer = forwardRef<ProteinViewerRef, ProteinViewerProps>(({
13101310
chainIdx++;
13111311
});
13121312
} else if (currentColoring === 'charge') {
1313-
// IMPROVEMENT: MANUAL CHARGE COLORING (SAFE SELECTION SCHEME)
1314-
// Rules are processed in order. First match wins.
1315-
// 1. Blue (Pos)
1316-
// 2. Red (Neg)
1317-
// 3. White (Base/Catch-all)
1318-
const chargeSchemeId = "charge_coloring_fixed";
1319-
1320-
NGL.ColormakerRegistry.addSelectionScheme(chargeSchemeId, [
1321-
["blue", "ARG or LYS or HIS"],
1322-
["red", "ASP or GLU"],
1323-
["white", "*"]
1324-
]);
1313+
// CHARGE COLORING: Multi-representation approach
1314+
// Base layer (white) ensures continuous structure
1315+
component.addRepresentation(repType, {
1316+
color: 0xFFFFFF,
1317+
name: "charge_base"
1318+
});
1319+
1320+
// Overlay: Positive residues (blue)
1321+
component.addRepresentation(repType, {
1322+
color: 0x0000FF,
1323+
sele: "ARG or LYS or HIS",
1324+
name: "charge_positive"
1325+
});
13251326

1327+
// Overlay: Negative residues (red)
13261328
component.addRepresentation(repType, {
1327-
color: chargeSchemeId
1329+
color: 0xFF0000,
1330+
sele: "ASP or GLU",
1331+
name: "charge_negative"
13281332
});
13291333
} else {
13301334
// Standard Coloring for other modes (sstruc, element, etc.) -> Robust Native NGL

0 commit comments

Comments
 (0)