def update_compress_api(compress_api: CompressAPI, dry_run: bool, ntasks: int = None, mem: int = None) -> None: """Update parameters in compress api""" compress_api.set_dry_run(dry_run) if ntasks: LOG.info("Set ntasks to %s", ntasks) compress_api.ntasks = ntasks if mem: LOG.info("Set mem to %s", ntasks) compress_api.mem = mem
def clean_bam(context, case_id, dry_run): """Remove compressed BAM files, and update links in scout and housekeeper to CRAM files""" compress_api = CompressAPI( hk_api=context.obj["hk"], crunchy_api=context.obj["crunchy"], scout_api=context.obj["scout"], ) if case_id: cases = [context.obj["db"].family(case_id)] else: cases = context.obj["db"].families() for case in cases: case_id = case.internal_id compress_api.clean_bams(case_id, dry_run=dry_run)
def fixture_real_compress_api(demultiplex_runs: Path, housekeeper_api: HousekeeperAPI, real_crunchy_api: CrunchyAPI) -> CompressAPI: """Return a compress context""" return CompressAPI(crunchy_api=real_crunchy_api, hk_api=housekeeper_api, demux_root=demultiplex_runs.as_posix())
def __init__(self, config: CGConfig): self.config = config self.chanjo_api: ChanjoAPI = config.chanjo_api self.crunchy_api: CrunchyAPI = config.crunchy_api self.genotype_api: GenotypeAPI = config.genotype_api self.hermes_api: HermesApi = config.hermes_api self.housekeeper_api: HousekeeperAPI = config.housekeeper_api self.lims_api: LimsAPI = config.lims_api self.madeline_api: MadelineAPI = config.madeline_api self.mutacc_auto_api: MutaccAutoAPI = config.mutacc_auto_api self.prepare_fastq_api: PrepareFastqAPI = PrepareFastqAPI( store=config.status_db, compress_api=CompressAPI( hk_api=config.housekeeper_api, crunchy_api=config.crunchy_api, demux_root=config.demultiplex.out_dir, ), ) self.status_db: Store = config.status_db self.scout_api: ScoutAPI = config.scout_api self.trailblazer_api: TrailblazerAPI = config.trailblazer_api self.upload_vogue_api: UploadVogueAPI = UploadVogueAPI( genotype_api=config.genotype_api, vogue_api=config.vogue_api, store=config.status_db, ) self.vogue_api: VogueAPI = config.vogue_api
def decompress(context: CGConfig): """Decompress files""" hk_api = context.housekeeper_api crunchy_api = context.crunchy_api compress_api = CompressAPI(hk_api=hk_api, crunchy_api=crunchy_api, demux_root=context.demultiplex.out_dir) context.meta_apis["compress_api"] = compress_api LOG.info("Running decompress spring")
def compress(context: CGConfig): """Compress files""" hk_api = context.housekeeper_api crunchy_api = context.crunchy_api compress_api = CompressAPI(hk_api=hk_api, crunchy_api=crunchy_api, demux_root=context.demultiplex.out_dir) context.meta_apis["compress_api"] = compress_api
def bam(context, case_id, number_of_conversions, ntasks, mem, dry_run): """Find cases with BAM files and compress into CRAM""" compress_api = CompressAPI( hk_api=context.obj["hk"], crunchy_api=context.obj["crunchy"], scout_api=context.obj["scout"], ) conversion_count = 0 if case_id: cases = [context.obj["db"].family(case_id)] else: cases = context.obj["db"].families() for case in cases: if conversion_count == number_of_conversions: LOG.info("compressed bam-files for %s cases", conversion_count) break case_id = case.internal_id bam_dict = compress_api.get_bam_files(case_id=case_id) if not bam_dict: LOG.info("skipping %s", case_id) continue case_has_bam_file = True compression_is_pending = False for sample, bam_files in bam_dict.items(): bam_path = Path(bam_files["bam"].full_path) if not context.obj["crunchy"].is_bam_compression_possible(bam_path=bam_path): LOG.info("BAM to CRAM compression not possible for %s", sample) case_has_bam_file = False break if context.obj["crunchy"].is_cram_compression_pending(bam_path=bam_path): LOG.info("BAM to CRAM compression pending for %s", sample) compression_is_pending = True break if case_has_bam_file and not compression_is_pending: LOG.info("Compressing bam-files for %s", case_id) compress_api.compress_case_bams( bam_dict=bam_dict, ntasks=ntasks, mem=mem, dry_run=dry_run ) conversion_count += 1
def test_get_flow_cell_name(compress_api: CompressAPI, flowcell_name: str, flowcell_full_name: str): """Test functionality to extract the flow cell name from a run name given a designated structure""" # GIVEN a CompressAPI with a demux_root and a flowcell with a fastq in given demux_root fixture_flow_cell_name: str = flowcell_name fastq_path: Path = compress_api.demux_root.joinpath( Path(flowcell_full_name, "dummy_fastq.fastq.gz")) # WHEN retrieving the the name of the flow cell flow_cell_name: str = compress_api.get_flow_cell_name( fastq_path=fastq_path) # THEN the flow cell name retrieved should be identical to the fixture flow cell name used assert flow_cell_name == fixture_flow_cell_name
def compress_api(crunchy_api, housekeeper_api): """compress api fixture""" hk_api = housekeeper_api scout_api = MockScout() _api = CompressAPI(crunchy_api=crunchy_api, hk_api=hk_api, scout_api=scout_api) yield _api