Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Move biolink methods to utils #218

Merged
merged 4 commits into from
Sep 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
72 changes: 0 additions & 72 deletions __test__/integration/biolink.test.ts

This file was deleted.

66 changes: 33 additions & 33 deletions __test__/integration/graph/graph.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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('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('3eb29a4cead0e5f3c3bdca4997bf215b');
expect(Array.from(g.edges['3eb29a4cead0e5f3c3bdca4997bf215b'].apis)).toEqual(['API1']);
expect(g.edges['3eb29a4cead0e5f3c3bdca4997bf215b'].sources).toHaveProperty('source1');
expect(Array.from(g.edges['3eb29a4cead0e5f3c3bdca4997bf215b'].publications)).toEqual(['PMID:1', 'PMID:2']);
expect(g.edges['3eb29a4cead0e5f3c3bdca4997bf215b'].attributes).toHaveProperty('relation', new Set(['relation1']));
});

test('Multiple query results are correctly updated for two edges having same input, predicate and output', () => {
Expand All @@ -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('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('3eb29a4cead0e5f3c3bdca4997bf215b');
expect(Array.from(g.edges['3eb29a4cead0e5f3c3bdca4997bf215b'].apis)).toEqual(['API1']);
expect(g.edges['3eb29a4cead0e5f3c3bdca4997bf215b'].sources).toHaveProperty('source1');
expect(Array.from(g.edges['3eb29a4cead0e5f3c3bdca4997bf215b'].publications)).toEqual(['PMID:1', 'PMID:2']);
expect(g.edges['3eb29a4cead0e5f3c3bdca4997bf215b'].attributes).toHaveProperty('relation', new Set(['relation1']));

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('6930dcb2e9363817e9f6e736829ce278');
expect(Array.from(g.edges['6930dcb2e9363817e9f6e736829ce278'].apis)).toEqual(['API2']);
expect(g.edges['6930dcb2e9363817e9f6e736829ce278'].sources).toHaveProperty('source2');
expect(Array.from(g.edges['6930dcb2e9363817e9f6e736829ce278'].publications)).toEqual(['PMC:1', 'PMC:2']);
expect(g.edges['6930dcb2e9363817e9f6e736829ce278'].attributes).toHaveProperty('relation', new Set(['relation2']));
});

test('Multiple query results for different edges are correctly updated', () => {
Expand All @@ -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('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('3eb29a4cead0e5f3c3bdca4997bf215b');
expect(Array.from(g.edges['3eb29a4cead0e5f3c3bdca4997bf215b'].apis)).toEqual(['API1']);
expect(g.edges['3eb29a4cead0e5f3c3bdca4997bf215b'].sources).toHaveProperty('source1');
expect(Array.from(g.edges['3eb29a4cead0e5f3c3bdca4997bf215b'].publications)).toEqual(['PMID:1', 'PMID:2']);
expect(g.edges['3eb29a4cead0e5f3c3bdca4997bf215b'].attributes).toHaveProperty('relation', new Set(['relation1']));

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('6930dcb2e9363817e9f6e736829ce278');
expect(Array.from(g.edges['6930dcb2e9363817e9f6e736829ce278'].apis)).toEqual(['API2']);
expect(g.edges['6930dcb2e9363817e9f6e736829ce278'].sources).toHaveProperty('source2');
expect(Array.from(g.edges['6930dcb2e9363817e9f6e736829ce278'].publications)).toEqual(['PMC:1', 'PMC:2']);
expect(g.edges['6930dcb2e9363817e9f6e736829ce278'].attributes).toHaveProperty('relation', new Set(['relation2']));

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']));
expect(g.edges).toHaveProperty('38e8cf1917452c83bb878c5a916ef86a');
expect(Array.from(g.edges['38e8cf1917452c83bb878c5a916ef86a'].apis)).toEqual(['API3']);
expect(g.edges['38e8cf1917452c83bb878c5a916ef86a'].sources).toHaveProperty('source3');
expect(Array.from(g.edges['38e8cf1917452c83bb878c5a916ef86a'].publications)).toEqual(['PMC:3', 'PMC:4']);
expect(g.edges['38e8cf1917452c83bb878c5a916ef86a'].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('3138ca0afca791770ed38c243dea2116');
expect(Array.from(g.edges['3138ca0afca791770ed38c243dea2116'].publications)).toEqual([
expect(g.edges).toHaveProperty('38e8cf1917452c83bb878c5a916ef86a');
expect(Array.from(g.edges['38e8cf1917452c83bb878c5a916ef86a'].publications)).toEqual([
'PMC:3',
'PMC:4',
'PMC:6',
'PMC:7',
]);
expect(g.edges['3138ca0afca791770ed38c243dea2116'].attributes).toHaveProperty(
expect(g.edges['38e8cf1917452c83bb878c5a916ef86a'].attributes).toHaveProperty(
'relation',
new Set(['relation3', 'relation3a', 'relation3b']),
);
Expand Down
29 changes: 29 additions & 0 deletions __test__/unittest/inferred_mode.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -351,11 +351,13 @@ describe('Test InferredQueryHandler', () => {
creativeQuerySubject: [
{
id: 'fakeCompound2',
attributes: []
},
],
creativeQueryObject: [
{
id: 'fakeDisease1',
attributes: []
},
],
},
Expand All @@ -366,6 +368,7 @@ describe('Test InferredQueryHandler', () => {
e0: [
{
id: 'edgeHash1',
attributes: []
},
],
},
Expand All @@ -378,11 +381,13 @@ describe('Test InferredQueryHandler', () => {
creativeQuerySubject: [
{
id: 'fakeCompound1',
attributes: []
},
],
creativeQueryObject: [
{
id: 'fakeDisease1',
attributes: []
},
],
},
Expand All @@ -393,6 +398,7 @@ describe('Test InferredQueryHandler', () => {
e0: [
{
id: 'edgeHash2',
attributes: []
},
],
},
Expand All @@ -405,11 +411,13 @@ describe('Test InferredQueryHandler', () => {
creativeQuerySubject: [
{
id: 'fakeCompound3',
attributes: []
},
],
creativeQueryObject: [
{
id: 'fakeDisease1',
attributes: []
},
],
},
Expand All @@ -420,6 +428,7 @@ describe('Test InferredQueryHandler', () => {
e0: [
{
id: 'edgeHash3',
attributes: []
},
],
},
Expand Down Expand Up @@ -477,11 +486,13 @@ describe('Test InferredQueryHandler', () => {
n01: [
{
id: 'fakeCompound1',
attributes: []
},
],
n02: [
{
id: 'fakeDisease1',
attributes: []
},
],
},
Expand All @@ -492,6 +503,7 @@ describe('Test InferredQueryHandler', () => {
e01: [
{
id: 'edgeHash1',
attributes: []
},
],
},
Expand All @@ -504,11 +516,13 @@ describe('Test InferredQueryHandler', () => {
n01: [
{
id: 'fakeCompound3',
attributes: []
},
],
n02: [
{
id: 'fakeDisease1',
attributes: []
},
],
},
Expand All @@ -518,6 +532,7 @@ describe('Test InferredQueryHandler', () => {
e01: [
{
id: 'edgeHash2',
attributes: []
},
],
},
Expand Down Expand Up @@ -635,16 +650,19 @@ describe('Test InferredQueryHandler', () => {
creativeQuerySubject: [
{
id: 'fakeCompound4',
attributes: []
},
],
creativeQueryObject: [
{
id: 'fakeDisease1',
attributes: []
},
],
n01: [
{
id: 'fakeGene1',
attributes: []
},
],
},
Expand All @@ -655,11 +673,13 @@ describe('Test InferredQueryHandler', () => {
e0: [
{
id: 'edgeHash1',
attributes: []
},
],
e01: [
{
id: 'edgeHash2',
attributes: []
},
],
},
Expand All @@ -672,11 +692,13 @@ describe('Test InferredQueryHandler', () => {
creativeQuerySubject: [
{
id: 'fakeCompound1',
attributes: []
},
],
creativeQueryObject: [
{
id: 'fakeDisease1',
attributes: []
},
],
},
Expand All @@ -687,6 +709,7 @@ describe('Test InferredQueryHandler', () => {
e0: [
{
id: 'edgeHash3',
attributes: []
},
],
},
Expand Down Expand Up @@ -783,11 +806,13 @@ describe('Test InferredQueryHandler', () => {
n01: [
{
id: 'fakeCompound1',
attributes: []
},
],
n02: [
{
id: 'fakeDisease1',
attributes: []
},
],
},
Expand All @@ -798,6 +823,7 @@ describe('Test InferredQueryHandler', () => {
e01: [
{
id: 'edgeHash1',
attributes: []
},
],
},
Expand Down Expand Up @@ -878,11 +904,13 @@ describe('Test InferredQueryHandler', () => {
creativeQuerySubject: [
{
id: 'creativeQuerySubject',
attributes: []
},
],
creativeQueryObject: [
{
id: 'creativeQueryObject',
attributes: []
},
],
},
Expand All @@ -892,6 +920,7 @@ describe('Test InferredQueryHandler', () => {
e01: [
{
id: 'edgeHash1',
attributes: []
},
],
},
Expand Down
Loading
Loading