@@ -227,7 +227,7 @@ function parsePwAnnotations(entitiesById, keys, ontology) {
227227 return pwAnnotations ;
228228}
229229
230- function getPathwayAnnotations ( pathwayJson ) {
230+ export function getPathwayAnnotations ( pathwayJson , selectedOntology ) {
231231 const entitiesById = pathwayJson . entitiesById ;
232232 const keys = Object . keys ( entitiesById ) . filter ( k => k . startsWith ( 'http://identifiers.org' ) ) ;
233233 const sentenceCases = {
@@ -238,12 +238,19 @@ function getPathwayAnnotations(pathwayJson) {
238238 'Disease'
239239 // 'Pathway Ontology' // maybe later
240240 ] ;
241- const pathwayAnnotationsList = ontologies . map ( ontology => {
241+ let selectedOntologies = ontologies ;
242+ if ( selectedOntology ) {
243+ selectedOntologies = [ ontologies . find (
244+ ontology => ontology . toLowerCase ( ) === selectedOntology . toLowerCase ( )
245+ ) ] ;
246+ }
247+ const pathwayAnnotationsList = selectedOntologies . map ( ontology => {
242248 const pwAnnotations = parsePwAnnotations ( entitiesById , keys , ontology ) ;
243249 const links = pwAnnotations . map ( pwa => {
244250 const id = pwa . xrefIdentifier . replace ( ':' , '_' ) ;
245251 const url = `https://purl.obolibrary.org/obo/${ id } ` ;
246- return `<a href="${ url } " target="_blank">${ pwa . term } </a>` ;
252+ const cls = 'class="_ideoPathwayOntologyLink"' ;
253+ return `<a href="${ url } " target="_blank" ${ cls } >${ pwa . term } </a>` ;
247254 } ) . join ( ', ' ) ;
248255
249256 const refinedOntology = sentenceCases [ ontology ] ?? ontology ;
@@ -281,9 +288,10 @@ export function getPathwayGenes() {
281288}
282289
283290
284- function addFooter ( pathwayJson , pathwayContainer ) {
291+ function addFooter ( pathwayJson , pathwayContainer , showOntologies ) {
285292 const description = getDescription ( pathwayJson ) ;
286- const pathwayAnnotations = getPathwayAnnotations ( pathwayJson ) ;
293+ const pathwayAnnotations =
294+ showOntologies ? getPathwayAnnotations ( pathwayJson ) : '' ;
287295 const footer =
288296 `<br/>` +
289297 `<div class="_ideoPathwayFooter">` +
@@ -302,6 +310,9 @@ export async function drawPathway(
302310 showClose = true ,
303311 geneNodeHoverFn ,
304312 pathwayNodeClickFn ,
313+ showDescription ,
314+ showOntologies ,
315+ showDefaultTooltips ,
305316 retryAttempt = 0
306317) {
307318 const pvjsScript = document . querySelector ( `script[src="${ PVJS_URL } "]` ) ;
@@ -324,6 +335,7 @@ export async function drawPathway(
324335 pwId , sourceGene , destGene ,
325336 outerSelector , dimensions , showClose ,
326337 geneNodeHoverFn , pathwayNodeClickFn ,
338+ showDescription ,
327339 retryAttempt ++
328340 ) ;
329341 } , 250 ) ;
@@ -390,7 +402,9 @@ export async function drawPathway(
390402 const pathwayViewer = new Pvjs ( pvjsContainer , pvjsProps ) ;
391403 addHeader ( pwId , pathwayJson , pathwayContainer , showClose ) ;
392404
393- addFooter ( pathwayJson , pathwayContainer ) ;
405+ if ( showDescription ) {
406+ addFooter ( pathwayJson , pathwayContainer , showOntologies ) ;
407+ }
394408
395409 // zoomToEntity(sourceEntityId);
396410
@@ -414,10 +428,15 @@ export async function drawPathway(
414428 }
415429 } ) ;
416430
417- geneNode . setAttribute ( `data-tippy-content` , tooltipContent ) ;
431+ if ( showDefaultTooltips ) {
432+ geneNode . setAttribute ( `data-tippy-content` , tooltipContent ) ;
433+ }
418434 } ) ;
419- const tippyConfig = getTippyConfig ( ) ;
420- tippy ( 'g.GeneProduct[data-tippy-content]' , tippyConfig ) ;
435+ if ( showDefaultTooltips ) {
436+ const tippyConfig = getTippyConfig ( ) ;
437+ tippyConfig . trigger = 'mouseenter' ;
438+ tippy ( 'g.GeneProduct[data-tippy-content]' , tippyConfig ) ;
439+ }
421440
422441 // Add click handler to pathway nodes in this pathway diagram
423442 if ( pathwayNodeClickFn ) {
@@ -433,11 +452,15 @@ export async function drawPathway(
433452 pathwayNodeClickFn ( event , pathwayId ) ;
434453 } ) ;
435454
436- // Indicate this new pathway can be rendered on click
437- const tooltipContent = 'Click to show pathway' ;
438- pathwayNode . setAttribute ( 'data-tippy-content' , tooltipContent ) ;
455+ if ( showDefaultTooltips ) {
456+ // Indicate this new pathway can be rendered on click
457+ const tooltipContent = 'Click to show pathway' ;
458+ pathwayNode . setAttribute ( 'data-tippy-content' , tooltipContent ) ;
459+ }
439460 } ) ;
440461
441- tippy ( 'g.Pathway[data-tippy-content]' , tippyConfig ) ;
462+ if ( showDefaultTooltips ) {
463+ tippy ( 'g.Pathway[data-tippy-content]' , tippyConfig ) ;
464+ }
442465 }
443466}
0 commit comments