diff --git a/.github/workflows/test_ws_codecov.yml b/.github/workflows/test_ws_codecov.yml index 4c27281..0b0b379 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@v7.0.7 - - 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: diff --git a/__test__/biolink_transformers.test.ts b/__test__/biolink_transformers.test.ts deleted file mode 100644 index ca52dfc..0000000 --- a/__test__/biolink_transformers.test.ts +++ /dev/null @@ -1,92 +0,0 @@ -import jq_tf from "../built/transformers/jq_transformer"; -import biolink_tf from "../src/transformers/biolink_transformer"; -import fs from "fs"; -import path from "path"; -import { JSONDoc } from "../src/json_transform/types"; - -describe("test biolink transformer", () => { - let response; - let input; - - beforeEach(() => { - const response_path = path.resolve(__dirname, "./data/biolink/response.json"); - response = JSON.parse(fs.readFileSync(response_path, { encoding: "utf8" })); - const edge_path = path.resolve(__dirname, "./data/biolink/edge.json"); - const edge = JSON.parse(fs.readFileSync(edge_path, { encoding: "utf8" })); - input = { - response, - edge, - }; - }); - - test("test biolink wrapper", async () => { - const tf = new jq_tf(input, { type: "biolink" }); - const res = await tf.wrap(response); - expect(res.associations[0].object.HGNC).toBe("10956"); - expect(res.associations[0].publications[0].id).toBe("21685912"); - expect(res.associations[1]).not.toHaveProperty("publications"); - expect(res.associations[1]).not.toHaveProperty("provided_by"); - }); - - test("test biolink wrapper if no association field as root key", async () => { - const tf = new jq_tf(input, { type: "biolink" }); - const res = await tf.wrap({ data: [] }); - expect(res).toEqual({ data: [] }); - }); - - test("test biolink wrapper if no object id should be prefixed", async () => { - const tf = new jq_tf(input, { type: "biolink" }); - const res = await tf.wrap({ - associations: [ - { - object: { - id: "MONDO:12345", - }, - }, - ], - }); - expect(res.associations[0].object.MONDO).toEqual("MONDO:12345"); - }); - - test("test biolink wrapper if no object field present", async () => { - const tf = new jq_tf(input, { type: "biolink" }); - const fake_response = { - associations: [ - { - object1: { - id: "MONDO:12345", - }, - }, - ], - }; - const res = await tf.wrap(fake_response); - expect(res).toEqual(fake_response); - }); - - test("test biolink wrapper if no object.id field present", async () => { - const tf = new jq_tf(input, { type: "biolink" }); - const fake_response = { - associations: [ - { - object: { - id1: "MONDO:12345", - }, - }, - ], - }; - const res = await tf.wrap(fake_response); - expect(res).toEqual(fake_response); - }); - - test("test biolink jsonTransform function", async () => { - const tf = new jq_tf(input, { type: "biolink" }); - const wrapped_response = await tf.wrap(response); - const res: JSONDoc = tf.jsonTransform(wrapped_response); - expect(res).toHaveProperty("related_to"); - expect(res.related_to[0].HGNC).toEqual("10956"); - expect(res.related_to[0].pubmed[0]).toEqual("21685912"); - expect(res.related_to[0].relation).toEqual("contributes to condition"); - expect(res.related_to[0].source[0]).toEqual("https://archive.monarchinitiative.org/#gwascatalog"); - expect(res.related_to[0].taxid).toEqual("NCBITaxon:9606"); - }); -}); diff --git a/src/record.ts b/src/record.ts index d9c2d2d..8450b2b 100644 --- a/src/record.ts +++ b/src/record.ts @@ -455,6 +455,8 @@ export class Record { sourceA.resource_id.localeCompare(sourceB.resource_id), ).map(source => _.omit(source, ["source_record_urls"])), ), + this.knowledge_level, + this.agent_type ].join("-"); } @@ -497,9 +499,9 @@ export class Record { get apiInforesCurie(): string { if (this.association["x-translator"]) { - return this.association["x-translator"]["infores"] || undefined; + return this.association["x-translator"]["infores"] || "infores:error-not-provided"; } - return undefined; + return "infores:error-not-provided"; } get metaEdgeSource(): string {