Skip to content

Commit edd63df

Browse files
AmirMohammad CheraghaliAmirMohammad Cheraghali
authored andcommitted
feat(contact-map): optimize display for single-chain proteins by showing only upper triangle
1 parent a98f582 commit edd63df

1 file changed

Lines changed: 12 additions & 2 deletions

File tree

src/components/ContactMap.tsx

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -237,6 +237,10 @@ export const ContactMap: React.FC<ContactMapProps> = ({
237237
}
238238
ctx.stroke();
239239

240+
// Check for Single Chain Mode
241+
const uniqueChains = new Set(distanceData.labels.map(l => l.chain));
242+
const isSingleChain = uniqueChains.size === 1;
243+
240244
// Draw Contacts
241245
for (let i = 0; i < size; i++) {
242246
for (let j = i; j < size; j++) {
@@ -273,7 +277,11 @@ export const ContactMap: React.FC<ContactMapProps> = ({
273277
// Draw with specific color for filtered mode
274278
ctx.fillStyle = color;
275279
ctx.fillRect(j * P, i * P, P, P);
276-
if (i !== j) ctx.fillRect(i * P, j * P, P, P);
280+
281+
// Only draw symmetric lower triangle if NOT single chain
282+
if (!isSingleChain && i !== j) {
283+
ctx.fillRect(i * P, j * P, P, P);
284+
}
277285

278286
} else {
279287
// Default "Show All" Mode (Blue Heatmap)
@@ -285,7 +293,9 @@ export const ContactMap: React.FC<ContactMapProps> = ({
285293
}
286294

287295
ctx.fillRect(j * P, i * P, P, P);
288-
if (i !== j) {
296+
297+
// Only draw symmetric lower triangle if NOT single chain
298+
if (!isSingleChain && i !== j) {
289299
ctx.fillRect(i * P, j * P, P, P);
290300
}
291301
}

0 commit comments

Comments
 (0)