Skip to content

Commit b60d315

Browse files
AmirMohammad CheraghaliAmirMohammad Cheraghali
authored andcommitted
Refine Backbone representation to use Trace for better visualization
1 parent cf32a9b commit b60d315

2 files changed

Lines changed: 31 additions & 5 deletions

File tree

src/components/ProteinViewer.tsx

Lines changed: 21 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2406,6 +2406,13 @@ export const ProteinViewer = forwardRef<ProteinViewerRef, ProteinViewerProps>(({
24062406

24072407

24082408
let repType = representation || 'cartoon';
2409+
2410+
// Fix: 'backbone' representation in NGL can sometimes render as disconnected dots if backbone atoms are incomplete.
2411+
// 'trace' is a robust C-alpha trace that guarantees a continuous tubular visualization.
2412+
if (repType === 'backbone') {
2413+
repType = 'trace';
2414+
}
2415+
24092416
let finalColor: any = coloring || 'chainid';
24102417

24112418
// --- 1. RESOLVE ALIASES & DEFAULTS ---
@@ -2424,12 +2431,22 @@ export const ProteinViewer = forwardRef<ProteinViewerRef, ProteinViewerProps>(({
24242431
finalColor = 'element';
24252432
}
24262433

2434+
// Note: Since we are using replace_file_content, I need to match the ENTIRE block or use multi-replace.
2435+
// To avoid replacing massive chunks, I will split this into two edits if needed, but let's try to target the top part first
2436+
// and the params part second?
2437+
// Actually, replace_file_content works on a contiguous block.
2438+
// The StartLine/EndLine must be precise.
2439+
2440+
// Let's rewrite the `repType` initialization logic at the top.
2441+
// And then the param logic at the bottom is separate.
2442+
2443+
// ERROR: I cannot easily edit two separated parts in one replace_file_content.
2444+
// I should use `multi_replace_file_content` instead.
2445+
2446+
24272447
// --- 2. REGISTER DYNAMIC SCHEMES (Charge & Custom) ---
24282448
const NGL = window.NGL;
24292449

2430-
// Custom Scheme Logic using Native NGL SelectionColormaker
2431-
// This is robust because it uses NGL's internal selection handling and fallback logic.
2432-
24332450
// Helper: Register Charge Scheme (Dynamic)
24342451
if (finalColor === 'charge') {
24352452
finalColor = NGL.ColormakerRegistry.addScheme(function (this: any, params: any) {
@@ -2521,7 +2538,7 @@ export const ProteinViewer = forwardRef<ProteinViewerRef, ProteinViewerProps>(({
25212538
delete globalParams.quality;
25222539
Object.assign(globalParams, cartoonParams);
25232540
// try { component.structure.eachModel((m: any) => m.calculateSecondaryStructure?.()); } catch (e) { }
2524-
} else if (repType === 'backbone') {
2541+
} else if (repType === 'trace') {
25252542
Object.assign(globalParams, backboneParams);
25262543
}
25272544

src/types.ts

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,16 @@ export interface ResidueInfo {
9494
}
9595

9696

97-
export type RepresentationType = 'cartoon' | 'licorice' | 'backbone' | 'spacefill' | 'surface' | 'ribbon' | 'ball+stick' | 'line';
97+
export type RepresentationType =
98+
| 'cartoon'
99+
| 'ribbon'
100+
| 'ball+stick'
101+
| 'spacefill'
102+
| 'surface'
103+
| 'line'
104+
| 'backbone'
105+
| 'licorice'
106+
| 'trace';
98107
export type ColoringType = 'chainid' | 'residue' | 'secondary' | 'hydrophobicity' | 'structure' | 'bfactor' | 'charge' | 'residueindex' | 'element' | 'custom';
99108
export type ColorPalette = 'standard' | 'viridis' | 'magma' | 'cividis' | 'plasma';
100109

0 commit comments

Comments
 (0)