diff --git a/cg/apps/demultiplex/demultiplex_api.py b/cg/apps/demultiplex/demultiplex_api.py index d2cdc4789c..0cd7a2b85b 100644 --- a/cg/apps/demultiplex/demultiplex_api.py +++ b/cg/apps/demultiplex/demultiplex_api.py @@ -34,7 +34,7 @@ def __init__(self, config: dict, housekeeper_api: HousekeeperAPI, out_dir: Path self.hk_api = housekeeper_api self.slurm_account: str = config["demultiplex"]["slurm"]["account"] self.mail: str = config["demultiplex"]["slurm"]["mail_user"] - self.flow_cells_dir: Path = Path(config["illumina_flow_cells_directory"]) + self.sequencing_runs_dir: Path = Path(config["illumina_flow_cells_directory"]) self.demultiplexed_runs_dir: Path = out_dir or Path( config["illumina_demultiplexed_runs_directory"] ) @@ -55,18 +55,18 @@ def set_dry_run(self, dry_run: bool) -> None: @staticmethod def get_sbatch_error( - flow_cell: IlluminaRunDirectoryData, + sequencing_run: IlluminaRunDirectoryData, email: str, demux_dir: Path, ) -> str: """Create the sbatch error string.""" LOG.debug("Creating the sbatch error string") error_parameters: SbatchError = SbatchError( - flow_cell_id=flow_cell.id, + flow_cell_id=sequencing_run.id, email=email, - logfile=DemultiplexingAPI.get_stderr_logfile(flow_cell=flow_cell).as_posix(), + logfile=DemultiplexingAPI.get_stderr_logfile(sequencing_run=sequencing_run).as_posix(), demux_dir=demux_dir.as_posix(), - demux_started=flow_cell.demultiplexing_started_path.as_posix(), + demux_started=sequencing_run.demultiplexing_started_path.as_posix(), ) return DEMULTIPLEX_ERROR.format(**error_parameters.model_dump()) @@ -95,28 +95,28 @@ def get_sbatch_command( return DEMULTIPLEX_COMMAND.format(**command_parameters.model_dump()) @staticmethod - def demultiplex_sbatch_path(flow_cell: IlluminaRunDirectoryData) -> Path: + def demultiplex_sbatch_path(sequencing_run: IlluminaRunDirectoryData) -> Path: """Get the path to where sbatch script file should be kept.""" - return Path(flow_cell.path, "demux-novaseq.sh") + return Path(sequencing_run.path, "demux-novaseq.sh") @staticmethod - def get_run_name(flow_cell: IlluminaRunDirectoryData) -> str: + def get_run_name(sequencing_run: IlluminaRunDirectoryData) -> str: """Create the run name for the sbatch job.""" - return f"{flow_cell.id}_demultiplex" + return f"{sequencing_run.id}_demultiplex" @staticmethod - def get_stderr_logfile(flow_cell: IlluminaRunDirectoryData) -> Path: + def get_stderr_logfile(sequencing_run: IlluminaRunDirectoryData) -> Path: """Create the path to the stderr logfile.""" - return Path(flow_cell.path, f"{DemultiplexingAPI.get_run_name(flow_cell)}.stderr") + return Path(sequencing_run.path, f"{DemultiplexingAPI.get_run_name(sequencing_run)}.stderr") @staticmethod - def get_stdout_logfile(flow_cell: IlluminaRunDirectoryData) -> Path: + def get_stdout_logfile(sequencing_run: IlluminaRunDirectoryData) -> Path: """Create the path to the stdout logfile.""" - return Path(flow_cell.path, f"{DemultiplexingAPI.get_run_name(flow_cell)}.stdout") + return Path(sequencing_run.path, f"{DemultiplexingAPI.get_run_name(sequencing_run)}.stdout") - def flow_cell_out_dir_path(self, flow_cell: IlluminaRunDirectoryData) -> Path: + def demultiplexed_run_dir_path(self, sequencing_run: IlluminaRunDirectoryData) -> Path: """Create the path to where the demultiplexed result should be produced.""" - return Path(self.demultiplexed_runs_dir, flow_cell.path.name) + return Path(self.demultiplexed_runs_dir, sequencing_run.path.name) def is_sample_sheet_in_housekeeper(self, flow_cell_id: str) -> bool: """Returns True if the sample sheet for the flow cell exists in Housekeeper.""" @@ -126,45 +126,52 @@ def is_sample_sheet_in_housekeeper(self, flow_cell_id: str) -> bool: except HousekeeperFileMissingError: return False - def get_flow_cell_unaligned_dir(self, flow_cell: IlluminaRunDirectoryData) -> Path: + def get_sequencing_run_unaligned_dir(self, sequencing_run: IlluminaRunDirectoryData) -> Path: """Returns the path to where the demultiplexed result are located.""" return Path( - self.flow_cell_out_dir_path(flow_cell), DemultiplexingDirsAndFiles.UNALIGNED_DIR_NAME + self.demultiplexed_run_dir_path(sequencing_run), + DemultiplexingDirsAndFiles.UNALIGNED_DIR_NAME, ) - def demultiplexing_completed_path(self, flow_cell: IlluminaRunDirectoryData) -> Path: + def demultiplexing_completed_path(self, sequencing_run: IlluminaRunDirectoryData) -> Path: """Return the path to demultiplexing complete file.""" LOG.info( - Path(self.flow_cell_out_dir_path(flow_cell), DemultiplexingDirsAndFiles.DEMUX_COMPLETE) + Path( + self.demultiplexed_run_dir_path(sequencing_run), + DemultiplexingDirsAndFiles.DEMUX_COMPLETE, + ) ) return Path( - self.flow_cell_out_dir_path(flow_cell), DemultiplexingDirsAndFiles.DEMUX_COMPLETE + self.demultiplexed_run_dir_path(sequencing_run), + DemultiplexingDirsAndFiles.DEMUX_COMPLETE, ) - def is_demultiplexing_possible(self, flow_cell: IlluminaRunDirectoryData) -> bool: + def is_demultiplexing_possible(self, sequencing_run: IlluminaRunDirectoryData) -> bool: """Check if it is possible to start demultiplexing. This means that - - flow cell should be ready for demultiplexing (all files in place) + - sequencing run should be ready for demultiplexing (all files in place) - sample sheet needs to exist - demultiplexing should not be running """ - LOG.info(f"Check if demultiplexing is possible for {flow_cell.id}") + LOG.info(f"Check if demultiplexing is possible for {sequencing_run.id}") demultiplexing_possible = True - if not flow_cell.is_sequencing_run_ready(): + if not sequencing_run.is_sequencing_run_ready(): demultiplexing_possible = False - if not flow_cell.sample_sheet_exists(): - LOG.warning(f"Could not find sample sheet in flow cell directory for {flow_cell.id}") + if not sequencing_run.sample_sheet_exists(): + LOG.warning( + f"Could not find sample sheet in sequencing run directory for {sequencing_run.id}" + ) demultiplexing_possible = False - if not self.is_sample_sheet_in_housekeeper(flow_cell_id=flow_cell.id): - LOG.warning(f"Could not find sample sheet in Housekeeper for {flow_cell.id}") + if not self.is_sample_sheet_in_housekeeper(flow_cell_id=sequencing_run.id): + LOG.warning(f"Could not find sample sheet in Housekeeper for {sequencing_run.id}") demultiplexing_possible = False if ( - flow_cell.has_demultiplexing_started_locally() - or flow_cell.has_demultiplexing_started_on_sequencer() + sequencing_run.has_demultiplexing_started_locally() + or sequencing_run.has_demultiplexing_started_on_sequencer() ): LOG.warning("Demultiplexing has already been started") demultiplexing_possible = False @@ -190,37 +197,39 @@ def write_trailblazer_config(content: dict, file_path: Path) -> None: ) def add_to_trailblazer( - self, tb_api: TrailblazerAPI, slurm_job_id: int, flow_cell: IlluminaRunDirectoryData + self, tb_api: TrailblazerAPI, slurm_job_id: int, sequencing_run: IlluminaRunDirectoryData ): """Add demultiplexing entry to trailblazer.""" if self.dry_run: return self.write_trailblazer_config( content=self.get_trailblazer_config(slurm_job_id=slurm_job_id), - file_path=flow_cell.trailblazer_config_path, + file_path=sequencing_run.trailblazer_config_path, ) tb_api.add_pending_analysis( - case_id=flow_cell.id, + case_id=sequencing_run.id, analysis_type=AnalysisTypes.OTHER, - config_path=flow_cell.trailblazer_config_path.as_posix(), - out_dir=flow_cell.trailblazer_config_path.parent.as_posix(), + config_path=sequencing_run.trailblazer_config_path.as_posix(), + out_dir=sequencing_run.trailblazer_config_path.parent.as_posix(), slurm_quality_of_service=self.slurm_quality_of_service, email=self.mail, workflow=Workflow.DEMULTIPLEX, ) - def start_demultiplexing(self, flow_cell: IlluminaRunDirectoryData): - """Start demultiplexing for a flow cell.""" - self.create_demultiplexing_started_file(flow_cell.demultiplexing_started_path) - log_path: Path = self.get_stderr_logfile(flow_cell=flow_cell) + def start_demultiplexing(self, sequencing_run: IlluminaRunDirectoryData): + """Start demultiplexing for a sequencing run.""" + self.create_demultiplexing_started_file(sequencing_run.demultiplexing_started_path) + log_path: Path = self.get_stderr_logfile(sequencing_run=sequencing_run) error_function: str = self.get_sbatch_error( - flow_cell=flow_cell, email=self.mail, demux_dir=self.flow_cell_out_dir_path(flow_cell) + sequencing_run=sequencing_run, + email=self.mail, + demux_dir=self.demultiplexed_run_dir_path(sequencing_run), ) commands: str = self.get_sbatch_command( - run_dir=flow_cell.path, - demux_dir=self.flow_cell_out_dir_path(flow_cell=flow_cell), - sample_sheet=flow_cell.sample_sheet_path, - demux_completed=self.demultiplexing_completed_path(flow_cell=flow_cell), + run_dir=sequencing_run.path, + demux_dir=self.demultiplexed_run_dir_path(sequencing_run=sequencing_run), + sample_sheet=sequencing_run.sample_sheet_path, + demux_completed=self.demultiplexing_completed_path(sequencing_run=sequencing_run), environment=self.environment, ) sbatch_parameters: SbatchDragen = SbatchDragen( @@ -229,31 +238,38 @@ def start_demultiplexing(self, flow_cell: IlluminaRunDirectoryData): email=self.mail, error=error_function, hours=36, - job_name=self.get_run_name(flow_cell), + job_name=self.get_run_name(sequencing_run), log_dir=log_path.parent.as_posix(), quality_of_service=self.slurm_quality_of_service, ) sbatch_content: str = self.slurm_api.generate_sbatch_content( sbatch_parameters=sbatch_parameters ) - sbatch_path: Path = self.demultiplex_sbatch_path(flow_cell=flow_cell) + sbatch_path: Path = self.demultiplex_sbatch_path(sequencing_run=sequencing_run) sbatch_number: int = self.slurm_api.submit_sbatch( sbatch_content=sbatch_content, sbatch_path=sbatch_path ) LOG.info(f"Demultiplexing running as job {sbatch_number}") return sbatch_number - def prepare_output_directory(self, flow_cell: IlluminaRunDirectoryData) -> None: + def prepare_output_directory(self, sequencing_run: IlluminaRunDirectoryData) -> None: """Makes sure the output directory is ready for demultiplexing.""" - self.remove_demultiplexing_output_directory(flow_cell) - self.create_demultiplexing_output_dir(flow_cell) + self.remove_demultiplexing_output_directory(sequencing_run) + self.create_demultiplexing_output_dir(sequencing_run) - def remove_demultiplexing_output_directory(self, flow_cell: IlluminaRunDirectoryData) -> None: - if not self.dry_run and self.flow_cell_out_dir_path(flow_cell=flow_cell).exists(): - shutil.rmtree(self.flow_cell_out_dir_path(flow_cell=flow_cell), ignore_errors=False) + def remove_demultiplexing_output_directory( + self, sequencing_run: IlluminaRunDirectoryData + ) -> None: + if ( + not self.dry_run + and self.demultiplexed_run_dir_path(sequencing_run=sequencing_run).exists() + ): + shutil.rmtree( + self.demultiplexed_run_dir_path(sequencing_run=sequencing_run), ignore_errors=False + ) - def create_demultiplexing_output_dir(self, flow_cell: IlluminaRunDirectoryData) -> None: - """Creates the demultiplexing output directory for the flow cell.""" - output_directory: Path = self.flow_cell_out_dir_path(flow_cell) + def create_demultiplexing_output_dir(self, sequencing_run: IlluminaRunDirectoryData) -> None: + """Creates the demultiplexing output directory for the sequencing run.""" + output_directory: Path = self.demultiplexed_run_dir_path(sequencing_run) LOG.debug(f"Creating demultiplexing output directory: {output_directory}") output_directory.mkdir(exist_ok=False, parents=True) diff --git a/cg/cli/demultiplex/demux.py b/cg/cli/demultiplex/demux.py index b88a56f638..d512af6e18 100644 --- a/cg/cli/demultiplex/demux.py +++ b/cg/cli/demultiplex/demux.py @@ -34,7 +34,7 @@ @DRY_RUN @click.pass_obj def demultiplex_all(context: CGConfig, flow_cells_directory: click.Path, dry_run: bool): - """Demultiplex all flow cells that are ready under the flow cells directory.""" + """Demultiplex all sequencing runs that are ready under the sequencing runs directory.""" LOG.info("Running cg demultiplex all ...") sample_sheet_api: SampleSheetAPI = context.sample_sheet_api demultiplex_api: DemultiplexingAPI = context.demultiplex_api @@ -42,36 +42,36 @@ def demultiplex_all(context: CGConfig, flow_cells_directory: click.Path, dry_run if flow_cells_directory: flow_cells_directory: Path = Path(str(flow_cells_directory)) else: - flow_cells_directory: Path = Path(demultiplex_api.flow_cells_dir) + flow_cells_directory: Path = Path(demultiplex_api.sequencing_runs_dir) - LOG.info(f"Search for flow cells ready to demultiplex in {flow_cells_directory}") + LOG.info(f"Search for sequencing run ready to demultiplex in {flow_cells_directory}") for sub_dir in flow_cells_directory.iterdir(): if not sub_dir.is_dir(): continue LOG.info(f"Found directory {sub_dir}") try: - flow_cell = IlluminaRunDirectoryData(sequencing_run_path=sub_dir) + sequencing_run = IlluminaRunDirectoryData(sequencing_run_path=sub_dir) except FlowCellError: continue - if not demultiplex_api.is_demultiplexing_possible(flow_cell=flow_cell): - LOG.warning(f"Can not start demultiplexing for flow cell {flow_cell.id}!") + if not demultiplex_api.is_demultiplexing_possible(sequencing_run=sequencing_run): + LOG.warning(f"Can not start demultiplexing for sequencing run {sequencing_run.id}!") continue try: - sample_sheet_api.validate_sample_sheet(flow_cell.sample_sheet_path) + sample_sheet_api.validate_sample_sheet(sequencing_run.sample_sheet_path) except (SampleSheetError, ValidationError): LOG.warning( - f"Malformed sample sheet. Run cg demultiplex samplesheet validate {flow_cell.sample_sheet_path}" + f"Malformed sample sheet. Run cg demultiplex samplesheet validate {sequencing_run.sample_sheet_path}" ) continue if not dry_run: - demultiplex_api.prepare_output_directory(flow_cell) - slurm_job_id: int = demultiplex_api.start_demultiplexing(flow_cell=flow_cell) + demultiplex_api.prepare_output_directory(sequencing_run) + slurm_job_id: int = demultiplex_api.start_demultiplexing(sequencing_run=sequencing_run) tb_api: TrailblazerAPI = context.trailblazer_api demultiplex_api.add_to_trailblazer( - tb_api=tb_api, slurm_job_id=slurm_job_id, flow_cell=flow_cell + tb_api=tb_api, slurm_job_id=slurm_job_id, sequencing_run=sequencing_run ) @@ -86,40 +86,40 @@ def demultiplex_flow_cell( ): """Demultiplex a flow cell using BCLConvert. - flow cell name is the flow cell run directory name, e.g. '230912_A00187_1009_AHK33MDRX3' + flow cell name is the sequencing run directory name, e.g. '230912_A00187_1009_AHK33MDRX3' """ - LOG.info(f"Starting demultiplexing of flow cell {flow_cell_name}") + LOG.info(f"Starting demultiplexing of sequencing run {flow_cell_name}") sample_sheet_api: SampleSheetAPI = context.sample_sheet_api demultiplex_api: DemultiplexingAPI = context.demultiplex_api - flow_cell_directory: Path = Path(context.demultiplex_api.flow_cells_dir, flow_cell_name) + sequencing_run_dir: Path = Path(context.demultiplex_api.sequencing_runs_dir, flow_cell_name) demultiplex_api.set_dry_run(dry_run=dry_run) LOG.info(f"setting flow cell id to {flow_cell_name}") LOG.info(f"setting demultiplexed runs dir to {demultiplex_api.demultiplexed_runs_dir}") try: - flow_cell = IlluminaRunDirectoryData(flow_cell_directory) + sequencing_run = IlluminaRunDirectoryData(sequencing_run_dir) except FlowCellError as error: raise click.Abort from error - if not demultiplex_api.is_demultiplexing_possible(flow_cell=flow_cell): + if not demultiplex_api.is_demultiplexing_possible(sequencing_run=sequencing_run): LOG.warning("Can not start demultiplexing!") return try: - sample_sheet_api.validate_sample_sheet(flow_cell.sample_sheet_path) + sample_sheet_api.validate_sample_sheet(sequencing_run.sample_sheet_path) except (SampleSheetError, ValidationError) as error: LOG.warning( - f"Malformed sample sheet. Run cg demultiplex samplesheet validate {flow_cell.sample_sheet_path}" + f"Malformed sample sheet. Run cg demultiplex samplesheet validate {sequencing_run.sample_sheet_path}" ) raise click.Abort from error if not dry_run: - demultiplex_api.prepare_output_directory(flow_cell) - slurm_job_id: int = demultiplex_api.start_demultiplexing(flow_cell=flow_cell) + demultiplex_api.prepare_output_directory(sequencing_run) + slurm_job_id: int = demultiplex_api.start_demultiplexing(sequencing_run=sequencing_run) tb_api: TrailblazerAPI = context.trailblazer_api demultiplex_api.add_to_trailblazer( - tb_api=tb_api, slurm_job_id=slurm_job_id, flow_cell=flow_cell + tb_api=tb_api, slurm_job_id=slurm_job_id, sequencing_run=sequencing_run ) @@ -127,24 +127,26 @@ def demultiplex_flow_cell( @click.pass_obj def copy_novaseqx_flow_cells(context: CGConfig): """Copy NovaSeq X flow cells ready for post-processing to demultiplexed runs.""" - flow_cells_dir: Path = Path(context.illumina_flow_cells_directory) + sequencing_runs_dir: Path = Path(context.illumina_flow_cells_directory) demultiplexed_runs_dir: Path = Path(context.illumina_demultiplexed_runs_directory) - for flow_cell_dir in flow_cells_dir.iterdir(): + for sequencing_run_dir in sequencing_runs_dir.iterdir(): if is_ready_for_post_processing( - flow_cell_dir=flow_cell_dir, demultiplexed_runs_dir=demultiplexed_runs_dir + flow_cell_dir=sequencing_run_dir, demultiplexed_runs_dir=demultiplexed_runs_dir ): - LOG.info(f"Copying {flow_cell_dir.name} to {demultiplexed_runs_dir}") + LOG.info(f"Copying {sequencing_run_dir.name} to {demultiplexed_runs_dir}") hardlink_flow_cell_analysis_data( - flow_cell_dir=flow_cell_dir, demultiplexed_runs_dir=demultiplexed_runs_dir + flow_cell_dir=sequencing_run_dir, demultiplexed_runs_dir=demultiplexed_runs_dir ) demultiplexed_runs_flow_cell_dir: Path = Path( - demultiplexed_runs_dir, flow_cell_dir.name + demultiplexed_runs_dir, sequencing_run_dir.name ) mark_as_demultiplexed(demultiplexed_runs_flow_cell_dir) - mark_flow_cell_as_queued_for_post_processing(flow_cell_dir) + mark_flow_cell_as_queued_for_post_processing(sequencing_run_dir) else: - LOG.info(f"Flow cell {flow_cell_dir.name} is not ready for post processing, skipping.") + LOG.info( + f"Flow cell {sequencing_run_dir.name} is not ready for post processing, skipping." + ) @click.command(name="confirm-flow-cell-sync") @@ -157,19 +159,19 @@ def copy_novaseqx_flow_cells(context: CGConfig): def confirm_flow_cell_sync(context: CGConfig, source_directory: str): """Checks if all relevant files for the demultiplexing have been synced. If so it creates a CopyComplete.txt file to show that that is the case.""" - target_flow_cells_directory = Path(context.illumina_flow_cells_directory) - for source_flow_cell in Path(source_directory).iterdir(): - target_flow_cell = Path(target_flow_cells_directory, source_flow_cell.name) - if is_flow_cell_sync_confirmed(target_flow_cell): - LOG.debug(f"Flow cell {source_flow_cell} has already been confirmed, skipping.") + target_sequencing_runs_directory = Path(context.illumina_flow_cells_directory) + for source_sequencing_run in Path(source_directory).iterdir(): + target_sequencig_run = Path(target_sequencing_runs_directory, source_sequencing_run.name) + if is_flow_cell_sync_confirmed(target_sequencig_run): + LOG.debug(f"Flow cell {source_sequencing_run} has already been confirmed, skipping.") continue if is_syncing_complete( - source_directory=source_flow_cell, - target_directory=Path(target_flow_cells_directory, source_flow_cell.name), + source_directory=source_sequencing_run, + target_directory=Path(target_sequencing_runs_directory, source_sequencing_run.name), ): Path( - target_flow_cells_directory, - source_flow_cell.name, + target_sequencing_runs_directory, + source_sequencing_run.name, DemultiplexingDirsAndFiles.COPY_COMPLETE, ).touch() @@ -181,7 +183,7 @@ def confirm_flow_cell_sync(context: CGConfig, source_directory: str): help="The path from where the syncing is done.", ) def create_manifest_files(source_directory: str): - """Creates a file manifest for each flow cell in the source directory.""" - for source_flow_cell in glob(f"{source_directory}/*"): - if is_manifest_file_required(Path(source_flow_cell)): - create_manifest_file(Path(source_flow_cell)) + """Creates a file manifest for each sequencing run in the source directory.""" + for source_sequencing_run in glob(f"{source_directory}/*"): + if is_manifest_file_required(Path(source_sequencing_run)): + create_manifest_file(Path(source_sequencing_run)) diff --git a/cg/models/run_devices/illumina_run_directory_data.py b/cg/models/run_devices/illumina_run_directory_data.py index a8aa5b589f..4b695c2037 100644 --- a/cg/models/run_devices/illumina_run_directory_data.py +++ b/cg/models/run_devices/illumina_run_directory_data.py @@ -40,7 +40,7 @@ class IlluminaRunDirectoryData: """Class to collect information about sequencing run directories and their particular files.""" def __init__(self, sequencing_run_path: Path): - LOG.debug(f"Instantiating FlowCellDirectoryData with path {sequencing_run_path}") + LOG.debug(f"Instantiating IlluminaRunDirectoryData with path {sequencing_run_path}") self.path: Path = sequencing_run_path self.machine_name: str = EMPTY_STRING self._run_parameters: RunParameters | None = None diff --git a/tests/apps/demultiplex/test_demultiplex_api.py b/tests/apps/demultiplex/test_demultiplex_api.py index 254780756d..817d29183a 100644 --- a/tests/apps/demultiplex/test_demultiplex_api.py +++ b/tests/apps/demultiplex/test_demultiplex_api.py @@ -70,8 +70,10 @@ def test_create_demultiplexing_output_dir_for_bcl_convert( # GIVEN that the demultiplexing output directory does not exist demultiplexing_api.demultiplexed_runs_dir = tmp_path - output_directory: Path = demultiplexing_api.flow_cell_out_dir_path(tmp_bcl_convert_flow_cell) - unaligned_directory: Path = demultiplexing_api.get_flow_cell_unaligned_dir( + output_directory: Path = demultiplexing_api.demultiplexed_run_dir_path( + tmp_bcl_convert_flow_cell + ) + unaligned_directory: Path = demultiplexing_api.get_sequencing_run_unaligned_dir( tmp_bcl_convert_flow_cell ) assert not output_directory.exists() @@ -99,7 +101,7 @@ def test_is_demultiplexing_possible_true( # WHEN checking if demultiplexing is possible result: bool = demultiplexing_api.is_demultiplexing_possible( - flow_cell=tmp_bcl_convert_flow_cell + sequencing_run=tmp_bcl_convert_flow_cell ) # THEN the flow cell is ready for demultiplexing assert result is True @@ -121,7 +123,8 @@ def test_is_demultiplexing_possible_missing_files( # GIVEN that all other demultiplexing criteria are fulfilled assert ( - demultiplexing_api.is_demultiplexing_possible(flow_cell=tmp_bcl_convert_flow_cell) is True + demultiplexing_api.is_demultiplexing_possible(sequencing_run=tmp_bcl_convert_flow_cell) + is True ) # GIVEN a flow cell with a missing file @@ -129,7 +132,7 @@ def test_is_demultiplexing_possible_missing_files( # WHEN checking if demultiplexing is possible result: bool = demultiplexing_api.is_demultiplexing_possible( - flow_cell=tmp_bcl_convert_flow_cell + sequencing_run=tmp_bcl_convert_flow_cell ) # THEN the flow cell should not be deemed ready for demultiplexing assert result is False @@ -148,7 +151,7 @@ def is_demultiplexing_possible_no_sample_sheet_in_hk( # WHEN checking if demultiplexing is possible result: bool = demultiplexing_api.is_demultiplexing_possible( - flow_cell=tmp_bcl_convert_flow_cell + sequencing_run=tmp_bcl_convert_flow_cell ) # THEN the flow cell should not be deemed ready for demultiplexing assert result is False @@ -167,7 +170,8 @@ def test_is_demultiplexing_possible_already_started( ) # GIVEN that all other demultiplexing criteria are fulfilled assert ( - demultiplexing_api.is_demultiplexing_possible(flow_cell=tmp_bcl_convert_flow_cell) is True + demultiplexing_api.is_demultiplexing_possible(sequencing_run=tmp_bcl_convert_flow_cell) + is True ) # GIVEN a flow cell where demultiplexing has already started @@ -175,7 +179,7 @@ def test_is_demultiplexing_possible_already_started( # WHEN checking if demultiplexing is possible result: bool = demultiplexing_api.is_demultiplexing_possible( - flow_cell=tmp_bcl_convert_flow_cell + sequencing_run=tmp_bcl_convert_flow_cell ) # THEN the flow cell should not be deemed ready for demultiplexing assert result is False @@ -190,13 +194,15 @@ def test_remove_demultiplexing_output_directory( # GIVEN a flow cell with a demultiplexing output directory demultiplexing_api.demultiplexed_runs_dir = tmp_path demultiplexing_api.create_demultiplexing_output_dir(novaseq_6000_post_1_5_kits_flow_cell) - assert demultiplexing_api.flow_cell_out_dir_path(novaseq_6000_post_1_5_kits_flow_cell).exists() + assert demultiplexing_api.demultiplexed_run_dir_path( + novaseq_6000_post_1_5_kits_flow_cell + ).exists() # WHEN removing the demultiplexing output directory demultiplexing_api.remove_demultiplexing_output_directory( - flow_cell=novaseq_6000_post_1_5_kits_flow_cell + sequencing_run=novaseq_6000_post_1_5_kits_flow_cell ) - assert not demultiplexing_api.flow_cell_out_dir_path( + assert not demultiplexing_api.demultiplexed_run_dir_path( novaseq_6000_post_1_5_kits_flow_cell ).exists() diff --git a/tests/cli/demultiplex/test_demultiplex_flowcell.py b/tests/cli/demultiplex/test_demultiplex_flowcell.py index 29f9fed5c2..9b27436d93 100644 --- a/tests/cli/demultiplex/test_demultiplex_flowcell.py +++ b/tests/cli/demultiplex/test_demultiplex_flowcell.py @@ -35,8 +35,8 @@ def test_demultiplex_dragen_flowcell( # GIVEN a flow cell that is ready for demultiplexing demux_api: DemultiplexingAPI = demultiplexing_context_for_demux.demultiplex_api - demux_dir: Path = demux_api.flow_cell_out_dir_path(flow_cell) - assert demux_api.is_demultiplexing_possible(flow_cell=flow_cell) + demux_dir: Path = demux_api.demultiplexed_run_dir_path(flow_cell) + assert demux_api.is_demultiplexing_possible(sequencing_run=flow_cell) mocker.patch("cg.apps.tb.TrailblazerAPI.add_pending_analysis") # GIVEN an already existing output directory @@ -76,7 +76,7 @@ def test_demultiplex_all_novaseq( # GIVEN a demultiplexing context with an API and correct structure demux_api: DemultiplexingAPI = demultiplexing_context_for_demux.demultiplex_api - assert demux_api.flow_cells_dir == tmp_illumina_flow_cells_demux_all_directory + assert demux_api.sequencing_runs_dir == tmp_illumina_flow_cells_demux_all_directory # GIVEN sequenced flow cells with their sample sheet in Housekeeper for flow_cell_dir in tmp_illumina_flow_cells_demux_all_directory.iterdir(): @@ -93,7 +93,7 @@ def test_demultiplex_all_novaseq( # WHEN running the demultiplex all command result: testing.Result = cli_runner.invoke( demultiplex_all, - ["--flow-cells-directory", str(demux_api.flow_cells_dir), "--dry-run"], + ["--flow-cells-directory", str(demux_api.sequencing_runs_dir), "--dry-run"], obj=demultiplexing_context_for_demux, ) diff --git a/tests/meta/demultiplex/test_housekeeper_storage_functions.py b/tests/meta/demultiplex/test_housekeeper_storage_functions.py index a1e011d46d..046146bf07 100644 --- a/tests/meta/demultiplex/test_housekeeper_storage_functions.py +++ b/tests/meta/demultiplex/test_housekeeper_storage_functions.py @@ -229,7 +229,7 @@ def test_add_run_parameters_to_housekeeper( # WHEN adding the run parameters file to housekeeper add_run_parameters_file_to_housekeeper( flow_cell_name=novaseq_x_flow_cell.full_name, - flow_cell_run_dir=demultiplex_context.demultiplex_api.flow_cells_dir, + flow_cell_run_dir=demultiplex_context.demultiplex_api.sequencing_runs_dir, hk_api=hk_api, )