Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: PHC-5229 Add VCF ingest command #234

Merged
merged 1 commit into from
Aug 30, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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: '[email protected]',
failedEmail: '[email protected]'
}
});
t.is(printSpy.callCount, 1);
t.true(printSpy.calledWith({ id: 'ingestionId' }));
t.end();
};

yargs.command(createVcf).parse('create-vcf projectId vcfFileId manifestFileId --succeededEmail [email protected] --failedEmail [email protected]');
});