Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
tokebe committed Sep 26, 2024
2 parents cb803ce + 6ebae13 commit 3a83c6f
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 21 deletions.
2 changes: 1 addition & 1 deletion src/inferred_mode/inferred_mode.ts
Original file line number Diff line number Diff line change
Expand Up @@ -724,7 +724,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
Expand Down
2 changes: 1 addition & 1 deletion src/inferred_mode/pathfinder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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());
Expand Down
20 changes: 1 addition & 19 deletions src/results_assembly/pfocr.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<StampedLog[]> {
export async function enrichTrapiResultsWithPfocrFigures(response: TrapiResponse): Promise<StampedLog[]> {
// 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;
Expand All @@ -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<string> = new Set();
let matchedNodes = 0;
Expand Down

0 comments on commit 3a83c6f

Please sign in to comment.