def fixture_balsamic_context( cg_context: CGConfig, helpers: StoreHelpers, balsamic_lims: MockLimsAPI, balsamic_housekeeper: HousekeeperAPI, trailblazer_api: MockTB, hermes_api: HermesApi, cg_dir, ) -> CGConfig: """context to use in cli""" cg_context.housekeeper_api_ = balsamic_housekeeper cg_context.lims_api_ = balsamic_lims cg_context.trailblazer_api_ = trailblazer_api cg_context.meta_apis["analysis_api"] = BalsamicAnalysisAPI( config=cg_context) status_db: Store = cg_context.status_db # Create tgs application version helpers.ensure_application_version(store=status_db, application_tag="TGSA", application_type="tgs") # Create wes application version helpers.ensure_application_version(store=status_db, application_tag="WESA", application_type="wes") # Create textbook case for WGS PAIRED with enough reads case_wgs_paired_enough_reads = helpers.add_case( store=status_db, internal_id="balsamic_case_wgs_paired_enough_reads", name="balsamic_case_wgs_paired_enough_reads", data_analysis=Pipeline.BALSAMIC, ) sample_case_wgs_paired_tumor_enough_reads = helpers.add_sample( status_db, internal_id="sample_case_wgs_paired_tumor_enough_reads", is_tumour=True, application_type="wgs", reads=10, sequenced_at=dt.datetime.now(), ) sample_case_wgs_paired_normal_enough_reads = helpers.add_sample( status_db, internal_id="sample_case_wgs_paired_normal_enough_reads", is_tumour=False, application_type="wgs", reads=10, sequenced_at=dt.datetime.now(), ) helpers.add_relationship( status_db, case=case_wgs_paired_enough_reads, sample=sample_case_wgs_paired_tumor_enough_reads, ) helpers.add_relationship( status_db, case=case_wgs_paired_enough_reads, sample=sample_case_wgs_paired_normal_enough_reads, ) # Create textbook case for WGS PAIRED case_wgs_paired = helpers.add_case( store=status_db, internal_id="balsamic_case_wgs_paired", name="balsamic_case_wgs_paired", data_analysis=Pipeline.BALSAMIC, ) sample_case_wgs_paired_tumor = helpers.add_sample( status_db, internal_id="sample_case_wgs_paired_tumor", is_tumour=True, application_type="wgs", reads=10, sequenced_at=dt.datetime.now(), ) sample_case_wgs_paired_normal = helpers.add_sample( status_db, internal_id="sample_case_wgs_paired_normal", is_tumour=False, application_type="wgs", reads=10, sequenced_at=dt.datetime.now(), ) helpers.add_relationship(status_db, case=case_wgs_paired, sample=sample_case_wgs_paired_tumor) helpers.add_relationship(status_db, case=case_wgs_paired, sample=sample_case_wgs_paired_normal) # Create textbook case for TGS PAIRED without enough reads case_tgs_paired = helpers.add_case( status_db, internal_id="balsamic_case_tgs_paired", name="balsamic_case_tgs_paired", data_analysis=Pipeline.BALSAMIC, ) sample_case_tgs_paired_tumor = helpers.add_sample( status_db, internal_id="sample_case_tgs_paired_tumor", is_tumour=True, application_tag="TGSA", application_type="tgs", reads=10, sequenced_at=dt.datetime.now(), ) sample_case_tgs_paired_normal = helpers.add_sample( status_db, internal_id="sample_case_tgs_paired_normal", is_tumour=False, application_tag="TGSA", application_type="tgs", reads=0, sequenced_at=dt.datetime.now(), ) helpers.add_relationship(status_db, case=case_tgs_paired, sample=sample_case_tgs_paired_tumor) helpers.add_relationship(status_db, case=case_tgs_paired, sample=sample_case_tgs_paired_normal) # Create textbook case for WGS TUMOR ONLY case_wgs_single = helpers.add_case( status_db, internal_id="balsamic_case_wgs_single", name="balsamic_case_wgs_single", data_analysis=Pipeline.BALSAMIC, ) sample_case_wgs_single_tumor = helpers.add_sample( status_db, internal_id="sample_case_wgs_single_tumor", is_tumour=True, application_type="wgs", reads=100, sequenced_at=dt.datetime.now(), ) helpers.add_relationship(status_db, case=case_wgs_single, sample=sample_case_wgs_single_tumor) # Create textbook case for TGS TUMOR ONLY case_tgs_single = helpers.add_case( status_db, internal_id="balsamic_case_tgs_single", name="balsamic_case_tgs_single", data_analysis=Pipeline.BALSAMIC, ) sample_case_tgs_single_tumor = helpers.add_sample( status_db, internal_id="sample_case_tgs_single_tumor", is_tumour=True, application_tag="TGSA", application_type="tgs", sequenced_at=dt.datetime.now(), ) helpers.add_relationship(status_db, case=case_tgs_single, sample=sample_case_tgs_single_tumor) # Create ERROR case for TGS NORMAL ONLY case_tgs_single_error = helpers.add_case( status_db, internal_id="balsamic_case_tgs_single_error", name="balsamic_case_tgs_single_error", data_analysis=Pipeline.BALSAMIC, ) sample_case_tgs_single_normal_error = helpers.add_sample( status_db, internal_id="sample_case_tgs_single_normal_error", is_tumour=False, application_tag="TGSA", application_type="tgs", sequenced_at=dt.datetime.now(), ) helpers.add_relationship( status_db, case=case_tgs_single_error, sample=sample_case_tgs_single_normal_error, ) # Create ERROR case for TGS TWO TUMOR ONE NORMAL case_tgs_paired_error = helpers.add_case( status_db, internal_id="balsamic_case_tgs_paired_error", name="balsamic_case_tgs_paired_error", data_analysis=Pipeline.BALSAMIC, ) sample_case_tgs_paired_tumor_error = helpers.add_sample( status_db, internal_id="sample_case_tgs_paired_tumor_error", is_tumour=True, application_tag="TGSA", application_type="tgs", sequenced_at=dt.datetime.now(), ) sample_case_tgs_paired_tumor2_error = helpers.add_sample( status_db, internal_id="sample_case_tgs_paired_tumor2_error", is_tumour=True, application_tag="TGSA", application_type="tgs", sequenced_at=dt.datetime.now(), ) sample_case_tgs_paired_normal_error = helpers.add_sample( status_db, internal_id="sample_case_tgs_paired_normal_error", is_tumour=False, application_tag="TGSA", application_type="tgs", sequenced_at=dt.datetime.now(), ) helpers.add_relationship( status_db, case=case_tgs_paired_error, sample=sample_case_tgs_paired_tumor_error, ) helpers.add_relationship( status_db, case=case_tgs_paired_error, sample=sample_case_tgs_paired_tumor2_error, ) helpers.add_relationship( status_db, case=case_tgs_paired_error, sample=sample_case_tgs_paired_normal_error, ) # Create ERROR case for MIXED application type case_mixed_paired_error = helpers.add_case( status_db, internal_id="balsamic_case_mixed_paired_error", name="balsamic_case_mixed_paired_error", data_analysis=Pipeline.BALSAMIC, ) mixed_sample_case_wgs_paired_tumor_error = helpers.add_sample( status_db, internal_id="mixed_sample_case_wgs_paired_tumor_error", is_tumour=True, application_type="wgs", sequenced_at=dt.datetime.now(), ) mixed_sample_case_tgs_paired_normal_error = helpers.add_sample( status_db, internal_id="mixed_sample_case_tgs_paired_normal_error", is_tumour=False, application_tag="TGSA", application_type="tgs", sequenced_at=dt.datetime.now(), ) helpers.add_relationship( status_db, case=case_mixed_paired_error, sample=mixed_sample_case_wgs_paired_tumor_error, ) helpers.add_relationship( status_db, case=case_mixed_paired_error, sample=mixed_sample_case_tgs_paired_normal_error, ) # Create ERROR case for MIXED application type NOT BALSAMIC APPLICATION case_mixed_wgs_mic_paired_error = helpers.add_case( status_db, internal_id="balsamic_case_mixed_wgs_mic_paired_error", name="balsamic_case_mixed_wgs_mic_paired_error", data_analysis=Pipeline.BALSAMIC, ) mixed_sample_case_wgs_mic_paired_tumor_error = helpers.add_sample( status_db, internal_id="mixed_sample_case_wgs_mic_paired_tumor_error", is_tumour=True, application_type="wgs", sequenced_at=dt.datetime.now(), ) mixed_sample_case_wgs_mic_paired_normal_error = helpers.add_sample( status_db, internal_id="mixed_sample_case_wgs_mic_paired_normal_error", is_tumour=False, application_tag="MICA", application_type="mic", sequenced_at=dt.datetime.now(), ) helpers.add_relationship( status_db, case=case_mixed_wgs_mic_paired_error, sample=mixed_sample_case_wgs_mic_paired_tumor_error, ) helpers.add_relationship( status_db, case=case_mixed_wgs_mic_paired_error, sample=mixed_sample_case_wgs_mic_paired_normal_error, ) # Create ERROR case for MIXED TARGET BED case_mixed_bed_paired_error = helpers.add_case( status_db, internal_id="balsamic_case_mixed_bed_paired_error", name="balsamic_case_mixed_bed_paired_error", data_analysis=Pipeline.BALSAMIC, ) mixed_sample_case_mixed_bed_paired_tumor_error = helpers.add_sample( status_db, internal_id="mixed_sample_case_mixed_bed_paired_tumor_error", is_tumour=True, application_tag="TGSA", application_type="tgs", sequenced_at=dt.datetime.now(), ) mixed_sample_case_mixed_bed_paired_normal_error = helpers.add_sample( status_db, internal_id="mixed_sample_case_mixed_bed_paired_normal_error", is_tumour=False, application_tag="TGSA", application_type="tgs", sequenced_at=dt.datetime.now(), ) helpers.add_relationship( status_db, case=case_mixed_bed_paired_error, sample=mixed_sample_case_mixed_bed_paired_tumor_error, ) helpers.add_relationship( status_db, case=case_mixed_bed_paired_error, sample=mixed_sample_case_mixed_bed_paired_normal_error, ) # Create ERROR case for WGS TUMOR ONLY MIP CLI_OPTION_ANALYSIS ONLY mip_case_wgs_single = helpers.add_case( status_db, internal_id="mip_case_wgs_single", name="mip_case_wgs_single", data_analysis=Pipeline.MIP_DNA, ) mip_sample_case_wgs_single_tumor = helpers.add_sample( status_db, internal_id="mip_sample_case_wgs_single_tumor", is_tumour=True, application_type="wgs", sequenced_at=dt.datetime.now(), ) helpers.add_relationship( status_db, case=mip_case_wgs_single, sample=mip_sample_case_wgs_single_tumor, ) # Create ERROR case for WGS ONE TUMOR TWO NORMAL case_wgs_paired_two_normal_error = helpers.add_case( status_db, internal_id="balsamic_case_wgs_paired_two_normal_error", name="balsamic_case_wgs_paired_two_normal_error", data_analysis=Pipeline.BALSAMIC, ) sample_case_wgs_paired_two_normal_tumor_error = helpers.add_sample( status_db, internal_id="sample_case_wgs_paired_two_normal_tumor_error", is_tumour=True, application_tag="WGSA", application_type="wgs", sequenced_at=dt.datetime.now(), ) sample_case_wgs_paired_two_normal_normal1_error = helpers.add_sample( status_db, internal_id="sample_case_wgs_paired_two_normal_normal1_error", is_tumour=False, application_tag="WGSA", application_type="wgs", sequenced_at=dt.datetime.now(), ) sample_case_wgs_paired_two_normal_normal2_error = helpers.add_sample( status_db, internal_id="sample_case_wgs_paired_two_normal_normal2_error", is_tumour=False, application_tag="WGSA", application_type="wgs", sequenced_at=dt.datetime.now(), ) helpers.add_relationship( status_db, case=case_wgs_paired_two_normal_error, sample=sample_case_wgs_paired_two_normal_tumor_error, ) helpers.add_relationship( status_db, case=case_wgs_paired_two_normal_error, sample=sample_case_wgs_paired_two_normal_normal1_error, ) helpers.add_relationship( status_db, case=case_wgs_paired_two_normal_error, sample=sample_case_wgs_paired_two_normal_normal2_error, ) # Create WES case with 1 tumor sample case_wes_tumor = helpers.add_case( status_db, internal_id="balsamic_case_wes_tumor", name="balsamic_case_wes_tumor", data_analysis=Pipeline.BALSAMIC, ) sample_case_wes_tumor = helpers.add_sample( status_db, internal_id="sample_case_wes_tumor", is_tumour=True, application_tag="WESA", application_type="wes", sequenced_at=dt.datetime.now(), ) helpers.add_relationship(status_db, case=case_wes_tumor, sample=sample_case_wes_tumor) # Create ERROR case for WES when no panel is found case_wes_panel_error = helpers.add_case( status_db, internal_id="balsamic_case_wes_panel_error", name="balsamic_case_wes_panel_error", data_analysis=Pipeline.BALSAMIC, ) sample_case_wes_panel_error = helpers.add_sample( status_db, internal_id="sample_case_wes_panel_error", is_tumour=True, application_tag="WESA", application_type="wes", sequenced_at=dt.datetime.now(), ) helpers.add_relationship(status_db, case=case_wes_panel_error, sample=sample_case_wes_panel_error) # Create ERROR case with NO SAMPLES helpers.add_case(status_db, internal_id="no_sample_case", name="no_sample_case") # Create BED1 version 1 bed1_name = "BalsamicBed1" bed1_filename = "balsamic_bed_1.bed" Path(cg_dir, bed1_filename).touch(exist_ok=True) bed1 = status_db.add_bed(name=bed1_name) status_db.add_commit(bed1) version1 = status_db.add_bed_version(bed=bed1, version=1, filename=bed1_filename, shortname=bed1_name) status_db.add_commit(version1) # Create BED2 version 1 bed2_name = "BalsamicBed2" bed2_filename = "balsamic_bed_2.bed" Path(cg_dir, bed2_filename).touch(exist_ok=True) bed2 = status_db.add_bed(name=bed2_name) status_db.add_commit(bed2) version2 = status_db.add_bed_version(bed=bed2, version=1, filename=bed2_filename, shortname=bed2_name) status_db.add_commit(version2) return cg_context
def base_context(cg_context: CGConfig) -> CGConfig: """context to use in cli""" cg_context.lims_api_ = MockLims() return cg_context
def base_context(cg_context: CGConfig, helpers: StoreHelpers, lims_api): """The click context for the microsalt cli""" helpers.add_microbial_sample(cg_context.status_db) cg_context.lims_api_ = lims_api cg_context.meta_apis["analysis_api"] = MicrosaltAnalysisAPI(cg_context) return cg_context
def fixture_sample_sheet_context(cg_context: CGConfig, lims_api: LimsAPI) -> CGConfig: cg_context.lims_api_ = lims_api return cg_context