From 733e0fec094b381464807e6e167bf3b91dda3ed8 Mon Sep 17 00:00:00 2001 From: jrobinso <933148+jrobinso@users.noreply.github.com> Date: Mon, 27 Nov 2023 19:38:03 -0800 Subject: [PATCH] Stabilize 3-frame translation rows. Fixes #1420 --- .../org/broad/igv/renderer/SequenceRenderer.java | 15 +++++++++------ .../java/org/broad/igv/track/SequenceTrack.java | 11 ++++------- 2 files changed, 13 insertions(+), 13 deletions(-) diff --git a/src/main/java/org/broad/igv/renderer/SequenceRenderer.java b/src/main/java/org/broad/igv/renderer/SequenceRenderer.java index 6d0b1c3a79..451a6802c2 100644 --- a/src/main/java/org/broad/igv/renderer/SequenceRenderer.java +++ b/src/main/java/org/broad/igv/renderer/SequenceRenderer.java @@ -377,21 +377,24 @@ public void draw(RenderContext context, int start, Rectangle trackRectangle, Seq AminoAcidSequence[] aa = strand == Strand.POSITIVE ? cache.posAA : cache.negAA; //only draw nucleotide lines the last time this is called - drawOneTranslation(context, bandRectangle, 0, shouldDrawLetters, fontSize, - nucleotideLineXPositions, aa[0], strand); + int frame = start % 3; + drawOneTranslation(context, bandRectangle, frame, shouldDrawLetters, fontSize, + nucleotideLineXPositions, aa[frame], strand); //rf 1 + frame = (start + 1) % 3; bandRectangle.y = trackRectangle.y + heightAlreadyUsed; bandRectangle.height = idealHeightPerBand; heightAlreadyUsed += bandRectangle.height; - drawOneTranslation(context, bandRectangle, 1, shouldDrawLetters, fontSize, - nucleotideLineXPositions, aa[1], strand); + drawOneTranslation(context, bandRectangle, frame, shouldDrawLetters, fontSize, + nucleotideLineXPositions, aa[frame], strand); //rf 2 + frame = (start + 2) % 3; bandRectangle.y = trackRectangle.y + heightAlreadyUsed; bandRectangle.height = trackRectangle.height - heightAlreadyUsed; - drawOneTranslation(context, bandRectangle, 2, shouldDrawLetters, fontSize, - nucleotideLineXPositions, aa[2], strand); + drawOneTranslation(context, bandRectangle, frame, shouldDrawLetters, fontSize, + nucleotideLineXPositions, aa[frame], strand); if (shouldDrawNucleotideLines) { Graphics2D graphicsForNucleotideLines = context.getGraphic2DForColor(NUCLEOTIDE_SEPARATOR_COLOR); diff --git a/src/main/java/org/broad/igv/track/SequenceTrack.java b/src/main/java/org/broad/igv/track/SequenceTrack.java index afcfe29bbf..4d11c7d747 100644 --- a/src/main/java/org/broad/igv/track/SequenceTrack.java +++ b/src/main/java/org/broad/igv/track/SequenceTrack.java @@ -222,7 +222,7 @@ public void load(ReferenceFrame referenceFrame) { int start = (int) referenceFrame.getOrigin(); Chromosome chromosome = currentGenome.getChromosome(chr); - if(chromosome == null) { + if (chromosome == null) { return; } @@ -445,8 +445,6 @@ public static class SeqCache { public SeqCache(int start, byte[] seq) { this.start = start; this.seq = seq; - this.posAA = posAA; - this.negAA = negAA; } /** @@ -455,10 +453,9 @@ public SeqCache(int start, byte[] seq) { * @param codonTable */ public void refreshAminoAcids(CodonTable codonTable) { - int mod = start % 3; - int n1 = normalize3(3 - mod); - int n2 = normalize3(n1 + 1); - int n3 = normalize3(n2 + 1); + int n1 = start % 3; + int n2 = (start + 1) % 3; + int n3 = (start + 2) % 3; String sequence = new String(seq); AminoAcidSequence[] posAA = {