From 83bfbe9c95eca2b93da6e7478d7f0650baf645c9 Mon Sep 17 00:00:00 2001 From: Luis Pedro Coelho Date: Wed, 30 Aug 2023 11:11:31 +0200 Subject: [PATCH] MIN Slightly better error message Specify which FASTA file the error occurred in when contig ID already contains the separator character /cc #143 --- ChangeLog | 2 ++ SemiBin/utils.py | 10 ++++++---- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/ChangeLog b/ChangeLog index 90aef57..1311555 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,6 +1,8 @@ Unreleased * SemiBin: Write a log file * concatenate_fasta: support compression + * concatenate_fasta: slightly better error message when contig ID already + contains separator Version 1.5.1 (SemiBin2 beta) Mar 7 2023 by BigDataBiology * Bugfix: using --no-recluster with multi_easy_bin (#128) diff --git a/SemiBin/utils.py b/SemiBin/utils.py index d72a6f2..0ca7167 100644 --- a/SemiBin/utils.py +++ b/SemiBin/utils.py @@ -541,17 +541,19 @@ def get_model_path(env): def concatenate_fasta(fasta_files, min_length, output, separator, output_compression='none'): """ Concatenate multiple FASTA files into one + + Returns name of the concatenated file """ ofname = os.path.join(output, 'concatenated.fa') if output_compression != 'none': ofname += '.' + output_compression with possibly_compressed_write(ofname) as concat_out: - for fasta in fasta_files: - sample_name = os.path.basename(fasta).split('.')[0] - for h, seq in fasta_iter(fasta): + for fname in fasta_files: + sample_name = os.path.basename(fname).split('.')[0] + for h, seq in fasta_iter(fname): if separator in h: sys.stderr.write( - f"Error: the header of the contig '{h}' contains the separator ('{separator}'), please choose another separator.\n") + f"Error in file {fname}: Contig ID '{h}' contains the separator ('{separator}'), please choose another separator.\n") sys.exit(1) if len(seq) >= min_length: header = f'{sample_name}{separator}{h}'