feat: implement feature extractors for issue #82#120
Merged
Conversation
Implement RED acceptance tests for derive metric computation: - extract_cigar_ops: count M/I/D operations for CIGAR complexity - extract_allele_frequency: compute frequency for specific allele - extract_multi_map_fraction: fraction of reads multi-mapping at position Tests cover happy path, edge cases (empty inputs), and error conditions. All 24 tests registered with issue_82 prefix. 18 pass, 6 fail (RED). Failing tests identify correct multi-mapping logic not yet implemented. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
- extract_cigar_ops: counts M/I/D operations from CIGAR strings - extract_allele_frequency: computes allele frequency from count maps - extract_multi_map_fraction: calculates proportion of reads with multiple alignments at a position Fixed extract_multi_map_fraction logic: counts reads that have multiple alignment records overall (indicating multi-mapping), for reads that align to the target position. Returns the fraction of multi-mapping reads among all reads at that position. All 24 feature extractor tests now pass. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Implements the three feature extractors required for issue #82:
extract_cigar_ops(cigar: &str) → usize: Counts M/I/D operations in CIGAR strings (complexity metric)extract_allele_frequency(all_alleles: &HashMap<u8, usize>, allele: u8) → f64: Computes allele frequency from count distributionsextract_multi_map_fraction(position: u32, query_index: &QueryIndex) → f64: Calculates the fraction of reads with multiple alignments at a reference positionImplementation Details
extract_cigar_ops: Filters CIGAR string characters and counts matches (M), insertions (I), and deletions (D).
extract_allele_frequency: Divides allele count by total sum; returns 0.0 for empty maps (graceful handling).
extract_multi_map_fraction:
.len() > 1)Test Results
All 24 feature extractor tests pass:
Closes #82
🤖 Generated with Claude Code