Skip to content

Commit a1477b8

Browse files
joshfactorialclaude
andcommitted
Fix infinite loop when contig is shorter than read_len
When read_len exceeds a contig's length, cover_dataset enters an infinite loop because no fragment ever satisfies the length check on line 78, so read_count never increments. Add an early-return guard in generate_reads that skips the contig with a WARNING log instead of hanging. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
1 parent 2d28f67 commit a1477b8

1 file changed

Lines changed: 7 additions & 0 deletions

File tree

neat/read_simulator/utils/generate_reads.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -183,6 +183,13 @@ def generate_reads(
183183
# _LOG.info(f'Sampling reads for thread {thread_index}...')
184184
start_time = time.time()
185185

186+
if len(reference) < options.read_len:
187+
_LOG.warning(
188+
f"Contig '{contig_name}' (length {len(reference)}) is shorter than read_len "
189+
f"({options.read_len}). Skipping contig."
190+
)
191+
return []
192+
186193
# _LOG.debug("Covering dataset.")
187194
t = time.time()
188195
reads = cover_dataset(

0 commit comments

Comments
 (0)