Skip to content

Commit

Permalink
MIN Slightly better error message
Browse files Browse the repository at this point in the history
Specify which FASTA file the error occurred in when contig ID already
contains the separator character

/cc #143
  • Loading branch information
luispedro committed Aug 30, 2023
1 parent e6e8918 commit 83bfbe9
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
2 changes: 2 additions & 0 deletions ChangeLog
Original file line number Diff line number Diff line change
@@ -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)
Expand Down
10 changes: 6 additions & 4 deletions SemiBin/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -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}'
Expand Down

0 comments on commit 83bfbe9

Please sign in to comment.