Skip to content

Commit

Permalink
Merge pull request #53 from molgenis/feat/genes
Browse files Browse the repository at this point in the history
Retrieve embedded genes data
  • Loading branch information
bartcharbon authored Apr 23, 2021
2 parents ca5f422 + 38857ab commit 8614bd2
Show file tree
Hide file tree
Showing 6 changed files with 19 additions and 4 deletions.
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@molgenis/vip-report-api",
"version": "2.1.0",
"version": "2.2.0",
"description": "Report API for Variant Call Format (VCF) Report Templates",
"main": "dist/index.js",
"types": "dist/index.d.ts",
Expand Down
5 changes: 5 additions & 0 deletions src/ApiClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ interface Data {
interface BinaryData extends BinaryDataNode {
vcfGz: Buffer;
fastaGz: BinaryDataNode;
genesGz: Buffer;
}

interface BinaryDataNode {
Expand Down Expand Up @@ -82,6 +83,10 @@ export class ApiClient implements Api {
return Promise.resolve(buffer);
}

getGenesGz(): Promise<Buffer> {
return Promise.resolve(this.reportData.binary.genesGz);
}

private get<T extends Resource>(resource: string, params: Params = {}): Promise<PagedItems<T>> {
return new Promise((resolve, reject) => {
if (!this.reportData.data[resource]) {
Expand Down
1 change: 1 addition & 0 deletions src/ApiData.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ export interface Items<T extends Resource> {
export interface EncodedData extends EncodedDataContainer {
vcfGz: string;
fastaGz: EncodedDataContainer;
genesGz: string;
}

export interface Resource {
Expand Down
9 changes: 8 additions & 1 deletion src/__tests__/ApiClient.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,8 @@ beforeEach(() => {
'2:47637200-47637300': new Base85().encode(
Buffer.from(gzipSync(fs.readFileSync(__dirname + '/interval1.fasta')))
)
}
},
genesGz: new Base85().encode(Buffer.from(gzipSync(fs.readFileSync(__dirname + '/example.gff'))))
}
};
api = new ApiClient(reportData);
Expand Down Expand Up @@ -661,3 +662,9 @@ test('getFastaGz - existing interval in other contig', async () => {
const fastaGz = await api.getFastaGz('1', 47637250);
expect(fastaGz).toBe(null);
});

test('getGenesGz', async () => {
const genesGz = await api.getGenesGz();
// null check, because size check differs between local machine and Travis
expect(genesGz).not.toBe(null);
});
2 changes: 2 additions & 0 deletions src/__tests__/example.gff
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
##gff-version 3
1 BestRefSeq exon 10002981 10003083 . + . ID=exon-NM_001297778.1-1;gene=NMNAT1

0 comments on commit 8614bd2

Please sign in to comment.