X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Fappletgui%2FAlignFrame.java;h=f9141086f12c9f05f8f254cd69b5cd47dd9ccc37;hb=4ff9ae2e29a4dc41fb5101a5e336809f097b88ae;hp=620ceb21d1cf3d7ed7484fcbee437b09bf0527f2;hpb=ca0a70b02a67f842a195319414d241ffa336656b;p=jalview.git diff --git a/src/jalview/appletgui/AlignFrame.java b/src/jalview/appletgui/AlignFrame.java index 620ceb2..f914108 100644 --- a/src/jalview/appletgui/AlignFrame.java +++ b/src/jalview/appletgui/AlignFrame.java @@ -22,6 +22,9 @@ package jalview.appletgui; import jalview.analysis.AlignmentSorter; import jalview.analysis.AnnotationSorter.SequenceAnnotationOrder; +import jalview.analysis.TreeBuilder; +import jalview.analysis.scoremodels.PIDModel; +import jalview.analysis.scoremodels.ScoreModels; import jalview.api.AlignViewControllerGuiI; import jalview.api.AlignViewControllerI; import jalview.api.AlignViewportI; @@ -43,6 +46,7 @@ import jalview.datamodel.AlignmentAnnotation; import jalview.datamodel.AlignmentI; import jalview.datamodel.AlignmentOrder; import jalview.datamodel.ColumnSelection; +import jalview.datamodel.HiddenColumns; import jalview.datamodel.PDBEntry; import jalview.datamodel.Sequence; import jalview.datamodel.SequenceGroup; @@ -65,7 +69,6 @@ import jalview.schemes.NucleotideColourScheme; import jalview.schemes.PIDColourScheme; import jalview.schemes.PurinePyrimidineColourScheme; import jalview.schemes.RNAHelicesColour; -import jalview.schemes.RNAHelicesColourChooser; import jalview.schemes.StrandColourScheme; import jalview.schemes.TCoffeeColourScheme; import jalview.schemes.TaylorColourScheme; @@ -76,6 +79,7 @@ import jalview.structures.models.AAStructureBindingModel; import jalview.util.MappingUtils; import jalview.util.MessageManager; import jalview.viewmodel.AlignmentViewport; +import jalview.viewmodel.ViewportRanges; import java.awt.BorderLayout; import java.awt.Canvas; @@ -169,14 +173,14 @@ public class AlignFrame extends EmbmenuFrame implements ActionListener, } public AlignFrame(AlignmentI al, SequenceI[] hiddenSeqs, - ColumnSelection columnSelection, JalviewLite applet, + HiddenColumns hidden, JalviewLite applet, String title, boolean embedded) { - this(al, hiddenSeqs, columnSelection, applet, title, embedded, true); + this(al, hiddenSeqs, hidden, applet, title, embedded, true); } public AlignFrame(AlignmentI al, SequenceI[] hiddenSeqs, - ColumnSelection columnSelection, JalviewLite applet, + HiddenColumns hidden, JalviewLite applet, String title, boolean embedded, boolean addToDisplay) { if (applet != null) @@ -219,9 +223,9 @@ public class AlignFrame extends EmbmenuFrame implements ActionListener, { viewport.hideSequence(hiddenSeqs); } - if (columnSelection != null) + if (hidden != null) { - viewport.setColumnSelection(columnSelection); + viewport.getAlignment().setHiddenColumns(hidden); } viewport.setScaleAboveWrapped(scaleAbove.getState()); @@ -285,6 +289,16 @@ public class AlignFrame extends EmbmenuFrame implements ActionListener, } if (viewport.getAlignment().isNucleotide()) { + conservationMenuItem.setEnabled(false); + clustalColour.setEnabled(false); + BLOSUM62Colour.setEnabled(false); + zappoColour.setEnabled(false); + taylorColour.setEnabled(false); + hydrophobicityColour.setEnabled(false); + helixColour.setEnabled(false); + strandColour.setEnabled(false); + turnColour.setEnabled(false); + buriedColour.setEnabled(false); viewport.updateStrucConsensus(alignPanel); if (viewport.getAlignment().hasRNAStructure()) { @@ -411,6 +425,8 @@ public class AlignFrame extends EmbmenuFrame implements ActionListener, @Override public void keyPressed(KeyEvent evt) { + ViewportRanges ranges = viewport.getRanges(); + if (viewport.cursorMode && ((evt.getKeyCode() >= KeyEvent.VK_0 && evt.getKeyCode() <= KeyEvent.VK_9) || (evt .getKeyCode() >= KeyEvent.VK_NUMPAD0 && evt @@ -562,8 +578,8 @@ public class AlignFrame extends EmbmenuFrame implements ActionListener, new String[] { (viewport.cursorMode ? "on" : "off") })); if (viewport.cursorMode) { - alignPanel.seqPanel.seqCanvas.cursorX = viewport.startRes; - alignPanel.seqPanel.seqCanvas.cursorY = viewport.startSeq; + alignPanel.seqPanel.seqCanvas.cursorX = ranges.getStartRes(); + alignPanel.seqPanel.seqCanvas.cursorY = ranges.getStartSeq(); } break; @@ -589,8 +605,8 @@ public class AlignFrame extends EmbmenuFrame implements ActionListener, } else { - alignPanel.setScrollValues(viewport.startRes, viewport.startSeq - - viewport.endSeq + viewport.startSeq); + alignPanel.setScrollValues(ranges.getStartRes(), + 2 * ranges.getStartSeq() - ranges.getEndSeq()); } break; @@ -601,8 +617,8 @@ public class AlignFrame extends EmbmenuFrame implements ActionListener, } else { - alignPanel.setScrollValues(viewport.startRes, viewport.startSeq - + viewport.endSeq - viewport.startSeq); + alignPanel + .setScrollValues(ranges.getStartRes(), ranges.getEndSeq()); } break; @@ -1059,6 +1075,14 @@ public class AlignFrame extends EmbmenuFrame implements ActionListener, { delete_actionPerformed(); } + else if (source == createGroup) + { + createGroup_actionPerformed(); + } + else if (source == unGroup) + { + unGroup_actionPerformed(); + } else if (source == grpsFromSelection) { makeGrpsFromSelection_actionPerformed(); @@ -1904,7 +1928,8 @@ public class AlignFrame extends EmbmenuFrame implements ActionListener, { copiedHiddenColumns = new Vector(); int hiddenOffset = viewport.getSelectionGroup().getStartRes(); - for (int[] region : viewport.getColumnSelection().getHiddenColumns()) + for (int[] region : viewport.getAlignment().getHiddenColumns() + .getHiddenRegions()) { copiedHiddenColumns.addElement(new int[] { region[0] - hiddenOffset, region[1] - hiddenOffset }); @@ -2054,7 +2079,7 @@ public class AlignFrame extends EmbmenuFrame implements ActionListener, seqs, 0, viewport.getAlignment().getWidth(), viewport.getAlignment())); - viewport.setEndSeq(viewport.getAlignment().getHeight()); + viewport.getRanges().setEndSeq(viewport.getAlignment().getHeight()); viewport.getAlignment().getWidth(); viewport.firePropertyChange("alignment", null, viewport.getAlignment() .getSequences()); @@ -2290,6 +2315,8 @@ public class AlignFrame extends EmbmenuFrame implements ActionListener, void trimAlignment(boolean trimLeft) { + AlignmentI al = viewport.getAlignment(); + ViewportRanges ranges = viewport.getRanges(); ColumnSelection colSel = viewport.getColumnSelection(); int column; @@ -2312,20 +2339,20 @@ public class AlignFrame extends EmbmenuFrame implements ActionListener, } else { - seqs = viewport.getAlignment().getSequencesArray(); + seqs = al.getSequencesArray(); } TrimRegionCommand trimRegion; if (trimLeft) { trimRegion = new TrimRegionCommand("Remove Left", true, seqs, - column, viewport.getAlignment()); - viewport.setStartRes(0); + column, al); + ranges.setStartRes(0); } else { trimRegion = new TrimRegionCommand("Remove Right", false, seqs, - column, viewport.getAlignment()); + column, al); } statusBar.setText(MessageManager.formatMessage( @@ -2334,23 +2361,25 @@ public class AlignFrame extends EmbmenuFrame implements ActionListener, .toString() })); addHistoryItem(trimRegion); - for (SequenceGroup sg : viewport.getAlignment().getGroups()) + for (SequenceGroup sg : al.getGroups()) { if ((trimLeft && !sg.adjustForRemoveLeft(column)) || (!trimLeft && !sg.adjustForRemoveRight(column))) { - viewport.getAlignment().deleteGroup(sg); + al.deleteGroup(sg); } } - viewport.firePropertyChange("alignment", null, viewport - .getAlignment().getSequences()); + viewport.firePropertyChange("alignment", null, al.getSequences()); } } public void removeGappedColumnMenuItem_actionPerformed() { - int start = 0, end = viewport.getAlignment().getWidth() - 1; + AlignmentI al = viewport.getAlignment(); + ViewportRanges ranges = viewport.getRanges(); + int start = 0; + int end = ranges.getAbsoluteAlignmentWidth() - 1; SequenceI[] seqs; if (viewport.getSelectionGroup() != null) @@ -2378,22 +2407,24 @@ public class AlignFrame extends EmbmenuFrame implements ActionListener, // This is to maintain viewport position on first residue // of first sequence - SequenceI seq = viewport.getAlignment().getSequenceAt(0); - int startRes = seq.findPosition(viewport.startRes); + SequenceI seq = al.getSequenceAt(0); + int startRes = seq.findPosition(ranges.getStartRes()); // ShiftList shifts; // viewport.getAlignment().removeGaps(shifts=new ShiftList()); // edit.alColumnChanges=shifts.getInverse(); // if (viewport.hasHiddenColumns) // viewport.getColumnSelection().compensateForEdits(shifts); - viewport.setStartRes(seq.findIndex(startRes) - 1); - viewport.firePropertyChange("alignment", null, viewport.getAlignment() - .getSequences()); + ranges.setStartRes(seq.findIndex(startRes) - 1); + viewport.firePropertyChange("alignment", null, al.getSequences()); } public void removeAllGapsMenuItem_actionPerformed() { - int start = 0, end = viewport.getAlignment().getWidth() - 1; + AlignmentI al = viewport.getAlignment(); + ViewportRanges ranges = viewport.getRanges(); + int start = 0; + int end = ranges.getAbsoluteAlignmentWidth() - 1; SequenceI[] seqs; if (viewport.getSelectionGroup() != null) @@ -2410,16 +2441,15 @@ public class AlignFrame extends EmbmenuFrame implements ActionListener, // This is to maintain viewport position on first residue // of first sequence - SequenceI seq = viewport.getAlignment().getSequenceAt(0); - int startRes = seq.findPosition(viewport.startRes); + SequenceI seq = al.getSequenceAt(0); + int startRes = seq.findPosition(ranges.getStartRes()); addHistoryItem(new RemoveGapsCommand("Remove Gaps", seqs, start, end, - viewport.getAlignment())); + al)); - viewport.setStartRes(seq.findIndex(startRes) - 1); + ranges.setStartRes(seq.findIndex(startRes) - 1); - viewport.firePropertyChange("alignment", null, viewport.getAlignment() - .getSequences()); + viewport.firePropertyChange("alignment", null, al.getSequences()); } @@ -2632,26 +2662,6 @@ public class AlignFrame extends EmbmenuFrame implements ActionListener, @Override public void changeColour(ColourSchemeI cs) { - - if (cs != null) - { - if (viewport.getAbovePIDThreshold()) - { - viewport.setThreshold(SliderPanel.setPIDSliderSource(alignPanel, - cs, "Background")); - } - - if (viewport.getConservationSelected()) - { - cs.setConservationApplied(true); - viewport.setIncrement(SliderPanel.setConservationSlider(alignPanel, - cs, "Background")); - } - else - { - cs.setConservationApplied(false); - } - } viewport.setGlobalColourScheme(cs); alignPanel.paintAlignment(true); @@ -2663,7 +2673,7 @@ public class AlignFrame extends EmbmenuFrame implements ActionListener, && viewport.getGlobalColourScheme() != null) { SliderPanel.setPIDSliderSource(alignPanel, - viewport.getGlobalColourScheme(), "Background"); + viewport.getResidueShading(), alignPanel.getViewName()); SliderPanel.showPIDSlider(); } } @@ -2674,40 +2684,58 @@ public class AlignFrame extends EmbmenuFrame implements ActionListener, && viewport.getGlobalColourScheme() != null) { SliderPanel.setConservationSlider(alignPanel, - viewport.getGlobalColourScheme(), "Background"); + viewport.getResidueShading(), alignPanel.getViewName()); SliderPanel.showConservationSlider(); } } protected void conservationMenuItem_actionPerformed() { - viewport.setConservationSelected(conservationMenuItem.getState()); - - viewport.setAbovePIDThreshold(false); - abovePIDThreshold.setState(false); + boolean selected = conservationMenuItem.getState(); + modifyConservation.setEnabled(selected); + viewport.setConservationSelected(selected); + viewport.getResidueShading().setConservationApplied(selected); changeColour(viewport.getGlobalColourScheme()); - modifyConservation_actionPerformed(); + if (selected) + { + modifyConservation_actionPerformed(); + } + else + { + SliderPanel.hideConservationSlider(); + } } public void abovePIDThreshold_actionPerformed() { - viewport.setAbovePIDThreshold(abovePIDThreshold.getState()); - - conservationMenuItem.setState(false); - viewport.setConservationSelected(false); + boolean selected = abovePIDThreshold.getState(); + modifyPID.setEnabled(selected); + viewport.setAbovePIDThreshold(selected); + if (!selected) + { + viewport.getResidueShading().setThreshold(0, + viewport.isIgnoreGapsConsensus()); + } changeColour(viewport.getGlobalColourScheme()); - modifyPID_actionPerformed(); + if (selected) + { + modifyPID_actionPerformed(); + } + else + { + SliderPanel.hidePIDSlider(); + } } public void sortPairwiseMenuItem_actionPerformed() { SequenceI[] oldOrder = viewport.getAlignment().getSequencesArray(); AlignmentSorter.sortByPID(viewport.getAlignment(), viewport - .getAlignment().getSequenceAt(0), null); + .getAlignment().getSequenceAt(0)); addHistoryItem(new OrderCommand("Pairwise Sort", oldOrder, viewport.getAlignment())); @@ -2799,25 +2827,31 @@ public class AlignFrame extends EmbmenuFrame implements ActionListener, public void averageDistanceTreeMenuItem_actionPerformed() { - NewTreePanel("AV", "PID", "Average distance tree using PID"); + newTreePanel(TreeBuilder.AVERAGE_DISTANCE, new PIDModel().getName(), + "Average distance tree using PID"); } public void neighbourTreeMenuItem_actionPerformed() { - NewTreePanel("NJ", "PID", "Neighbour joining tree using PID"); + newTreePanel(TreeBuilder.NEIGHBOUR_JOINING, new PIDModel().getName(), + "Neighbour joining tree using PID"); } protected void njTreeBlosumMenuItem_actionPerformed() { - NewTreePanel("NJ", "BL", "Neighbour joining tree using BLOSUM62"); + newTreePanel(TreeBuilder.NEIGHBOUR_JOINING, ScoreModels.getInstance() + .getBlosum62().getName(), + "Neighbour joining tree using BLOSUM62"); } protected void avTreeBlosumMenuItem_actionPerformed() { - NewTreePanel("AV", "BL", "Average distance tree using BLOSUM62"); + newTreePanel(TreeBuilder.AVERAGE_DISTANCE, ScoreModels.getInstance() + .getBlosum62().getName(), + "Average distance tree using BLOSUM62"); } - void NewTreePanel(String type, String pwType, String title) + void newTreePanel(String type, String pwType, String title) { // are the sequences aligned? if (!viewport.getAlignment().isAligned(false)) @@ -3323,7 +3357,10 @@ public class AlignFrame extends EmbmenuFrame implements ActionListener, .getString("action.make_groups_selection")); grpsFromSelection.addActionListener(this); createGroup.setLabel(MessageManager.getString("action.create_group")); + createGroup.addActionListener(this); unGroup.setLabel(MessageManager.getString("action.remove_group")); + unGroup.addActionListener(this); + annotationColumnSelection.setLabel(MessageManager .getString("action.select_by_annotation")); annotationColumnSelection.addActionListener(this); @@ -3528,9 +3565,11 @@ public class AlignFrame extends EmbmenuFrame implements ActionListener, nucleotideColour.addActionListener(this); modifyPID.setLabel(MessageManager .getString("label.modify_identity_threshold")); + modifyPID.setEnabled(abovePIDThreshold.getState()); modifyPID.addActionListener(this); modifyConservation.setLabel(MessageManager .getString("label.modify_conservation_threshold")); + modifyConservation.setEnabled(conservationMenuItem.getState()); modifyConservation.addActionListener(this); annotationColour.setLabel(MessageManager .getString("action.by_annotation")); @@ -4170,9 +4209,10 @@ public class AlignFrame extends EmbmenuFrame implements ActionListener, * @param csel * - columns to be selected on the alignment */ - public void select(SequenceGroup sel, ColumnSelection csel) + public void select(SequenceGroup sel, ColumnSelection csel, + HiddenColumns hidden) { - alignPanel.seqPanel.selection(sel, csel, null); + alignPanel.seqPanel.selection(sel, csel, hidden, null); } public void scrollTo(int row, int column)