Skip to content

Commit

Permalink
Consolidate alignment track menu options
Browse files Browse the repository at this point in the history
  • Loading branch information
jrobinso committed Aug 31, 2023
1 parent 58c23a1 commit f3c256b
Showing 1 changed file with 38 additions and 50 deletions.
88 changes: 38 additions & 50 deletions src/main/java/org/broad/igv/sam/AlignmentTrackMenu.java
Original file line number Diff line number Diff line change
Expand Up @@ -89,19 +89,17 @@ class AlignmentTrackMenu extends IGVPopupMenu {
Collection<Track> tracks = List.of(alignmentTrack);
addSeparator();
add(TrackMenuUtils.getTrackRenameItem(tracks));
addCopyToClipboardItem(e, clickedAlignment);

addSeparator();
JMenuItem item = new JMenuItem("Change Track Color...");
item.addActionListener(evt -> TrackMenuUtils.changeTrackColor(tracks));
add(item);

// Experiment type (RNA, THIRD GEN, OTHER)
addSeparator();
addExperimentTypeMenuItem();
if (alignmentTrack.getExperimentType() == AlignmentTrack.ExperimentType.THIRD_GEN) {
addHaplotype(e);
}
// if (alignmentTrack.getExperimentType() == AlignmentTrack.ExperimentType.THIRD_GEN) {
// addHaplotype(e);
// }

// Linked read items
addLinkedReadItems();
Expand All @@ -124,16 +122,17 @@ class AlignmentTrackMenu extends IGVPopupMenu {
showAllItem.addActionListener(new Deselector(showAllItem, misMatchesItem));

// Paired end items
addSeparator();
addViewAsPairsMenuItem();
if (clickedAlignment != null) {
addGoToMate(e, clickedAlignment);
showMateRegion(e, clickedAlignment);
if(dataManager.isPairedEnd()) {
addSeparator();
addViewAsPairsMenuItem();
if (clickedAlignment != null) {
addGoToMate(e, clickedAlignment);
showMateRegion(e, clickedAlignment);
}
addInsertSizeMenuItem();
}
addInsertSizeMenuItem();

// Third gen (primarily) items
addSeparator();
addThirdGenItems(clickedAlignment, e);

// Display mode items
Expand All @@ -147,6 +146,7 @@ class AlignmentTrackMenu extends IGVPopupMenu {

// Copy items
addSeparator();
addCopyToClipboardItem(e, clickedAlignment);
addCopySequenceItems(e);
addConsensusSequence(e);

Expand All @@ -163,11 +163,13 @@ class AlignmentTrackMenu extends IGVPopupMenu {
}

// Sashimi plot
addSeparator();
JMenuItem sashimi = new JMenuItem("Sashimi Plot");
sashimi.addActionListener(e1 -> SashimiPlot.openSashimiPlot());
sashimi.setEnabled(alignmentTrack.getExperimentType() == AlignmentTrack.ExperimentType.RNA);
add(sashimi);
if(alignmentTrack.getExperimentType() == AlignmentTrack.ExperimentType.RNA) {
addSeparator();
JMenuItem sashimi = new JMenuItem("Sashimi Plot");
sashimi.addActionListener(e1 -> SashimiPlot.openSashimiPlot());
sashimi.setEnabled(alignmentTrack.getExperimentType() == AlignmentTrack.ExperimentType.RNA);
add(sashimi);
}

// Show alignments, coverage, splice junctions
addSeparator();
Expand Down Expand Up @@ -744,7 +746,7 @@ void addPackMenuItem() {
void addCopyToClipboardItem(final TrackClickEvent te, Alignment alignment) {

final MouseEvent me = te.getMouseEvent();
JMenuItem item = new JMenuItem("Copy read details to clipboard");
JMenuItem item = new JMenuItem("Copy read details");
final ReferenceFrame frame = te.getFrame();
if (frame == null) {
item.setEnabled(false);
Expand Down Expand Up @@ -825,17 +827,6 @@ JMenuItem addShowAllBasesMenuItem() {
return item;
}

void addQuickConsensusModeItem() {
// Change track height by attribute
final JMenuItem item = new JCheckBoxMenuItem("Quick consensus mode");
item.setSelected(renderOptions.isQuickConsensusMode());
item.addActionListener(aEvt -> {
renderOptions.setQuickConsensusMode(item.isSelected());
alignmentTrack.repaint();
});
add(item);
}

JMenuItem addShowMismatchesMenuItem() {
// Change track height by attribute
final JMenuItem item = new JCheckBoxMenuItem("Show mismatched bases");
Expand Down Expand Up @@ -1075,7 +1066,6 @@ void addExtViewItem(final TrackClickEvent te) {
* and linking by arbitrary tag.
*/
void addLinkedReadItems() {
addSeparator();

addSeparator();
final JCheckBoxMenuItem supplementalItem = new JCheckBoxMenuItem("Link supplementary alignments");
Expand Down Expand Up @@ -1160,36 +1150,33 @@ void addThirdGenItems(Alignment clickedAlignment, final TrackClickEvent tce) {
addShowChimericRegions(alignmentTrack, tce, clickedAlignment);
addShowDiagram(tce, clickedAlignment);

final JMenuItem qcItem = new JCheckBoxMenuItem("Quick consensus mode");
qcItem.setSelected(renderOptions.isQuickConsensusMode());
qcItem.addActionListener(aEvt -> {
renderOptions.setQuickConsensusMode(qcItem.isSelected());
alignmentTrack.repaint();
});
// final JMenuItem qcItem = new JCheckBoxMenuItem("Quick consensus mode");
// qcItem.setSelected(renderOptions.isQuickConsensusMode());
// qcItem.addActionListener(aEvt -> {
// renderOptions.setQuickConsensusMode(qcItem.isSelected());
// alignmentTrack.repaint();
// });

final JMenuItem thresholdItem = new JMenuItem("Small indel threshold...");
thresholdItem.addActionListener(evt -> UIUtilities.invokeOnEventThread(() -> {
String sith = MessageUtils.showInputDialog("Small indel threshold: ", String.valueOf(renderOptions.getSmallIndelThreshold()));
try {
renderOptions.setSmallIndelThreshold(Integer.parseInt(sith));
alignmentTrack.repaint();
} catch (NumberFormatException e) {
log.error("Error setting small indel threshold - not an integer", e);
}
}));
thresholdItem.setEnabled(renderOptions.isHideSmallIndels());

final JMenuItem item = new JCheckBoxMenuItem("Hide small indels");
item.setSelected(renderOptions.isHideSmallIndels());
item.addActionListener(aEvt -> UIUtilities.invokeOnEventThread(() -> {

if(item.isSelected()) {
String sith = MessageUtils.showInputDialog("Small indel threshold: ", String.valueOf(renderOptions.getSmallIndelThreshold()));
try {
renderOptions.setSmallIndelThreshold(Integer.parseInt(sith));
} catch (NumberFormatException e) {
log.error("Error setting small indel threshold - not an integer", e);
}
}

renderOptions.setHideSmallIndels(item.isSelected());
thresholdItem.setEnabled(item.isSelected());
alignmentTrack.repaint();
}));

add(qcItem);
//add(qcItem);
add(item);
add(thresholdItem);
}

/**
Expand Down Expand Up @@ -1383,3 +1370,4 @@ public void actionPerformed(ActionEvent e) {
}

}

0 comments on commit f3c256b

Please sign in to comment.