Skip to content
Merged

Dev #1831

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,11 @@ plugins {
repositories {
mavenCentral()
mavenLocal()
maven {
name = "sonatypeSnapshots"
url = uri("https://central.sonatype.com/repository/maven-snapshots/")
mavenContent { snapshotsOnly() }
}
}

import org.apache.tools.ant.filters.ReplaceTokens
Expand Down Expand Up @@ -95,7 +100,7 @@ dependencies {
[group: 'org.apache.commons', name: 'commons-compress', version: '1.26.0'],
[group: 'org.apache.commons', name: 'commons-jexl', version: '2.1.1'],
[group: 'org.apache.commons', name: 'commons-lang3', version: '3.18.0'],
[group: 'com.github.samtools', name: 'htsjdk', version: '4.3.0'],
[group: 'com.github.samtools', name: 'htsjdk', version: '5.0.0'],
[group: 'org.swinglabs', name: 'swing-layout', version: '1.0.3'],
[group: 'com.formdev', name: 'jide-oss', version: '3.7.12'],
[group: 'com.google.guava', name: 'guava', version: '32.1.3-jre'],
Expand Down
31 changes: 29 additions & 2 deletions src/main/java/org/igv/batch/CommandExecutor.java
Original file line number Diff line number Diff line change
Expand Up @@ -200,14 +200,16 @@ public String execute(String commandLine) throws IOException {
HttpUtils.getInstance().clearAccessTokens();
} else if (cmd.equalsIgnoreCase("sortByAttribute")) {
result = sortByAttribute(args);
} else if (cmd.equalsIgnoreCase("fitTracks")) {
igv.fitTracksToPanel();
} else if (cmd.equalsIgnoreCase("fitTracks") || cmd.equals("minimizeTrackHeights")) {
igv.minimizeTrackHeights();
} else if (cmd.equalsIgnoreCase("showAttributes")) {
result = this.showAttributes(args);
} else if (cmd.equalsIgnoreCase("showDataRange")) {
result = this.setShowDataRange(param1, param2);
} else if (cmd.equalsIgnoreCase("setTrackHeight")) {
result = this.setTrackHeight(param1, param2);
} else if (cmd.equalsIgnoreCase("setRowHeight")) {
result = this.setRowHeight(param1, param2);
} else if (cmd.equalsIgnoreCase("overlay")) {
result = this.overlay(args);
} else if (cmd.equalsIgnoreCase("separate")) {
Expand Down Expand Up @@ -539,6 +541,31 @@ private String setTrackHeight(String param1, String param2) {
}
}

private String setRowHeight(String param1, String param2) {

int height;
String trackName;
try {
height = Integer.parseInt(param1);
trackName = parseTrackName(param2);
} catch (NumberFormatException e) {
height = Integer.parseInt(param2);
trackName = parseTrackName(param1);
}

height = Math.max(0, height);
List<Track> tracks = tracksMatchingName(trackName);
if (tracks.size() > 0) {
for (Track track : tracks) {
track.setRowHeight(height);
}
igv.repaint();
return "OK";
} else {
return String.format("Error: Track %s not found", trackName);
}
}

private String setShowDataRange(String show, String trackName) {

boolean showDataRange;
Expand Down
7 changes: 7 additions & 0 deletions src/main/java/org/igv/event/TrackSelectionEvent.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package org.igv.event;

/**
* Posted when a track's selection checkbox is toggled.
*/
public final class TrackSelectionEvent implements IGVEvent {
}
1 change: 0 additions & 1 deletion src/main/java/org/igv/feature/EmblFeatureTableParser.java
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,6 @@ public List<FeatureTrack> loadTracks(ResourceLocator locator, Genome genome) {
} else {
FeatureTrack track = new FeatureTrack(locator, new FeatureCollectionSource(features, genome));
track.setName(locator.getTrackName());
track.setMinimumHeight(35);
track.setHeight(45);
track.setRenderer(new GeneTrackRenderer());

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,6 @@ private static FeatureTrack createGeneTrack(Genome genome, BufferedReader reader

String id = genome.getId() + "_genes";
geneFeatureTrack = new FeatureTrack(id, name, new FeatureCollectionSource(genes, genome));
geneFeatureTrack.setMinimumHeight(5);
geneFeatureTrack.setHeight(35);
geneFeatureTrack.setDataType(DataType.GENE);
TrackProperties props = parser.getTrackProperties();
if (props != null) {
Expand Down
6 changes: 3 additions & 3 deletions src/main/java/org/igv/feature/genome/load/GenomeLoader.java
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,9 @@ public static GenomeLoader getLoader(String genomePath) throws IOException {


/**
* Create an annotation track for the genome from a supplied list of features
* Create an annotation track for the genome from a supplied list of features.
*
* This is used by the ".genome" and genbank loaders, which include annotations within the genome file.
*
* @param genome
* @param features
Expand All @@ -81,8 +83,6 @@ public static FeatureTrack createGeneTrack(Genome genome, List<htsjdk.tribble.Fe

String id = genome.getId() + "_genes";
geneFeatureTrack = new FeatureTrack(id, name, new FeatureCollectionSource(features, genome));
geneFeatureTrack.setMinimumHeight(5);
geneFeatureTrack.setHeight(35);

return geneFeatureTrack;
}
Expand Down
1 change: 1 addition & 0 deletions src/main/java/org/igv/prefs/Constants.java
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ private Constants() {
public static final String CHART_SHOW_ALL_HEATMAP = "CHART.SHOW_ALL_HEATMAP";
public static final String SHOW_REGION_BARS = "SHOW_REGION_BARS";
public static final String DEFAULT_VISIBILITY_WINDOW = "DEFAULT_VISIBILITY_WINDOW";
public static final String FIT_TO_VIEWPORT_MAX_ROWS = "FIT_TO_VIEWPORT_MAX_ROWS";
public static final String EXPAND_FEAUTRE_TRACKS = "EXPAND_FEATURE_TRACKS";
public static final String IGV_PLUGIN_LIST_KEY = "IGV_PLUGIN_LIST";
public static final String SASHIMI_SHOW_COVERAGE = "SASHIMI.SHOW_COVERAGE";
Expand Down
6 changes: 5 additions & 1 deletion src/main/java/org/igv/renderer/DataRenderer.java
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,11 @@ public abstract class DataRenderer implements Renderer<LocusScore> {
protected static final int AXIS_AREA_WIDTH = 60;
protected static Color axisLineColor = new Color(255, 180, 180);


public int getMinimumHeight() {
return 20;
}

/**
* Render the track in the given rectangle.
*
Expand All @@ -54,7 +59,6 @@ public void render(List<LocusScore> scores, RenderContext context, Rectangle rec
}
}
renderGuides(track, context, rect);

}

/**
Expand Down
5 changes: 3 additions & 2 deletions src/main/java/org/igv/renderer/HeatmapRenderer.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,9 @@ public class HeatmapRenderer extends DataRenderer {

private static Logger log = LogManager.getLogger(HeatmapRenderer.class);

public String getDisplayName() {
return "Heatmap";
@Override
public int getMinimumHeight() {
return 1;
}

/**
Expand Down
63 changes: 27 additions & 36 deletions src/main/java/org/igv/renderer/IGVFeatureRenderer.java
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,10 @@ public class IGVFeatureRenderer extends FeatureRenderer {
static protected final int REGION_STRAND_THICKNESS = 4;
static final int BLOCK_HEIGHT = 14;
static final int THIN_BLOCK_HEIGHT = 6;
static final int NON_CODING_HEIGHT = 8;
protected Color AA_COLOR_1 = new Color(92, 92, 164);
protected Color AA_COLOR_2 = new Color(12, 12, 120);
static final int NON_CODING_HEIGHT = 8;


private static final Color VARIANT_HET_COLOR = Color.blue.brighter();
private static final Color VARIANT_HOM_COLOR = new Color(0, 245, 255);
Expand All @@ -49,13 +50,9 @@ public class IGVFeatureRenderer extends FeatureRenderer {
//protected double lastRegionMaxY = 0;


int blockHeight = BLOCK_HEIGHT;
int thinBlockHeight = THIN_BLOCK_HEIGHT;

//Map from Exon to y offset
//Could use more coordinates, but they are all contained in the Exon
private Map<IExon, Integer> exonMap = new HashMap<IExon, Integer>(100);
private Set<String> drawnNames = new HashSet<String>(100);
transient int blockHeight ;
transient int thinBlockHeight;
transient int nonCodingHeight ;

protected boolean isGenotypeRenderer = false;

Expand Down Expand Up @@ -85,9 +82,10 @@ public void render(List<IGVFeature> featureList,
double locScale = context.getScale();
double end = origin + trackRectangle.getWidth() * locScale;

final Track.DisplayMode displayMode = track.getDisplayMode();
blockHeight = displayMode == Track.DisplayMode.SQUISHED ? BLOCK_HEIGHT / 2 : BLOCK_HEIGHT;
thinBlockHeight = displayMode == Track.DisplayMode.SQUISHED ? THIN_BLOCK_HEIGHT / 2 : THIN_BLOCK_HEIGHT;
final int rowHeight = Math.max(1, track.getRowHeight());
blockHeight = Math.min(BLOCK_HEIGHT, rowHeight / 2);
thinBlockHeight = Math.min( THIN_BLOCK_HEIGHT, blockHeight / 2);
nonCodingHeight = Math.min(thinBlockHeight, NON_CODING_HEIGHT);

if ((featureList != null) && (featureList.size() > 0)) {

Expand Down Expand Up @@ -188,18 +186,18 @@ public void render(List<IGVFeature> featureList,
if ((pixelWidth < 3)) {
drawFeatureBounds(pixelStart, pixelEnd, pixelYCenter, g2D);
} else {
drawExons(feature, pixelYCenter, context, g2D, trackRectangle, displayMode,
drawExons(feature, pixelYCenter, context, g2D, trackRectangle, rowHeight,
alternateExonColor, track.getColor(), track.getAltColor());
}
} else {

// If there is room create a gap between this feature and the next
drawFeatureBlock(pixelStart, pixelEnd, pixelThickStart, pixelThickEnd, pixelYCenter, g2D);

if (displayMode != Track.DisplayMode.SQUISHED) {
if (rowHeight >= 5) {
Graphics2D arrowGraphics = context.getGraphic2DForColor(Color.WHITE);
drawStrandArrows(feature.getStrand(), pixelStart, pixelEnd, pixelYCenter, 0,
displayMode, trackRectangle, arrowGraphics);
rowHeight, trackRectangle, arrowGraphics);
}

// This is ugly, but alternatives are probably worse
Expand All @@ -223,7 +221,7 @@ public void render(List<IGVFeature> featureList,


// Draw name , if there is room
if (displayMode != Track.DisplayMode.SQUISHED && track.isShowFeatureNames()) {
if (rowHeight >= 10 && track.isShowFeatureNames()) {

String name = labelField != null ? feature.getDisplayName(labelField) : feature.getName();

Expand All @@ -247,7 +245,7 @@ public void render(List<IGVFeature> featureList,
// Calculate the minimum amount of vertical track
// space required be we draw the
// track name without drawing over the features
int verticalSpaceRequiredForText = textBaselineY - (int) trackRectangleY;
int verticalSpaceRequiredForText = fontHeight + blockHeight + 5;

if (verticalSpaceRequiredForText <= trackRectangle.height) {
lastNamePixelEnd = drawFeatureName(name, track.getDisplayMode(), nameStart, nameEnd,
Expand Down Expand Up @@ -339,7 +337,7 @@ private void drawFeatureBounds(int pixelStart, int pixelEnd, int yOffset, Graphi
}

protected void drawExons(IGVFeature gene, int yOffset, RenderContext context,
Graphics2D g2D, Rectangle trackRectangle, Track.DisplayMode mode,
Graphics2D g2D, Rectangle trackRectangle, int rowHeight,
boolean alternateExonColor, Color color1, Color color2) {

// Now get the individual regions of the
Expand Down Expand Up @@ -420,7 +418,7 @@ protected void drawExons(IGVFeature gene, int yOffset, RenderContext context,
&& lastExonEndX >= maxLineEndX) {
drawConnectingLine(lastExonEndX, lastY, pStart, curYOffset, exon.getStrand(), blockGraphics);
double angle = Math.atan(-(curYOffset - lastY) / ((pStart - lastExonEndX) + 1e-12));
drawStrandArrows(gene.getStrand(), lastExonEndX, pStart, lastY, angle, mode, trackRectangle, blockGraphics);
drawStrandArrows(gene.getStrand(), lastExonEndX, pStart, lastY, angle, rowHeight, trackRectangle, blockGraphics);
maxLineEndX = Math.max(maxLineEndX, pStart);
}
lastExonEndX = pEnd;
Expand All @@ -444,9 +442,9 @@ protected void drawExons(IGVFeature gene, int yOffset, RenderContext context,
blockGraphics,
exon,
pClippedStart,
curYOffset - NON_CODING_HEIGHT / 2,
curYOffset - nonCodingHeight / 2,
pClippedWidth,
NON_CODING_HEIGHT);
nonCodingHeight);

} else {
// Exon contains 5' UTR -- draw non-coding part
Expand All @@ -458,9 +456,9 @@ protected void drawExons(IGVFeature gene, int yOffset, RenderContext context,
blockGraphics,
exon,
pClippedStart,
curYOffset - NON_CODING_HEIGHT / 2,
curYOffset - nonCodingHeight / 2,
pClippedWidth,
NON_CODING_HEIGHT);
nonCodingHeight);
pStart = pCdStart;
}
// Exon contains 3' UTR -- draw non-coding part
Expand All @@ -472,8 +470,8 @@ protected void drawExons(IGVFeature gene, int yOffset, RenderContext context,
blockGraphics,
exon,
pClippedStart,
curYOffset - NON_CODING_HEIGHT / 2,
pClippedWidth, NON_CODING_HEIGHT);
curYOffset - nonCodingHeight / 2,
pClippedWidth, nonCodingHeight);
pEnd = pCdEnd;
}
// At least part of this exon is coding. Draw the coding part.
Expand All @@ -486,10 +484,10 @@ protected void drawExons(IGVFeature gene, int yOffset, RenderContext context,
}

Graphics2D whiteArrowGraphics = context.getGraphic2DForColor(Color.white);
drawStrandArrows(gene.getStrand(), pStart + ARROW_SPACING / 2, pEnd, curYOffset, 0, mode,
drawStrandArrows(gene.getStrand(), pStart + ARROW_SPACING / 2, pEnd, curYOffset, 0, rowHeight,
trackRectangle, whiteArrowGraphics);

if (locationScale < 0.25) {
if (locationScale < 0.25 && rowHeight > 10) {
labelAminoAcids(pStart, fontGraphics, theOrigin, context, gene, locationScale,
curYOffset, trackRectangle, idx);
}
Expand Down Expand Up @@ -518,15 +516,15 @@ protected void drawExonRect(Graphics blockGraphics, Exon exon, int x, int y, int
* @param endX
* @param startY
* @param angle
* @param mode
* @param rowHeight
* @param g2D
*/
protected void drawStrandArrows(Strand strand,
int startX,
int endX,
int startY,
double angle,
Track.DisplayMode mode,
int rowHeight,
Rectangle trackRectangle,
Graphics2D g2D) {

Expand All @@ -546,7 +544,7 @@ protected void drawStrandArrows(Strand strand,


// Draw the directional arrows on the feature
int sz = mode == Track.DisplayMode.EXPANDED ? 3 : 2;
int sz = rowHeight < 5 ? 2 : 3;
sz = strand.equals(Strand.POSITIVE) ? -sz : sz;
final int asz = Math.abs(sz);

Expand Down Expand Up @@ -594,8 +592,6 @@ final private int drawFeatureName(String name,
// g2D.clearRect(xString2, textBaselineY, (int) stringBounds.getWidth(), (int) stringBounds.getHeight());
g2D.drawString(name, nameStart, textBaselineY);
lastFeatureEndedAtPixelX = nameStart + nameWidth;
drawnNames.add(name);

}

return lastFeatureEndedAtPixelX;
Expand Down Expand Up @@ -695,9 +691,4 @@ protected int getPixelFromChromosomeLocation(String chr, int chromosomeLocation,
return (int) Math.round((chromosomeLocation - origin) / locationScale);
}

@Override
public void reset() {
exonMap.clear();
drawnNames.clear();
}
}
5 changes: 3 additions & 2 deletions src/main/java/org/igv/sam/AlignmentRenderer.java
Original file line number Diff line number Diff line change
Expand Up @@ -306,7 +306,7 @@ public void renderAlignments(List<Alignment> alignments,
// Does the change for Bisulfite kill some machines?
double pixelWidth = pixelEnd - pixelStart;
Color alignmentColor = getAlignmentColor(alignment, track);
final boolean leaveMargin = (this.track.getDisplayMode() != Track.DisplayMode.SQUISHED);
final boolean leaveMargin = (this.track.getRowHeight() > 2);
final ColorOption colorOption = renderOptions.getColorOption();
if ((pixelWidth < 2) &&
!((AlignmentTrack.isBisulfiteColorType(colorOption) ||
Expand Down Expand Up @@ -976,6 +976,7 @@ private void drawAlignment(

/**
* get a texture to apply to duplicate reads, caches the created textures according to their color
*
* @param baseColor the color to render the read
* @return a texture matching the base color with shading
*/
Expand Down Expand Up @@ -1158,7 +1159,7 @@ private Color getAlignmentColor(Alignment alignment, AlignmentTrack track) {
// Set color used to draw the feature. Highlight features that intersect the
// center line. Also restorePersistentState row "score" if alignment intersects center line

Color defaultColor = track.getColor();
Color defaultColor = alignment.isNegativeStrand() ? track.getAltColor() : track.getColor();
Color c = defaultColor;
AlignmentTrack.RenderOptions renderOptions = track.getRenderOptions();
ColorOption colorOption = renderOptions.getColorOption();
Expand Down
Loading
Loading