def test_bam_to_cram(crunchy_config_dict, sbatch_content, bam_path, mocker): """Test bam_to_cram method""" # GIVEN a crunchy-api, and a bam_path mocker_submit_sbatch = mocker.patch.object(CrunchyAPI, "_submit_sbatch") crunchy_api = CrunchyAPI(crunchy_config_dict) # WHEN calling bam_to_cram method on bam-path crunchy_api.bam_to_cram(bam_path=bam_path, dry_run=False, ntasks=1, mem=2) # THEN _submit_sbatch method is called with expected sbatch-content mocker_submit_sbatch.assert_called_with(sbatch_content=sbatch_content, dry_run=False)
def test_is_bam_compression_possible_cram_done(crunchy_config_dict, crunchy_test_dir, mock_bam_to_cram, mocker): """Test bam_compression_possible for existing compression""" # GIVEN a bam path to a existing file and a crunchy api mocker.patch.object(CrunchyAPI, "bam_to_cram", side_effect=mock_bam_to_cram) crunchy_api = CrunchyAPI(crunchy_config_dict) bam_path = crunchy_test_dir / "file.bam" bam_path.touch() # WHEN calling test_bam_compression_possible when cram_compression is done crunchy_api.bam_to_cram(bam_path=bam_path, dry_run=False, ntasks=1, mem=2) result = crunchy_api.is_bam_compression_possible(bam_path=bam_path) # THEN this should return False assert not result
def test_cram_compression_before_after(crunchy_config_dict, crunchy_test_dir, mock_bam_to_cram, mocker): """Test cram_compression_done without before and after creating files""" # GIVEN a crunchy-api, and a bam_path bam_path = Path(crunchy_test_dir / "file.bam") mocker.patch.object(CrunchyAPI, "bam_to_cram", side_effect=mock_bam_to_cram) crunchy_api = CrunchyAPI(crunchy_config_dict) # WHEN calling cram_compression_done on bam_path result = crunchy_api.is_cram_compression_done(bam_path=bam_path) # Cram compression is not done assert not result # GIVEN created cram, crai, and flag paths crunchy_api.bam_to_cram(bam_path=bam_path, dry_run=False, ntasks=1, mem=2) # WHEN calling cram_compression_done on bam_path result = crunchy_api.is_cram_compression_done(bam_path=bam_path) # THEN compression is marked as done assert result