Skip to content

Commit 2c06564

Browse files
committed
MIN Better error checking
Check early or you get a very difficult to read error message later
1 parent 255b969 commit 2c06564

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

SemiBin/main.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1265,6 +1265,16 @@ def main():
12651265
binned_length = 1000 if binned_short else 2500
12661266
else:
12671267
binned_length = args.min_len
1268+
if not contig_dict:
1269+
logger.error(f'Input file {args.contig_fasta} is empty. Please check inputs.')
1270+
sys.exit(1)
1271+
n_pass = sum(len(c) >= binned_length for c in contig_dict.values())
1272+
if n_pass == 0:
1273+
logger.error(f'Input file {args.contig_fasta} contains {len(contigs_dict)} contigs, but all are shorter than {binned_length} basepairs.')
1274+
sys.exit(1)
1275+
elif n_pass < 4:
1276+
logger.error(f'There are {len(contig_dict)} contigs in input file {args.contig_fasta}, but only {n_pass} contain(s) at least {binned_length} basepairs.')
1277+
sys.exit(1)
12681278

12691279
if args.cmd in ['generate_cannot_links', 'generate_sequence_features_single', 'generate_sequence_features_multi', 'single_easy_bin', 'multi_easy_bin']:
12701280
if args.ml_threshold is not None:

0 commit comments

Comments
 (0)