Skip to content

Commit

Permalink
Merge branch 'track_hubs'
Browse files Browse the repository at this point in the history
  • Loading branch information
jrobinso committed Feb 8, 2025
2 parents 9df5975 + b1a1701 commit eb810fb
Show file tree
Hide file tree
Showing 17 changed files with 759 additions and 534 deletions.
3 changes: 2 additions & 1 deletion src/main/java/org/broad/igv/feature/genome/Genome.java
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@
import org.broad.igv.track.FeatureTrack;
import org.broad.igv.track.TribbleFeatureSource;
import org.broad.igv.ucsc.hub.Hub;
import org.broad.igv.ucsc.hub.HubParser;
import org.broad.igv.ucsc.twobit.TwoBitSequence;
import org.broad.igv.util.ResourceLocator;
import org.broad.igv.util.liftover.Liftover;
Expand Down Expand Up @@ -231,7 +232,7 @@ public Genome(GenomeConfig config) throws IOException {
if(config.getHubs() != null) {
for(String hubUrl : config.getHubs()) {
try {
trackHubs.add(Hub.loadHub(hubUrl));
trackHubs.add(HubParser.loadHub(hubUrl, getId()));
} catch (IOException e) {
log.error("Error loading hub", e);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,6 @@ public boolean loadGenomeById(String genomeId) throws IOException {
return loadGenome(genomePath) != null; // monitor[0]);
}


/**
* The main load method -- loads a genome from a file or url path. Note this is a long running operation and
* should not be done on the Swing event thread as it will block the UI.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import org.broad.igv.feature.genome.Genome;
import org.broad.igv.prefs.PreferencesManager;
import org.broad.igv.ucsc.hub.Hub;
import org.broad.igv.ucsc.hub.HubParser;
import org.broad.igv.ucsc.hub.TrackConfigGroup;
import org.broad.igv.ui.IGV;
import org.broad.igv.ucsc.hub.TrackHubSelectionDialog;
Expand Down Expand Up @@ -44,9 +45,9 @@ public static String convertToHubURL(String accension) {
@Override
public Genome loadGenome() throws IOException {

Hub hub = Hub.loadHub(this.hubURL);
Hub hub = HubParser.loadAssemblyHub(this.hubURL);

GenomeConfig config = hub.getGenomeConfig(false);
GenomeConfig config = hub.getGenomeConfig();

// Potentially override default tracks from hub with user selections

Expand All @@ -68,7 +69,7 @@ public Genome loadGenome() throws IOException {
else if (IGV.hasInstance() && !Globals.isBatch() && !Globals.isHeadless() && !Globals.isTesting()) {

int count = 0;
for(TrackConfigGroup g : groupedTrackConfigurations) {
for (TrackConfigGroup g : groupedTrackConfigurations) {
count += g.tracks.size();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ public class TrackConfig implements Cloneable {

private String id;
private String name;
private String longLabel;
private String url;
private String indexURL;
private String trixURL;
Expand Down Expand Up @@ -62,6 +63,14 @@ public void setName(String name) {
this.name = name;
}

public String getLongLabel() {
return longLabel;
}

public void setLongLabel(String longLabel) {
this.longLabel = longLabel;
}

public String getUrl() {
return url;
}
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/org/broad/igv/track/FeatureTrack.java
Original file line number Diff line number Diff line change
Expand Up @@ -389,7 +389,7 @@ public String getValueStringAt(String chr, double position, int mouseX, int mous

StringBuffer buf = new StringBuffer();
boolean firstFeature = true;
int maxNumber = IGV.getInstance().isShowDetailsOnClick() ? 100 : 10;
int maxNumber = 10;
int n = 1;
for (Feature feature : allFeatures) {
if (feature != null && feature instanceof IGVFeature) {
Expand All @@ -409,7 +409,7 @@ public String getValueStringAt(String chr, double position, int mouseX, int mous
}
firstFeature = false;
if (n > maxNumber) {
buf.append("<hr><br<b>>+ " + (allFeatures.size() - maxNumber) + " more ...</b>");
buf.append("<hr><br<b>+ " + (allFeatures.size() - maxNumber) + " more</b>");
break;
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package org.broad.igv.ui.panel;
package org.broad.igv.ucsc.hub;

import org.broad.igv.ui.FontManager;
import org.broad.igv.ui.util.IconFactory;
Expand Down Expand Up @@ -26,9 +26,6 @@ public CollapsiblePanel(String label, JComponent content, boolean isOpen) {

setLayout(new BorderLayout());
this.content = content;

//setBorder(BorderFactory.createLineBorder(Color.BLACK));

this.openIcon = IconFactory.getInstance().getIcon(IconFactory.IconID.MINUS);
this.closeIcon = IconFactory.getInstance().getIcon(IconFactory.IconID.PLUS);

Expand Down Expand Up @@ -70,23 +67,22 @@ public void expand() {
content.setVisible(true);
}

@Override
public Dimension getPreferredSize() {
Dimension d = super.getPreferredSize();
if(!content.isVisible()) {
return new Dimension(d.width, header.getHeight());
} else {
return d;
}
}

/**
* Constrain the maximum height to prevent BoxLayout from needlessly resizing the panel to fill space. This is
* rather hardcoded for the TrackHubSelectionDialog.
*
* @return
*/

@Override
public Dimension getMaximumSize() {
Dimension d = super.getMaximumSize();
Dimension d4 = header.getMinimumSize();
if(!content.isVisible()) {
return new Dimension(d.width, header.getHeight());
return new Dimension(Integer.MAX_VALUE, d4.height);
} else {
return d;
Dimension d5 = content.getMinimumSize();
return new Dimension(Integer.MAX_VALUE, d4.height + (int) (1.2 * d5.height));
}
}

Expand All @@ -101,3 +97,5 @@ public static void main(String[] args) {
f.setVisible(true);
}
}


Loading

0 comments on commit eb810fb

Please sign in to comment.