Skip to content

Commit

Permalink
Stabilize 3-frame translation rows. Fixes #1420
Browse files Browse the repository at this point in the history
  • Loading branch information
jrobinso committed Dec 4, 2023
1 parent 7d0c415 commit c84524b
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 13 deletions.
15 changes: 9 additions & 6 deletions src/main/java/org/broad/igv/renderer/SequenceRenderer.java
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
11 changes: 4 additions & 7 deletions src/main/java/org/broad/igv/track/SequenceTrack.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down Expand Up @@ -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;
}

/**
Expand All @@ -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 = {
Expand Down

0 comments on commit c84524b

Please sign in to comment.