Skip to content

Commit 6553258

Browse files
committed
Fix tag-walk selected-residue highlight to always mirror
The LinePlot tag walk receives residues already REVERSED to align with the stored mass order, so the tag-relative selectedAA (an N->C index) always maps to the mirrored walk gap. Publish nTerminal=False on the tagMasses walk so the LinePlot mirrors it -- geometrically correct for both N- and C-anchored tags and matching the legacy behavior (whose nTerminal was effectively always false). Driving it off Nmass==-1 misplaced the gold highlight for C-anchored tags. The SequenceView tag-span still carries the real nTerminal (Nmass==-1) for its own orientation.
1 parent ed7a504 commit 6553258

1 file changed

Lines changed: 17 additions & 8 deletions

File tree

content/FLASHTnT/FLASHTnTViewerOI.py

Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -348,7 +348,8 @@ def _clear_all() -> None:
348348
.list.eval(pl.element().cast(pl.Float64, strict=False))
349349
.alias("tag_masses"),
350350
pl.col("TagSequence").alias("tag_sequence"),
351-
# Anchoring + span (legacy TabulatorTagTable.vue:142-173).
351+
# Tag span for the selected-residue (selectedAA) highlight (legacy
352+
# TabulatorTagTable.vue:142-173).
352353
pl.col("StartPos").alias("start_pos"),
353354
pl.col("EndPos").alias("end_pos"),
354355
pl.col("Nmass").alias("n_mass"),
@@ -377,16 +378,19 @@ def _clear_all() -> None:
377378
seq = selected["tag_sequence"][0] or ""
378379
residues = list(reversed(str(seq)))[: max(len(masses) - 1, 0)]
379380

380-
# Terminal anchoring (legacy `nTerminal = (Nmass == -1)`): an N-terminal tag is
381-
# one whose N-mass is the `-1` sentinel. Forwarded into the tag-walk so the
382-
# LinePlot honors the requested direction.
383-
n_mass = selected["n_mass"][0]
384-
n_terminal = (n_mass is not None) and (float(n_mass) == -1.0)
385-
381+
# Selected-residue highlight direction. The residue list above is already
382+
# REVERSED to align with the stored mass order, so a tag-relative `selectedAA`
383+
# (an N->C index) always maps to the MIRRORED walk gap (gaps-1-selectedAA).
384+
# Publish `nTerminal=False` so the LinePlot mirrors it: this is geometrically
385+
# correct for BOTH N- and C-terminal-anchored tags AND matches the legacy
386+
# behavior, whose `nTerminal` was effectively always false (it read a
387+
# non-existent `row["N mass"]` key, so the legacy walk always mirrored). Driving
388+
# the direction off `Nmass == -1` here instead would misplace the gold highlight
389+
# for C-anchored tags relative to the (already reversed) residue letters.
386390
tag_masses = {
387391
"masses": list(masses),
388392
"residues": residues,
389-
"nTerminal": n_terminal,
393+
"nTerminal": False,
390394
}
391395

392396
# Selected-residue gold (#F3A712) highlight (legacy
@@ -411,6 +415,11 @@ def _clear_all() -> None:
411415
# Tag-span highlight on the SequenceView. StartPos/EndPos are protein-absolute
412416
# (matching the full-protein residue grid), so they bracket the tag directly.
413417
if start_pos is not None and end_pos is not None:
418+
# Real terminal anchoring (legacy `selectedTag.nTerminal = (N mass == -1)`)
419+
# for the SequenceView tag-span orientation -- distinct from the LinePlot
420+
# walk above, which always mirrors because its residues are pre-reversed.
421+
n_mass = selected["n_mass"][0]
422+
n_terminal = (n_mass is not None) and (float(n_mass) == -1.0)
414423
state_manager.set_selection(
415424
TAG_SPAN_KEY,
416425
{"start": int(start_pos), "end": int(end_pos), "nTerminal": n_terminal},

0 commit comments

Comments
 (0)