diff --git a/binette/bin_quality.py b/binette/bin_quality.py index 154660d..e84f8ab 100644 --- a/binette/bin_quality.py +++ b/binette/bin_quality.py @@ -242,7 +242,7 @@ def assess_bins_quality_by_chunk( for i, chunk_bins_iter in enumerate(chunks(bins, chunk_size)): chunk_bins = set(chunk_bins_iter) - logging.debug(f"chunk {i}: assessing quality of {len(chunk_bins)}") + logging.debug(f"chunk {i}: assessing quality of {len(chunk_bins)} bins") assess_bins_quality( bins=chunk_bins, contig_to_kegg_counter=contig_to_kegg_counter, diff --git a/tests/bin_manager_test.py b/tests/bin_manager_test.py index cac472d..7a036ce 100644 --- a/tests/bin_manager_test.py +++ b/tests/bin_manager_test.py @@ -256,11 +256,11 @@ def test_select_best_bins_with_equality(): # The function should create intersection bins when there are overlapping contigs between bins. def test_intersection_bins_created(): - set1 = [ + set1 = { bin_manager.Bin(contigs={"1", "2"}, origin="A", name="bin1"), bin_manager.Bin(contigs={"3", "4"}, origin="A", name="bin2"), bin_manager.Bin(contigs={"5"}, origin="A", name="bin2"), - ] + } # need to defined completeness and conta # because when too low the bin is not used in all operation for b in set1: @@ -270,14 +270,12 @@ def test_intersection_bins_created(): binA = bin_manager.Bin(contigs={"1", "3"}, origin="B", name="binA") binA.contamination = 0 binA.completeness = 100 - set2 = [ + set2 = { binA, - ] - bin_set_name_to_bins = {"set1": set1, "set2": set2} + } + input_bins = set1 | set2 - intermediate_bins_result = bin_manager.create_intermediate_bins( - bin_set_name_to_bins - ) + intermediate_bins_result = bin_manager.create_intermediate_bins(input_bins) expected_intermediate_bins = { bin_manager.Bin(contigs={"1", "2", "3"}, origin="bin1 | binA ", name="NA"), @@ -337,19 +335,19 @@ def test_dereplicate_bin_sets(): assert derep_bins_result == {b1, b2, b3} -def test_from_bin_sets_to_bin_graph(): +def test_from_bins_to_bin_graph(): bin1 = bin_manager.Bin(contigs={"1", "2"}, origin="A", name="bin1") bin2 = bin_manager.Bin(contigs={"3", "4"}, origin="A", name="bin2") bin3 = bin_manager.Bin(contigs={"5"}, origin="A", name="bin3") - set1 = [bin1, bin2, bin3] + set1 = {bin1, bin2, bin3} binA = bin_manager.Bin(contigs={"1", "3"}, origin="B", name="binA") - set2 = [binA] + set2 = {binA} - result_graph = bin_manager.from_bin_sets_to_bin_graph({"B": set2, "A": set1}) + result_graph = bin_manager.from_bins_to_bin_graph(set1 | set2) assert result_graph.number_of_edges() == 2 # bin3 is not connected to any bin so it is not in the graph diff --git a/tests/io_manager_test.py b/tests/io_manager_test.py index 3d857ab..5562140 100644 --- a/tests/io_manager_test.py +++ b/tests/io_manager_test.py @@ -350,17 +350,16 @@ def test_write_original_bin_metrics(mock_write_bin_info, bin1, bin2, tmp_path): temp_directory = tmp_path / "test_output" - mock_bins = {"set1": {bin1}, "set2": {bin2}} # Call the function with mock data - io_manager.write_original_bin_metrics(mock_bins, temp_directory) + io_manager.write_original_bin_metrics({bin1, bin2}, temp_directory) # Check if the output directory was created assert temp_directory.exists(), "Output directory should be created." # Check that the correct files are created expected_files = [ - temp_directory / "input_bins_1.set1.tsv", - temp_directory / "input_bins_2.set2.tsv", + temp_directory / "input_bins_1.origin1.tsv", + temp_directory / "input_bins_2.origin2.tsv", ] assert ( @@ -373,5 +372,5 @@ def test_write_original_bin_metrics(mock_write_bin_info, bin1, bin2, tmp_path): ), "write_bin_info should be called once for each bin set." # Verify the specific calls to `write_bin_info` - mock_write_bin_info.assert_any_call(mock_bins["set1"], expected_files[0]) - mock_write_bin_info.assert_any_call(mock_bins["set2"], expected_files[1]) + mock_write_bin_info.assert_any_call({bin1}, expected_files[0]) + mock_write_bin_info.assert_any_call({bin2}, expected_files[1]) diff --git a/tests/main_binette_test.py b/tests/main_binette_test.py index 8de8238..0b2aba7 100644 --- a/tests/main_binette_test.py +++ b/tests/main_binette_test.py @@ -207,17 +207,15 @@ def test_parse_input_files_with_contig2bin_tables(tmp_path): fasta_file.write_text(fasta_file_content) # Call the function and capture the return values - bin_set_name_to_bins, original_bins, contigs_in_bins, contig_to_length = ( - parse_input_files(None, [bin_set1, bin_set2], fasta_file) + original_bins, contigs_in_bins, contig_to_length = parse_input_files( + None, [bin_set1, bin_set2], fasta_file ) # # Perform assertions on the returned values - assert isinstance(bin_set_name_to_bins, dict) assert isinstance(original_bins, set) assert isinstance(contigs_in_bins, set) assert isinstance(contig_to_length, dict) - assert set(bin_set_name_to_bins) == {"bin_set1", "bin_set2"} assert len(original_bins) == 4 assert contigs_in_bins == {"contig1", "contig2", "contig3", "contig4"} assert len(contig_to_length) == 4 @@ -248,17 +246,15 @@ def test_parse_input_files_bin_dirs(create_temp_bin_directories, tmp_path): fasta_file.write_text(fasta_file_content) # Call the function and capture the return values - bin_set_name_to_bins, original_bins, contigs_in_bins, contig_to_length = ( - parse_input_files(bin_dirs, contig2bin_tables, fasta_file) + original_bins, contigs_in_bins, contig_to_length = parse_input_files( + bin_dirs, contig2bin_tables, fasta_file ) # # Perform assertions on the returned values - assert isinstance(bin_set_name_to_bins, dict) assert isinstance(original_bins, set) assert isinstance(contigs_in_bins, set) assert isinstance(contig_to_length, dict) - assert set(bin_set_name_to_bins) == {"set1", "set2"} assert len(original_bins) == 3 assert contigs_in_bins == { "contig1", @@ -471,7 +467,7 @@ def test_main(monkeypatch, test_environment): ) as mock_select_bins_and_write_them: # Set return values for mocked functions if needed - mock_parse_input_files.return_value = (None, None, None, None) + mock_parse_input_files.return_value = (None, None, None) mock_manage_protein_alignement.return_value = ( {"contig1": 1}, {"contig1": ["gene1"]},