From 6cd50702c0889522f04f7f21c5ba8e4d7e20ab88 Mon Sep 17 00:00:00 2001 From: Anudeep Tubati <40491005+NeuralFlux@users.noreply.github.com> Date: Thu, 8 Aug 2024 11:46:18 -0400 Subject: [PATCH 1/4] Update test_ws_codecov.yml --- .github/workflows/test_ws_codecov.yml | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/.github/workflows/test_ws_codecov.yml b/.github/workflows/test_ws_codecov.yml index 54c3c6a7..d8226b3b 100644 --- a/.github/workflows/test_ws_codecov.yml +++ b/.github/workflows/test_ws_codecov.yml @@ -13,11 +13,21 @@ jobs: id: branch-name uses: tj-actions/branch-names@v6 - - uses: actions/checkout@v3 + - name: Checkout to specific branch + uses: actions/checkout@v3 + id: specific-checkout + continue-on-error: true with: repository: biothings/biothings_explorer ref: ${{ steps.branch-name.outputs.current_branch }} + - name: Checkout to main if above failed + if: steps.specific-checkout.outcome = 'failure' + uses: actions/checkout@v3 + with: + repository: biothings/biothings_explorer + ref: main + - name: Use Node.js 18.x uses: actions/setup-node@v3 with: From 5e5e2882bf7ef12b73adae14405195a89bbd8cb6 Mon Sep 17 00:00:00 2001 From: Anudeep Tubati <40491005+NeuralFlux@users.noreply.github.com> Date: Thu, 8 Aug 2024 11:54:14 -0400 Subject: [PATCH 2/4] fix: updated test workflow to fallback to main if branch does not exist --- .github/workflows/test_ws_codecov.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/test_ws_codecov.yml b/.github/workflows/test_ws_codecov.yml index d8226b3b..9fbb7106 100644 --- a/.github/workflows/test_ws_codecov.yml +++ b/.github/workflows/test_ws_codecov.yml @@ -22,7 +22,7 @@ jobs: ref: ${{ steps.branch-name.outputs.current_branch }} - name: Checkout to main if above failed - if: steps.specific-checkout.outcome = 'failure' + if: steps.specific-checkout.outcome == 'failure' uses: actions/checkout@v3 with: repository: biothings/biothings_explorer From 079842399fb2d68cb67ff345f71d0bd46ede1fee Mon Sep 17 00:00:00 2001 From: NeuralFlux <40491005+NeuralFlux@users.noreply.github.com> Date: Thu, 15 Aug 2024 17:06:15 -0400 Subject: [PATCH 3/4] fix: update test module imports, function arguments, hashes, and scores --- __test__/integration/KnowledgeGraph.test.ts | 2 +- __test__/integration/QueryEdge.test.ts | 1 - __test__/integration/graph/graph.test.ts | 66 ++++++++++----------- __test__/unittest/inferred_mode.test.ts | 5 +- src/index.ts | 1 + 5 files changed, 38 insertions(+), 37 deletions(-) diff --git a/__test__/integration/KnowledgeGraph.test.ts b/__test__/integration/KnowledgeGraph.test.ts index c993c583..18c99a90 100644 --- a/__test__/integration/KnowledgeGraph.test.ts +++ b/__test__/integration/KnowledgeGraph.test.ts @@ -1,7 +1,7 @@ import KGEdge from '../../src/graph/kg_edge'; import KGNode from '../../src/graph/kg_node'; import KnowledgeGraph from '../../src/graph/knowledge_graph'; -import { TrapiAttribute } from '../../src/types'; +import { TrapiAttribute } from '@biothings-explorer/types'; describe('Testing KnowledgeGraph Module', () => { const nodeInput = new KGNode('PUBCHEM.COMPOUND:2662-n0', { diff --git a/__test__/integration/QueryEdge.test.ts b/__test__/integration/QueryEdge.test.ts index ff2c3195..b195f01e 100644 --- a/__test__/integration/QueryEdge.test.ts +++ b/__test__/integration/QueryEdge.test.ts @@ -143,7 +143,6 @@ describe('Testing QueryEdge Module', () => { expect(res).toContain('contributes_to'); expect(res).toContain('causes'); expect(res).toContain('ameliorates'); - expect(res).toContain('treats'); }); test('Predicates not in biolink model should return itself', () => { diff --git a/__test__/integration/graph/graph.test.ts b/__test__/integration/graph/graph.test.ts index fcdb2a4c..0d650621 100644 --- a/__test__/integration/graph/graph.test.ts +++ b/__test__/integration/graph/graph.test.ts @@ -109,11 +109,11 @@ describe('Test graph class', () => { expect(g.nodes['inputPrimaryCurie'].qNodeID).toEqual('qg1'); expect(Array.from(g.nodes['inputPrimaryCurie'].targetNodes)).toEqual(['outputPrimaryCurie']); expect(Array.from(g.nodes['inputPrimaryCurie'].targetQNodeIDs)).toEqual(['qg2']); - expect(g.edges).toHaveProperty('95fe2a8089c0d79ea093b97c5991f7ba'); - expect(Array.from(g.edges['95fe2a8089c0d79ea093b97c5991f7ba'].apis)).toEqual(['API1']); - expect(g.edges['95fe2a8089c0d79ea093b97c5991f7ba'].sources).toHaveProperty('source1'); - expect(Array.from(g.edges['95fe2a8089c0d79ea093b97c5991f7ba'].publications)).toEqual(['PMID:1', 'PMID:2']); - expect(g.edges['95fe2a8089c0d79ea093b97c5991f7ba'].attributes).toHaveProperty('relation', new Set(['relation1'])); + expect(g.edges).toHaveProperty('2c826c3663b91f65a1cba70f06c7fc65'); + expect(Array.from(g.edges['2c826c3663b91f65a1cba70f06c7fc65'].apis)).toEqual(['API1']); + expect(g.edges['2c826c3663b91f65a1cba70f06c7fc65'].sources).toHaveProperty('source1'); + expect(Array.from(g.edges['2c826c3663b91f65a1cba70f06c7fc65'].publications)).toEqual(['PMID:1', 'PMID:2']); + expect(g.edges['2c826c3663b91f65a1cba70f06c7fc65'].attributes).toHaveProperty('relation', new Set(['relation1'])); }); test('Multiple query results are correctly updated for two edges having same input, predicate and output', () => { @@ -130,17 +130,17 @@ describe('Test graph class', () => { expect(Array.from(g.nodes['inputPrimaryCurie'].targetNodes)).toEqual(['outputPrimaryCurie']); expect(Array.from(g.nodes['inputPrimaryCurie'].targetQNodeIDs)).toEqual(['qg2']); - expect(g.edges).toHaveProperty('95fe2a8089c0d79ea093b97c5991f7ba'); - expect(Array.from(g.edges['95fe2a8089c0d79ea093b97c5991f7ba'].apis)).toEqual(['API1']); - expect(g.edges['95fe2a8089c0d79ea093b97c5991f7ba'].sources).toHaveProperty('source1'); - expect(Array.from(g.edges['95fe2a8089c0d79ea093b97c5991f7ba'].publications)).toEqual(['PMID:1', 'PMID:2']); - expect(g.edges['95fe2a8089c0d79ea093b97c5991f7ba'].attributes).toHaveProperty('relation', new Set(['relation1'])); + expect(g.edges).toHaveProperty('2c826c3663b91f65a1cba70f06c7fc65'); + expect(Array.from(g.edges['2c826c3663b91f65a1cba70f06c7fc65'].apis)).toEqual(['API1']); + expect(g.edges['2c826c3663b91f65a1cba70f06c7fc65'].sources).toHaveProperty('source1'); + expect(Array.from(g.edges['2c826c3663b91f65a1cba70f06c7fc65'].publications)).toEqual(['PMID:1', 'PMID:2']); + expect(g.edges['2c826c3663b91f65a1cba70f06c7fc65'].attributes).toHaveProperty('relation', new Set(['relation1'])); - expect(g.edges).toHaveProperty('9d334cb674d5671364c45cc8403184c6'); - expect(Array.from(g.edges['9d334cb674d5671364c45cc8403184c6'].apis)).toEqual(['API2']); - expect(g.edges['9d334cb674d5671364c45cc8403184c6'].sources).toHaveProperty('source2'); - expect(Array.from(g.edges['9d334cb674d5671364c45cc8403184c6'].publications)).toEqual(['PMC:1', 'PMC:2']); - expect(g.edges['9d334cb674d5671364c45cc8403184c6'].attributes).toHaveProperty('relation', new Set(['relation2'])); + expect(g.edges).toHaveProperty('827c366e2e3088b3f4a90dd88a524f15'); + expect(Array.from(g.edges['827c366e2e3088b3f4a90dd88a524f15'].apis)).toEqual(['API2']); + expect(g.edges['827c366e2e3088b3f4a90dd88a524f15'].sources).toHaveProperty('source2'); + expect(Array.from(g.edges['827c366e2e3088b3f4a90dd88a524f15'].publications)).toEqual(['PMC:1', 'PMC:2']); + expect(g.edges['827c366e2e3088b3f4a90dd88a524f15'].attributes).toHaveProperty('relation', new Set(['relation2'])); }); test('Multiple query results for different edges are correctly updated', () => { @@ -157,37 +157,37 @@ describe('Test graph class', () => { expect(Array.from(g.nodes['inputPrimaryCurie'].targetNodes)).toEqual(['outputPrimaryCurie']); expect(Array.from(g.nodes['inputPrimaryCurie'].targetQNodeIDs)).toEqual(['qg2']); - expect(g.edges).toHaveProperty('95fe2a8089c0d79ea093b97c5991f7ba'); - expect(Array.from(g.edges['95fe2a8089c0d79ea093b97c5991f7ba'].apis)).toEqual(['API1']); - expect(g.edges['95fe2a8089c0d79ea093b97c5991f7ba'].sources).toHaveProperty('source1'); - expect(Array.from(g.edges['95fe2a8089c0d79ea093b97c5991f7ba'].publications)).toEqual(['PMID:1', 'PMID:2']); - expect(g.edges['95fe2a8089c0d79ea093b97c5991f7ba'].attributes).toHaveProperty('relation', new Set(['relation1'])); + expect(g.edges).toHaveProperty('2c826c3663b91f65a1cba70f06c7fc65'); + expect(Array.from(g.edges['2c826c3663b91f65a1cba70f06c7fc65'].apis)).toEqual(['API1']); + expect(g.edges['2c826c3663b91f65a1cba70f06c7fc65'].sources).toHaveProperty('source1'); + expect(Array.from(g.edges['2c826c3663b91f65a1cba70f06c7fc65'].publications)).toEqual(['PMID:1', 'PMID:2']); + expect(g.edges['2c826c3663b91f65a1cba70f06c7fc65'].attributes).toHaveProperty('relation', new Set(['relation1'])); - expect(g.edges).toHaveProperty('9d334cb674d5671364c45cc8403184c6'); - expect(Array.from(g.edges['9d334cb674d5671364c45cc8403184c6'].apis)).toEqual(['API2']); - expect(g.edges['9d334cb674d5671364c45cc8403184c6'].sources).toHaveProperty('source2'); - expect(Array.from(g.edges['9d334cb674d5671364c45cc8403184c6'].publications)).toEqual(['PMC:1', 'PMC:2']); - expect(g.edges['9d334cb674d5671364c45cc8403184c6'].attributes).toHaveProperty('relation', new Set(['relation2'])); + expect(g.edges).toHaveProperty('827c366e2e3088b3f4a90dd88a524f15'); + expect(Array.from(g.edges['827c366e2e3088b3f4a90dd88a524f15'].apis)).toEqual(['API2']); + expect(g.edges['827c366e2e3088b3f4a90dd88a524f15'].sources).toHaveProperty('source2'); + expect(Array.from(g.edges['827c366e2e3088b3f4a90dd88a524f15'].publications)).toEqual(['PMC:1', 'PMC:2']); + expect(g.edges['827c366e2e3088b3f4a90dd88a524f15'].attributes).toHaveProperty('relation', new Set(['relation2'])); - expect(g.edges).toHaveProperty('4fe2d5d3e03e0f78f272745caf6b627d'); - expect(Array.from(g.edges['4fe2d5d3e03e0f78f272745caf6b627d'].apis)).toEqual(['API3']); - expect(g.edges['4fe2d5d3e03e0f78f272745caf6b627d'].sources).toHaveProperty('source3'); - expect(Array.from(g.edges['4fe2d5d3e03e0f78f272745caf6b627d'].publications)).toEqual(['PMC:3', 'PMC:4']); - expect(g.edges['4fe2d5d3e03e0f78f272745caf6b627d'].attributes).toHaveProperty('relation', new Set(['relation3'])); + expect(g.edges).toHaveProperty('3138ca0afca791770ed38c243dea2116'); + expect(Array.from(g.edges['3138ca0afca791770ed38c243dea2116'].apis)).toEqual(['API3']); + expect(g.edges['3138ca0afca791770ed38c243dea2116'].sources).toHaveProperty('source3'); + expect(Array.from(g.edges['3138ca0afca791770ed38c243dea2116'].publications)).toEqual(['PMC:3', 'PMC:4']); + expect(g.edges['3138ca0afca791770ed38c243dea2116'].attributes).toHaveProperty('relation', new Set(['relation3'])); }); test('Multiple attributes with the same name are merged', () => { const g = new graph(); g.update([record3, record3a]); - expect(g.edges).toHaveProperty('4fe2d5d3e03e0f78f272745caf6b627d'); - expect(Array.from(g.edges['4fe2d5d3e03e0f78f272745caf6b627d'].publications)).toEqual([ + expect(g.edges).toHaveProperty('3138ca0afca791770ed38c243dea2116'); + expect(Array.from(g.edges['3138ca0afca791770ed38c243dea2116'].publications)).toEqual([ 'PMC:3', 'PMC:4', 'PMC:6', 'PMC:7', ]); - expect(g.edges['4fe2d5d3e03e0f78f272745caf6b627d'].attributes).toHaveProperty( + expect(g.edges['3138ca0afca791770ed38c243dea2116'].attributes).toHaveProperty( 'relation', new Set(['relation3', 'relation3a', 'relation3b']), ); diff --git a/__test__/unittest/inferred_mode.test.ts b/__test__/unittest/inferred_mode.test.ts index 3aedd136..94565d1c 100644 --- a/__test__/unittest/inferred_mode.test.ts +++ b/__test__/unittest/inferred_mode.test.ts @@ -201,6 +201,7 @@ describe('Test InferredQueryHandler', () => { }, }, template: 'Chem-treats-DoP.json', + qualifiers: {} }, ]; @@ -549,7 +550,7 @@ describe('Test InferredQueryHandler', () => { expect(creativeLimitHit).toBeTruthy(); expect(Object.keys(combinedResponse.message.results)).toHaveLength(3); expect(combinedResponse.message.results['fakeCompound1-fakeDisease1'].analyses[0].score).toEqual( - 0.8421052631578949, + 0.7836531040612146, ); expect(combinedResponse.message.results['fakeCompound3-fakeDisease1'].analyses[0].score).toEqual(0.2); expect(combinedResponse.logs).toHaveLength(3); @@ -712,7 +713,7 @@ describe('Test InferredQueryHandler', () => { expect(Object.keys(mergedResults1)).toHaveLength(1); expect(creativeLimitHit1).toBeTruthy(); expect(combinedResponse.message.results['fakeCompound1-fakeDisease1'].analyses[0].score).toEqual( - 0.8421052631578949, + 0.7836531040612146, ); }); diff --git a/src/index.ts b/src/index.ts index 54d752c1..c1749190 100644 --- a/src/index.ts +++ b/src/index.ts @@ -38,6 +38,7 @@ export { default as QEdge } from './query_edge'; export { default as QNode } from './query_node'; export { default as InvalidQueryGraphError } from './exceptions/invalid_query_graph_error'; export * from './qedge2apiedge'; +export {TrapiQueryGraph, TrapiResponse, TrapiResult}; // better readability export default class TRAPIQueryHandler { logs: StampedLog[]; From ed1f2371aeab66ba7bac4365631b5301738a201d Mon Sep 17 00:00:00 2001 From: NeuralFlux <40491005+NeuralFlux@users.noreply.github.com> Date: Fri, 16 Aug 2024 12:38:52 -0400 Subject: [PATCH 4/4] fix: add x-translator infores to some tests --- __test__/integration/QueryResult.test.ts | 35 ++++++++++++++++++++++++ 1 file changed, 35 insertions(+) diff --git a/__test__/integration/QueryResult.test.ts b/__test__/integration/QueryResult.test.ts index 2fb8cf0a..b2dce3b1 100644 --- a/__test__/integration/QueryResult.test.ts +++ b/__test__/integration/QueryResult.test.ts @@ -43,6 +43,11 @@ describe('Testing QueryResults Module', () => { predicate: 'biolink:physically_interacts_with', source: 'DGIdb', api_name: 'BioThings DGIDB API', + "x-translator": { + infores: "infores:biothings-dgidb", + component: "KP", + team: ["Service Provider"] + } }, edge1, ); @@ -98,6 +103,11 @@ describe('Testing QueryResults Module', () => { { predicate: 'biolink:gene_associated_with_condition', api_name: 'Automat Pharos', + "x-translator": { + infores: "infores:automat-pharos", + component: "KP", + team: ["Ranking Agent"] + } }, edge1, ); @@ -197,6 +207,11 @@ describe('Testing QueryResults Module', () => { { predicate: 'biolink:gene_associated_with_condition', api_name: 'Automat Pharos', + "x-translator": { + infores: "infores:automat-pharos", + component: "KP", + team: ["Ranking Agent"] + } }, edge1, ); @@ -295,6 +310,11 @@ describe('Testing QueryResults Module', () => { { predicate: 'biolink:gene_associated_with_condition', api_name: 'Automat Pharos', + "x-translator": { + infores: "infores:automat-pharos", + component: "KP", + team: ["Ranking Agent"] + } }, edge1, ); @@ -393,6 +413,11 @@ describe('Testing QueryResults Module', () => { { predicate: 'biolink:gene_associated_with_condition', api_name: 'Automat Pharos', + "x-translator": { + infores: "infores:automat-pharos", + component: "KP", + team: ["Ranking Agent"] + } }, edge1, ); @@ -493,6 +518,11 @@ describe('Testing QueryResults Module', () => { { predicate: 'biolink:gene_associated_with_condition', api_name: 'Automat Pharos', + "x-translator": { + infores: "infores:automat-pharos", + component: "KP", + team: ["Ranking Agent"] + } }, edge1, ); @@ -594,6 +624,11 @@ describe('Testing QueryResults Module', () => { { predicate: 'biolink:gene_associated_with_condition', api_name: 'Automat Pharos', + "x-translator": { + infores: "infores:automat-pharos", + component: "KP", + team: ["Ranking Agent"] + } }, edge1, );