def post(self): """Create a new run. This will import the VCF's genotypes into the database in a worker, as well as annotate it with gene names. """ run = request.validated_body try: expect_one_of(request.validated_body, 'project_name', 'project_id') except voluptuous.MultipleInvalid as e: errors = [str(err) for err in e.errors] abort(409, message='Validation error', errors=errors) try: projects.set_and_verify_project_id_on(run) except voluptuous.Invalid as e: abort(404, message='Project not found.', errors=[str(e)]) try: _set_or_verify_bam_id_on(run, bam_type='normal') _set_or_verify_bam_id_on(run, bam_type='tumor') except voluptuous.Invalid as e: abort(404, message='BAM not found.', errors=[str(e)]) with tables(db.engine, 'vcfs') as (con, runs): run = runs.insert( request.validated_body).returning(*runs.c).execute().fetchone() workers.runner.start_workers_for_vcf_id(run['id']) return dict(run), 201
def post(self): """Create a new BAM.""" try: expect_one_of(request.validated_body, 'project_name', 'project_id') except voluptuous.MultipleInvalid as e: errors = [str(err) for err in e.errors] abort(409, message='Validation error', errors=errors) try: projects.set_and_verify_project_id_on(request.validated_body) except voluptuous.Invalid as e: abort(404, message='Project not found.', error=str(e)) with tables(db.engine, 'bams') as (con, bams): result = bams.insert( request.validated_body).returning(*bams.c).execute() bam = dict(result.fetchone()) return bam, 201