// Ignore (Disable) if we are in gene list mode
if (FrameManager.isGeneListMode()) {
return;
}
ReferenceFrame vc = FrameManager.getDefaultFrame();
Collection<Track> tracks = IGV.getInstance().getSelectedTracks();
if (tracks.size() == 1) {
Track t = tracks.iterator().next();
if (!(t instanceof FeatureTrack)) {
//JOptionPane.showMessageDialog(IGV.getInstance(),
// "Track panning is not enabled for data tracks.");
return;
}
Exon e = null;
if (t instanceof FeatureTrack) {
int center = (int) vc.getCenter();
FeatureTrack ft = (FeatureTrack) t;
if (ft.getDisplayMode() == Track.DisplayMode.COLLAPSED ||
ft.getSelectedFeatureRowIndex() == FeatureTrack.NO_FEATURE_ROW_SELECTED) {
MessageUtils.showMessage(
"Exon navigation is only allowed when track is expanded and a single " +
"feature row is selected.");
return;
}
List<Feature> featureList = ft.getFeaturesAtPositionInFeatureRow(center, ft.getSelectedFeatureRowIndex(), vc);
Feature feature = featureList != null && featureList.size() > 0 ? featureList.get(0) : null;
if (feature == null)
return;
if (feature instanceof BasicFeature) {
BasicFeature bf = (BasicFeature) feature;
java.util.List<Exon> exons = bf.getExons();
if (exons == null || exons.isEmpty()) {
MessageUtils.showMessage("At least one centered feature does not have exon structure");
return;
}
if (forward) {
for (Exon exon : bf.getExons()) {
//the "+ 1" here is necessary because the rounding in the recentering method
//sometimes places the center one base off. This should be perfectly safe,
//but it does assume no one's abusing the exon datastructure and creating
//exons that are right next to each other.
if (exon.getStart() > vc.getCenter() + 1) {
e = exon;
break;
}
}
} else {
for (int i = exons.size() - 1; i >= 0; i--) {
Exon exon = exons.get(i);
if (exon.getEnd() < vc.getCenter()) {
e = exon;
break;
}
}
}
}
if (e != null) {
vc.centerOnLocation(forward ? e.getStart() : e.getEnd());
int i = 3;
}
}
//todo: implement handling for VariantTrack