Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Restore genome annotation tracks from sessions when paths have change… #1446

Merged
merged 1 commit into from
Nov 28, 2023
Merged
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
2 changes: 2 additions & 0 deletions src/main/java/org/broad/igv/feature/Strand.java
Original file line number Diff line number Diff line change
Expand Up @@ -57,4 +57,6 @@ public String toShortString() {
public String toString() {
return this == POSITIVE ? "+" : this == NEGATIVE ? "-" : "";
}


}
36 changes: 30 additions & 6 deletions src/main/java/org/broad/igv/feature/genome/GenomeManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@
import org.broad.igv.track.FeatureTrack;
import org.broad.igv.track.Track;
import org.broad.igv.ui.IGV;
import org.broad.igv.ui.PanelName;
import org.broad.igv.ui.commandbar.GenomeListManager;
import org.broad.igv.ui.panel.FrameManager;
import org.broad.igv.ui.util.MessageUtils;
Expand All @@ -71,10 +72,12 @@
import java.net.SocketException;
import java.net.URL;
import java.net.URLDecoder;
import java.util.LinkedHashMap;
import java.util.*;
import java.util.List;
import java.util.Map;
import java.util.Set;

import static org.broad.igv.prefs.Constants.SHOW_SINGLE_TRACK_PANE_KEY;
import static org.broad.igv.ui.IGV.DATA_PANEL_NAME;
import static org.broad.igv.ui.IGV.FEATURE_PANEL_NAME;

/**
* @author jrobinso
Expand Down Expand Up @@ -200,7 +203,7 @@ public Genome loadGenome(String genomePath, ProgressMonitor monitor) throws IOEx
// Load user-defined chr aliases, if any. This is done last so they have priority
try {
String aliasPath = (new File(DirectoryManager.getGenomeCacheDirectory(), newGenome.getId() + "_alias.tab")).getAbsolutePath();
if(!(new File(aliasPath)).exists()) {
if (!(new File(aliasPath)).exists()) {
aliasPath = (new File(DirectoryManager.getGenomeCacheDirectory(), newGenome.getId() + "_alias.tab.txt")).getAbsolutePath();
}
if ((new File(aliasPath)).exists()) {
Expand Down Expand Up @@ -244,6 +247,12 @@ public Genome loadGenome(String genomePath, ProgressMonitor monitor) throws IOEx
}
}

/**
* Load and initialize the track objects from the genome's track resource locators. Does not add the tracks
* to the IGV instance.
*
* @param genome
*/
public void loadGenomeAnnotations(Genome genome) {
List<ResourceLocator> resources = genome.getAnnotationResources();
if (resources != null) {
Expand All @@ -255,16 +264,31 @@ public void loadGenomeAnnotations(Genome genome) {
} catch (DataLoadException e) {
log.error("Error loading genome annotations", e);
}
}
}//
genome.setAnnotationTracks(annotationTracks);
}
restoreGenomeTracks(genome);
IGV.getInstance().repaint();
}

/**
* Add a genomes tracks to the IGV instance.
*
* @param genome
*/
public void restoreGenomeTracks(Genome genome) {

IGV.getInstance().setSequenceTrack();

FeatureTrack geneFeatureTrack = genome.getGeneTrack(); // Can be null
IGV.getInstance().setGenomeTracks(geneFeatureTrack);
if (geneFeatureTrack != null) {
PanelName panelName = PreferencesManager.getPreferences().getAsBoolean(SHOW_SINGLE_TRACK_PANE_KEY) ?
PanelName.DATA_PANEL : PanelName.FEATURE_PANEL;
geneFeatureTrack.setAttributeValue(Globals.TRACK_NAME_ATTRIBUTE, geneFeatureTrack.getName());
geneFeatureTrack.setAttributeValue(Globals.TRACK_DATA_FILE_ATTRIBUTE, "");
geneFeatureTrack.setAttributeValue(Globals.TRACK_DATA_TYPE_ATTRIBUTE, geneFeatureTrack.getTrackType().toString());
IGV.getInstance().addTracks(Arrays.asList(geneFeatureTrack), panelName);
}

Map<ResourceLocator, List<Track>> annotationTracks = currentGenome.getAnnotationTracks();
if (annotationTracks != null) {
Expand Down
Loading
Loading