@@ -51,9 +51,12 @@ const squaredDist = (pos1: Position, pos2: Position) => {
5151
5252const dist = ( pos1 : Position , pos2 : Position ) => Math . sqrt ( squaredDist ( pos1 , pos2 ) )
5353
54- const isFinitePoint = ( point : Position | undefined | null ) : point is Position =>
55- ! ! point && Number . isFinite ( point . x ) && Number . isFinite ( point . y ) ;
56-
54+ const isFinitePoint = ( point : Position | undefined | null ) : point is Position => {
55+ const isFinite = ! ! point && Number . isFinite ( point . x ) && Number . isFinite ( point . y ) ;
56+ console . assert ( isFinite , `Invalid point with coordinates: ${ point ?. x } , ${ point ?. y } ` ) ;
57+ return isFinite ;
58+ }
59+
5760const closestToAverage = ( positions : Position [ ] ) : Position => {
5861 const average = avg ( positions ) ;
5962 let closest = positions [ 0 ] ;
@@ -566,11 +569,11 @@ export class DiagramService {
566569
567570 let [ from , to ] = [ points . shift ( ) ! , points . pop ( ) ! ]
568571 // Keep fallback direction aligned with edge source/target for connectors that have missing segment endpoints.
569- from = from ?? sourceP ;
570- to = to ?? targetP ;
572+ from = from ?? nodeP ;
573+ to = to ?? reactionP ;
571574 if ( equal ( from , to ) ) {
572- from = sourceP ;
573- to = targetP ;
575+ from = nodeP ;
576+ to = reactionP ;
574577 }
575578 if ( connector . type === 'CATALYST' && connector . endShape ) {
576579 to = scale ( connector . endShape . centre || connector . endShape . c ) ;
@@ -590,7 +593,7 @@ export class DiagramService {
590593 if ( equal ( from , reactionP ) || equal ( to , reactionP ) ) d -= REACTION_RADIUS ;
591594 if ( classes . includes ( 'positive-regulation' ) || classes . includes ( 'catalysis' ) || classes . includes ( 'production' ) ) d -= ARROW_MULT * T ;
592595 // 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}`)
593- console . assert ( Math . abs ( d ) >= MIN_DIST , `${ 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 } ` )
596+ console . assert ( d >= MIN_DIST , `${ 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 } ` )
594597
595598 let replacement , replacedBy ;
596599 if ( connector . isFadeOut ) {
0 commit comments