Skip to content

Commit 79e2a8e

Browse files
feat: cherry-pick #49 diagram edge fixes + drop 'Reaction Diagram' from TOC
Salvaging the still-relevant parts of PR #49 (open since March 30, since superseded for the description-tab arrow-function form). Two behaviour changes in diagram.service.ts, plus Eliot's review note: diagram.service.ts: - Connectors whose segments are missing endpoints now fall back to the underlying nodeP/reactionP positions instead of sourceP/targetP. source/target swap for OUTPUT connectors, which was pulling some edges the wrong way (Eliot's repro: R-HSA-112307, R-HSA-1296071). - console.assert near MIN_DIST drops the abs() so the assert reflects the actual signed distance (negative d would always pass otherwise). description-tab.component.ts: - The `case 'reactionDiagram'` arm of isTOCIncluded picked up the same `&& showReactionDiagram()` guard the elements array already uses, so reactions whose embedded diagram is suppressed no longer leave an orphaned "Reaction Diagram" item in the right-rail TOC (Eliot's review comment). Closes PR #49. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1 parent e4a27dc commit 79e2a8e

2 files changed

Lines changed: 9 additions & 7 deletions

File tree

projects/pathway-browser/src/app/details/tabs/description-tab/description-tab.component.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -759,7 +759,7 @@ export class DescriptionTabComponent implements OnDestroy {
759759
case 'locationsInPWB':
760760
return this.showLocations();
761761
case 'reactionDiagram':
762-
return this.isReaction();
762+
return this.isReaction() && this.showReactionDiagram();
763763
case DataKeys.PROTEIN_MARKER:
764764
return this.proteinMarkers().length + this.rnaMarkers().length > 0;
765765
case DataKeys.CATALYST_ACTIVITY:

projects/pathway-browser/src/app/services/diagram.service.ts

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -747,12 +747,14 @@ export class DiagramService {
747747
this.addEdgeInfo(reaction, points, 'forward', targetP);
748748

749749
let [from, to] = [points.shift()!, points.pop()!];
750-
// Keep fallback direction aligned with edge source/target for connectors that have missing segment endpoints.
751-
from = from ?? sourceP;
752-
to = to ?? targetP;
750+
// Connectors whose segments are missing endpoints fall back to the
751+
// underlying node and reaction positions (not source/target, which
752+
// swap for OUTPUT connectors and pulled some edges the wrong way).
753+
from = from ?? nodeP;
754+
to = to ?? reactionP;
753755
if (equal(from, to)) {
754-
from = sourceP;
755-
to = targetP;
756+
from = nodeP;
757+
to = reactionP;
756758
}
757759
if (connector.type === 'CATALYST' && connector.endShape) {
758760
to = scale(connector.endShape.centre || connector.endShape.c);
@@ -783,7 +785,7 @@ export class DiagramService {
783785
d -= ARROW_MULT * T;
784786
// console.assert(d > MIN_DIST, `The edge between reaction: R-HSA-${reaction.reactomeId} and entity: R-HSA-${node.reactomeId} in pathway ${id} has a visible length of ${d} which is shorter than ${MIN_DIST}`)
785787
console.assert(
786-
Math.abs(d) >= MIN_DIST,
788+
d >= MIN_DIST,
787789
`${id}\t${diagram.displayName}\t${hasFadeOut}\tR-HSA-${reaction.reactomeId}\tR-HSA-${node.reactomeId}\thttps://release.reactome.org/PathwayBrowser/#/${id}&SEL=R-HSA-${reaction.reactomeId}&FLG=R-HSA-${node.reactomeId}\thttps://reactome-pwp.github.io/PathwayBrowser/${id}?select=${reaction.reactomeId}&flag=${node.reactomeId}`
788790
);
789791

0 commit comments

Comments
 (0)