From 1eadee72283d3c74bd5d873c41d4b346f5a595f0 Mon Sep 17 00:00:00 2001 From: Colleen Xu Date: Thu, 21 Mar 2024 23:26:20 -0700 Subject: [PATCH 1/2] feat: update templates for treats-refactor --- data/templates/Drug-treats-Disease/Chem-treats-DoP.json | 2 +- .../Drug-treats-Disease/Chem-treats-PhenoOfDisease.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/data/templates/Drug-treats-Disease/Chem-treats-DoP.json b/data/templates/Drug-treats-Disease/Chem-treats-DoP.json index 1bdf23ad..663d467b 100644 --- a/data/templates/Drug-treats-Disease/Chem-treats-DoP.json +++ b/data/templates/Drug-treats-Disease/Chem-treats-DoP.json @@ -13,7 +13,7 @@ "eA": { "subject": "creativeQuerySubject", "object": "creativeQueryObject", - "predicates": ["biolink:treats"] + "predicates": ["biolink:treats_or_applied_or_studied_to_treat"] } } } diff --git a/data/templates/Drug-treats-Disease/Chem-treats-PhenoOfDisease.json b/data/templates/Drug-treats-Disease/Chem-treats-PhenoOfDisease.json index a8f23fc1..e54787f1 100644 --- a/data/templates/Drug-treats-Disease/Chem-treats-PhenoOfDisease.json +++ b/data/templates/Drug-treats-Disease/Chem-treats-PhenoOfDisease.json @@ -17,7 +17,7 @@ "eA": { "subject": "creativeQuerySubject", "object": "nA", - "predicates": ["biolink:treats"] + "predicates": ["biolink:treats_or_applied_or_studied_to_treat"] }, "eB": { "subject": "creativeQueryObject", From e602f5a16d626a51694737a790ffa46c0bcc8fff Mon Sep 17 00:00:00 2001 From: tokebe <43009413+tokebe@users.noreply.github.com> Date: Fri, 22 Mar 2024 13:28:45 -0400 Subject: [PATCH 2/2] fix: terminate on broken chain --- src/edge_manager.ts | 24 ++++++++++++++++-------- 1 file changed, 16 insertions(+), 8 deletions(-) diff --git a/src/edge_manager.ts b/src/edge_manager.ts index 145e415c..d62db752 100644 --- a/src/edge_manager.ts +++ b/src/edge_manager.ts @@ -231,7 +231,7 @@ export default class QueryEdgeManager { return keep; } - collectRecords(): void { + collectRecords(): boolean { //go through edges and collect records organized by edge let recordsByQEdgeID: RecordsByQEdgeID = {}; //all res merged @@ -268,12 +268,10 @@ export default class QueryEdgeManager { new LogEntry( 'WARNING', null, - `qEdges ${JSON.stringify(brokenEdges)} ` + `resulted in (0) records. No complete paths can be formed.`, + `qEdges ${brokenEdges} resulted in (0) records. No complete paths can be formed.`, ).getLog(), ); - debug( - `(12) qEdges ${JSON.stringify(brokenEdges)} ` + `resulted in (0) records. No complete paths can be formed.`, - ); + debug(`(12) qEdges ${brokenEdges} resulted in (0) records. No complete paths can be formed.`); } //Organized by edge: update query records this._organizedRecords = recordsByQEdgeID; @@ -289,8 +287,12 @@ export default class QueryEdgeManager { // console.log(err); // } // }); - debug(`(12) Collected (${this._records.length}) records!`); - this.logs.push(new LogEntry('DEBUG', null, `Edge manager collected (${this._records.length}) records!`).getLog()); + if (!brokenChain) { + debug(`(12) Collected (${this._records.length}) records!`); + this.logs.push(new LogEntry('DEBUG', null, `Edge manager collected (${this._records.length}) records!`).getLog()); + } + + return !brokenChain; } updateEdgeRecords(currentQEdge: QEdge): void { @@ -474,7 +476,13 @@ export default class QueryEdgeManager { } this._logSkippedQueries(unavailableAPIs); // collect and organize records - this.collectRecords(); + if (!this.collectRecords()) { + debug(`(X) Terminating...No complete paths.`); + this.logs.push( + new LogEntry('WARNING', null, `No complete paths could be formed. Your query terminates.`).getLog(), + ); + return; + } // dump records if set to do so if (process.env.DUMP_RECORDS) { await this.dumpRecords(this.getRecords());