def demultiplex_flowcell( context: CGConfig, dry_run: bool, flowcell_id: str, bcl_converter: str, ): """Demultiplex a flowcell on slurm using CG flowcell-id is the flowcell run directory name, e.g. '201203_A00689_0200_AHVKJCDRXX' """ LOG.info("Running cg demultiplex flowcell, using %s.", bcl_converter) flowcell_directory: Path = Path(context.demultiplex.run_dir) / flowcell_id demultiplex_api: DemultiplexingAPI = context.demultiplex_api demultiplex_api.set_dry_run(dry_run=dry_run) LOG.info(f"SETTING FLOWCELL ID TO {flowcell_id}") LOG.info(f"SETTING OUT DIR TO {demultiplex_api.out_dir}") try: flowcell_obj = Flowcell(flowcell_path=flowcell_directory, bcl_converter=bcl_converter) except FlowcellError as e: raise click.Abort from e delete_demux_api: DeleteDemuxAPI = DeleteDemuxAPI( config=context, demultiplex_base=demultiplex_api.out_dir, dry_run=dry_run, run_path=flowcell_directory, ) delete_demux_api.delete_flow_cell( cg_stats=True, demultiplexing_dir=True, run_dir=False, housekeeper=True, init_files=True, status_db=False, ) if not demultiplex_api.is_demultiplexing_possible( flowcell=flowcell_obj) and not dry_run: LOG.warning("Can not start demultiplexing!") return if not flowcell_obj.validate_sample_sheet(): LOG.warning( "Malformed sample sheet. Run cg demultiplex samplesheet validate %s", flowcell_obj.sample_sheet_path, ) raise click.Abort slurm_job_id: int = demultiplex_api.start_demultiplexing( flowcell=flowcell_obj) tb_api: TrailblazerAPI = context.trailblazer_api demultiplex_api.add_to_trailblazer(tb_api=tb_api, slurm_job_id=slurm_job_id, flowcell=flowcell_obj)
def demultiplex_all(context: CGConfig, bcl_converter: str, flowcells_directory: click.Path, dry_run: bool): """Demultiplex all flowcells that are ready under the flowcells_directory""" LOG.info("Running cg demultiplex all, using %s.", bcl_converter) if flowcells_directory: flowcells_directory: Path = Path(str(flowcells_directory)) else: flowcells_directory: Path = Path(context.demultiplex.run_dir) demultiplex_api: DemultiplexingAPI = context.demultiplex_api demultiplex_api.set_dry_run(dry_run=dry_run) tb_api: TrailblazerAPI = context.trailblazer_api LOG.info("Search for flowcells ready to demultiplex in %s", flowcells_directory) for sub_dir in flowcells_directory.iterdir(): if not sub_dir.is_dir(): continue LOG.info("Found directory %s", sub_dir) try: flowcell_obj = Flowcell(flowcell_path=sub_dir, bcl_converter=bcl_converter) except FlowcellError: continue if not demultiplex_api.is_demultiplexing_possible( flowcell=flowcell_obj) and not dry_run: continue if not flowcell_obj.validate_sample_sheet(): LOG.warning( "Malformed sample sheet. Run cg demultiplex samplesheet validate %s", flowcell_obj.sample_sheet_path, ) continue delete_demux_api: DeleteDemuxAPI = DeleteDemuxAPI( config=context, demultiplex_base=demultiplex_api.out_dir, dry_run=dry_run, run_path=(flowcells_directory / sub_dir), ) delete_demux_api.delete_flow_cell( cg_stats=False, demultiplexing_dir=True, run_dir=False, housekeeper=True, init_files=False, status_db=False, ) slurm_job_id: int = demultiplex_api.start_demultiplexing( flowcell=flowcell_obj) demultiplex_api.add_to_trailblazer(tb_api=tb_api, slurm_job_id=slurm_job_id, flowcell=flowcell_obj)