diff --git a/__test__/integration/BatchEdgeQueryHandler.test.js b/__test__/integration/BatchEdgeQueryHandler.test.js index 01046556..d8d2e82d 100644 --- a/__test__/integration/BatchEdgeQueryHandler.test.js +++ b/__test__/integration/BatchEdgeQueryHandler.test.js @@ -1,6 +1,3 @@ -const QNode = require("../../src/query_node"); -const QEdge = require("../../src/query_edge"); -const QExeEdge = require("../../src/query_execution_edge") const BatchEdgeQueryHandler = require("../../src/batch_edge_query"); const meta_kg = require("@biothings-explorer/smartapi-kg"); @@ -9,18 +6,6 @@ describe("Testing BatchEdgeQueryHandler Module", () => { kg.constructMetaKGSync(); describe("Testing query function", () => { - // test("test with one query edge", async () => { - // let gene_node1 = new QNode("n1", { category: "Gene", id: "NCBIGene:1017" }); - // let chemical_node1 = new QNode("n3", { category: "SmallMolecule" }); - // const edge1 = new QEdge("e01", { subject: gene_node1, object: chemical_node1 }); - // const exeEdge1 = new QExeEdge(edge1, false, undefined); - // const batchHandler = new BatchEdgeQueryHandler(kg); - // batchHandler.setEdges([edge1]); - // expect(chemical_node1.hasEquivalentIDs()).toEqual(false); - // const res = await batchHandler.query([edge1]); - // expect(res.length).toBeGreaterThan(1); - // expect(chemical_node1.hasEquivalentIDs()).toEqual(true); - // }) test("test subscribe and unsubscribe function", () => { const batchHandler = new BatchEdgeQueryHandler(kg); diff --git a/__test__/integration/QEdge2BTEEdgeHandler.test.js b/__test__/integration/QEdge2BTEEdgeHandler.test.js index 2b56d153..e6e4f11f 100644 --- a/__test__/integration/QEdge2BTEEdgeHandler.test.js +++ b/__test__/integration/QEdge2BTEEdgeHandler.test.js @@ -12,33 +12,16 @@ describe("Testing NodeUpdateHandler Module", () => { } } } - //gene_node1.setEquivalentIDs(node1_equivalent_ids); - const node2_equivalent_ids = { - "NCBIGene:1017": { - db_ids: { - NCBIGene: ["1017"], - SYMBOL: ['CDK2'] - } - }, - "NCBIGene:1018": { - db_ids: { - NCBIGene: ["1018"], - SYMBOL: ['CDK3'] - } - } - } + const gene_node2 = new QNode("n2", { categories: "Gene", ids: ["NCBIGene:1017", "NCBIGene:1018"] }); const gene_node1_with_id_annotated = new QNode("n1", { categories: "Gene", ids: "NCBIGene:1017" }); gene_node1_with_id_annotated.setEquivalentIDs(node1_equivalent_ids); //gene_node2.setEquivalentIDs(node2_equivalent_ids); - const invalid_node = new QNode("n3", { categories: "INVALID", curie: ["NCBIGene:1017", "NCBIGene:1018"] }) const chemical_node1 = new QNode("n3", { categories: "SmallMolecule" }); - const chemical_node2 = new QNode("n4", { categories: "SmallMolecule", curie: "CHEMBL.COMPUND:CHEMBL744" }); const edge1 = new QEdge("e01", { subject: gene_node1, object: chemical_node1 }); const edge2 = new QEdge("e02", { subject: gene_node1_with_id_annotated, object: chemical_node1 }); const edge3 = new QEdge('e04', { subject: gene_node2, object: chemical_node1 }); const edge4 = new QEdge('e05', { object: gene_node2, subject: chemical_node1 }); - const invalid_edge = new QEdge("e03", { subject: invalid_node, object: chemical_node1 }) describe("Testing _getCuries function", () => { test("test edge with one curie input return an array of one", () => { diff --git a/__test__/integration/QueryEdge.test.js b/__test__/integration/QueryEdge.test.js index 1498f805..e9a76f54 100644 --- a/__test__/integration/QueryEdge.test.js +++ b/__test__/integration/QueryEdge.test.js @@ -13,34 +13,16 @@ describe("Testing QueryEdge Module", () => { } } } - //gene_node1.setEquivalentIDs(node1_equivalent_ids); - const node2_equivalent_ids = { - "NCBIGene:1017": { - db_ids: { - NCBIGene: ["1017"], - SYMBOL: ['CDK2'] - } - }, - "NCBIGene:1018": { - db_ids: { - NCBIGene: ["1018"], - SYMBOL: ['CDK3'] - } - } - } + const gene_node2 = new QNode("n2", { categories: "Gene", ids: ["NCBIGene:1017", "NCBIGene:1018"] }); const gene_node1_with_id_annotated = new QNode("n1", { categories: "Gene", ids: "NCBIGene:1017" }); gene_node1_with_id_annotated.setEquivalentIDs(node1_equivalent_ids); - //gene_node2.setEquivalentIDs(node2_equivalent_ids); - const invalid_node = new QNode("n3", { categories: "INVALID", curie: ["NCBIGene:1017", "NCBIGene:1018"] }) const chemical_node1 = new QNode("n3", { categories: "SmallMolecule" }); - const chemical_node2 = new QNode("n4", { categories: "SmallMolecule", curie: "CHEMBL.COMPUND:CHEMBL744" }); const edge1 = new QEdge("e01", { subject: gene_node1, object: chemical_node1 }); const edge2 = new QEdge("e02", { subject: gene_node1_with_id_annotated, object: chemical_node1 }); const edge3 = new QEdge('e04', { subject: gene_node2, object: chemical_node1 }); const edge4 = new QEdge('e05', { object: gene_node2, subject: chemical_node1 }); const edge5 = new QEdge('e06', { object: gene_node1_with_id_annotated, subject: chemical_node1 }); - const invalid_edge = new QEdge("e03", { subject: invalid_node, object: chemical_node1 }) describe("Testing isReversed function", () => { test("test if only the object of the edge has curie defined, should return true", () => { diff --git a/__test__/integration/QueryGraphHandler.test.js b/__test__/integration/QueryGraphHandler.test.js index 28a2b3f1..065d48a0 100644 --- a/__test__/integration/QueryGraphHandler.test.js +++ b/__test__/integration/QueryGraphHandler.test.js @@ -1,28 +1,27 @@ const QueryGraphHandler = require("../../src/query_graph"); -const QNode = require("../../src/query_node"); +const QNode2 = require("../../src/query_node_2"); const QEdge = require("../../src/query_edge"); -const InvalidQueryGraphError = require("../../src/exceptions/invalid_query_graph_error"); describe("Testing QueryGraphHandler Module", () => { const disease_entity_node = { - categories: "biolink:Disease", - ids: "MONDO:0005737" + categories: ["biolink:Disease"], + ids: ["MONDO:0005737"] }; const gene_entity_node = { - categories: "biolink:Gene", - ids: "NCBIGene:1017" + categories: ["biolink:Gene"], + ids: ["NCBIGene:1017"] }; const gene_class_node = { - categories: "biolink:Gene" + categories: ["biolink:Gene"] }; const chemical_class_node = { - categories: "biolink:SmallMolecule" + categories: ["biolink:SmallMolecule"] }; const pathway_class_node = { - categories: "biolink:Pathways" + categories: ["biolink:Pathways"] }; const phenotype_class_node = { - categories: "biolink:Phenotype" + categories: ["biolink:Phenotype"] }; const OneHopQuery = { nodes: { @@ -37,142 +36,6 @@ describe("Testing QueryGraphHandler Module", () => { } }; - const OneHopQueryReverse = { - nodes: { - n1: disease_entity_node, - n0: gene_class_node, - }, - edges: { - e01: { - subject: "n0", - object: "n1" - } - } - }; - - const TwoHopQuery = { - nodes: { - n0: disease_entity_node, - n1: gene_class_node, - n2: chemical_class_node, - }, - edges: { - e01: { - subject: "n0", - object: "n1" - }, - e02: { - subject: "n1", - object: "n2" - }, - } - }; - - const TwoHopQueryReversed = { - nodes: { - n0: disease_entity_node, - n1: gene_class_node, - n2: chemical_class_node, - }, - edges: { - e01: { - object: "n0", - subject: "n1" - }, - e02: { - object: "n1", - subject: "n2" - }, - } - }; - - const OneHopExplainQuery = { - nodes: { - n0: disease_entity_node, - n1: chemical_class_node, - n2: gene_entity_node, - }, - edges: { - e01: { - subject: "n0", - object: "n1" - }, - e02: { - object: "n1", - subject: "n2" - }, - } - }; - - const TwoHopExplainQuery = { - nodes: { - n0: disease_entity_node, - n1: chemical_class_node, - n2: gene_class_node, - n3: gene_entity_node, - }, - edges: { - e01: { - subject: "n0", - object: "n1" - }, - e02: { - subject: "n1", - object: "n2" - }, - e03: { - subject: "n2", - object: "n3" - }, - } - }; - - const TwoHopBranchedQuery = { - nodes: { - n0: disease_entity_node, - n1: gene_class_node, - n2: chemical_class_node, - n3: phenotype_class_node, - }, - edges: { - e01: { - subject: "n0", - object: "n1" - }, - e02: { - subject: "n1", - object: "n2" - }, - e03: { - subject: "n1", - object: "n3" - } - } - }; - - const ThreeHopQuery = { - nodes: { - n0: disease_entity_node, - n1: gene_class_node, - n2: chemical_class_node, - n3: phenotype_class_node, - }, - edges: { - e01: { - subject: "n0", - object: "n1" - }, - e02: { - subject: "n1", - object: "n2" - }, - e03: { - subject: "n2", - object: "n3" - } - } - }; - const ThreeHopExplainQuery = { nodes: { n0: disease_entity_node, @@ -224,50 +87,23 @@ describe("Testing QueryGraphHandler Module", () => { } }; - const ThreeHopMixedQuery = { - nodes: { - n0: disease_entity_node, - n1: gene_class_node, - n2: chemical_class_node, - n3: phenotype_class_node, - }, - edges: { - e01: { - subject: "n0", - object: "n1" - }, - e02: { - subject: "n1", - object: "n2" - }, - e03: { - subject: "n0", - object: "n2" - }, - e04: { - subject: "n2", - object: "n3" - }, - } - }; - describe("test _storeNodes function", () => { test("test if storeNodes with one hop query", async () => { let handler = new QueryGraphHandler(OneHopQuery); - let nodes = handler._storeNodes(); + let nodes = await handler._storeNodes_2(); expect(nodes).toHaveProperty("n0"); expect(nodes).not.toHaveProperty("n2"); - expect(nodes.n0).toBeInstanceOf(QNode); + expect(nodes.n0).toBeInstanceOf(QNode2); }); test("test if storeNodes with multi hop query", async () => { let handler = new QueryGraphHandler(FourHopQuery); - let nodes = handler._storeNodes(); + let nodes = await handler._storeNodes_2(); expect(nodes).toHaveProperty("n0"); expect(nodes).toHaveProperty("n3"); - expect(nodes.n0).toBeInstanceOf(QNode); - expect(nodes.n3).toBeInstanceOf(QNode); + expect(nodes.n0).toBeInstanceOf(QNode2); + expect(nodes.n3).toBeInstanceOf(QNode2); }); }); @@ -275,141 +111,31 @@ describe("Testing QueryGraphHandler Module", () => { test("test storeEdges with one hop query", async () => { let handler = new QueryGraphHandler(OneHopQuery); - let edges = handler._storeEdges(); + let edges = await handler._storeEdges_2(); expect(edges).toHaveProperty("e01"); expect(edges).not.toHaveProperty("e02"); expect(edges.e01).toBeInstanceOf(QEdge); - expect(edges.e01.getSubject()).toBeInstanceOf(QNode); + expect(edges.e01.getSubject()).toBeInstanceOf(QNode2); }); test("test storeEdges with multi hop query", async () => { let handler = new QueryGraphHandler(FourHopQuery); - let edges = handler._storeEdges(); + let edges = await handler._storeEdges_2(); expect(edges).toHaveProperty("e01"); expect(edges).toHaveProperty("e02"); expect(edges.e01).toBeInstanceOf(QEdge); }); }); - // describe("test _findFirstLevelEdges function", () => { - - // test("test findFirstLevelEdges with one hop query", async () => { - // let handler = new QueryGraphHandler(OneHopQuery); - // let edges = handler._findFirstLevelEdges(); - // expect(edges).toHaveProperty("paths"); - // expect(edges.paths).toHaveLength(1); - // expect(edges).toHaveProperty("edge_mapping"); - // expect(edges.edge_mapping.n0.nodes).toHaveLength(1); - // expect(edges.edge_mapping.n0.nodes[0].getID()).toEqual("n1"); - // }); - - // test("test findFirstLevelEdges with multi hop query", async () => { - // let handler = new QueryGraphHandler(FourHopQuery); - // let edges = handler._findFirstLevelEdges(); - // expect(edges).toHaveProperty("paths"); - // expect(edges.paths).toHaveLength(1); - // expect(edges).toHaveProperty("edge_mapping"); - // expect(edges.edge_mapping.n0.nodes).toHaveLength(1); - // }); - - // test("test findFirstLevelEdges with reversed one hop query", async () => { - // let handler = new QueryGraphHandler(OneHopQueryReverse); - // let edges = handler._findFirstLevelEdges(); - // expect(edges).toHaveProperty("paths"); - // expect(edges.paths).toHaveLength(1); - // expect(edges).toHaveProperty("edge_mapping"); - // expect(edges.edge_mapping.n1.nodes).toHaveLength(1); - // expect(edges.edge_mapping.n1.nodes[0].getID()).toEqual("n0") - // }); - - // test("test findFirstLevelEdges with one hop explain query", async () => { - // let handler = new QueryGraphHandler(OneHopExplainQuery); - // let edges = handler._findFirstLevelEdges(); - // expect(edges).toHaveProperty("paths"); - // expect(edges.paths).toHaveLength(2); - // expect(edges).toHaveProperty("edge_mapping"); - // expect(edges.edge_mapping.n0.nodes).toHaveLength(1); - // expect(edges.edge_mapping.n0.nodes[0].getID()).toEqual("n1"); - // expect(edges.edge_mapping.n2.nodes).toHaveLength(1); - // expect(edges.edge_mapping.n2.nodes[0].getID()).toEqual("n1"); - // }); - // }); - describe("test _createQueryPaths function", () => { - // test("test createQueryPaths with one hop query", async () => { - // let handler = new QueryGraphHandler(OneHopQuery); - // let edges = handler.createQueryPaths(); - // expect(Object.keys(edges)).toHaveLength(1); - // }); - - // test("test createQueryPaths with two hop query", async () => { - // let handler = new QueryGraphHandler(TwoHopQuery); - // let edges = handler.createQueryPaths(); - // expect(Object.keys(edges)).toHaveLength(2); - // }); - - // test("test createQueryPaths with two hop query reversed", async () => { - // let handler = new QueryGraphHandler(TwoHopQueryReversed); - // let edges = handler.createQueryPaths(); - // expect(Object.keys(edges)).toHaveLength(2); - // }); - - // test("test createQueryPaths with three hop query", async () => { - // let handler = new QueryGraphHandler(ThreeHopQuery); - // let edges = handler.createQueryPaths(); - // expect(Object.keys(edges)).toHaveLength(3); - // }); - - // test("test createQueryPaths with four hop query", async () => { - // const handler = new QueryGraphHandler(FourHopQuery); - // console.log("query graph", handler.queryGraph); - // expect(() => { - // handler.createQueryPaths(); - // }).toThrowError(new InvalidQueryGraphError("Your Query Graph exceeds the maximum query depth set in bte, which is 3")); - // }); - - // test("test createQueryPaths with one hop explain query", async () => { - // let handler = new QueryGraphHandler(OneHopExplainQuery); - // let edges = handler.createQueryPaths(); - // expect(Object.keys(edges)).toHaveLength(2); - // expect(edges[0]).toHaveLength(2); - // expect(edges[1]).toHaveLength(2); - // }); - - // test("test createQueryPaths with two hop explain query", async () => { - // let handler = new QueryGraphHandler(TwoHopExplainQuery); - // let edges = handler.createQueryPaths(); - // expect(Object.keys(edges)).toHaveLength(3); - // expect(edges[0]).toHaveLength(2); - // expect(edges[1]).toHaveLength(2); - // expect(edges[2]).toHaveLength(2); - // }); - - // test("test createQueryPaths with two hop branched query", async () => { - // let handler = new QueryGraphHandler(TwoHopBranchedQuery); - // let edges = handler.createQueryPaths(); - // expect(Object.keys(edges)).toHaveLength(2); - // expect(edges[0]).toHaveLength(1); - // expect(edges[1]).toHaveLength(2); - // }); - - // test("test createQueryPaths with three hop mixed query", async () => { - // let handler = new QueryGraphHandler(ThreeHopMixedQuery); - // let edges = handler.createQueryPaths(); - // expect(Object.keys(edges)).toHaveLength(3); - // expect(edges[0]).toHaveLength(2); - // expect(edges[1]).toHaveLength(2); - // expect(edges[2]).toHaveLength(1); - // }); - test("test createQueryPaths with three hop explain query", async () => { let handler = new QueryGraphHandler(ThreeHopExplainQuery); - let edges = handler.createQueryPaths(); + let edges = await handler.calculateEdges(); expect(Object.keys(edges)).toHaveLength(3); - expect(edges[0]).toHaveLength(2); - expect(edges[1]).toHaveLength(2); - expect(edges[2]).toHaveLength(2); + expect(edges[0]).toHaveLength(1); + expect(edges[1]).toHaveLength(1); + expect(edges[2]).toHaveLength(1); }); }); }); \ No newline at end of file diff --git a/__test__/integration/TRAPIGeneralizedQuery.test.js b/__test__/integration/TRAPIGeneralizedQuery.test.js index 5d44b7de..72fc6494 100644 --- a/__test__/integration/TRAPIGeneralizedQuery.test.js +++ b/__test__/integration/TRAPIGeneralizedQuery.test.js @@ -22,186 +22,190 @@ describe("Testing TRAPI QueryHandler Generalized Query Handling", () => { } }; + + describe("Testing query function", () => { - test("One hop has only nodes specified", async () => { + test.skip("One hop has only nodes specified", async (done) => { const queryHandler = new TRAPIQueryHandler.TRAPIQueryHandler(); queryHandler.setQueryGraph(OneHopQuery); - await queryHandler.query_2(); + await queryHandler.query(); let res = queryHandler.getResponse(); - expect(Object.keys(res.message.knowledge_graph.nodes).length).toBe(2); - expect(res.message.knowledge_graph.nodes).toHaveProperty("NCBIGene:5742"); - expect(res.message.knowledge_graph.nodes).toHaveProperty("CHEBI:41423"); + await expect(queryHandler.knowledgeGraph.kg).toHaveProperty('nodes'); + await expect(Object.keys(res.message.knowledge_graph.nodes).length).toBe(2); + await expect(res.message.knowledge_graph.nodes).toHaveProperty("NCBIGene:5742"); + await expect(res.message.knowledge_graph.nodes).toHaveProperty("PUBCHEM.COMPOUND:2662"); + done(); }) }) - const TwoHopQuery = { - "nodes": { - "n0": { - "ids":["PUBCHEM.COMPOUND:2662"], - "categories":["biolink:SmallMolecule"] - }, - "n1": { - "categories":["biolink:Disease"] - }, - "n2": { - "categories":["biolink:Gene"], - "ids":["HGNC:9604"] - } - }, - "edges": { - "e0": { - "subject": "n0", - "object": "n1" - }, - "e1": { - "subject": "n2", - "object": "n1" - } - } - }; + // const TwoHopQuery = { + // "nodes": { + // "n0": { + // "ids":["PUBCHEM.COMPOUND:2662"], + // "categories":["biolink:SmallMolecule"] + // }, + // "n1": { + // "categories":["biolink:Disease"] + // }, + // "n2": { + // "categories":["biolink:Gene"], + // "ids":["HGNC:9604"] + // } + // }, + // "edges": { + // "e0": { + // "subject": "n0", + // "object": "n1" + // }, + // "e1": { + // "subject": "n2", + // "object": "n1" + // } + // } + // }; - describe("Testing query function", () => { - test("Two hop has edges connecting end to end", async () => { - const queryHandler = new TRAPIQueryHandler.TRAPIQueryHandler(); - queryHandler.setQueryGraph(TwoHopQuery); - await queryHandler.query_2(); - let res = queryHandler.getResponse(); - expect(Object.keys(res.message.knowledge_graph.nodes).length).toBeGreaterThan(2); - expect(res.message.knowledge_graph.nodes).toHaveProperty("NCBIGene:5742"); - expect(res.message.knowledge_graph.nodes).toHaveProperty("CHEBI:41423"); - expect(res.message.knowledge_graph.edges).toHaveProperty("CHEBI:41423-biolink:treats-MONDO:0018874"); - expect(res.message.knowledge_graph.edges).toHaveProperty("NCBIGene:5742-biolink:related_to-MONDO:001887"); - }) - }) + // describe("Testing query function", () => { + // test("Two hop has edges connecting end to end", async () => { + // const queryHandler = new TRAPIQueryHandler.TRAPIQueryHandler(); + // queryHandler.setQueryGraph(TwoHopQuery); + // await queryHandler.query_2(); + // let res = queryHandler.getResponse(); + // expect(Object.keys(res.message.knowledge_graph.nodes).length).toBeGreaterThan(2); + // expect(res.message.knowledge_graph.nodes).toHaveProperty("NCBIGene:5742"); + // expect(res.message.knowledge_graph.nodes).toHaveProperty("CHEBI:41423"); + // expect(res.message.knowledge_graph.edges).toHaveProperty("CHEBI:41423-biolink:treats-MONDO:0018874"); + // expect(res.message.knowledge_graph.edges).toHaveProperty("NCBIGene:5742-biolink:related_to-MONDO:001887"); + // }) + // }) - const ThreeHopQuery = { - "message": { - "query_graph": { - "nodes": { - "n0": { - "ids":["PUBCHEM.COMPOUND:2662"], - "categories":["biolink:SmallMolecule"] - }, - "n1": { - "categories":["biolink:Disease"] - }, - "n2": { - "categories":["biolink:Pathway"] - }, - "n3": { - "categories":["biolink:Gene"], - "ids":["HGNC:17947"] - } - }, - "edges": { - "e0": { - "subject": "n0", - "object": "n1" - }, - "e1": { - "subject": "n1", - "object": "n2" - }, - "e2": { - "subject": "n2", - "object": "n3" - } - } - } - } - } + // const ThreeHopQuery = { + // "message": { + // "query_graph": { + // "nodes": { + // "n0": { + // "ids":["PUBCHEM.COMPOUND:2662"], + // "categories":["biolink:SmallMolecule"] + // }, + // "n1": { + // "categories":["biolink:Disease"] + // }, + // "n2": { + // "categories":["biolink:Pathway"] + // }, + // "n3": { + // "categories":["biolink:Gene"], + // "ids":["HGNC:17947"] + // } + // }, + // "edges": { + // "e0": { + // "subject": "n0", + // "object": "n1" + // }, + // "e1": { + // "subject": "n1", + // "object": "n2" + // }, + // "e2": { + // "subject": "n2", + // "object": "n3" + // } + // } + // } + // } + // } - describe("Testing query function", () => { - test("Three hop has edges connecting end to end", async () => { - const queryHandler = new TRAPIQueryHandler.TRAPIQueryHandler(); - queryHandler.setQueryGraph(ThreeHopQuery); - await queryHandler.query_2(); - let res = queryHandler.getResponse(); - expect(Object.keys(res.message.knowledge_graph.nodes).length).toBeGreaterThan(4); - expect(res.message.knowledge_graph.nodes).toHaveProperty("NCBIGene:117145"); - expect(res.message.knowledge_graph.nodes).toHaveProperty("REACT:R-HSA-109704"); - expect(res.message.knowledge_graph.nodes).toHaveProperty("MONDO:0018874"); - expect(res.message.knowledge_graph.nodes).toHaveProperty("CHEBI:41423"); - expect(res.message.knowledge_graph.edges).toHaveProperty("CHEBI:41423-biolink:related_to-MONDO:0002974"); - expect(res.message.knowledge_graph.edges).toHaveProperty("MONDO:0002974-biolink:related_to-REACT:R-HSA-109704"); - expect(res.message.knowledge_graph.edges).toHaveProperty("REACT:R-HSA-109704-biolink:has_participant-NCBIGene:117145"); - }) - }) + // describe("Testing query function", () => { + // test("Three hop has edges connecting end to end", async () => { + // const queryHandler = new TRAPIQueryHandler.TRAPIQueryHandler(); + // queryHandler.setQueryGraph(ThreeHopQuery); + // await queryHandler.query_2(); + // let res = queryHandler.getResponse(); + // expect(Object.keys(res.message.knowledge_graph.nodes).length).toBeGreaterThan(4); + // expect(res.message.knowledge_graph.nodes).toHaveProperty("NCBIGene:117145"); + // expect(res.message.knowledge_graph.nodes).toHaveProperty("REACT:R-HSA-109704"); + // expect(res.message.knowledge_graph.nodes).toHaveProperty("MONDO:0018874"); + // expect(res.message.knowledge_graph.nodes).toHaveProperty("CHEBI:41423"); + // expect(res.message.knowledge_graph.edges).toHaveProperty("CHEBI:41423-biolink:related_to-MONDO:0002974"); + // expect(res.message.knowledge_graph.edges).toHaveProperty("MONDO:0002974-biolink:related_to-REACT:R-HSA-109704"); + // expect(res.message.knowledge_graph.edges).toHaveProperty("REACT:R-HSA-109704-biolink:has_participant-NCBIGene:117145"); + // }) + // }) - const BroadCategoryQuery = { - "message": { - "query_graph": { - "nodes": { - "n0": { - "categories": ["biolink:DiseaseOrPhenotypicFeature"] - }, - "n1": { - "ids": ["HGNC:6284"], - "categories":["biolink:Gene"] - } - }, - "edges": { - "e0": { - "subject": "n0", - "object": "n1" - } - } - } - } - } + // const BroadCategoryQuery = { + // "message": { + // "query_graph": { + // "nodes": { + // "n0": { + // "categories": ["biolink:DiseaseOrPhenotypicFeature"] + // }, + // "n1": { + // "ids": ["HGNC:6284"], + // "categories":["biolink:Gene"] + // } + // }, + // "edges": { + // "e0": { + // "subject": "n0", + // "object": "n1" + // } + // } + // } + // } + // } - describe("Testing query function", () => { - test("Broad category to known entity with all expected branching entities present", async () => { - const queryHandler = new TRAPIQueryHandler.TRAPIQueryHandler(); - queryHandler.setQueryGraph(BroadCategoryQuery); - await queryHandler.query_2(); - let res = queryHandler.getResponse(); - expect(res.message.knowledge_graph.nodes).toHaveProperty("NCBIGene:3778"); - expect(res.message.knowledge_graph.nodes).toHaveProperty("MONDO:0005247"); - expect(res.message.knowledge_graph.nodes).toHaveProperty("HP:0002465"); - expect(res.message.knowledge_graph.edges).toHaveProperty("MONDO:0005247-biolink:related_to-NCBIGene:3778"); - expect(res.message.knowledge_graph.edges).toHaveProperty("HP:0002465-biolink:related_to-NCBIGene:3778"); - }) - }) + // describe("Testing query function", () => { + // test("Broad category to known entity with all expected branching entities present", async () => { + // const queryHandler = new TRAPIQueryHandler.TRAPIQueryHandler(); + // queryHandler.setQueryGraph(BroadCategoryQuery); + // await queryHandler.query_2(); + // let res = queryHandler.getResponse(); + // expect(res.message.knowledge_graph.nodes).toHaveProperty("NCBIGene:3778"); + // expect(res.message.knowledge_graph.nodes).toHaveProperty("MONDO:0005247"); + // expect(res.message.knowledge_graph.nodes).toHaveProperty("HP:0002465"); + // expect(res.message.knowledge_graph.edges).toHaveProperty("MONDO:0005247-biolink:related_to-NCBIGene:3778"); + // expect(res.message.knowledge_graph.edges).toHaveProperty("HP:0002465-biolink:related_to-NCBIGene:3778"); + // }) + // }) - const PredictQuery = { - "message": { - "query_graph": { - "nodes": { - "n0": { - "ids": ["NCBIGene:3778"], - "categories": ["biolink:Gene"] - }, - "n1": { - "categories": [ - "biolink:Disease", - "biolink:BiologicalProcess", - "biolink:Pathway" - ] - } - }, - "edges": { - "e01": { - "subject": "n0", - "object": "n1" - } - } - } - } - } + // const PredictQuery = { + // "message": { + // "query_graph": { + // "nodes": { + // "n0": { + // "ids": ["NCBIGene:3778"], + // "categories": ["biolink:Gene"] + // }, + // "n1": { + // "categories": [ + // "biolink:Disease", + // "biolink:BiologicalProcess", + // "biolink:Pathway" + // ] + // } + // }, + // "edges": { + // "e01": { + // "subject": "n0", + // "object": "n1" + // } + // } + // } + // } + // } - describe("Testing query function", () => { - test("Predict known entity to general category to have all nodes expected", async () => { - const queryHandler = new TRAPIQueryHandler.TRAPIQueryHandler(); - queryHandler.setQueryGraph(PredictQuery); - await queryHandler.query_2(); - let res = queryHandler.getResponse(); - expect(res.message.knowledge_graph.nodes).toHaveProperty("MONDO:0005030"); - expect(res.message.knowledge_graph.nodes).toHaveProperty("NCBIGene:3778"); - expect(res.message.knowledge_graph.nodes).toHaveProperty("GO:0001666"); - expect(res.message.knowledge_graph.nodes).toHaveProperty("REACT:R-HSA-109582"); - }) - }) + // describe("Testing query function", () => { + // test("Predict known entity to general category to have all nodes expected", async () => { + // const queryHandler = new TRAPIQueryHandler.TRAPIQueryHandler(); + // queryHandler.setQueryGraph(PredictQuery); + // await queryHandler.query_2(); + // let res = queryHandler.getResponse(); + // expect(res.message.knowledge_graph.nodes).toHaveProperty("MONDO:0005030"); + // expect(res.message.knowledge_graph.nodes).toHaveProperty("NCBIGene:3778"); + // expect(res.message.knowledge_graph.nodes).toHaveProperty("GO:0001666"); + // expect(res.message.knowledge_graph.nodes).toHaveProperty("REACT:R-HSA-109582"); + // }) + // }) }) \ No newline at end of file diff --git a/__test__/integration/TRAPIQueryHandler.test.js b/__test__/integration/TRAPIQueryHandler.test.js index 88d8bed5..f2152717 100644 --- a/__test__/integration/TRAPIQueryHandler.test.js +++ b/__test__/integration/TRAPIQueryHandler.test.js @@ -26,7 +26,7 @@ describe("Testing TRAPIQueryHandler Module", () => { test("test with one query edge", async () => { const queryHandler = new TRAPIQueryHandler.TRAPIQueryHandler(); queryHandler.setQueryGraph(OneHopQuery); - await queryHandler.query(); + await queryHandler.query_2(); expect(queryHandler.knowledgeGraph.kg).toHaveProperty('nodes'); }) }) diff --git a/__test__/integration/integrity.test.js b/__test__/integration/integrity.test.js index afdc3501..b53bd6f8 100644 --- a/__test__/integration/integrity.test.js +++ b/__test__/integration/integrity.test.js @@ -11,7 +11,7 @@ describe("Testing TRAPIQueryHandler Module", () => { const queryHandler = new TRAPIQueryHandler.TRAPIQueryHandler({}, undefined, undefined, true); const query = JSON.parse(fs.readFileSync(path.join(example_foler, 'increased_urinary_glycerol_affects_glycerol.json'))); queryHandler.setQueryGraph(query.message.query_graph); - await queryHandler.query(); + await queryHandler.query_2(); const res = queryHandler.getResponse(); expect(res.message.knowledge_graph.nodes).toHaveProperty('CHEBI:17754'); }) @@ -20,7 +20,7 @@ describe("Testing TRAPIQueryHandler Module", () => { const queryHandler = new TRAPIQueryHandler.TRAPIQueryHandler({}, undefined, undefined, true); const query = JSON.parse(fs.readFileSync(path.join(example_foler, 'FDFM_caused_by_ACDY5.json'))); queryHandler.setQueryGraph(query.message.query_graph); - await queryHandler.query(); + await queryHandler.query_2(); const res = queryHandler.getResponse(); expect(res.message.knowledge_graph.nodes).toHaveProperty('NCBIGene:111'); }) @@ -30,7 +30,7 @@ describe("Testing TRAPIQueryHandler Module", () => { const queryHandler = new TRAPIQueryHandler.TRAPIQueryHandler({}, undefined, undefined, true); const query = JSON.parse(fs.readFileSync(path.join(example_foler, 'chemicals_targeting_IL1_Signaling_Pathway.json'))); queryHandler.setQueryGraph(query.message.query_graph); - await queryHandler.query(); + await queryHandler.query_2(); const res = queryHandler.getResponse(); expect(res.message.knowledge_graph.nodes).toHaveProperty('CHEBI:3962'); })