diff --git a/src/main/java/org/broad/igv/sam/AlignmentRenderer.java b/src/main/java/org/broad/igv/sam/AlignmentRenderer.java index 3e709e860..b93184bd8 100644 --- a/src/main/java/org/broad/igv/sam/AlignmentRenderer.java +++ b/src/main/java/org/broad/igv/sam/AlignmentRenderer.java @@ -1083,104 +1083,6 @@ private void drawLargeIndelLabel(Graphics2D g, boolean isInsertion, String label } } - public void renderExpandedInsertion(InsertionMarker i, - List alignments, - RenderContext context, - Rectangle rect, - boolean leaveMargin) { - double origin = context.getOrigin(); - double locScale = context.getScale(); - if ((alignments != null) && (alignments.size() > 0)) { - - Graphics2D g = context.getGraphics2D("INSERTIONS"); - double dX = 1 / context.getScale(); - int fontSize = (int) Math.min(dX, 12); - if (fontSize >= 8) { - Font f = FontManager.getFont(Font.BOLD, fontSize); - g.setFont(f); - } - - for (Alignment alignment : alignments) { - if (alignment.getEnd() < i.position) continue; - if (alignment.getStart() > i.position) break; - AlignmentBlock insertion = alignment.getInsertionAt(i.position); - if (insertion != null) { - - // Compute the start and dend of the alignment in pixels - double pixelStart = (insertion.getStart() - origin) / locScale; - double pixelEnd = (insertion.getEnd() - origin) / locScale; - int x = (int) pixelStart; - - // If any any part of the feature fits in the track rectangle draw it - if (pixelEnd < rect.x || pixelStart > rect.getMaxX()) { - continue; - } - - int bpWidth = insertion.getBasesLength(); - double pxWidthExact = ((double) bpWidth) / locScale; - int h = (int) Math.max(1, rect.getHeight() - 2); - int y = (int) (rect.getY() + (rect.getHeight() - h) / 2) - 1; - - if (!insertion.hasBases()) { - g.setColor(purple); - g.fillRect(x, y, (int) pxWidthExact, h); - - } else { - drawExpandedInsertionBases(x, context, rect, insertion, leaveMargin); - } - } - } - } - } - - - private void drawExpandedInsertionBases(int pixelPosition, - RenderContext context, - Rectangle rect, - AlignmentBlock block, - boolean leaveMargin) { - Graphics2D g = context.getGraphics2D("INSERTIONS"); - ByteSubarray bases = block.getBases(); - int padding = block.getPadding(); - - double locScale = context.getScale(); - double origin = context.getOrigin(); - - // Compute bounds - int pY = (int) rect.getY(); - int dY = (int) rect.getHeight(); - int dX = (int) Math.max(1, (1.0 / locScale)); - - final int size = bases.length + padding; - for (int p = 0; p < size; p++) { - - char c = p < padding ? '-' : (char) bases.getByte(p - padding); - - Color color = SequenceRenderer.nucleotideColors.get(c); - if (color == null) { - color = Color.black; - } - - // If there is room for text draw the character, otherwise - // just draw a rectangle to represent the - int pX = (int) (pixelPosition + (p / locScale)); - - // Don't draw out of clipping rect - if (pX > rect.getMaxX()) { - break; - } else if (pX + dX < rect.getX()) { - continue; - } - BaseRenderer.drawBase(g, color, c, pX, pY, dX, dY - (leaveMargin ? 2 : 0), false, null); - } - - int leftX = pixelPosition + context.translateX; - int rightX = leftX + rect.width; - block.setPixelRange(leftX, rightX); - - } - - private Color getAlignmentColor(Alignment alignment, AlignmentTrack track) { // Set color used to draw the feature. Highlight features that intersect the diff --git a/src/main/java/org/broad/igv/sam/BaseRenderer.java b/src/main/java/org/broad/igv/sam/BaseRenderer.java index 8e8d29aad..a2b024431 100644 --- a/src/main/java/org/broad/igv/sam/BaseRenderer.java +++ b/src/main/java/org/broad/igv/sam/BaseRenderer.java @@ -88,7 +88,7 @@ public static void drawExpandedInsertions(InsertionMarker insertionMarker, if (alignment.getStart() > insertionMarker.position) break; AlignmentBlock insertion = alignment.getInsertionAt(insertionMarker.position); - if (insertion != null && insertion.hasBases()) { + if (insertion != null && insertion.getBasesLength() > 0) { double origin = context.getOrigin(); double locScale = context.getScale(); @@ -104,8 +104,7 @@ public static void drawExpandedInsertions(InsertionMarker insertionMarker, ByteSubarray bases = insertion.getBases(); int padding = insertion.getPadding(); - - final int size = bases.length + padding; + final int size = insertion.getBasesLength() + padding; for (int p = 0; p < size; p++) { double pX = (pixelStart + (p / locScale)); @@ -114,8 +113,10 @@ public static void drawExpandedInsertions(InsertionMarker insertionMarker, if (pX > rect.getMaxX()) break; else if (pX + dX < rect.getX()) continue; - char c = p < padding ? '-' : (char) bases.getByte(p - padding); - + // idx can be out of range due to (1) padding, (2) no read sequence (sequence == *) + int idx = p - padding; + char c = idx >= 0 && idx < bases.length ? (char) bases.getByte(p - padding) : + padding > 0 ? '-' : '*'; Color color = null; // TODO -- support bisulfite mode? Probably not possible as that depends on the reference diff --git a/src/main/java/org/broad/igv/sam/InsertionManager.java b/src/main/java/org/broad/igv/sam/InsertionManager.java index be9692035..098f9efdc 100644 --- a/src/main/java/org/broad/igv/sam/InsertionManager.java +++ b/src/main/java/org/broad/igv/sam/InsertionManager.java @@ -69,7 +69,6 @@ public void clear() { public List getInsertions(String chrName, double start, double end) { - Map insertionMap = insertionMaps.get(chrName); if(insertionMap == null ) return null; @@ -81,11 +80,6 @@ public void setSelected(InsertionMarker insertionMarker) { this.selectedInsertion = insertionMarker; } - public InsertionMarker getSelectedInsertion(String chrName) { - return this.selectedInsertion; - } - - public synchronized void processAlignments(String chr, List alignments) { Genome genome = GenomeManager.getInstance().getCurrentGenome(); @@ -107,7 +101,7 @@ public synchronized void processAlignments(String chr, List alignment AlignmentBlock[] blocks = a.getInsertions(); if (blocks != null) { for (AlignmentBlock block : blocks) { - if (block.getBases() == null || block.getBases().length < minLength) continue; + if (block.getBasesLength() < minLength) continue; Integer key = block.getStart(); InsertionMarker insertionMarker = insertionMap.get(key); if (insertionMarker == null) { diff --git a/src/main/java/org/broad/igv/ui/panel/ReferenceFrame.java b/src/main/java/org/broad/igv/ui/panel/ReferenceFrame.java index 3941c8660..8e315fdd9 100644 --- a/src/main/java/org/broad/igv/ui/panel/ReferenceFrame.java +++ b/src/main/java/org/broad/igv/ui/panel/ReferenceFrame.java @@ -762,11 +762,7 @@ private static int getChromosomeLength(String chrName) { } public void setExpandedInsertion(InsertionMarker im) { - InsertionMarker previousInsertion = this.expandedInsertion; this.expandedInsertion = im; - if (im == null && previousInsertion != null) { - this.centerOnLocation(previousInsertion.position); - } } public InsertionMarker getExpandedInsertion() { diff --git a/src/main/java/org/broad/igv/ui/panel/RulerPanel.java b/src/main/java/org/broad/igv/ui/panel/RulerPanel.java index 5dcd82692..19a2a42e8 100644 --- a/src/main/java/org/broad/igv/ui/panel/RulerPanel.java +++ b/src/main/java/org/broad/igv/ui/panel/RulerPanel.java @@ -501,18 +501,11 @@ public void doMouseClick(MouseEvent evt) { setCursor(Cursor.getDefaultCursor()); WaitCursorManager.CursorToken token = WaitCursorManager.showWaitCursor(); try { - boolean clickHandled = false; for (final ClickLink link : clickLinks) { if (link.region.contains(e.getPoint())) { link.action.accept(link.value); - clickHandled = true; } } - if (!clickHandled && !isWholeGenomeView()) { - double newLocation = frame.getChromosomePosition(e); - frame.centerOnLocation(newLocation); - } - } finally { WaitCursorManager.removeWaitCursor(token); }