Skip to content

Commit

Permalink
Merge 4f0294e into 2fc0596
Browse files Browse the repository at this point in the history
  • Loading branch information
kevinxin90 committed Feb 19, 2021
2 parents 2fc0596 + 4f0294e commit 32a7600
Show file tree
Hide file tree
Showing 57 changed files with 4,574 additions and 3,131 deletions.
39 changes: 26 additions & 13 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -1,30 +1,43 @@
# This workflow will do a clean install of node dependencies, build the source code and run tests across different versions of node
# For more information see: https://help.github.com/actions/language-and-framework-guides/using-nodejs-with-github-actions

name: Test

on:
push:
branches:
- "**"
pull_request:
branches: [ master ]

name: Test Coveralls

jobs:
test:

test-coverage:
name: Generate coverage report
runs-on: ubuntu-latest
steps:

strategy:
matrix:
node-version: [12.x]
- uses: actions/checkout@v1

steps:
- uses: actions/checkout@v2
- name: Use Node.js ${{ matrix.node-version }}
- name: Use Node.js 12.x
uses: actions/setup-node@v1
with:
node-version: ${{ matrix.node-version }}
- run: npm ci
- run: npm run build --if-present
- run: npm test
node-version: 12.x

- name: npm install, generate coverage report
run: |
npm ci
npm run test-cov
- name: Send coverage report to coveralls for visualization
uses: coverallsapp/github-action@master
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
finish:
needs: test-coverage
runs-on: ubuntu-latest
steps:
- name: Coveralls Finished
uses: coverallsapp/github-action@master
with:
github-token: ${{ secrets.github_token }}
parallel-finished: true
12 changes: 6 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# BioThings Explorer TRAPI API
[![Build Status](https://travis-ci.com/kevinxin90/BioThings_Explorer_TRAPI.svg?branch=master)](https://travis-ci.com/kevinxin90/BioThings_Explorer_TRAPI)
[![Coverage Status](https://coveralls.io/repos/github/kevinxin90/BioThings_Explorer_TRAPI/badge.svg?branch=master)](https://coveralls.io/github/kevinxin90/BioThings_Explorer_TRAPI?branch=master)
[![Coverage Status](https://coveralls.io/repos/github/biothings/BioThings_Explorer_TRAPI/badge.svg?branch=master)](https://coveralls.io/github/biothings/BioThings_Explorer_TRAPI?branch=master)

## Introduction

Expand Down Expand Up @@ -76,14 +76,14 @@ If you need to update `npm`, you can make it using `npm`! Cool right? After runn

## Install

`$ git clone https://github.com/biothings/BioThings_Explorer_TRAPI`
`$ cd BioThings_Explorer_TRAPI`
`$ npm install`
$ git clone https://github.com/biothings/BioThings_Explorer_TRAPI`
$ cd BioThings_Explorer_TRAPI`
$ npm install`


## Running the project

`$ npm start`
$ npm start

To enable debug mode, which outputs logging statements to the terminal in real time:

Expand All @@ -93,7 +93,7 @@ To enable debug mode, which outputs logging statements to the terminal in real t

## Simple build for production

`$ npm build`
$ npm build

## Deploy

Expand Down
130 changes: 93 additions & 37 deletions __test__/integration/KnowledgeGraph.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,55 +6,111 @@ describe("Testing KnowledgeGraph Module", () => {
const gene_node1 = new QNode("n1", { category: "Gene", id: "NCBIGene:1017" });
const chemical_node1 = new QNode("n3", { category: "ChemicalSubstance" });
const edge1 = new QEdge("e01", { subject: gene_node1, object: chemical_node1 });
describe("Testing _createInputNode function", () => {
test("test when input with string, should output a hash of 40 characters", () => {
const record = {
"$reasoner_edge": edge1,
"$input": "SYMBOL:CDK2",
"id": "CHEMBL.COMPOUND:CHEMBL354634",
"$original_input": {
"SYMBOL:CDK2": "NCBIGene:1017"
const record = {
"$edge_metadata": {
trapi_qEdge_obj: edge1,
source: "DGIdb",
api_name: "BioThings DGIDB API"
},
"publications": ['PMID:123', 'PMID:1234'],
"interactionType": "inhibitor",
"$input": {
original: "SYMBOL:CDK2",
obj: {
primaryID: 'NCBIGene:1017',
label: "CDK2",
dbIDs: {
SYMBOL: "CDK2",
NCBIGene: "1017"
},
"$input_resolved_identifiers": {
"NCBIGene:1017": {
id: {
label: "CDK2"
}
}
curies: ['SYMBOL:CDK2', 'NCBIGene:1017']
}
},
"$output": {
original: "CHEMBL.COMPOUND:CHEMBL744",
obj: {
primaryID: 'CHEMBL.COMPOUND:CHEMBL744',
label: "RILUZOLE",
dbIDs: {
"CHEMBL.COMPOUND": "CHEMBL744",
"PUBCHEM": "1234",
"name": "RILUZOLE"
},
"label": "DRUG A"
curies: ['CHEMBL.COMPOUND:CHEMBL744', 'PUBCHEM:1234', "name:RILUZOLE"]
}
},
}
describe("Testing _createInputNode function", () => {
test("test when input with string, should output a hash of 40 characters", () => {
const kg = new KnowledgeGraph();
const res = kg._createInputNode(record);
expect(res).toHaveProperty("NCBIGene:1017");
expect(res["NCBIGene:1017"]).toHaveProperty("name", "CDK2");
expect(res["NCBIGene:1017"]).toHaveProperty("category", "biolink:Gene");
expect(res["NCBIGene:1017"].attributes[0]).toHaveProperty("type", "biolink:id");
expect(res).toHaveProperty("category", "biolink:Gene");
expect(res).toHaveProperty("name", "CDK2");
expect(res.attributes[0]).toHaveProperty("type", "biolink:id");
expect(res.attributes[0]).toHaveProperty("value", ["SYMBOL:CDK2", "NCBIGene:1017"])
})
})

describe("Testing _createOutputNode function", () => {
test("test when input with string, should output a hash of 40 characters", () => {
const record = {
"$reasoner_edge": edge1,
"$input": "SYMBOL:CDK2",
"id": "CHEMBL.COMPOUND:CHEMBL354634",
"$original_input": {
"SYMBOL:CDK2": "NCBIGene:1017"
},
"$input_resolved_identifiers": {
"NCBIGene:1017": {
id: {
label: "CDK2"
}
}
},
"label": "DRUG A"
}
const kg = new KnowledgeGraph();
const res = kg._createOutputNode(record);
expect(res["CHEMBL.COMPOUND:CHEMBL354634"]).toHaveProperty("name", "DRUG A");
expect(res["CHEMBL.COMPOUND:CHEMBL354634"]).toHaveProperty("category", "biolink:ChemicalSubstance");
expect(res).toHaveProperty("category", "biolink:ChemicalSubstance");
expect(res).toHaveProperty("name", "RILUZOLE");
expect(res.attributes[0]).toHaveProperty("type", "biolink:id");
expect(res.attributes[0]).toHaveProperty("value", ['CHEMBL.COMPOUND:CHEMBL744', 'PUBCHEM:1234', "name:RILUZOLE"])
})
})

describe("Testing _createAttributes function", () => {
test("test edge attribute provided_by and api are correctly found", () => {
const kg = new KnowledgeGraph();
const res = kg._createAttributes(record);
expect(res.length).toBeGreaterThanOrEqual(2);
expect(res[0]).toHaveProperty("name", "provided_by");
expect(res[0]).toHaveProperty("type", "biolink:provided_by");
expect(res[0]).toHaveProperty("value", "DGIdb");
expect(res[1]).toHaveProperty("name", "api");
expect(res[1]).toHaveProperty("type", "bts:api");
expect(res[1]).toHaveProperty("value", "BioThings DGIDB API");
})

test("test edge attribute other than provided_by and api are correctly found", () => {
const kg = new KnowledgeGraph();
const res = kg._createAttributes(record);
expect(res.length).toBeGreaterThan(2);
expect(res[2]).toHaveProperty("name", "publications");
expect(res[2]).toHaveProperty("type", "biolink:publications");
expect(res[2]).toHaveProperty("value", ['PMID:123', 'PMID:1234']);
expect(res[3]).toHaveProperty("name", "interactionType");
expect(res[3]).toHaveProperty("type", "bts:interactionType");
expect(res[3]).toHaveProperty("value", 'inhibitor');
})
})

describe("Testing _createEdge function", () => {
test("test edge attribute provided_by and api are correctly found", () => {
const kg = new KnowledgeGraph();
const res = kg._createAttributes(record);
expect(res.length).toBeGreaterThanOrEqual(2);
expect(res[0]).toHaveProperty("name", "provided_by");
expect(res[0]).toHaveProperty("type", "biolink:provided_by");
expect(res[0]).toHaveProperty("value", "DGIdb");
expect(res[1]).toHaveProperty("name", "api");
expect(res[1]).toHaveProperty("type", "bts:api");
expect(res[1]).toHaveProperty("value", "BioThings DGIDB API");
})

test("test edge attribute other than provided_by and api are correctly found", () => {
const kg = new KnowledgeGraph();
const res = kg._createAttributes(record);
expect(res.length).toBeGreaterThan(2);
expect(res[2]).toHaveProperty("name", "publications");
expect(res[2]).toHaveProperty("type", "biolink:publications");
expect(res[2]).toHaveProperty("value", ['PMID:123', 'PMID:1234']);
expect(res[3]).toHaveProperty("name", "interactionType");
expect(res[3]).toHaveProperty("type", "bts:interactionType");
expect(res[3]).toHaveProperty("value", 'inhibitor');
})
})

Expand Down
6 changes: 3 additions & 3 deletions __test__/integration/QEdge2BTEEdgeHandler.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ describe("Testing QEdge2BTEEdgeHandler Module", () => {
const gene_node1 = new QNode("n1", { category: "Gene", curie: "NCBIGene:1017" });
const node1_equivalent_ids = {
"NCBIGene:1017": {
db_ids: {
dbIDs: {
NCBIGene: ["1017"],
SYMBOL: ['CDK2']
}
Expand All @@ -16,13 +16,13 @@ describe("Testing QEdge2BTEEdgeHandler Module", () => {
gene_node1.setEquivalentIDs(node1_equivalent_ids);
const node2_equivalent_ids = {
"NCBIGene:1017": {
db_ids: {
dbIDs: {
NCBIGene: ["1017"],
SYMBOL: ['CDK2']
}
},
"NCBIGene:1018": {
db_ids: {
dbIDs: {
NCBIGene: ["1018"],
SYMBOL: ['CDK3']
}
Expand Down
70 changes: 35 additions & 35 deletions __test__/integration/QueryResult.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,41 +6,54 @@ describe("Testing QueryResults Module", () => {
const gene_node1 = new QNode("n1", { category: "Gene", id: "NCBIGene:1017" });
const chemical_node1 = new QNode("n3", { category: "ChemicalSubstance" });
const edge1 = new QEdge("e01", { subject: gene_node1, object: chemical_node1 });
const record = {
"$edge_metadata": {
trapi_qEdge_obj: edge1,
source: "DGIdb",
api_name: "BioThings DGIDB API"
},
"publications": ['PMID:123', 'PMID:1234'],
"interactionType": "inhibitor",
"$input": {
original: "SYMBOL:CDK2",
obj: {
primaryID: 'NCBIGene:1017',
label: "CDK2",
dbIDs: {
SYMBOL: "CDK2",
NCBIGene: "1017"
},
curies: ['SYMBOL:CDK2', 'NCBIGene:1017']
}
},
"$output": {
original: "CHEMBL.COMPOUND:CHEMBL744",
obj: {
primaryID: 'CHEMBL.COMPOUND:CHEMBL744',
label: "RILUZOLE",
dbIDs: {
"CHEMBL.COMPOUND": "CHEMBL744",
"PUBCHEM": "1234",
"name": "RILUZOLE"
},
curies: ['CHEMBL.COMPOUND:CHEMBL744', 'PUBCHEM:1234', "name:RILUZOLE"]
}
},
}
describe("Testing _createNodeBindings function", () => {
test("test when input with string, should output a hash of 40 characters", () => {
const record = {
"$reasoner_edge": edge1,
"$input": "SYMBOL:CDK2",
"id": "CHEMBL.COMPOUND:CHEMBL354634",
"$original_input": {
"SYMBOL:CDK2": "NCBIGene:1017"
}
}
const queryResult = new QueryResult();
const res = queryResult._createNodeBindings(record);
expect(res).toHaveProperty("n1");
expect(res).toHaveProperty("n3");
expect(res.n1[0].id).toEqual("NCBIGene:1017");
expect(res.n3[0].id).toEqual("CHEMBL.COMPOUND:CHEMBL354634");
expect(res.n3[0].id).toEqual("CHEMBL.COMPOUND:CHEMBL744");

})
})

describe("Testing _createEdgeBindings function", () => {
test("test when input with string, should output a hash of 40 characters", () => {
const record = {
"$reasoner_edge": edge1,
"$input": "SYMBOL:CDK2",
"id": "CHEMBL.COMPOUND:CHEMBL354634",
"$original_input": {
"SYMBOL:CDK2": "NCBIGene:1017"
},
"$association": {
api_name: "MyChem.info API",
source: "drugbank",
predicate: "physically_interacts_with"
}
}
const queryResult = new QueryResult();
const res = queryResult._createEdgeBindings(record);
expect(res).toHaveProperty("e01");
Expand All @@ -50,19 +63,6 @@ describe("Testing QueryResults Module", () => {

describe("Testing update function", () => {
test("test when input with string, should output a hash of 40 characters", () => {
const record = {
"$reasoner_edge": edge1,
"$input": "SYMBOL:CDK2",
"id": "CHEMBL.COMPOUND:CHEMBL354634",
"$original_input": {
"SYMBOL:CDK2": "NCBIGene:1017"
},
"$association": {
api_name: "MyChem.info API",
source: "drugbank",
predicate: "physically_interacts_with"
}
}
const queryResult = new QueryResult();
queryResult.update([record]);
expect(queryResult.results.length).toEqual(1);
Expand Down
Loading

0 comments on commit 32a7600

Please sign in to comment.