Skip to content

Commit c26da37

Browse files
authored
Merge pull request #234 from lifeomic/PHC-5229
feat: PHC-5229 Add VCF ingest command
2 parents b3819e7 + 1b3df2d commit c26da37

2 files changed

Lines changed: 66 additions & 0 deletions

File tree

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
'use strict';
2+
3+
const { post } = require('../../../api');
4+
const print = require('../../../print');
5+
6+
exports.command = 'create-vcf <projectId> <vcfFileId> <manifestFileId>';
7+
exports.desc = 'Create VCF ingestion for <vcfFileId> and <manifestFileId> in <projectId>';
8+
exports.builder = yargs => {
9+
yargs.positional('projectId', {
10+
describe: 'The project ID.',
11+
type: 'string'
12+
}).positional('vcfFileId', {
13+
describe: 'The ID of the VCF file.',
14+
type: 'string'
15+
}).positional('manifestFileId', {
16+
describe: 'The ID of the manifest file.',
17+
type: 'string'
18+
}).option('succeededEmail', {
19+
describe: 'An email address to notify if the ingestion succeeds',
20+
type: 'string'
21+
}).option('failedEmail', {
22+
describe: 'An email address to notify if the ingestion fails',
23+
type: 'string'
24+
});
25+
};
26+
27+
exports.handler = async argv => {
28+
const response = await post(argv, `/v1/genomic-ingestion/projects/${argv.projectId}/ingestions`, {
29+
ingestionType: 'Vcf',
30+
inputFiles: {
31+
vcf: argv.vcfFileId,
32+
manifest: argv.manifestFileId
33+
},
34+
notificationConfig: {
35+
succeededEmail: argv.succeededEmail,
36+
failedEmail: argv.failedEmail
37+
}
38+
});
39+
print(response.data, argv);
40+
};

test/unit/commands/genomics-ingestions.test.js

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ const createFoundationBam = proxyquire('../../../lib/cmds/genomics_cmds/ingestio
2929
const createCarisBam = proxyquire('../../../lib/cmds/genomics_cmds/ingestions_cmds/create-caris-bam', mocks);
3030
const createNextGen = proxyquire('../../../lib/cmds/genomics_cmds/ingestions_cmds/create-nextgen', mocks);
3131
const getByGermlineCaseId = proxyquire('../../../lib/cmds/genomics_cmds/ingestions_cmds/get-by-germline-case-id', mocks);
32+
const createVcf = proxyquire('../../../lib/cmds/genomics_cmds/ingestions_cmds/create-vcf', mocks);
3233

3334
test.always.afterEach(t => {
3435
getStub.resetHistory();
@@ -200,3 +201,28 @@ test.serial.cb('The "create-nextgen" command should create a NextGen ingestion',
200201

201202
yargs.command(createNextGen).parse('create-nextgen projectId tarFileId');
202203
});
204+
205+
test.serial.cb('The "create-vcf" command should create a VCF ingestion', t => {
206+
const res = { data: { id: 'ingestionId' } };
207+
postStub.onFirstCall().returns(res);
208+
callback = () => {
209+
t.is(postStub.callCount, 1);
210+
t.is(postStub.getCall(0).args[1], '/v1/genomic-ingestion/projects/projectId/ingestions');
211+
t.deepEqual(postStub.getCall(0).args[2], {
212+
ingestionType: 'Vcf',
213+
inputFiles: {
214+
vcf: 'vcfFileId',
215+
manifest: 'manifestFileId'
216+
},
217+
notificationConfig: {
218+
succeededEmail: 'test@testing.com',
219+
failedEmail: 'test@testing.com'
220+
}
221+
});
222+
t.is(printSpy.callCount, 1);
223+
t.true(printSpy.calledWith({ id: 'ingestionId' }));
224+
t.end();
225+
};
226+
227+
yargs.command(createVcf).parse('create-vcf projectId vcfFileId manifestFileId --succeededEmail test@testing.com --failedEmail test@testing.com');
228+
});

0 commit comments

Comments
 (0)