Skip to content

Commit

Permalink
Merge pull request #234 from lifeomic/PHC-5229
Browse files Browse the repository at this point in the history
feat: PHC-5229 Add VCF ingest command
  • Loading branch information
cluebbehusen authored Aug 30, 2023
2 parents b3819e7 + 1b3df2d commit c26da37
Show file tree
Hide file tree
Showing 2 changed files with 66 additions and 0 deletions.
40 changes: 40 additions & 0 deletions lib/cmds/genomics_cmds/ingestions_cmds/create-vcf.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
'use strict';

const { post } = require('../../../api');
const print = require('../../../print');

exports.command = 'create-vcf <projectId> <vcfFileId> <manifestFileId>';
exports.desc = 'Create VCF ingestion for <vcfFileId> and <manifestFileId> in <projectId>';
exports.builder = yargs => {
yargs.positional('projectId', {
describe: 'The project ID.',
type: 'string'
}).positional('vcfFileId', {
describe: 'The ID of the VCF file.',
type: 'string'
}).positional('manifestFileId', {
describe: 'The ID of the manifest file.',
type: 'string'
}).option('succeededEmail', {
describe: 'An email address to notify if the ingestion succeeds',
type: 'string'
}).option('failedEmail', {
describe: 'An email address to notify if the ingestion fails',
type: 'string'
});
};

exports.handler = async argv => {
const response = await post(argv, `/v1/genomic-ingestion/projects/${argv.projectId}/ingestions`, {
ingestionType: 'Vcf',
inputFiles: {
vcf: argv.vcfFileId,
manifest: argv.manifestFileId
},
notificationConfig: {
succeededEmail: argv.succeededEmail,
failedEmail: argv.failedEmail
}
});
print(response.data, argv);
};
26 changes: 26 additions & 0 deletions test/unit/commands/genomics-ingestions.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ const createFoundationBam = proxyquire('../../../lib/cmds/genomics_cmds/ingestio
const createCarisBam = proxyquire('../../../lib/cmds/genomics_cmds/ingestions_cmds/create-caris-bam', mocks);
const createNextGen = proxyquire('../../../lib/cmds/genomics_cmds/ingestions_cmds/create-nextgen', mocks);
const getByGermlineCaseId = proxyquire('../../../lib/cmds/genomics_cmds/ingestions_cmds/get-by-germline-case-id', mocks);
const createVcf = proxyquire('../../../lib/cmds/genomics_cmds/ingestions_cmds/create-vcf', mocks);

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

yargs.command(createNextGen).parse('create-nextgen projectId tarFileId');
});

test.serial.cb('The "create-vcf" command should create a VCF ingestion', t => {
const res = { data: { id: 'ingestionId' } };
postStub.onFirstCall().returns(res);
callback = () => {
t.is(postStub.callCount, 1);
t.is(postStub.getCall(0).args[1], '/v1/genomic-ingestion/projects/projectId/ingestions');
t.deepEqual(postStub.getCall(0).args[2], {
ingestionType: 'Vcf',
inputFiles: {
vcf: 'vcfFileId',
manifest: 'manifestFileId'
},
notificationConfig: {
succeededEmail: 'test@testing.com',
failedEmail: 'test@testing.com'
}
});
t.is(printSpy.callCount, 1);
t.true(printSpy.calledWith({ id: 'ingestionId' }));
t.end();
};

yargs.command(createVcf).parse('create-vcf projectId vcfFileId manifestFileId --succeededEmail test@testing.com --failedEmail test@testing.com');
});

0 comments on commit c26da37

Please sign in to comment.