Partial implementation of allowing TSMs to start and end outside of the focus region#191
Merged
sebschmi merged 18 commits intoJun 5, 2026
Conversation
These are found based on the alignment information present in the input sequences. The additional starts and ends assume that all skipped characters are gap markers of a given alignment. Each position in this alignment is then an additional start or end of a TSM if it is outside of the specified alignment range.
We decided against alternative starts for now, so we disabled that feature but left existing work in place.
Contributor
There was a problem hiding this comment.
Pull request overview
This PR introduces an (explicitly partial) implementation path toward allowing template-switch alignments (TSMs) to start and/or end outside the configured focus AlignmentRange, primarily to support inputs that are already gapped (e.g., derived from an existing alignment).
Changes:
- Adds a new
Ts14OutOfRangeStrategyplus plumbing to compute and pass “additional explicit” TSM start/end coordinates derived from the original (gapped) sequences. - Introduces new internal alignment node/edge kinds (
Root,AlternativeStart, and indexedPrimaryReentry) to support multiple possible alignment starts/ends. - Extends the configurable aligner + Python bindings to accept
gap_charactersso callers can treat sequences as gapped alignments while keeping range coordinates on ungapped sequences.
Reviewed changes
Copilot reviewed 29 out of 29 changed files in this pull request and generated 5 comments.
Show a summary per file
| File | Description |
|---|---|
| tsalign/src/align/template_switch_distance_type_selectors.rs | Threads AdditionalExplicitTSMStartsAndEnds through the CLI strategy-selection pipeline and switches primary range pruning strategy. |
| tsalign/src/align.rs | Adds --allow-ts-14-out-of-range flag and computes AdditionalExplicitTSMStartsAndEnds from original sequences + skip characters. |
| test_files/config/bench/config.tsa | Updates benchmark configuration numeric parameters (offset/cost tables). |
| test_files/chr15_52720987_52721016.sh | Adds a repro script invoking --allow-ts-14-out-of-range. |
| test_files/chr15_52720987_52721016.fa | Adds a repro FASTA input pair for the new behavior. |
| test_files/chr11_39595337_39595347.sh | Adds another repro script (including a --no-ts run) invoking --allow-ts-14-out-of-range. |
| test_files/chr11_39595337_39595347.fa | Adds another repro FASTA input pair. |
| python_bindings/src/lib.rs | Adds gap_characters argument to Python Aligner.align() and forwards it to the Rust aligner. |
| lib_tsshow/src/ts_arrangement/source.rs | Updates pattern matches for the new/changed alignment types. |
| lib_tsshow/src/plain_text/mutlipair_alignment_renderer.rs | Updates rendering validation to account for new/changed alignment types. |
| lib_tsalign/src/tests.rs | Updates tests to pass new args/dynamic strategies and adjusts expected costs. |
| lib_tsalign/src/a_star_aligner/template_switch_distance/strategies/allow_ts_14_out_of_range.rs | New strategy helper to compute explicit TSM start/end coordinates outside the focus range. |
| lib_tsalign/src/a_star_aligner/template_switch_distance/strategies.rs | Exposes the new allow_ts_14_out_of_range module. |
| lib_tsalign/src/a_star_aligner/template_switch_distance/lower_bounds/template_switch.rs | Updates lower bound construction for new context args and new identifiers. |
| lib_tsalign/src/a_star_aligner/template_switch_distance/lower_bounds/template_switch_alignment.rs | Same as above for alignment lower bound logic. |
| lib_tsalign/src/a_star_aligner/template_switch_distance/identifier.rs | Adds Root + AlternativeStart identifiers and a constructor helper. |
| lib_tsalign/src/a_star_aligner/template_switch_distance/display.rs | Updates Display for new alignment/identifier variants. |
| lib_tsalign/src/a_star_aligner/template_switch_distance/context.rs | Adds dynamic strategy + explicit start/end data to context; adds successor generation and updated target detection. |
| lib_tsalign/src/a_star_aligner/template_switch_distance/alignment_type.rs | Adds AlternativeStart and indexed PrimaryReentry, plus trait hooks for alternative start/end coordinates. |
| lib_tsalign/src/a_star_aligner/template_switch_distance.rs | Threads the new PrimaryReentry { reference_index, query_index } into successor construction. |
| lib_tsalign/src/a_star_aligner/gap_affine_edit_distance.rs | Implements new IAlignmentType hooks (alternative_start/end) as no-ops for non-TS alignment. |
| lib_tsalign/src/a_star_aligner/configurable_a_star_align.rs | Adds gap_characters filtering + ts_14_out_of_range plumbing and computes explicit starts/ends when enabled. |
| lib_tsalign/src/a_star_aligner/alignment_result/alignment/template_switch_specifics.rs | Accounts for new internal alignment types when computing alignment costs. |
| lib_tsalign/src/a_star_aligner/alignment_result/alignment/stream.rs | Accounts for new internal alignment types in stream coordinate logic. |
| lib_tsalign/src/a_star_aligner/alignment_result.rs | Extends IAlignmentType and stores alignment limits in statistics; adds alignment_range() accessor. |
| lib_tsalign/src/a_star_aligner/alignment_geometry.rs | Adds AlignmentRange::new(...) plus convenience setters and coordinate accessors. |
| lib_tsalign/src/a_star_aligner.rs | Tries to adjust reported alignment range based on alternative start/end markers. |
| lib_ts_chainalign/src/chain_align.rs | Updates alignment result construction to pass an AlignmentRange instead of separate offsets. |
| Cargo.toml | Tweaks workspace dev/release debug profile settings. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.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.
No description provided.