Skip to content

chunking: edge guard hardcodes 5 bases instead of using kmer_context #151

Description

@jayhesselberth

Found during the generalization audit (#125). Not tRNA-specific, but the same class of baked-in default.

Problem

The chunk edge guard hardcodes 5 bases rather than using the configured kmer_context:

  • src/leech/chunking/extractor.py:350base_idx = int(np.clip(base_idx, 5, leech_read.num_bases - 6))
  • src/leech/chunking/extractor.py:360focus_bases = list(range(5, leech_read.num_bases - 5))
  • src/leech/preparation/parallel.py:142-144return list(range(5, max(5, num_bases - 5)))

5 is DEFAULT_KMER_CONTEXT, but ChunkConfig.kmer_context is configurable. A run with kmer_context=10 still guards only 5 bases, so edge chunks get N-padded k-mers; a run with kmer_context=2 needlessly discards usable focus bases.

Same pattern, lower stakes

  • src/leech/chunking/serialization.py:80-81chunk.get("feature_start", -5)
  • src/leech/preparation/parallel.py:275-276config.chunk.feature_start or -5

The second one has an additional bug: or treats a legitimate feature_start=0 as falsy and silently substitutes -5. Should be an explicit is None check.

Suggested fix

Use chunk_config.kmer_context at all three guard sites (np.clip(base_idx, k, num_bases - k - 1), range(k, num_bases - k)), thread it into _find_motif_positions, and derive the feature_start/feature_end fallbacks from it as well.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions