Skip to content

7 - (ui) - Reverse complement annotations for reverse alignments - #8

Merged
Skitionek merged 1 commit into
mainfrom
7-fix-reverse-complement-annotations
Oct 29, 2026
Merged

Skitionek merged 1 commit into
mainfrom
7-fix-reverse-complement-annotations

Conversation

@Skitionek

Copy link
Copy Markdown
Member

What

Annotations are now reverse complemented when the alignment is a reverse one (forward is 0), so they line up with the reference row and the trace. The reference-row numbers for such an alignment are positions on the reverse complement. A warning in the Annotations panel appears when the annotation file's sequence does not contain the aligned reference at refpos.

Why

tracy writes refalign as the reverse complement of the reference, but refpos is the original-strand position of its last column. Annotations were placed from refpos as if it were the first column, so every reverse alignment, including the bundled example, showed them in the wrong place. I checked the bundled example against its GenBank file: the reverse complement of the bases at refpos equals refalign, and the converted first column matches where refalign is found in the reverse complement.

Decision

The annotations are mirrored with getReverseComplementAnnotation from @teselagen/sequence-utils, with end converted to and from inclusive around the call. Without an annotation file the reference length is unknown, so refpos is left in original-strand coordinates in that case.

Not in this PR

  • No before/after screenshots and no browser check of the banner; the new logic is covered by unit tests and the example is checked against its GenBank file as described above.
  • The mismatch check only covers the aligned stretch, not the rest of the annotation sequence.

Fixes #7


Coding and writing assisted with Claude Sonnet 5.5

…ignments

tracy aligns a reverse read against the reverse complement of the
reference, and its refpos is the original-strand position of the last
refalign column. Annotations were drawn on the original strand from
refpos as if it were the first column, so they sat in the wrong place.

For forward = 0 the annotations are now mirrored onto the reverse
complement with sequence-utils and refpos is converted to the position
of the first column. The reference-row numbers are then positions on
the reverse complement.

Because refalign is only the aligned stretch, a mismatch between the
annotation file and the reference cannot otherwise be seen. When the
file carries a sequence, the aligned bases are looked up in it at refpos
and a warning is shown in the annotation panel if they are not found.

Coding and writing assisted with Claude Sonnet 5.5

Prompts (edited for grammar, private details removed):
- 2026-10-29: "Implement issue 7: reverse complement the annotations if forward = 0."
- 2026-10-29: "Use the reverse complement utility from the libraries if there is one."
- 2026-10-29: "Add a runtime check that the GenBank reference sequence matches the aligned one, otherwise show a warning in the UI."
@Skitionek
Skitionek marked this pull request as ready for review October 29, 2026 15:26
@Skitionek Skitionek self-assigned this Oct 29, 2026
@Skitionek
Skitionek merged commit bd7b92f into main Oct 29, 2026
1 check passed
@Skitionek
Skitionek deleted the 7-fix-reverse-complement-annotations branch October 29, 2026 15:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Annotation of alignments from reverse-complemented reference sequences are incorrect

1 participant