Skip to content

Commit

Permalink
Merge pull request #56 from molgenis/feat/bam
Browse files Browse the repository at this point in the history
Retrieve embedded bam data
  • Loading branch information
bartcharbon authored May 11, 2021
2 parents 8614bd2 + f062aac commit e73475c
Show file tree
Hide file tree
Showing 7 changed files with 1,746 additions and 1,188 deletions.
2,887 changes: 1,716 additions & 1,171 deletions package-lock.json

Large diffs are not rendered by default.

26 changes: 13 additions & 13 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@molgenis/vip-report-api",
"version": "2.2.0",
"version": "2.3.0",
"description": "Report API for Variant Call Format (VCF) Report Templates",
"main": "dist/index.js",
"types": "dist/index.d.ts",
Expand All @@ -22,21 +22,21 @@
},
"homepage": "https://github.com/molgenis/vip-report-api#readme",
"devDependencies": {
"@babel/core": "^7.12.10",
"@babel/preset-env": "^7.12.11",
"@babel/preset-typescript": "^7.12.7",
"@types/jest": "^26.0.20",
"@types/node": "^14.14.37",
"@typescript-eslint/eslint-plugin": "^4.20.0",
"@typescript-eslint/parser": "^4.20.0",
"@babel/core": "^7.14.0",
"@babel/preset-env": "^7.14.1",
"@babel/preset-typescript": "^7.13.0",
"@types/jest": "^26.0.23",
"@types/node": "^15.0.2",
"@typescript-eslint/eslint-plugin": "^4.23.0",
"@typescript-eslint/parser": "^4.23.0",
"babel-jest": "^26.6.3",
"eslint": "^7.23.0",
"eslint": "^7.26.0",
"jest": "^26.6.3",
"prettier": "2.0.5",
"ts-jest": "^26.4.4",
"prettier": "2.3.0",
"ts-jest": "^26.5.6",
"tslint": "^6.1.3",
"tslint-config-prettier": "^1.18.0",
"typescript": "^3.9.7"
"typescript": "^4.2.4"
},
"publishConfig": {
"access": "public"
Expand All @@ -47,6 +47,6 @@
"dependencies": {
"ascii85": "^1.0.2",
"buffer": "^6.0.3",
"fflate": "^0.6.9"
"fflate": "^0.6.10"
}
}
7 changes: 6 additions & 1 deletion src/ApiClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ interface BinaryData extends BinaryDataNode {
vcfGz: Buffer;
fastaGz: BinaryDataNode;
genesGz: Buffer;
bam: Buffer;
}

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

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

getBam(): Promise<Buffer | null> {
return Promise.resolve(this.reportData.binary.bam);
}

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 @@ -35,6 +35,7 @@ export interface EncodedData extends EncodedDataContainer {
vcfGz: string;
fastaGz: EncodedDataContainer;
genesGz: string;
bam: string;
}

export interface Resource {
Expand Down
8 changes: 7 additions & 1 deletion src/__tests__/ApiClient.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,8 @@ beforeEach(() => {
Buffer.from(gzipSync(fs.readFileSync(__dirname + '/interval1.fasta')))
)
},
genesGz: new Base85().encode(Buffer.from(gzipSync(fs.readFileSync(__dirname + '/example.gff'))))
genesGz: new Base85().encode(Buffer.from(gzipSync(fs.readFileSync(__dirname + '/example.gff')))),
bam: new Base85().encode(Buffer.from('dummy bam content', 'utf8'))
}
};
api = new ApiClient(reportData);
Expand Down Expand Up @@ -668,3 +669,8 @@ test('getGenesGz', async () => {
// null check, because size check differs between local machine and Travis
expect(genesGz).not.toBe(null);
});

test('getBam', async () => {
const bam = await api.getBam();
expect(bam !== null ? bam.toString('utf-8') : null).toBe('dummy bam content');
});
3 changes: 2 additions & 1 deletion src/vcf/MetadataParser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,8 @@ export interface NestedInfoMetadata {
items: InfoMetadata[];
}

const REG_EXP_INFO = /##INFO=<ID=(.+?),Number=(.+?),Type=(.+?),Description="(.+?)"(?:,Source="(.+?)")?(?:,Version="(.+?)")?>/;
const REG_EXP_INFO =
/##INFO=<ID=(.+?),Number=(.+?),Type=(.+?),Description="(.+?)"(?:,Source="(.+?)")?(?:,Version="(.+?)")?>/;

export function parseInfoMetadata(token: string): InfoMetadata {
const result = token.match(REG_EXP_INFO);
Expand Down
2 changes: 1 addition & 1 deletion src/vcf/__tests__/DataParser.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ test('parse value - invalid', () => {
expect(() =>
parseValue('', {
id: 'INT',
number: ({ type: 'xx', separator: ',' } as unknown) as NumberMetadata,
number: { type: 'xx', separator: ',' } as unknown as NumberMetadata,
type: 'INTEGER',
description: 'Integer'
})
Expand Down

0 comments on commit e73475c

Please sign in to comment.