From 6ebae138f00307b5ca34989d4a424fa10c371c52 Mon Sep 17 00:00:00 2001 From: tokebe <43009413+tokebe@users.noreply.github.com> Date: Thu, 26 Sep 2024 16:03:16 -0400 Subject: [PATCH] fix: don't use aux graphs for nodes in creative --- src/inferred_mode/inferred_mode.ts | 2 +- src/inferred_mode/pathfinder.ts | 2 +- src/results_assembly/pfocr.ts | 20 +------------------- 3 files changed, 3 insertions(+), 21 deletions(-) diff --git a/src/inferred_mode/inferred_mode.ts b/src/inferred_mode/inferred_mode.ts index 5fdda412..15dfc63e 100644 --- a/src/inferred_mode/inferred_mode.ts +++ b/src/inferred_mode/inferred_mode.ts @@ -725,7 +725,7 @@ export default class InferredQueryHandler { // add pfocr figures if (!this.pathfinder) { - this.logs = [...this.logs, ...(await enrichTrapiResultsWithPfocrFigures(response, true))]; + this.logs = [...this.logs, ...(await enrichTrapiResultsWithPfocrFigures(response))]; } // get the final summary log diff --git a/src/inferred_mode/pathfinder.ts b/src/inferred_mode/pathfinder.ts index ddcc61d4..1cbad7ef 100644 --- a/src/inferred_mode/pathfinder.ts +++ b/src/inferred_mode/pathfinder.ts @@ -144,7 +144,7 @@ export default class PathfinderQueryHandler { this._pruneKg(creativeResponse); // pfocr - this.logs = [...this.logs, ...(await enrichTrapiResultsWithPfocrFigures(creativeResponse, true))]; + this.logs = [...this.logs, ...(await enrichTrapiResultsWithPfocrFigures(creativeResponse))]; // logs creativeResponse.logs = this.logs.map((log) => log.toJSON()); diff --git a/src/results_assembly/pfocr.ts b/src/results_assembly/pfocr.ts index b4819c0b..b6d59e04 100644 --- a/src/results_assembly/pfocr.ts +++ b/src/results_assembly/pfocr.ts @@ -176,7 +176,7 @@ function traverseResultForNodes(result: TrapiResult, response: TrapiResponse): S * t: trapiResults.length * f: figures.length */ -export async function enrichTrapiResultsWithPfocrFigures(response: TrapiResponse, checkAuxGraphs = false): Promise { +export async function enrichTrapiResultsWithPfocrFigures(response: TrapiResponse): Promise { // NOTE: This function operates on the actual TRAPI information that will be returned // to the client. Don't mutate what shouldn't be mutated! const results = response.message.results; @@ -192,24 +192,6 @@ export async function enrichTrapiResultsWithPfocrFigures(response: TrapiResponse Object.values(result.node_bindings).forEach((bindings) => bindings.forEach((binding) => nodes.add(response.message.knowledge_graph.nodes[binding.id])), ); - // check aux graphs if applicable - if (checkAuxGraphs) { - for (const edgeId in result.analyses[0].edge_bindings) { - for (const eb of result.analyses[0].edge_bindings[edgeId]) { - const edge = response.message.knowledge_graph.edges[eb.id]; - const supportGraphs = edge.attributes.find((attribute) => attribute.attribute_type_id == 'biolink:support_graphs'); - if (supportGraphs) { - (supportGraphs.value as string[]).forEach((auxGraphID) => - response.message.auxiliary_graphs[auxGraphID].edges.forEach((edgeID) => { - const edge = response.message.knowledge_graph.edges[edgeID]; - nodes.add(response.message.knowledge_graph.nodes[edge.subject]); - nodes.add(response.message.knowledge_graph.nodes[edge.object]); - }), - ); - } - } - } - } const combo: Set = new Set(); let matchedNodes = 0;