2 * Jalview - A Sequence Alignment Editor and Viewer (Version 2.7)
\r
3 * Copyright (C) 2011 J Procter, AM Waterhouse, J Engelhardt, LM Lui, G Barton, M Clamp, S Searle
\r
5 * This file is part of Jalview.
\r
7 * Jalview is free software: you can redistribute it and/or
\r
8 * modify it under the terms of the GNU General Public License
\r
9 * as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
\r
11 * Jalview is distributed in the hope that it will be useful, but
\r
12 * WITHOUT ANY WARRANTY; without even the implied warranty
\r
13 * of MERCHANTABILITY or FITNESS FOR A PARTICULAR
\r
14 * PURPOSE. See the GNU General Public License for more details.
\r
16 * You should have received a copy of the GNU General Public License along with Jalview. If not, see <http://www.gnu.org/licenses/>.
\r
18 package jalview.appletgui;
\r
24 import java.awt.event.*;
\r
26 import jalview.analysis.*;
\r
27 import jalview.api.SequenceStructureBinding;
\r
28 import jalview.bin.JalviewLite;
\r
29 import jalview.commands.*;
\r
30 import jalview.datamodel.*;
\r
31 import jalview.io.*;
\r
32 import jalview.schemes.*;
\r
33 import jalview.structure.StructureSelectionManager;
\r
35 public class AlignFrame extends EmbmenuFrame implements ActionListener,
\r
36 ItemListener, KeyListener
\r
38 public AlignmentPanel alignPanel;
\r
40 public AlignViewport viewport;
\r
42 int DEFAULT_WIDTH = 700;
\r
44 int DEFAULT_HEIGHT = 500;
\r
46 String jalviewServletURL;
\r
48 public AlignFrame(AlignmentI al, jalview.bin.JalviewLite applet,
\r
49 String title, boolean embedded)
\r
54 jalviewServletURL = applet.getParameter("APPLICATION_URL");
\r
60 } catch (Exception ex)
\r
62 ex.printStackTrace();
\r
65 viewport = new AlignViewport(al, applet);
\r
66 alignPanel = new AlignmentPanel(this, viewport);
\r
68 viewport.updateConservation(alignPanel);
\r
69 viewport.updateConsensus(alignPanel);
\r
71 annotationPanelMenuItem.setState(viewport.showAnnotation);
\r
72 displayNonconservedMenuItem.setState(viewport.getShowUnconserved());
\r
73 followMouseOverFlag.setState(viewport.getFollowHighlight());
\r
74 showGroupConsensus.setState(viewport.isShowGroupConsensus());
\r
75 showGroupConservation.setState(viewport.isShowGroupConservation());
\r
76 showConsensusHistogram.setState(viewport.isShowConsensusHistogram());
\r
77 showSequenceLogo.setState(viewport.isShowSequenceLogo());
\r
79 seqLimits.setState(viewport.showJVSuffix);
\r
83 String param = applet.getParameter("sortBy");
\r
86 if (param.equalsIgnoreCase("Id"))
\r
88 sortIDMenuItem_actionPerformed();
\r
90 else if (param.equalsIgnoreCase("Pairwise Identity"))
\r
92 sortPairwiseMenuItem_actionPerformed();
\r
94 else if (param.equalsIgnoreCase("Length"))
\r
96 sortLengthMenuItem_actionPerformed();
\r
100 param = applet.getParameter("wrap");
\r
103 if (param.equalsIgnoreCase("true"))
\r
105 wrapMenuItem.setState(true);
\r
106 wrapMenuItem_actionPerformed();
\r
109 param = applet.getParameter("centrecolumnlabels");
\r
112 centreColumnLabelFlag.setState(true);
\r
113 centreColumnLabelFlag_stateChanged();
\r
117 param = applet.getParameter("windowWidth");
\r
120 int width = Integer.parseInt(param);
\r
121 DEFAULT_WIDTH = width;
\r
123 param = applet.getParameter("windowHeight");
\r
126 int height = Integer.parseInt(param);
\r
127 DEFAULT_HEIGHT = height;
\r
129 } catch (Exception ex)
\r
134 if (viewport.getAlignment().isNucleotide())
\r
136 viewport.updateStrucConsensus(alignPanel);
\r
137 if (viewport.getAlignment().hasRNAStructure())
\r
139 RNAHelixColour.setEnabled(true);
\r
142 RNAHelixColour.setEnabled(false);
\r
145 RNAHelixColour.setEnabled(false);
\r
146 purinePyrimidineColour.setEnabled(false);
\r
148 // Some JVMS send keyevents to Top frame or lowest panel,
\r
149 // Havent worked out why yet. So add to both this frame and seqCanvas for
\r
151 this.addKeyListener(this);
\r
152 alignPanel.seqPanel.seqCanvas.addKeyListener(this);
\r
153 alignPanel.idPanel.idCanvas.addKeyListener(this);
\r
154 alignPanel.scalePanel.addKeyListener(this);
\r
155 alignPanel.annotationPanel.addKeyListener(this);
\r
156 alignPanel.annotationPanelHolder.addKeyListener(this);
\r
157 alignPanel.annotationSpaceFillerHolder.addKeyListener(this);
\r
158 alignPanel.alabels.addKeyListener(this);
\r
159 createAlignFrameWindow(embedded, title);
\r
162 alignPanel.adjustAnnotationHeight();
\r
163 alignPanel.paintAlignment(true);
\r
166 public AlignViewport getAlignViewport()
\r
171 public SeqCanvas getSeqcanvas()
\r
173 return alignPanel.seqPanel.seqCanvas;
\r
177 * Load a features file onto the alignment
\r
179 * @param file file URL, content, or other resolvable path
\r
180 * @param type is protocol for accessing data referred to by file
\r
183 public void parseFeaturesFile(String file, String type)
\r
185 parseFeaturesFile(file, type, true);
\r
189 * Load a features file onto the alignment
\r
191 * @param file file URL, content, or other resolvable path
\r
192 * @param type is protocol for accessing data referred to by file
\r
193 * @param autoenabledisplay when true, display features flag will be automatically enabled if features are loaded
\r
195 public void parseFeaturesFile(String file, String type, boolean autoenabledisplay)
\r
197 Hashtable featureLinks = new Hashtable();
\r
198 boolean featuresFile = false;
\r
201 featuresFile = new jalview.io.FeaturesFile(file, type)
\r
202 .parse(viewport.getAlignment(),
\r
203 alignPanel.seqPanel.seqCanvas.getFeatureRenderer().featureColours,
\r
204 featureLinks, true, viewport.applet.getDefaultParameter("relaxedidmatch", false));
\r
205 } catch (Exception ex)
\r
207 ex.printStackTrace();
\r
212 if (featureLinks.size() > 0)
\r
214 alignPanel.seqPanel.seqCanvas.getFeatureRenderer().featureLinks = featureLinks;
\r
216 if (autoenabledisplay)
\r
218 viewport.showSequenceFeatures = true;
\r
219 sequenceFeatures.setState(true);
\r
221 if (viewport.featureSettings != null)
\r
223 viewport.featureSettings.refreshTable();
\r
225 alignPanel.paintAlignment(true);
\r
230 public void keyPressed(KeyEvent evt)
\r
232 if (viewport.cursorMode
\r
233 && ((evt.getKeyCode() >= KeyEvent.VK_0 && evt.getKeyCode() <= KeyEvent.VK_9) || (evt
\r
234 .getKeyCode() >= KeyEvent.VK_NUMPAD0 && evt
\r
235 .getKeyCode() <= KeyEvent.VK_NUMPAD9))
\r
236 && Character.isDigit(evt.getKeyChar()))
\r
237 alignPanel.seqPanel.numberPressed(evt.getKeyChar());
\r
239 switch (evt.getKeyCode())
\r
241 case 27: // escape key
\r
242 deselectAllSequenceMenuItem_actionPerformed();
\r
244 alignPanel.alabels.cancelDrag();
\r
246 case KeyEvent.VK_X:
\r
247 if (evt.isControlDown() || evt.isMetaDown())
\r
249 cut_actionPerformed();
\r
252 case KeyEvent.VK_C:
\r
253 if (viewport.cursorMode && !evt.isControlDown())
\r
255 alignPanel.seqPanel.setCursorColumn();
\r
257 if (evt.isControlDown() || evt.isMetaDown())
\r
259 copy_actionPerformed();
\r
262 case KeyEvent.VK_V:
\r
263 if (evt.isControlDown())
\r
265 paste(evt.isShiftDown());
\r
268 case KeyEvent.VK_A:
\r
269 if (evt.isControlDown() || evt.isMetaDown())
\r
271 selectAllSequenceMenuItem_actionPerformed();
\r
274 case KeyEvent.VK_DOWN:
\r
275 if (viewport.cursorMode)
\r
277 alignPanel.seqPanel.moveCursor(0, 1);
\r
281 moveSelectedSequences(false);
\r
285 case KeyEvent.VK_UP:
\r
286 if (viewport.cursorMode)
\r
288 alignPanel.seqPanel.moveCursor(0, -1);
\r
292 moveSelectedSequences(true);
\r
296 case KeyEvent.VK_LEFT:
\r
297 if (evt.isAltDown() || !viewport.cursorMode)
\r
298 slideSequences(false, alignPanel.seqPanel.getKeyboardNo1());
\r
300 alignPanel.seqPanel.moveCursor(-1, 0);
\r
303 case KeyEvent.VK_RIGHT:
\r
304 if (evt.isAltDown() || !viewport.cursorMode)
\r
305 slideSequences(true, alignPanel.seqPanel.getKeyboardNo1());
\r
307 alignPanel.seqPanel.moveCursor(1, 0);
\r
310 case KeyEvent.VK_SPACE:
\r
311 if (viewport.cursorMode)
\r
313 alignPanel.seqPanel.insertGapAtCursor(evt.isControlDown()
\r
314 || evt.isShiftDown() || evt.isAltDown());
\r
318 case KeyEvent.VK_DELETE:
\r
319 case KeyEvent.VK_BACK_SPACE:
\r
320 if (viewport.cursorMode)
\r
322 alignPanel.seqPanel.deleteGapAtCursor(evt.isControlDown()
\r
323 || evt.isShiftDown() || evt.isAltDown());
\r
327 cut_actionPerformed();
\r
328 alignPanel.seqPanel.seqCanvas.repaint();
\r
332 case KeyEvent.VK_S:
\r
333 if (viewport.cursorMode)
\r
335 alignPanel.seqPanel.setCursorRow();
\r
338 case KeyEvent.VK_P:
\r
339 if (viewport.cursorMode)
\r
341 alignPanel.seqPanel.setCursorPosition();
\r
345 case KeyEvent.VK_ENTER:
\r
346 case KeyEvent.VK_COMMA:
\r
347 if (viewport.cursorMode)
\r
349 alignPanel.seqPanel.setCursorRowAndColumn();
\r
353 case KeyEvent.VK_Q:
\r
354 if (viewport.cursorMode)
\r
356 alignPanel.seqPanel.setSelectionAreaAtCursor(true);
\r
359 case KeyEvent.VK_M:
\r
360 if (viewport.cursorMode)
\r
362 alignPanel.seqPanel.setSelectionAreaAtCursor(false);
\r
366 case KeyEvent.VK_F2:
\r
367 viewport.cursorMode = !viewport.cursorMode;
\r
368 statusBar.setText("Keyboard editing mode is "
\r
369 + (viewport.cursorMode ? "on" : "off"));
\r
370 if (viewport.cursorMode)
\r
372 alignPanel.seqPanel.seqCanvas.cursorX = viewport.startRes;
\r
373 alignPanel.seqPanel.seqCanvas.cursorY = viewport.startSeq;
\r
377 case KeyEvent.VK_F:
\r
378 if (evt.isControlDown())
\r
380 findMenuItem_actionPerformed();
\r
384 case KeyEvent.VK_H:
\r
386 boolean toggleSeqs = !evt.isControlDown();
\r
387 boolean toggleCols = !evt.isShiftDown();
\r
388 toggleHiddenRegions(toggleSeqs, toggleCols);
\r
392 case KeyEvent.VK_PAGE_UP:
\r
393 if (viewport.wrapAlignment)
\r
395 alignPanel.scrollUp(true);
\r
399 alignPanel.setScrollValues(viewport.startRes, viewport.startSeq
\r
400 - viewport.endSeq + viewport.startSeq);
\r
404 case KeyEvent.VK_PAGE_DOWN:
\r
405 if (viewport.wrapAlignment)
\r
407 alignPanel.scrollUp(false);
\r
411 alignPanel.setScrollValues(viewport.startRes, viewport.startSeq
\r
412 + viewport.endSeq - viewport.startSeq);
\r
416 case KeyEvent.VK_Z:
\r
417 if (evt.isControlDown())
\r
419 undoMenuItem_actionPerformed();
\r
423 case KeyEvent.VK_Y:
\r
424 if (evt.isControlDown())
\r
426 redoMenuItem_actionPerformed();
\r
430 case KeyEvent.VK_L:
\r
431 if (evt.isControlDown())
\r
433 trimAlignment(true);
\r
437 case KeyEvent.VK_R:
\r
438 if (evt.isControlDown())
\r
440 trimAlignment(false);
\r
444 case KeyEvent.VK_E:
\r
445 if (evt.isControlDown())
\r
447 if (evt.isShiftDown())
\r
449 this.removeAllGapsMenuItem_actionPerformed();
\r
453 removeGappedColumnMenuItem_actionPerformed();
\r
457 case KeyEvent.VK_I:
\r
458 if (evt.isControlDown())
\r
460 if (evt.isAltDown())
\r
462 invertColSel_actionPerformed();
\r
466 invertSequenceMenuItem_actionPerformed();
\r
471 case KeyEvent.VK_U:
\r
472 if (evt.isControlDown())
\r
474 this.deleteGroups_actionPerformed();
\r
478 case KeyEvent.VK_T:
\r
479 if (evt.isControlDown())
\r
486 alignPanel.paintAlignment(true);
\r
490 * called by key handler and the hide all/show all menu items
\r
492 * @param toggleSeqs
\r
493 * @param toggleCols
\r
495 private void toggleHiddenRegions(boolean toggleSeqs, boolean toggleCols)
\r
497 boolean hide = false;
\r
498 SequenceGroup sg = viewport.getSelectionGroup();
\r
499 if (!toggleSeqs && !toggleCols)
\r
501 // Hide everything by the current selection - this is a hack - we do the
\r
502 // invert and then hide
\r
503 // first check that there will be visible columns after the invert.
\r
504 if ((viewport.getColumnSelection() != null && viewport.getColumnSelection().getSelected() != null && viewport.getColumnSelection()
\r
505 .getSelected().size() > 0)
\r
506 || (sg != null && sg.getSize() > 0 && sg.getStartRes() <= sg
\r
509 // now invert the sequence set, if required - empty selection implies
\r
510 // that no hiding is required.
\r
513 invertSequenceMenuItem_actionPerformed();
\r
514 sg = viewport.getSelectionGroup();
\r
518 viewport.expandColSelection(sg, true);
\r
519 // finally invert the column selection and get the new sequence
\r
520 // selection and indicate it should be hidden.
\r
521 invertColSel_actionPerformed();
\r
528 if (sg != null && sg.getSize() != viewport.getAlignment().getHeight())
\r
531 viewport.hideAllSelectedSeqs();
\r
533 else if (!(toggleCols && viewport.getColumnSelection().getSelected().size() > 0))
\r
535 viewport.showAllHiddenSeqs();
\r
541 if (viewport.getColumnSelection().getSelected().size() > 0)
\r
543 viewport.hideSelectedColumns();
\r
546 viewport.setSelectionGroup(sg);
\r
551 viewport.showAllHiddenColumns();
\r
556 public void keyReleased(KeyEvent evt)
\r
560 public void keyTyped(KeyEvent evt)
\r
564 public void itemStateChanged(ItemEvent evt)
\r
566 if (evt.getSource() == displayNonconservedMenuItem)
\r
568 displayNonconservedMenuItem_actionPerformed();
\r
570 else if (evt.getSource() == colourTextMenuItem)
\r
572 colourTextMenuItem_actionPerformed();
\r
574 else if (evt.getSource() == wrapMenuItem)
\r
576 wrapMenuItem_actionPerformed();
\r
578 else if (evt.getSource() == scaleAbove)
\r
580 viewport.setScaleAboveWrapped(scaleAbove.getState());
\r
582 else if (evt.getSource() == scaleLeft)
\r
584 viewport.setScaleLeftWrapped(scaleLeft.getState());
\r
586 else if (evt.getSource() == scaleRight)
\r
588 viewport.setScaleRightWrapped(scaleRight.getState());
\r
590 else if (evt.getSource() == seqLimits)
\r
592 seqLimits_itemStateChanged();
\r
594 else if (evt.getSource() == viewBoxesMenuItem)
\r
596 viewport.setShowBoxes(viewBoxesMenuItem.getState());
\r
598 else if (evt.getSource() == viewTextMenuItem)
\r
600 viewport.setShowText(viewTextMenuItem.getState());
\r
602 else if (evt.getSource() == renderGapsMenuItem)
\r
604 viewport.setRenderGaps(renderGapsMenuItem.getState());
\r
606 else if (evt.getSource() == annotationPanelMenuItem)
\r
608 viewport.setShowAnnotation(annotationPanelMenuItem.getState());
\r
609 alignPanel.setAnnotationVisible(annotationPanelMenuItem.getState());
\r
611 else if (evt.getSource() == sequenceFeatures)
\r
613 viewport.showSequenceFeatures(sequenceFeatures.getState());
\r
614 alignPanel.seqPanel.seqCanvas.repaint();
\r
616 else if (evt.getSource() == conservationMenuItem)
\r
618 conservationMenuItem_actionPerformed();
\r
620 else if (evt.getSource() == abovePIDThreshold)
\r
622 abovePIDThreshold_actionPerformed();
\r
624 else if (evt.getSource() == applyToAllGroups)
\r
626 viewport.setColourAppliesToAllGroups(applyToAllGroups.getState());
\r
628 else if (evt.getSource() == autoCalculate)
\r
630 viewport.autoCalculateConsensus = autoCalculate.getState();
\r
632 else if (evt.getSource() == sortByTree)
\r
634 viewport.sortByTree = sortByTree.getState();
\r
636 else if (evt.getSource() == this.centreColumnLabelFlag)
\r
638 centreColumnLabelFlag_stateChanged();
\r
640 else if (evt.getSource() == this.followMouseOverFlag)
\r
642 mouseOverFlag_stateChanged();
\r
644 else if (evt.getSource() == showGroupConsensus)
\r
646 showGroupConsensus_actionPerformed();
\r
648 else if (evt.getSource() == showGroupConservation)
\r
650 showGroupConservation_actionPerformed();
\r
652 else if (evt.getSource() == showSequenceLogo)
\r
654 showSequenceLogo_actionPerformed();
\r
656 else if (evt.getSource() == showConsensusHistogram)
\r
658 showConsensusHistogram_actionPerformed();
\r
660 else if (evt.getSource() == applyAutoAnnotationSettings)
\r
662 applyAutoAnnotationSettings_actionPerformed();
\r
664 alignPanel.paintAlignment(true);
\r
667 private void mouseOverFlag_stateChanged()
\r
669 viewport.followHighlight = followMouseOverFlag.getState();
\r
670 // TODO: could kick the scrollTo mechanism to reset view for current
\r
674 private void centreColumnLabelFlag_stateChanged()
\r
676 viewport.centreColumnLabels = centreColumnLabelFlag.getState();
\r
677 this.alignPanel.annotationPanel.repaint();
\r
680 public void actionPerformed(ActionEvent evt)
\r
682 Object source = evt.getSource();
\r
684 if (source == inputText)
\r
686 inputText_actionPerformed();
\r
688 else if (source == loadTree)
\r
690 loadTree_actionPerformed();
\r
692 else if (source == loadApplication)
\r
694 launchFullApplication();
\r
696 else if (source == loadAnnotations)
\r
700 else if (source == outputAnnotations)
\r
702 outputAnnotations(true);
\r
704 else if (source == outputFeatures)
\r
706 outputFeatures(true, "Jalview");
\r
708 else if (source == closeMenuItem)
\r
710 closeMenuItem_actionPerformed();
\r
712 else if (source == copy)
\r
714 copy_actionPerformed();
\r
716 else if (source == undoMenuItem)
\r
718 undoMenuItem_actionPerformed();
\r
720 else if (source == redoMenuItem)
\r
722 redoMenuItem_actionPerformed();
\r
724 else if (source == inputText)
\r
726 inputText_actionPerformed();
\r
728 else if (source == closeMenuItem)
\r
730 closeMenuItem_actionPerformed();
\r
732 else if (source == undoMenuItem)
\r
734 undoMenuItem_actionPerformed();
\r
736 else if (source == redoMenuItem)
\r
738 redoMenuItem_actionPerformed();
\r
740 else if (source == copy)
\r
742 copy_actionPerformed();
\r
744 else if (source == pasteNew)
\r
746 pasteNew_actionPerformed();
\r
748 else if (source == pasteThis)
\r
750 pasteThis_actionPerformed();
\r
752 else if (source == cut)
\r
754 cut_actionPerformed();
\r
756 else if (source == delete)
\r
758 delete_actionPerformed();
\r
760 else if (source == grpsFromSelection)
\r
762 makeGrpsFromSelection_actionPerformed();
\r
764 else if (source == deleteGroups)
\r
766 deleteGroups_actionPerformed();
\r
768 else if (source == selectAllSequenceMenuItem)
\r
770 selectAllSequenceMenuItem_actionPerformed();
\r
772 else if (source == deselectAllSequenceMenuItem)
\r
774 deselectAllSequenceMenuItem_actionPerformed();
\r
776 else if (source == invertSequenceMenuItem)
\r
778 invertSequenceMenuItem_actionPerformed();
\r
780 else if (source == invertColSel)
\r
782 viewport.invertColumnSelection();
\r
783 alignPanel.paintAlignment(true);
\r
785 else if (source == remove2LeftMenuItem)
\r
787 trimAlignment(true);
\r
789 else if (source == remove2RightMenuItem)
\r
791 trimAlignment(false);
\r
793 else if (source == removeGappedColumnMenuItem)
\r
795 removeGappedColumnMenuItem_actionPerformed();
\r
797 else if (source == removeAllGapsMenuItem)
\r
799 removeAllGapsMenuItem_actionPerformed();
\r
801 else if (source == findMenuItem)
\r
803 findMenuItem_actionPerformed();
\r
805 else if (source == font)
\r
807 new FontChooser(alignPanel);
\r
809 else if (source == newView)
\r
813 else if (source == showColumns)
\r
815 viewport.showAllHiddenColumns();
\r
816 alignPanel.paintAlignment(true);
\r
818 else if (source == showSeqs)
\r
820 viewport.showAllHiddenSeqs();
\r
821 alignPanel.paintAlignment(true);
\r
823 else if (source == hideColumns)
\r
825 viewport.hideSelectedColumns();
\r
826 alignPanel.paintAlignment(true);
\r
828 else if (source == hideSequences
\r
829 && viewport.getSelectionGroup() != null)
\r
831 viewport.hideAllSelectedSeqs();
\r
832 alignPanel.paintAlignment(true);
\r
834 else if (source == hideAllButSelection)
\r
836 toggleHiddenRegions(false, false);
\r
837 alignPanel.paintAlignment(true);
\r
839 else if (source == hideAllSelection)
\r
841 SequenceGroup sg = viewport.getSelectionGroup();
\r
842 viewport.expandColSelection(sg, false);
\r
843 viewport.hideAllSelectedSeqs();
\r
844 viewport.hideSelectedColumns();
\r
845 alignPanel.paintAlignment(true);
\r
847 else if (source == showAllHidden)
\r
849 viewport.showAllHiddenColumns();
\r
850 viewport.showAllHiddenSeqs();
\r
851 alignPanel.paintAlignment(true);
\r
853 else if (source == showGroupConsensus)
\r
855 showGroupConsensus_actionPerformed();
\r
857 else if (source == showGroupConservation)
\r
859 showGroupConservation_actionPerformed();
\r
861 else if (source == showSequenceLogo)
\r
863 showSequenceLogo_actionPerformed();
\r
865 else if (source == showConsensusHistogram)
\r
867 showConsensusHistogram_actionPerformed();
\r
869 else if (source == applyAutoAnnotationSettings)
\r
871 applyAutoAnnotationSettings_actionPerformed();
\r
873 else if (source == featureSettings)
\r
875 new FeatureSettings(alignPanel);
\r
877 else if (source == alProperties)
\r
879 StringBuffer contents = new jalview.io.AlignmentProperties(
\r
880 viewport.getAlignment()).formatAsString();
\r
881 CutAndPasteTransfer cap = new CutAndPasteTransfer(false, this);
\r
882 cap.setText(contents.toString());
\r
883 Frame frame = new Frame();
\r
885 jalview.bin.JalviewLite.addFrame(frame, "Alignment Properties: "
\r
886 + getTitle(), 400, 250);
\r
888 else if (source == overviewMenuItem)
\r
890 overviewMenuItem_actionPerformed();
\r
892 else if (source == noColourmenuItem)
\r
894 changeColour(null);
\r
896 else if (source == clustalColour)
\r
898 abovePIDThreshold.setState(false);
\r
899 changeColour(new ClustalxColourScheme(
\r
900 viewport.getAlignment().getSequences(),
\r
901 viewport.getAlignment().getWidth()));
\r
903 else if (source == zappoColour)
\r
905 changeColour(new ZappoColourScheme());
\r
907 else if (source == taylorColour)
\r
909 changeColour(new TaylorColourScheme());
\r
911 else if (source == hydrophobicityColour)
\r
913 changeColour(new HydrophobicColourScheme());
\r
915 else if (source == helixColour)
\r
917 changeColour(new HelixColourScheme());
\r
919 else if (source == strandColour)
\r
921 changeColour(new StrandColourScheme());
\r
923 else if (source == turnColour)
\r
925 changeColour(new TurnColourScheme());
\r
927 else if (source == buriedColour)
\r
929 changeColour(new BuriedColourScheme());
\r
931 else if (source == nucleotideColour)
\r
933 changeColour(new NucleotideColourScheme());
\r
935 else if (source == purinePyrimidineColour)
\r
937 changeColour(new PurinePyrimidineColourScheme());
\r
939 else if (source == RNAHelixColour)
\r
941 new RNAHelicesColourChooser(viewport, alignPanel);
\r
943 else if (source == modifyPID)
\r
945 modifyPID_actionPerformed();
\r
947 else if (source == modifyConservation)
\r
949 modifyConservation_actionPerformed();
\r
951 else if (source == userDefinedColour)
\r
953 new UserDefinedColours(alignPanel, null);
\r
955 else if (source == PIDColour)
\r
957 changeColour(new PIDColourScheme());
\r
959 else if (source == BLOSUM62Colour)
\r
961 changeColour(new Blosum62ColourScheme());
\r
963 else if (source == annotationColour)
\r
965 new AnnotationColourChooser(viewport, alignPanel);
\r
967 else if (source == sortPairwiseMenuItem)
\r
969 sortPairwiseMenuItem_actionPerformed();
\r
971 else if (source == sortIDMenuItem)
\r
973 sortIDMenuItem_actionPerformed();
\r
975 else if (source == sortLengthMenuItem)
\r
977 sortLengthMenuItem_actionPerformed();
\r
979 else if (source == sortGroupMenuItem)
\r
981 sortGroupMenuItem_actionPerformed();
\r
983 else if (source == removeRedundancyMenuItem)
\r
985 removeRedundancyMenuItem_actionPerformed();
\r
987 else if (source == pairwiseAlignmentMenuItem)
\r
989 pairwiseAlignmentMenuItem_actionPerformed();
\r
991 else if (source == PCAMenuItem)
\r
993 PCAMenuItem_actionPerformed();
\r
995 else if (source == averageDistanceTreeMenuItem)
\r
997 averageDistanceTreeMenuItem_actionPerformed();
\r
999 else if (source == neighbourTreeMenuItem)
\r
1001 neighbourTreeMenuItem_actionPerformed();
\r
1003 else if (source == njTreeBlosumMenuItem)
\r
1005 njTreeBlosumMenuItem_actionPerformed();
\r
1007 else if (source == avDistanceTreeBlosumMenuItem)
\r
1009 avTreeBlosumMenuItem_actionPerformed();
\r
1011 else if (source == documentation)
\r
1013 documentation_actionPerformed();
\r
1015 else if (source == about)
\r
1017 about_actionPerformed();
\r
1022 public void inputText_actionPerformed()
\r
1024 CutAndPasteTransfer cap = new CutAndPasteTransfer(true, this);
\r
1025 Frame frame = new Frame();
\r
1027 jalview.bin.JalviewLite.addFrame(frame, "Cut & Paste Input", 500, 500);
\r
1030 protected void outputText_actionPerformed(ActionEvent e)
\r
1032 CutAndPasteTransfer cap = new CutAndPasteTransfer(true, this);
\r
1033 Frame frame = new Frame();
\r
1035 jalview.bin.JalviewLite.addFrame(frame,
\r
1036 "Alignment output - " + e.getActionCommand(), 600, 500);
\r
1037 cap.setText(new AppletFormatAdapter().formatSequences(
\r
1038 e.getActionCommand(), viewport.getAlignment(),
\r
1039 viewport.showJVSuffix));
\r
1042 public void loadAnnotations()
\r
1044 CutAndPasteTransfer cap = new CutAndPasteTransfer(true, this);
\r
1045 cap.setText("Paste your features / annotations file here.");
\r
1046 cap.setAnnotationImport();
\r
1047 Frame frame = new Frame();
\r
1049 jalview.bin.JalviewLite.addFrame(frame, "Paste Annotations ", 400, 300);
\r
1053 public String outputAnnotations(boolean displayTextbox)
\r
1055 String annotation = new AnnotationFile().printAnnotations(
\r
1056 viewport.showAnnotation ? viewport.getAlignment()
\r
1057 .getAlignmentAnnotation() : null, viewport.getAlignment()
\r
1059 ((Alignment) viewport.getAlignment()).alignmentProperties);
\r
1061 if (displayTextbox)
\r
1063 CutAndPasteTransfer cap = new CutAndPasteTransfer(false, this);
\r
1064 Frame frame = new Frame();
\r
1066 jalview.bin.JalviewLite.addFrame(frame, "Annotations", 600, 500);
\r
1067 cap.setText(annotation);
\r
1070 return annotation;
\r
1073 private Hashtable getDisplayedFeatureCols()
\r
1075 if (alignPanel.getFeatureRenderer() != null && viewport.featuresDisplayed!=null)
\r
1077 FeatureRenderer fr = alignPanel.getFeatureRenderer();
\r
1078 Hashtable fcols = new Hashtable();
\r
1079 Enumeration en = viewport.featuresDisplayed.keys();
\r
1080 while (en.hasMoreElements())
\r
1082 Object col = en.nextElement();
\r
1083 fcols.put(col, fr.featureColours.get(col));
\r
1090 public String outputFeatures(boolean displayTextbox, String format)
\r
1093 if (format.equalsIgnoreCase("Jalview"))
\r
1095 features = new FeaturesFile().printJalviewFormat(
\r
1096 viewport.getAlignment().getSequencesArray(),
\r
1097 getDisplayedFeatureCols());
\r
1101 features = new FeaturesFile().printGFFFormat(
\r
1102 viewport.getAlignment().getSequencesArray(),
\r
1103 getDisplayedFeatureCols());
\r
1106 if (displayTextbox)
\r
1108 boolean frimport=false;
\r
1109 if (features==null || features.equals("No Features Visible"))
\r
1111 features = "# No features visible - paste some and import them here.";
\r
1115 CutAndPasteTransfer cap = new CutAndPasteTransfer(frimport, this);
\r
1118 cap.setAnnotationImport();
\r
1120 Frame frame = new Frame();
\r
1122 jalview.bin.JalviewLite.addFrame(frame, "Features", 600, 500);
\r
1123 cap.setText(features);
\r
1125 if (features==null)
\r
1132 void launchFullApplication()
\r
1134 StringBuffer url = new StringBuffer(jalviewServletURL);
\r
1136 url.append("?open="
\r
1137 + appendProtocol(viewport.applet.getParameter("file")));
\r
1139 if (viewport.applet.getParameter("features") != null)
\r
1141 url.append("&features=");
\r
1142 url.append(appendProtocol(viewport.applet.getParameter("features")));
\r
1145 if (viewport.applet.getParameter("annotations") != null)
\r
1147 url.append("&annotations=");
\r
1148 url.append(appendProtocol(viewport.applet.getParameter("annotations")));
\r
1151 if (viewport.applet.getParameter("jnetfile") != null)
\r
1153 url.append("&annotations=");
\r
1154 url.append(appendProtocol(viewport.applet.getParameter("jnetfile")));
\r
1157 if (viewport.applet.getParameter("defaultColour") != null)
\r
1159 url.append("&colour="
\r
1160 + removeWhiteSpace(viewport.applet
\r
1161 .getParameter("defaultColour")));
\r
1164 if (viewport.applet.getParameter("userDefinedColour") != null)
\r
1166 url.append("&colour="
\r
1167 + removeWhiteSpace(viewport.applet
\r
1168 .getParameter("userDefinedColour")));
\r
1170 if (viewport.applet.getParameter("tree") != null)
\r
1172 url.append("&tree="
\r
1173 + appendProtocol(viewport.applet.getParameter("tree")));
\r
1175 if (viewport.applet.getParameter("treeFile") != null)
\r
1177 url.append("&tree="
\r
1178 + appendProtocol(viewport.applet.getParameter("treeFile")));
\r
1181 showURL(url.toString(), "FULL_APP");
\r
1184 String removeWhiteSpace(String colour)
\r
1186 StringBuffer sb = new StringBuffer();
\r
1187 for (int i = 0; i < colour.length(); i++)
\r
1189 if (Character.isWhitespace(colour.charAt(i)))
\r
1195 sb.append(colour.charAt(i));
\r
1199 return sb.toString();
\r
1202 String appendProtocol(String url)
\r
1207 url = URLEncoder.encode(url);
\r
1210 * When we finally deprecate 1.1 compatibility, we can start to use
\r
1211 * URLEncoder.encode(url,"UTF-8") and then we'll need this catch: catch
\r
1212 * (UnsupportedEncodingException ex) { System.err.println("WARNING -
\r
1213 * IMPLEMENTATION ERROR - UNSUPPORTED ENCODING EXCEPTION FOR "+url);
\r
1214 * ex.printStackTrace(); }
\r
1216 catch (java.net.MalformedURLException ex)
\r
1218 url = viewport.applet.getCodeBase() + url;
\r
1223 public void closeMenuItem_actionPerformed()
\r
1225 PaintRefresher.RemoveComponent(alignPanel);
\r
1226 PaintRefresher.RemoveComponent(alignPanel.seqPanel.seqCanvas);
\r
1227 PaintRefresher.RemoveComponent(alignPanel.idPanel.idCanvas);
\r
1229 if (PaintRefresher.components.size() == 0 && viewport.applet == null)
\r
1235 alignPanel = null;
\r
1242 void updateEditMenuBar()
\r
1245 if (viewport.historyList.size() > 0)
\r
1247 undoMenuItem.setEnabled(true);
\r
1248 CommandI command = (CommandI) viewport.historyList.peek();
\r
1249 undoMenuItem.setLabel("Undo " + command.getDescription());
\r
1253 undoMenuItem.setEnabled(false);
\r
1254 undoMenuItem.setLabel("Undo");
\r
1257 if (viewport.redoList.size() > 0)
\r
1259 redoMenuItem.setEnabled(true);
\r
1261 CommandI command = (CommandI) viewport.redoList.peek();
\r
1262 redoMenuItem.setLabel("Redo " + command.getDescription());
\r
1266 redoMenuItem.setEnabled(false);
\r
1267 redoMenuItem.setLabel("Redo");
\r
1271 public void addHistoryItem(CommandI command)
\r
1273 if (command.getSize() > 0)
\r
1275 viewport.historyList.push(command);
\r
1276 viewport.redoList.removeAllElements();
\r
1277 updateEditMenuBar();
\r
1278 viewport.updateHiddenColumns();
\r
1288 protected void undoMenuItem_actionPerformed()
\r
1290 if (viewport.historyList.size() < 1)
\r
1295 CommandI command = (CommandI) viewport.historyList.pop();
\r
1296 viewport.redoList.push(command);
\r
1297 command.undoCommand(null);
\r
1299 AlignViewport originalSource = getOriginatingSource(command);
\r
1301 if (originalSource!=viewport) {
\r
1302 System.err.println("Warning: Viewport object mismatch whilst undoing");
\r
1304 originalSource.updateHiddenColumns(); // originalSource.hasHiddenColumns = viewport.getColumnSelection().getHiddenColumns() != null;
\r
1305 updateEditMenuBar();
\r
1306 originalSource.firePropertyChange("alignment", null,
\r
1307 originalSource.getAlignment().getSequences());
\r
1316 protected void redoMenuItem_actionPerformed()
\r
1318 if (viewport.redoList.size() < 1)
\r
1323 CommandI command = (CommandI) viewport.redoList.pop();
\r
1324 viewport.historyList.push(command);
\r
1325 command.doCommand(null);
\r
1327 AlignViewport originalSource = getOriginatingSource(command);
\r
1329 if (originalSource!=viewport) {
\r
1330 System.err.println("Warning: Viewport object mismatch whilst re-doing");
\r
1332 originalSource.updateHiddenColumns(); //sethasHiddenColumns(); = viewport.getColumnSelection().getHiddenColumns() != null;
\r
1334 updateEditMenuBar();
\r
1335 originalSource.firePropertyChange("alignment", null,
\r
1336 originalSource.getAlignment().getSequences());
\r
1339 AlignViewport getOriginatingSource(CommandI command)
\r
1341 AlignViewport originalSource = null;
\r
1342 // For sequence removal and addition, we need to fire
\r
1343 // the property change event FROM the viewport where the
\r
1344 // original alignment was altered
\r
1345 AlignmentI al = null;
\r
1346 if (command instanceof EditCommand)
\r
1348 EditCommand editCommand = (EditCommand) command;
\r
1349 al = editCommand.getAlignment();
\r
1350 Vector comps = (Vector) PaintRefresher.components.get(viewport
\r
1351 .getSequenceSetId());
\r
1352 for (int i = 0; i < comps.size(); i++)
\r
1354 if (comps.elementAt(i) instanceof AlignmentPanel)
\r
1356 if (al == ((AlignmentPanel) comps.elementAt(i)).av.getAlignment())
\r
1358 originalSource = ((AlignmentPanel) comps.elementAt(i)).av;
\r
1365 if (originalSource == null)
\r
1367 // The original view is closed, we must validate
\r
1368 // the current view against the closed view first
\r
1371 PaintRefresher.validateSequences(al, viewport.getAlignment());
\r
1374 originalSource = viewport;
\r
1377 return originalSource;
\r
1380 public void moveSelectedSequences(boolean up)
\r
1382 SequenceGroup sg = viewport.getSelectionGroup();
\r
1390 for (int i = 1; i < viewport.getAlignment().getHeight(); i++)
\r
1392 SequenceI seq = viewport.getAlignment().getSequenceAt(i);
\r
1393 if (!sg.getSequences(null).contains(seq))
\r
1398 SequenceI temp = viewport.getAlignment().getSequenceAt(i - 1);
\r
1399 if (sg.getSequences(null).contains(temp))
\r
1404 viewport.getAlignment().getSequences().setElementAt(temp, i);
\r
1405 viewport.getAlignment().getSequences().setElementAt(seq, i - 1);
\r
1410 for (int i = viewport.getAlignment().getHeight() - 2; i > -1; i--)
\r
1412 SequenceI seq = viewport.getAlignment().getSequenceAt(i);
\r
1413 if (!sg.getSequences(viewport.getHiddenRepSequences()).contains(seq))
\r
1418 SequenceI temp = viewport.getAlignment().getSequenceAt(i + 1);
\r
1419 if (sg.getSequences(viewport.getHiddenRepSequences()).contains(temp))
\r
1424 viewport.getAlignment().getSequences().setElementAt(temp, i);
\r
1425 viewport.getAlignment().getSequences().setElementAt(seq, i + 1);
\r
1429 alignPanel.paintAlignment(true);
\r
1432 synchronized void slideSequences(boolean right, int size)
\r
1434 Vector sg = new Vector();
\r
1435 if (viewport.cursorMode)
\r
1437 sg.addElement(viewport.getAlignment()
\r
1438 .getSequenceAt(alignPanel.seqPanel.seqCanvas.cursorY));
\r
1440 else if (viewport.getSelectionGroup() != null
\r
1441 && viewport.getSelectionGroup().getSize() != viewport.getAlignment()
\r
1444 sg = viewport.getSelectionGroup().getSequences(
\r
1445 viewport.getHiddenRepSequences());
\r
1448 if (sg.size() < 1)
\r
1453 Vector invertGroup = new Vector();
\r
1455 for (int i = 0; i < viewport.getAlignment().getHeight(); i++)
\r
1457 if (!sg.contains(viewport.getAlignment().getSequenceAt(i)))
\r
1458 invertGroup.addElement(viewport.getAlignment().getSequenceAt(i));
\r
1461 SequenceI[] seqs1 = new SequenceI[sg.size()];
\r
1462 for (int i = 0; i < sg.size(); i++)
\r
1463 seqs1[i] = (SequenceI) sg.elementAt(i);
\r
1465 SequenceI[] seqs2 = new SequenceI[invertGroup.size()];
\r
1466 for (int i = 0; i < invertGroup.size(); i++)
\r
1467 seqs2[i] = (SequenceI) invertGroup.elementAt(i);
\r
1469 SlideSequencesCommand ssc;
\r
1471 ssc = new SlideSequencesCommand("Slide Sequences", seqs2, seqs1,
\r
1472 size, viewport.getGapCharacter());
\r
1474 ssc = new SlideSequencesCommand("Slide Sequences", seqs1, seqs2,
\r
1475 size, viewport.getGapCharacter());
\r
1477 int groupAdjustment = 0;
\r
1478 if (ssc.getGapsInsertedBegin() && right)
\r
1480 if (viewport.cursorMode)
\r
1481 alignPanel.seqPanel.moveCursor(size, 0);
\r
1483 groupAdjustment = size;
\r
1485 else if (!ssc.getGapsInsertedBegin() && !right)
\r
1487 if (viewport.cursorMode)
\r
1488 alignPanel.seqPanel.moveCursor(-size, 0);
\r
1490 groupAdjustment = -size;
\r
1493 if (groupAdjustment != 0)
\r
1495 viewport.getSelectionGroup().setStartRes(
\r
1496 viewport.getSelectionGroup().getStartRes() + groupAdjustment);
\r
1497 viewport.getSelectionGroup().setEndRes(
\r
1498 viewport.getSelectionGroup().getEndRes() + groupAdjustment);
\r
1501 boolean appendHistoryItem = false;
\r
1502 if (viewport.historyList != null && viewport.historyList.size() > 0
\r
1503 && viewport.historyList.peek() instanceof SlideSequencesCommand)
\r
1505 appendHistoryItem = ssc
\r
1506 .appendSlideCommand((SlideSequencesCommand) viewport.historyList
\r
1510 if (!appendHistoryItem)
\r
1511 addHistoryItem(ssc);
\r
1516 static StringBuffer copiedSequences;
\r
1518 static Vector copiedHiddenColumns;
\r
1520 protected void copy_actionPerformed()
\r
1522 if (viewport.getSelectionGroup() == null)
\r
1527 SequenceGroup sg = viewport.getSelectionGroup();
\r
1528 copiedSequences = new StringBuffer();
\r
1529 Hashtable orderedSeqs = new Hashtable();
\r
1530 for (int i = 0; i < sg.getSize(); i++)
\r
1532 SequenceI seq = sg.getSequenceAt(i);
\r
1533 int index = viewport.getAlignment().findIndex(seq);
\r
1534 orderedSeqs.put(index + "", seq);
\r
1537 int index = 0, startRes, endRes;
\r
1540 if (viewport.hasHiddenColumns() && viewport.getSelectionGroup() != null)
\r
1542 copiedHiddenColumns = new Vector();
\r
1543 int hiddenOffset = viewport.getSelectionGroup().getStartRes();
\r
1544 for (int i = 0; i < viewport.getColumnSelection().getHiddenColumns()
\r
1547 int[] region = (int[]) viewport.getColumnSelection()
\r
1548 .getHiddenColumns().elementAt(i);
\r
1550 copiedHiddenColumns.addElement(new int[]
\r
1551 { region[0] - hiddenOffset, region[1] - hiddenOffset });
\r
1556 copiedHiddenColumns = null;
\r
1559 for (int i = 0; i < sg.getSize(); i++)
\r
1561 SequenceI seq = null;
\r
1563 while (seq == null)
\r
1565 if (orderedSeqs.containsKey(index + ""))
\r
1567 seq = (SequenceI) orderedSeqs.get(index + "");
\r
1579 // Returns residue following index if gap
\r
1580 startRes = seq.findPosition(sg.getStartRes());
\r
1583 // Need to find the residue preceeding index if gap
\r
1586 for (int j = 0; j < sg.getEndRes() + 1 && j < seq.getLength(); j++)
\r
1588 ch = seq.getCharAt(j);
\r
1589 if (!jalview.util.Comparison.isGap((ch)))
\r
1597 endRes += seq.getStart() - 1;
\r
1600 copiedSequences.append(seq.getName()
\r
1606 + seq.getSequenceAsString(sg.getStartRes(),
\r
1607 sg.getEndRes() + 1) + "\n");
\r
1612 protected void pasteNew_actionPerformed()
\r
1617 protected void pasteThis_actionPerformed()
\r
1622 void paste(boolean newAlignment)
\r
1627 if (copiedSequences == null)
\r
1632 StringTokenizer st = new StringTokenizer(copiedSequences.toString());
\r
1633 Vector seqs = new Vector();
\r
1634 while (st.hasMoreElements())
\r
1636 String name = st.nextToken();
\r
1637 int start = Integer.parseInt(st.nextToken());
\r
1638 int end = Integer.parseInt(st.nextToken());
\r
1639 seqs.addElement(new Sequence(name, st.nextToken(), start, end));
\r
1641 SequenceI[] newSeqs = new SequenceI[seqs.size()];
\r
1642 for (int i = 0; i < seqs.size(); i++)
\r
1644 newSeqs[i] = (SequenceI) seqs.elementAt(i);
\r
1649 String newtitle = new String("Copied sequences");
\r
1650 if (getTitle().startsWith("Copied sequences"))
\r
1652 newtitle = getTitle();
\r
1656 newtitle = newtitle.concat("- from " + getTitle());
\r
1658 AlignFrame af = new AlignFrame(new Alignment(newSeqs),
\r
1659 viewport.applet, newtitle, false);
\r
1660 if (copiedHiddenColumns != null)
\r
1662 for (int i = 0; i < copiedHiddenColumns.size(); i++)
\r
1664 int[] region = (int[]) copiedHiddenColumns.elementAt(i);
\r
1665 af.viewport.hideColumns(region[0], region[1]);
\r
1669 jalview.bin.JalviewLite.addFrame(af, newtitle, DEFAULT_WIDTH,
\r
1674 addSequences(newSeqs);
\r
1677 } catch (Exception ex)
\r
1679 } // could be anything being pasted in here
\r
1683 void addSequences(SequenceI[] seqs)
\r
1685 for (int i = 0; i < seqs.length; i++)
\r
1687 viewport.getAlignment().addSequence(seqs[i]);
\r
1691 addHistoryItem(new EditCommand("Add sequences", EditCommand.PASTE,
\r
1692 seqs, 0, viewport.getAlignment().getWidth(), viewport.getAlignment()));
\r
1694 viewport.setEndSeq(viewport.getAlignment().getHeight());
\r
1695 viewport.getAlignment().getWidth();
\r
1696 viewport.firePropertyChange("alignment", null,
\r
1697 viewport.getAlignment().getSequences());
\r
1701 protected void cut_actionPerformed()
\r
1703 copy_actionPerformed();
\r
1704 delete_actionPerformed();
\r
1707 protected void delete_actionPerformed()
\r
1710 SequenceGroup sg = viewport.getSelectionGroup();
\r
1716 Vector seqs = new Vector();
\r
1718 for (int i = 0; i < sg.getSize(); i++)
\r
1720 seq = sg.getSequenceAt(i);
\r
1721 seqs.addElement(seq);
\r
1724 // If the cut affects all sequences, remove highlighted columns
\r
1725 if (sg.getSize() == viewport.getAlignment().getHeight())
\r
1727 viewport.getColumnSelection().removeElements(sg.getStartRes(),
\r
1728 sg.getEndRes() + 1);
\r
1731 SequenceI[] cut = new SequenceI[seqs.size()];
\r
1732 for (int i = 0; i < seqs.size(); i++)
\r
1734 cut[i] = (SequenceI) seqs.elementAt(i);
\r
1738 * //ADD HISTORY ITEM
\r
1740 addHistoryItem(new EditCommand("Cut Sequences", EditCommand.CUT, cut,
\r
1741 sg.getStartRes(), sg.getEndRes() - sg.getStartRes() + 1,
\r
1742 viewport.getAlignment()));
\r
1744 viewport.setSelectionGroup(null);
\r
1745 viewport.getAlignment().deleteGroup(sg);
\r
1747 viewport.firePropertyChange("alignment", null, viewport.getAlignment()
\r
1750 if (viewport.getAlignment().getHeight() < 1)
\r
1752 this.setVisible(false);
\r
1754 viewport.sendSelection();
\r
1758 * group consensus toggled
\r
1761 protected void showGroupConsensus_actionPerformed()
\r
1763 viewport.setShowGroupConsensus(showGroupConsensus.getState());
\r
1764 alignPanel.updateAnnotation(applyAutoAnnotationSettings.getState());
\r
1769 * group conservation toggled.
\r
1771 protected void showGroupConservation_actionPerformed()
\r
1773 viewport.setShowGroupConservation(showGroupConservation.getState());
\r
1774 alignPanel.updateAnnotation(applyAutoAnnotationSettings.getState());
\r
1781 * jalview.jbgui.GAlignFrame#showConsensusHistogram_actionPerformed(java.awt
\r
1782 * .event.ActionEvent)
\r
1784 protected void showConsensusHistogram_actionPerformed()
\r
1786 viewport.setShowConsensusHistogram(showConsensusHistogram.getState());
\r
1787 alignPanel.updateAnnotation(applyAutoAnnotationSettings.getState());
\r
1793 * jalview.jbgui.GAlignFrame#showConsensusProfile_actionPerformed(java.awt
\r
1794 * .event.ActionEvent)
\r
1796 protected void showSequenceLogo_actionPerformed()
\r
1798 viewport.setShowSequenceLogo(showSequenceLogo.getState());
\r
1799 alignPanel.updateAnnotation(applyAutoAnnotationSettings.getState());
\r
1802 protected void applyAutoAnnotationSettings_actionPerformed()
\r
1804 alignPanel.updateAnnotation(applyAutoAnnotationSettings.getState());
\r
1807 protected void makeGrpsFromSelection_actionPerformed()
\r
1809 if (viewport.getSelectionGroup() != null)
\r
1811 SequenceGroup[] gps = jalview.analysis.Grouping.makeGroupsFrom(
\r
1812 viewport.getSequenceSelection(),
\r
1813 viewport.getAlignmentView(true).getSequenceStrings(
\r
1814 viewport.getGapCharacter()),
\r
1815 viewport.getAlignment().getGroups());
\r
1816 viewport.getAlignment().deleteAllGroups();
\r
1817 viewport.sequenceColours = null;
\r
1818 viewport.setSelectionGroup(null);
\r
1819 // set view properties for each group
\r
1820 for (int g = 0; g < gps.length; g++)
\r
1822 // gps[g].setShowunconserved(viewport.getShowUnconserved());
\r
1823 gps[g].setshowSequenceLogo(viewport.isShowSequenceLogo());
\r
1824 viewport.getAlignment().addGroup(gps[g]);
\r
1825 Color col = new Color((int) (Math.random() * 255),
\r
1826 (int) (Math.random() * 255), (int) (Math.random() * 255));
\r
1827 col = col.brighter();
\r
1828 for (Enumeration sq = gps[g].getSequences(null).elements(); sq
\r
1829 .hasMoreElements(); viewport.setSequenceColour(
\r
1830 (SequenceI) sq.nextElement(), col))
\r
1833 PaintRefresher.Refresh(this, viewport.getSequenceSetId());
\r
1834 alignPanel.updateAnnotation();
\r
1835 alignPanel.paintAlignment(true);
\r
1839 protected void deleteGroups_actionPerformed()
\r
1841 viewport.getAlignment().deleteAllGroups();
\r
1842 viewport.sequenceColours = null;
\r
1843 viewport.setSelectionGroup(null);
\r
1845 alignPanel.paintAlignment(true);
\r
1848 public void selectAllSequenceMenuItem_actionPerformed()
\r
1850 SequenceGroup sg = new SequenceGroup();
\r
1851 for (int i = 0; i < viewport.getAlignment().getSequences().size(); i++)
\r
1853 sg.addSequence(viewport.getAlignment().getSequenceAt(i), false);
\r
1855 sg.setEndRes(viewport.getAlignment().getWidth() - 1);
\r
1856 viewport.setSelectionGroup(sg);
\r
1857 alignPanel.paintAlignment(true);
\r
1858 PaintRefresher.Refresh(alignPanel, viewport.getSequenceSetId());
\r
1859 viewport.sendSelection();
\r
1862 public void deselectAllSequenceMenuItem_actionPerformed()
\r
1864 if (viewport.cursorMode)
\r
1866 alignPanel.seqPanel.keyboardNo1 = null;
\r
1867 alignPanel.seqPanel.keyboardNo2 = null;
\r
1869 viewport.setSelectionGroup(null);
\r
1870 viewport.getColumnSelection().clear();
\r
1871 viewport.setSelectionGroup(null);
\r
1872 alignPanel.idPanel.idCanvas.searchResults = null;
\r
1873 alignPanel.seqPanel.seqCanvas.highlightSearchResults(null);
\r
1874 alignPanel.paintAlignment(true);
\r
1875 PaintRefresher.Refresh(alignPanel, viewport.getSequenceSetId());
\r
1876 viewport.sendSelection();
\r
1879 public void invertSequenceMenuItem_actionPerformed()
\r
1881 SequenceGroup sg = viewport.getSelectionGroup();
\r
1882 for (int i = 0; i < viewport.getAlignment().getSequences().size(); i++)
\r
1884 sg.addOrRemove(viewport.getAlignment().getSequenceAt(i), false);
\r
1887 PaintRefresher.Refresh(alignPanel, viewport.getSequenceSetId());
\r
1888 viewport.sendSelection();
\r
1891 public void invertColSel_actionPerformed()
\r
1893 viewport.invertColumnSelection();
\r
1894 alignPanel.paintAlignment(true);
\r
1895 PaintRefresher.Refresh(alignPanel, viewport.getSequenceSetId());
\r
1896 viewport.sendSelection();
\r
1899 void trimAlignment(boolean trimLeft)
\r
1901 ColumnSelection colSel = viewport.getColumnSelection();
\r
1904 if (colSel.size() > 0)
\r
1908 column = colSel.getMin();
\r
1912 column = colSel.getMax();
\r
1916 if (viewport.getSelectionGroup() != null)
\r
1918 seqs = viewport.getSelectionGroup().getSequencesAsArray(
\r
1919 viewport.getHiddenRepSequences());
\r
1923 seqs = viewport.getAlignment().getSequencesArray();
\r
1926 TrimRegionCommand trimRegion;
\r
1929 trimRegion = new TrimRegionCommand("Remove Left",
\r
1930 TrimRegionCommand.TRIM_LEFT, seqs, column,
\r
1931 viewport.getAlignment(), viewport.getColumnSelection(),
\r
1932 viewport.getSelectionGroup());
\r
1933 viewport.setStartRes(0);
\r
1937 trimRegion = new TrimRegionCommand("Remove Right",
\r
1938 TrimRegionCommand.TRIM_RIGHT, seqs, column,
\r
1939 viewport.getAlignment(), viewport.getColumnSelection(),
\r
1940 viewport.getSelectionGroup());
\r
1943 statusBar.setText("Removed " + trimRegion.getSize() + " columns.");
\r
1945 addHistoryItem(trimRegion);
\r
1947 Vector groups = viewport.getAlignment().getGroups();
\r
1949 for (int i = 0; i < groups.size(); i++)
\r
1951 SequenceGroup sg = (SequenceGroup) groups.elementAt(i);
\r
1953 if ((trimLeft && !sg.adjustForRemoveLeft(column))
\r
1954 || (!trimLeft && !sg.adjustForRemoveRight(column)))
\r
1956 viewport.getAlignment().deleteGroup(sg);
\r
1960 viewport.firePropertyChange("alignment", null, viewport
\r
1961 .getAlignment().getSequences());
\r
1965 public void removeGappedColumnMenuItem_actionPerformed()
\r
1967 int start = 0, end = viewport.getAlignment().getWidth() - 1;
\r
1970 if (viewport.getSelectionGroup() != null)
\r
1972 seqs = viewport.getSelectionGroup().getSequencesAsArray(
\r
1973 viewport.getHiddenRepSequences());
\r
1974 start = viewport.getSelectionGroup().getStartRes();
\r
1975 end = viewport.getSelectionGroup().getEndRes();
\r
1979 seqs = viewport.getAlignment().getSequencesArray();
\r
1982 RemoveGapColCommand removeGapCols = new RemoveGapColCommand(
\r
1983 "Remove Gapped Columns", seqs, start, end, viewport.getAlignment());
\r
1985 addHistoryItem(removeGapCols);
\r
1987 statusBar.setText("Removed " + removeGapCols.getSize()
\r
1988 + " empty columns.");
\r
1990 // This is to maintain viewport position on first residue
\r
1991 // of first sequence
\r
1992 SequenceI seq = viewport.getAlignment().getSequenceAt(0);
\r
1993 int startRes = seq.findPosition(viewport.startRes);
\r
1994 // ShiftList shifts;
\r
1995 // viewport.getAlignment().removeGaps(shifts=new ShiftList());
\r
1996 // edit.alColumnChanges=shifts.getInverse();
\r
1997 // if (viewport.hasHiddenColumns)
\r
1998 // viewport.getColumnSelection().compensateForEdits(shifts);
\r
1999 viewport.setStartRes(seq.findIndex(startRes) - 1);
\r
2000 viewport.firePropertyChange("alignment", null, viewport.getAlignment()
\r
2005 public void removeAllGapsMenuItem_actionPerformed()
\r
2007 int start = 0, end = viewport.getAlignment().getWidth() - 1;
\r
2010 if (viewport.getSelectionGroup() != null)
\r
2012 seqs = viewport.getSelectionGroup().getSequencesAsArray(
\r
2013 viewport.getHiddenRepSequences());
\r
2014 start = viewport.getSelectionGroup().getStartRes();
\r
2015 end = viewport.getSelectionGroup().getEndRes();
\r
2019 seqs = viewport.getAlignment().getSequencesArray();
\r
2022 // This is to maintain viewport position on first residue
\r
2023 // of first sequence
\r
2024 SequenceI seq = viewport.getAlignment().getSequenceAt(0);
\r
2025 int startRes = seq.findPosition(viewport.startRes);
\r
2027 addHistoryItem(new RemoveGapsCommand("Remove Gaps", seqs, start, end,
\r
2028 viewport.getAlignment()));
\r
2030 viewport.setStartRes(seq.findIndex(startRes) - 1);
\r
2032 viewport.firePropertyChange("alignment", null, viewport.getAlignment()
\r
2037 public void findMenuItem_actionPerformed()
\r
2039 new Finder(alignPanel);
\r
2043 * create a new view derived from the current view
\r
2045 * @param viewtitle
\r
2046 * @return frame for the new view
\r
2048 public AlignFrame newView(String viewtitle)
\r
2051 if (viewport.hasHiddenRows())
\r
2053 newal = new Alignment(viewport.getAlignment().getHiddenSequences()
\r
2054 .getFullAlignment().getSequencesArray());
\r
2058 newal = new Alignment(viewport.getAlignment().getSequencesArray());
\r
2061 if (viewport.getAlignment().getAlignmentAnnotation() != null)
\r
2063 for (int i = 0; i < viewport.getAlignment().getAlignmentAnnotation().length; i++)
\r
2065 if (!viewport.getAlignment().getAlignmentAnnotation()[i].autoCalculated)
\r
2067 newal.addAnnotation(viewport.getAlignment().getAlignmentAnnotation()[i]);
\r
2072 AlignFrame newaf = new AlignFrame(newal, viewport.applet, "", false);
\r
2074 newaf.viewport.setSequenceSetId(alignPanel.av.getSequenceSetId());
\r
2075 PaintRefresher.Register(alignPanel, alignPanel.av.getSequenceSetId());
\r
2076 PaintRefresher.Register(newaf.alignPanel,
\r
2077 newaf.alignPanel.av.getSequenceSetId());
\r
2079 PaintRefresher.Register(newaf.alignPanel.idPanel.idCanvas,
\r
2080 newaf.alignPanel.av.getSequenceSetId());
\r
2081 PaintRefresher.Register(newaf.alignPanel.seqPanel.seqCanvas,
\r
2082 newaf.alignPanel.av.getSequenceSetId());
\r
2084 Vector comps = (Vector) PaintRefresher.components.get(viewport
\r
2085 .getSequenceSetId());
\r
2086 int viewSize = -1;
\r
2087 for (int i = 0; i < comps.size(); i++)
\r
2089 if (comps.elementAt(i) instanceof AlignmentPanel)
\r
2095 String title = new String(this.getTitle());
\r
2096 if (viewtitle != null)
\r
2098 title = viewtitle + " ( " + title + ")";
\r
2102 if (title.indexOf("(View") > -1)
\r
2104 title = title.substring(0, title.indexOf("(View"));
\r
2106 title += "(View " + viewSize + ")";
\r
2109 newaf.setTitle(title.toString());
\r
2111 newaf.viewport.historyList = viewport.historyList;
\r
2112 newaf.viewport.redoList = viewport.redoList;
\r
2118 * @return list of feature groups on the view
\r
2120 public String[] getFeatureGroups()
\r
2122 FeatureRenderer fr = null;
\r
2123 if (alignPanel != null
\r
2124 && (fr = alignPanel.getFeatureRenderer()) != null)
\r
2126 return fr.getGroups();
\r
2132 * get sequence feature groups that are hidden or shown
\r
2138 public String[] getFeatureGroupsOfState(boolean visible)
\r
2140 FeatureRenderer fr = null;
\r
2141 if (alignPanel != null
\r
2142 && (fr = alignPanel.getFeatureRenderer()) != null)
\r
2144 return fr.getGroups(visible);
\r
2150 * Change the display state for the given feature groups
\r
2153 * list of group strings
\r
2155 * visible or invisible
\r
2157 public void setFeatureGroupState(String[] groups, boolean state)
\r
2159 FeatureRenderer fr = null;
\r
2160 this.sequenceFeatures.setState(true);
\r
2161 viewport.showSequenceFeatures(true);
\r
2162 if (alignPanel != null
\r
2163 && (fr = alignPanel.getFeatureRenderer()) != null)
\r
2165 fr.setGroupState(groups, state);
\r
2166 alignPanel.seqPanel.seqCanvas.repaint();
\r
2167 if (alignPanel.overviewPanel != null)
\r
2169 alignPanel.overviewPanel.updateOverviewImage();
\r
2174 public void seqLimits_itemStateChanged()
\r
2176 viewport.setShowJVSuffix(seqLimits.getState());
\r
2177 alignPanel.fontChanged();
\r
2178 alignPanel.paintAlignment(true);
\r
2181 protected void colourTextMenuItem_actionPerformed()
\r
2183 viewport.setColourText(colourTextMenuItem.getState());
\r
2184 alignPanel.paintAlignment(true);
\r
2187 protected void displayNonconservedMenuItem_actionPerformed()
\r
2189 viewport.setShowunconserved(displayNonconservedMenuItem.getState());
\r
2190 alignPanel.paintAlignment(true);
\r
2193 protected void wrapMenuItem_actionPerformed()
\r
2195 viewport.setWrapAlignment(wrapMenuItem.getState());
\r
2196 alignPanel.setWrapAlignment(wrapMenuItem.getState());
\r
2197 scaleAbove.setEnabled(wrapMenuItem.getState());
\r
2198 scaleLeft.setEnabled(wrapMenuItem.getState());
\r
2199 scaleRight.setEnabled(wrapMenuItem.getState());
\r
2200 alignPanel.paintAlignment(true);
\r
2203 public void overviewMenuItem_actionPerformed()
\r
2205 if (alignPanel.overviewPanel != null)
\r
2210 Frame frame = new Frame();
\r
2211 OverviewPanel overview = new OverviewPanel(alignPanel);
\r
2212 frame.add(overview);
\r
2213 // +50 must allow for applet frame window
\r
2214 jalview.bin.JalviewLite.addFrame(frame, "Overview " + this.getTitle(),
\r
2215 overview.getPreferredSize().width,
\r
2216 overview.getPreferredSize().height + 50);
\r
2219 frame.addWindowListener(new WindowAdapter()
\r
2221 public void windowClosing(WindowEvent e)
\r
2223 alignPanel.setOverviewPanel(null);
\r
2227 alignPanel.setOverviewPanel(overview);
\r
2231 void changeColour(ColourSchemeI cs)
\r
2233 int threshold = 0;
\r
2237 if (viewport.getAbovePIDThreshold())
\r
2239 threshold = SliderPanel.setPIDSliderSource(alignPanel, cs,
\r
2242 cs.setThreshold(threshold, viewport.getIgnoreGapsConsensus());
\r
2244 viewport.setGlobalColourScheme(cs);
\r
2248 cs.setThreshold(0, viewport.getIgnoreGapsConsensus());
\r
2251 if (viewport.getConservationSelected())
\r
2254 Alignment al = (Alignment) viewport.getAlignment();
\r
2255 Conservation c = new Conservation("All",
\r
2256 ResidueProperties.propHash, 3, al.getSequences(), 0,
\r
2257 al.getWidth() - 1);
\r
2260 c.verdict(false, viewport.getConsPercGaps());
\r
2262 cs.setConservation(c);
\r
2264 cs.setConservationInc(SliderPanel.setConservationSlider(alignPanel,
\r
2265 cs, "Background"));
\r
2270 cs.setConservation(null);
\r
2273 cs.setConsensus(viewport.getSequenceConsensusHash());
\r
2276 viewport.setGlobalColourScheme(cs);
\r
2278 if (viewport.getColourAppliesToAllGroups())
\r
2280 Vector groups = viewport.getAlignment().getGroups();
\r
2281 for (int i = 0; i < groups.size(); i++)
\r
2283 SequenceGroup sg = (SequenceGroup) groups.elementAt(i);
\r
2290 if (cs instanceof ClustalxColourScheme)
\r
2292 sg.cs = new ClustalxColourScheme(
\r
2293 sg.getSequences(viewport.getHiddenRepSequences()),
\r
2300 sg.cs = (ColourSchemeI) cs.getClass().newInstance();
\r
2301 } catch (Exception ex)
\r
2303 ex.printStackTrace();
\r
2308 if (viewport.getAbovePIDThreshold()
\r
2309 || cs instanceof PIDColourScheme
\r
2310 || cs instanceof Blosum62ColourScheme)
\r
2312 sg.cs.setThreshold(threshold, viewport.getIgnoreGapsConsensus());
\r
2313 sg.cs.setConsensus(AAFrequency.calculate(
\r
2314 sg.getSequences(viewport.getHiddenRepSequences()), 0,
\r
2319 sg.cs.setThreshold(0, viewport.getIgnoreGapsConsensus());
\r
2322 if (viewport.getConservationSelected())
\r
2324 Conservation c = new Conservation("Group",
\r
2325 ResidueProperties.propHash, 3,
\r
2326 sg.getSequences(viewport.getHiddenRepSequences()), 0,
\r
2327 viewport.getAlignment().getWidth() - 1);
\r
2329 c.verdict(false, viewport.getConsPercGaps());
\r
2330 sg.cs.setConservation(c);
\r
2334 sg.cs.setConservation(null);
\r
2335 sg.cs.setThreshold(0, viewport.getIgnoreGapsConsensus());
\r
2341 if (alignPanel.getOverviewPanel() != null)
\r
2343 alignPanel.getOverviewPanel().updateOverviewImage();
\r
2346 jalview.structure.StructureSelectionManager
\r
2347 .getStructureSelectionManager(viewport.applet).sequenceColoursChanged(
\r
2350 alignPanel.paintAlignment(true);
\r
2353 protected void modifyPID_actionPerformed()
\r
2355 if (viewport.getAbovePIDThreshold()
\r
2356 && viewport.getGlobalColourScheme() != null)
\r
2358 SliderPanel.setPIDSliderSource(alignPanel,
\r
2359 viewport.getGlobalColourScheme(), "Background");
\r
2360 SliderPanel.showPIDSlider();
\r
2364 protected void modifyConservation_actionPerformed()
\r
2366 if (viewport.getConservationSelected()
\r
2367 && viewport.getGlobalColourScheme() != null)
\r
2369 SliderPanel.setConservationSlider(alignPanel,
\r
2370 viewport.getGlobalColourScheme(), "Background");
\r
2371 SliderPanel.showConservationSlider();
\r
2375 protected void conservationMenuItem_actionPerformed()
\r
2377 viewport.setConservationSelected(conservationMenuItem.getState());
\r
2379 viewport.setAbovePIDThreshold(false);
\r
2380 abovePIDThreshold.setState(false);
\r
2382 changeColour(viewport.getGlobalColourScheme());
\r
2384 modifyConservation_actionPerformed();
\r
2387 public void abovePIDThreshold_actionPerformed()
\r
2389 viewport.setAbovePIDThreshold(abovePIDThreshold.getState());
\r
2391 conservationMenuItem.setState(false);
\r
2392 viewport.setConservationSelected(false);
\r
2394 changeColour(viewport.getGlobalColourScheme());
\r
2396 modifyPID_actionPerformed();
\r
2399 public void sortPairwiseMenuItem_actionPerformed()
\r
2401 SequenceI[] oldOrder = viewport.getAlignment().getSequencesArray();
\r
2402 AlignmentSorter.sortByPID(viewport.getAlignment(), viewport
\r
2403 .getAlignment().getSequenceAt(0), null);
\r
2405 addHistoryItem(new OrderCommand("Pairwise Sort", oldOrder,
\r
2406 viewport.getAlignment()));
\r
2407 alignPanel.paintAlignment(true);
\r
2410 public void sortIDMenuItem_actionPerformed()
\r
2412 SequenceI[] oldOrder = viewport.getAlignment().getSequencesArray();
\r
2413 AlignmentSorter.sortByID(viewport.getAlignment());
\r
2414 addHistoryItem(new OrderCommand("ID Sort", oldOrder, viewport.getAlignment()));
\r
2415 alignPanel.paintAlignment(true);
\r
2418 public void sortLengthMenuItem_actionPerformed()
\r
2420 SequenceI[] oldOrder = viewport.getAlignment().getSequencesArray();
\r
2421 AlignmentSorter.sortByLength(viewport.getAlignment());
\r
2422 addHistoryItem(new OrderCommand("Length Sort", oldOrder,
\r
2423 viewport.getAlignment()));
\r
2424 alignPanel.paintAlignment(true);
\r
2427 public void sortGroupMenuItem_actionPerformed()
\r
2429 SequenceI[] oldOrder = viewport.getAlignment().getSequencesArray();
\r
2430 AlignmentSorter.sortByGroup(viewport.getAlignment());
\r
2431 addHistoryItem(new OrderCommand("Group Sort", oldOrder,
\r
2432 viewport.getAlignment()));
\r
2433 alignPanel.paintAlignment(true);
\r
2437 public void removeRedundancyMenuItem_actionPerformed()
\r
2439 new RedundancyPanel(alignPanel);
\r
2442 public void pairwiseAlignmentMenuItem_actionPerformed()
\r
2444 if (viewport.getSelectionGroup() != null
\r
2445 && viewport.getSelectionGroup().getSize() > 1)
\r
2447 Frame frame = new Frame();
\r
2448 frame.add(new PairwiseAlignPanel(alignPanel));
\r
2449 jalview.bin.JalviewLite.addFrame(frame, "Pairwise Alignment", 600,
\r
2454 public void PCAMenuItem_actionPerformed()
\r
2456 // are the sequences aligned?
\r
2457 if (!viewport.getAlignment().isAligned(false))
\r
2459 SequenceI current;
\r
2460 int Width = viewport.getAlignment().getWidth();
\r
2462 for (int i = 0; i < viewport.getAlignment().getSequences().size(); i++)
\r
2464 current = viewport.getAlignment().getSequenceAt(i);
\r
2466 if (current.getLength() < Width)
\r
2468 current.insertCharAt(Width - 1, viewport.getGapCharacter());
\r
2471 alignPanel.paintAlignment(true);
\r
2474 if ((viewport.getSelectionGroup() != null
\r
2475 && viewport.getSelectionGroup().getSize() < 4 && viewport
\r
2476 .getSelectionGroup().getSize() > 0)
\r
2477 || viewport.getAlignment().getHeight() < 4)
\r
2484 new PCAPanel(viewport);
\r
2485 } catch (java.lang.OutOfMemoryError ex)
\r
2491 public void averageDistanceTreeMenuItem_actionPerformed()
\r
2493 NewTreePanel("AV", "PID", "Average distance tree using PID");
\r
2496 public void neighbourTreeMenuItem_actionPerformed()
\r
2498 NewTreePanel("NJ", "PID", "Neighbour joining tree using PID");
\r
2501 protected void njTreeBlosumMenuItem_actionPerformed()
\r
2503 NewTreePanel("NJ", "BL", "Neighbour joining tree using BLOSUM62");
\r
2506 protected void avTreeBlosumMenuItem_actionPerformed()
\r
2508 NewTreePanel("AV", "BL", "Average distance tree using BLOSUM62");
\r
2511 void NewTreePanel(String type, String pwType, String title)
\r
2513 // are the sequences aligned?
\r
2514 if (!viewport.getAlignment().isAligned(false))
\r
2516 SequenceI current;
\r
2517 int Width = viewport.getAlignment().getWidth();
\r
2519 for (int i = 0; i < viewport.getAlignment().getSequences().size(); i++)
\r
2521 current = viewport.getAlignment().getSequenceAt(i);
\r
2523 if (current.getLength() < Width)
\r
2525 current.insertCharAt(Width - 1, viewport.getGapCharacter());
\r
2528 alignPanel.paintAlignment(true);
\r
2532 if ((viewport.getSelectionGroup() != null && viewport
\r
2533 .getSelectionGroup().getSize() > 1)
\r
2534 || (viewport.getSelectionGroup() == null && viewport.getAlignment()
\r
2535 .getHeight() > 1))
\r
2537 final TreePanel tp = new TreePanel(alignPanel, type, pwType);
\r
2539 addTreeMenuItem(tp, title);
\r
2541 jalview.bin.JalviewLite.addFrame(tp, title, 600, 500);
\r
2545 void loadTree_actionPerformed()
\r
2547 CutAndPasteTransfer cap = new CutAndPasteTransfer(true, this);
\r
2548 cap.setText("Paste your Newick tree file here.");
\r
2549 cap.setTreeImport();
\r
2550 Frame frame = new Frame();
\r
2552 jalview.bin.JalviewLite.addFrame(frame, "Paste Newick file ", 400, 300);
\r
2555 public void loadTree(jalview.io.NewickFile tree, String treeFile)
\r
2557 TreePanel tp = new TreePanel(alignPanel, treeFile, "From File - ", tree);
\r
2558 jalview.bin.JalviewLite.addFrame(tp, treeFile, 600, 500);
\r
2559 addTreeMenuItem(tp, treeFile);
\r
2563 * sort the alignment using the given treePanel
\r
2565 * @param treePanel
\r
2566 * tree used to sort view
\r
2568 * string used for undo event name
\r
2570 public void sortByTree(TreePanel treePanel, String title)
\r
2572 SequenceI[] oldOrder = viewport.getAlignment().getSequencesArray();
\r
2574 .sortByTree(viewport.getAlignment(), treePanel.getTree());
\r
2575 // addHistoryItem(new HistoryItem("Sort", viewport.alignment,
\r
2576 // HistoryItem.SORT));
\r
2577 addHistoryItem(new OrderCommand("Order by " + title, oldOrder,
\r
2578 viewport.getAlignment()));
\r
2579 alignPanel.paintAlignment(true);
\r
2583 * Do any automatic reordering of the alignment and add the necessary bits to
\r
2584 * the menu structure for the new tree
\r
2586 * @param treePanel
\r
2589 protected void addTreeMenuItem(final TreePanel treePanel,
\r
2590 final String title)
\r
2592 final MenuItem item = new MenuItem(title);
\r
2593 sortByTreeMenu.add(item);
\r
2594 item.addActionListener(new java.awt.event.ActionListener()
\r
2596 public void actionPerformed(ActionEvent evt)
\r
2598 sortByTree(treePanel, title); // treePanel.getTitle());
\r
2602 treePanel.addWindowListener(new WindowAdapter()
\r
2604 public void windowOpened(WindowEvent e)
\r
2606 if (viewport.sortByTree)
\r
2608 sortByTree(treePanel, title);
\r
2610 super.windowOpened(e);
\r
2613 public void windowClosing(WindowEvent e)
\r
2615 sortByTreeMenu.remove(item);
\r
2619 public boolean sortBy(AlignmentOrder alorder, String undoname)
\r
2621 SequenceI[] oldOrder = viewport.getAlignment()
\r
2622 .getSequencesArray();
\r
2623 if (viewport.applet.debug)
\r
2625 System.err.println("Sorting "+alorder.getOrder().size()+" in alignment '"+getTitle()+"'");
\r
2627 AlignmentSorter.sortBy(viewport.getAlignment(), alorder);
\r
2628 if (undoname!=null)
\r
2630 addHistoryItem(new OrderCommand(undoname, oldOrder, viewport.getAlignment()));
\r
2632 alignPanel.paintAlignment(true);
\r
2636 protected void documentation_actionPerformed()
\r
2638 alignPanel.av.applet.openJalviewHelpUrl();
\r
2641 protected void about_actionPerformed()
\r
2644 class AboutPanel extends Canvas
\r
2650 public AboutPanel(String version, String builddate)
\r
2652 this.version = version;
\r
2653 this.builddate = builddate;
\r
2656 public void paint(Graphics g)
\r
2658 g.setColor(Color.white);
\r
2659 g.fillRect(0, 0, getSize().width, getSize().height);
\r
2660 g.setFont(new Font("Helvetica", Font.PLAIN, 12));
\r
2661 FontMetrics fm = g.getFontMetrics();
\r
2662 int fh = fm.getHeight();
\r
2664 g.setColor(Color.black);
\r
2665 // TODO: update this text for each release or centrally store it for
\r
2666 // lite and application
\r
2667 g.setFont(new Font("Helvetica", Font.BOLD, 14));
\r
2668 g.drawString("JalviewLite - Release " + version, x, y += fh);
\r
2669 g.setFont(new Font("Helvetica", Font.BOLD, 12));
\r
2670 g.drawString("Build date: " + builddate, x, y += fh);
\r
2671 g.setFont(new Font("Helvetica", Font.PLAIN, 12));
\r
2673 "Authors: Jim Procter, Andrew Waterhouse, Michele Clamp, James Cuff, Steve Searle,",
\r
2674 x, y += fh * 1.5);
\r
2675 g.drawString("David Martin & Geoff Barton.", x + 50, y += fh);
\r
2677 "Development managed by The Barton Group, University of Dundee, Scotland, UK.",
\r
2680 "For help, see the FAQ at www.jalview.org and/or join the jalview-discuss@jalview.org mailing list",
\r
2682 g.drawString("If you use Jalview, please cite:", x, y += fh + 8);
\r
2684 "Waterhouse, A.M., Procter, J.B., Martin, D.M.A, Clamp, M. and Barton, G. J. (2009)",
\r
2687 "Jalview Version 2 - a multiple sequence alignment editor and analysis workbench",
\r
2689 g.drawString("Bioinformatics doi: 10.1093/bioinformatics/btp033",
\r
2694 Frame frame = new Frame();
\r
2695 frame.add(new AboutPanel(JalviewLite.getVersion(), JalviewLite
\r
2696 .getBuildDate()));
\r
2697 jalview.bin.JalviewLite.addFrame(frame, "Jalview", 580, 220);
\r
2701 public void showURL(String url, String target)
\r
2703 if (viewport.applet == null)
\r
2705 System.out.println("Not running as applet - no browser available.");
\r
2709 viewport.applet.showURL(url, target);
\r
2713 // ////////////////////////////////////////////////////////////////////////////////
\r
2714 // JBuilder Graphics here
\r
2716 MenuBar alignFrameMenuBar = new MenuBar();
\r
2718 Menu fileMenu = new Menu("File");
\r
2720 MenuItem loadApplication = new MenuItem("View in Full Application");
\r
2722 MenuItem loadTree = new MenuItem("Load Associated Tree ...");
\r
2724 MenuItem loadAnnotations = new MenuItem("Load Features/Annotations ...");
\r
2726 MenuItem outputFeatures = new MenuItem("Export Features ...");
\r
2728 MenuItem outputAnnotations = new MenuItem("Export Annotations ...");
\r
2730 MenuItem closeMenuItem = new MenuItem("Close");
\r
2732 Menu editMenu = new Menu("Edit");
\r
2734 Menu viewMenu = new Menu("View");
\r
2736 Menu colourMenu = new Menu("Colour");
\r
2738 Menu calculateMenu = new Menu("Calculate");
\r
2740 MenuItem selectAllSequenceMenuItem = new MenuItem("Select all");
\r
2742 MenuItem deselectAllSequenceMenuItem = new MenuItem("Deselect All");
\r
2744 MenuItem invertSequenceMenuItem = new MenuItem("Invert Selection");
\r
2746 MenuItem remove2LeftMenuItem = new MenuItem();
\r
2748 MenuItem remove2RightMenuItem = new MenuItem();
\r
2750 MenuItem removeGappedColumnMenuItem = new MenuItem();
\r
2752 MenuItem removeAllGapsMenuItem = new MenuItem();
\r
2754 CheckboxMenuItem viewBoxesMenuItem = new CheckboxMenuItem();
\r
2756 CheckboxMenuItem viewTextMenuItem = new CheckboxMenuItem();
\r
2758 MenuItem sortPairwiseMenuItem = new MenuItem();
\r
2760 MenuItem sortIDMenuItem = new MenuItem();
\r
2762 MenuItem sortLengthMenuItem = new MenuItem();
\r
2764 MenuItem sortGroupMenuItem = new MenuItem();
\r
2766 MenuItem removeRedundancyMenuItem = new MenuItem();
\r
2768 MenuItem pairwiseAlignmentMenuItem = new MenuItem();
\r
2770 MenuItem PCAMenuItem = new MenuItem();
\r
2772 MenuItem averageDistanceTreeMenuItem = new MenuItem();
\r
2774 MenuItem neighbourTreeMenuItem = new MenuItem();
\r
2776 BorderLayout borderLayout1 = new BorderLayout();
\r
2778 public Label statusBar = new Label();
\r
2780 Menu outputTextboxMenu = new Menu();
\r
2782 MenuItem clustalColour = new MenuItem();
\r
2784 MenuItem zappoColour = new MenuItem();
\r
2786 MenuItem taylorColour = new MenuItem();
\r
2788 MenuItem hydrophobicityColour = new MenuItem();
\r
2790 MenuItem helixColour = new MenuItem();
\r
2792 MenuItem strandColour = new MenuItem();
\r
2794 MenuItem turnColour = new MenuItem();
\r
2796 MenuItem buriedColour = new MenuItem();
\r
2798 MenuItem purinePyrimidineColour = new MenuItem();
\r
2799 MenuItem RNAHelixColour = new MenuItem();
\r
2801 MenuItem userDefinedColour = new MenuItem();
\r
2803 MenuItem PIDColour = new MenuItem();
\r
2805 MenuItem BLOSUM62Colour = new MenuItem();
\r
2807 MenuItem njTreeBlosumMenuItem = new MenuItem();
\r
2809 MenuItem avDistanceTreeBlosumMenuItem = new MenuItem();
\r
2811 CheckboxMenuItem annotationPanelMenuItem = new CheckboxMenuItem();
\r
2813 CheckboxMenuItem colourTextMenuItem = new CheckboxMenuItem();
\r
2815 CheckboxMenuItem displayNonconservedMenuItem = new CheckboxMenuItem();
\r
2817 MenuItem alProperties = new MenuItem("Alignment Properties...");
\r
2819 MenuItem overviewMenuItem = new MenuItem();
\r
2821 MenuItem undoMenuItem = new MenuItem();
\r
2823 MenuItem redoMenuItem = new MenuItem();
\r
2825 CheckboxMenuItem conservationMenuItem = new CheckboxMenuItem();
\r
2827 MenuItem noColourmenuItem = new MenuItem();
\r
2829 CheckboxMenuItem wrapMenuItem = new CheckboxMenuItem();
\r
2831 CheckboxMenuItem renderGapsMenuItem = new CheckboxMenuItem();
\r
2833 MenuItem findMenuItem = new MenuItem();
\r
2835 CheckboxMenuItem abovePIDThreshold = new CheckboxMenuItem();
\r
2837 MenuItem nucleotideColour = new MenuItem();
\r
2839 MenuItem deleteGroups = new MenuItem();
\r
2841 MenuItem grpsFromSelection = new MenuItem();
\r
2843 MenuItem delete = new MenuItem();
\r
2845 MenuItem copy = new MenuItem();
\r
2847 MenuItem cut = new MenuItem();
\r
2849 Menu pasteMenu = new Menu();
\r
2851 MenuItem pasteNew = new MenuItem();
\r
2853 MenuItem pasteThis = new MenuItem();
\r
2855 CheckboxMenuItem applyToAllGroups = new CheckboxMenuItem();
\r
2857 MenuItem font = new MenuItem();
\r
2859 CheckboxMenuItem scaleAbove = new CheckboxMenuItem();
\r
2861 CheckboxMenuItem scaleLeft = new CheckboxMenuItem();
\r
2863 CheckboxMenuItem scaleRight = new CheckboxMenuItem();
\r
2865 MenuItem modifyPID = new MenuItem();
\r
2867 MenuItem modifyConservation = new MenuItem();
\r
2869 CheckboxMenuItem autoCalculate = new CheckboxMenuItem(
\r
2870 "Autocalculate Consensus", true);
\r
2872 CheckboxMenuItem sortByTree = new CheckboxMenuItem(
\r
2873 "Sort Alignment With New Tree", true);
\r
2875 Menu sortByTreeMenu = new Menu();
\r
2877 Menu sort = new Menu();
\r
2879 Menu calculate = new Menu();
\r
2881 MenuItem inputText = new MenuItem();
\r
2883 Menu helpMenu = new Menu();
\r
2885 MenuItem documentation = new MenuItem();
\r
2887 MenuItem about = new MenuItem();
\r
2889 CheckboxMenuItem seqLimits = new CheckboxMenuItem();
\r
2891 CheckboxMenuItem centreColumnLabelFlag = new CheckboxMenuItem();
\r
2893 CheckboxMenuItem followMouseOverFlag = new CheckboxMenuItem();
\r
2894 Menu autoAnnMenu=new Menu();
\r
2895 CheckboxMenuItem showSequenceLogo= new CheckboxMenuItem();
\r
2896 CheckboxMenuItem applyAutoAnnotationSettings = new CheckboxMenuItem();
\r
2897 CheckboxMenuItem showConsensusHistogram = new CheckboxMenuItem();
\r
2898 CheckboxMenuItem showGroupConsensus = new CheckboxMenuItem();
\r
2899 CheckboxMenuItem showGroupConservation = new CheckboxMenuItem();
\r
2901 private void jbInit() throws Exception
\r
2904 setMenuBar(alignFrameMenuBar);
\r
2908 // dynamically fill save as menu with available formats
\r
2909 for (int i = 0; i < jalview.io.AppletFormatAdapter.WRITEABLE_FORMATS.length; i++)
\r
2912 item = new MenuItem(
\r
2913 jalview.io.AppletFormatAdapter.WRITEABLE_FORMATS[i]);
\r
2915 item.addActionListener(new java.awt.event.ActionListener()
\r
2917 public void actionPerformed(ActionEvent e)
\r
2919 outputText_actionPerformed(e);
\r
2923 outputTextboxMenu.add(item);
\r
2925 closeMenuItem.addActionListener(this);
\r
2926 loadApplication.addActionListener(this);
\r
2928 loadTree.addActionListener(this);
\r
2929 loadAnnotations.addActionListener(this);
\r
2930 outputFeatures.addActionListener(this);
\r
2931 outputAnnotations.addActionListener(this);
\r
2932 selectAllSequenceMenuItem.addActionListener(this);
\r
2933 deselectAllSequenceMenuItem.addActionListener(this);
\r
2934 invertSequenceMenuItem.addActionListener(this);
\r
2935 remove2LeftMenuItem.setLabel("Remove Left");
\r
2936 remove2LeftMenuItem.addActionListener(this);
\r
2937 remove2RightMenuItem.setLabel("Remove Right");
\r
2938 remove2RightMenuItem.addActionListener(this);
\r
2939 removeGappedColumnMenuItem.setLabel("Remove Empty Columns");
\r
2940 removeGappedColumnMenuItem.addActionListener(this);
\r
2941 removeAllGapsMenuItem.setLabel("Remove All Gaps");
\r
2942 removeAllGapsMenuItem.addActionListener(this);
\r
2943 viewBoxesMenuItem.setLabel("Boxes");
\r
2944 viewBoxesMenuItem.setState(true);
\r
2945 viewBoxesMenuItem.addItemListener(this);
\r
2946 viewTextMenuItem.setLabel("Text");
\r
2947 viewTextMenuItem.setState(true);
\r
2948 viewTextMenuItem.addItemListener(this);
\r
2949 sortPairwiseMenuItem.setLabel("by Pairwise Identity");
\r
2950 sortPairwiseMenuItem.addActionListener(this);
\r
2951 sortIDMenuItem.setLabel("by ID");
\r
2952 sortIDMenuItem.addActionListener(this);
\r
2953 sortLengthMenuItem.setLabel("by Length");
\r
2954 sortLengthMenuItem.addActionListener(this);
\r
2955 sortGroupMenuItem.setLabel("by Group");
\r
2956 sortGroupMenuItem.addActionListener(this);
\r
2957 removeRedundancyMenuItem.setLabel("Remove Redundancy...");
\r
2958 removeRedundancyMenuItem.addActionListener(this);
\r
2959 pairwiseAlignmentMenuItem.setLabel("Pairwise Alignments...");
\r
2960 pairwiseAlignmentMenuItem.addActionListener(this);
\r
2961 PCAMenuItem.setLabel("Principal Component Analysis");
\r
2962 PCAMenuItem.addActionListener(this);
\r
2963 averageDistanceTreeMenuItem
\r
2964 .setLabel("Average Distance Using % Identity");
\r
2965 averageDistanceTreeMenuItem.addActionListener(this);
\r
2966 neighbourTreeMenuItem.setLabel("Neighbour Joining Using % Identity");
\r
2967 neighbourTreeMenuItem.addActionListener(this);
\r
2968 statusBar.setBackground(Color.white);
\r
2969 statusBar.setFont(new java.awt.Font("Verdana", 0, 11));
\r
2970 statusBar.setText("Status bar");
\r
2971 outputTextboxMenu.setLabel("Output to Textbox");
\r
2972 clustalColour.setLabel("Clustalx");
\r
2974 clustalColour.addActionListener(this);
\r
2975 zappoColour.setLabel("Zappo");
\r
2976 zappoColour.addActionListener(this);
\r
2977 taylorColour.setLabel("Taylor");
\r
2978 taylorColour.addActionListener(this);
\r
2979 hydrophobicityColour.setLabel("Hydrophobicity");
\r
2980 hydrophobicityColour.addActionListener(this);
\r
2981 helixColour.setLabel("Helix Propensity");
\r
2982 helixColour.addActionListener(this);
\r
2983 strandColour.setLabel("Strand Propensity");
\r
2984 strandColour.addActionListener(this);
\r
2985 turnColour.setLabel("Turn Propensity");
\r
2986 turnColour.addActionListener(this);
\r
2987 buriedColour.setLabel("Buried Index");
\r
2988 buriedColour.addActionListener(this);
\r
2989 purinePyrimidineColour.setLabel("Purine/Pyrimidine");
\r
2990 purinePyrimidineColour.addActionListener(this);
\r
2991 RNAHelixColour.setLabel("by RNA Helices");
\r
2992 RNAHelixColour.addActionListener(this);
\r
2993 userDefinedColour.setLabel("User Defined...");
\r
2994 userDefinedColour.addActionListener(this);
\r
2995 PIDColour.setLabel("Percentage Identity");
\r
2996 PIDColour.addActionListener(this);
\r
2997 BLOSUM62Colour.setLabel("BLOSUM62 Score");
\r
2998 BLOSUM62Colour.addActionListener(this);
\r
2999 avDistanceTreeBlosumMenuItem
\r
3000 .setLabel("Average Distance Using BLOSUM62");
\r
3001 avDistanceTreeBlosumMenuItem.addActionListener(this);
\r
3002 njTreeBlosumMenuItem.setLabel("Neighbour Joining Using BLOSUM62");
\r
3003 njTreeBlosumMenuItem.addActionListener(this);
\r
3004 annotationPanelMenuItem.setLabel("Show Annotations");
\r
3005 annotationPanelMenuItem.addItemListener(this);
\r
3006 colourTextMenuItem.setLabel("Colour Text");
\r
3007 colourTextMenuItem.addItemListener(this);
\r
3008 displayNonconservedMenuItem.setLabel("Show nonconserved");
\r
3009 displayNonconservedMenuItem.addItemListener(this);
\r
3010 alProperties.addActionListener(this);
\r
3011 overviewMenuItem.setLabel("Overview Window");
\r
3012 overviewMenuItem.addActionListener(this);
\r
3013 undoMenuItem.setEnabled(false);
\r
3014 undoMenuItem.setLabel("Undo");
\r
3015 undoMenuItem.addActionListener(this);
\r
3016 redoMenuItem.setEnabled(false);
\r
3017 redoMenuItem.setLabel("Redo");
\r
3018 redoMenuItem.addActionListener(this);
\r
3019 conservationMenuItem.setLabel("by Conservation");
\r
3020 conservationMenuItem.addItemListener(this);
\r
3021 noColourmenuItem.setLabel("None");
\r
3022 noColourmenuItem.addActionListener(this);
\r
3023 wrapMenuItem.setLabel("Wrap");
\r
3024 wrapMenuItem.addItemListener(this);
\r
3025 renderGapsMenuItem.setLabel("Show Gaps");
\r
3026 renderGapsMenuItem.setState(true);
\r
3027 renderGapsMenuItem.addItemListener(this);
\r
3028 findMenuItem.setLabel("Find...");
\r
3029 findMenuItem.addActionListener(this);
\r
3030 abovePIDThreshold.setLabel("Above Identity Threshold");
\r
3031 abovePIDThreshold.addItemListener(this);
\r
3032 nucleotideColour.setLabel("Nucleotide");
\r
3033 nucleotideColour.addActionListener(this);
\r
3034 deleteGroups.setLabel("Undefine Groups");
\r
3035 deleteGroups.addActionListener(this);
\r
3036 grpsFromSelection.setLabel("Make Groups for selection");
\r
3037 grpsFromSelection.addActionListener(this);
\r
3038 copy.setLabel("Copy");
\r
3039 copy.addActionListener(this);
\r
3040 cut.setLabel("Cut");
\r
3041 cut.addActionListener(this);
\r
3042 delete.setLabel("Delete");
\r
3043 delete.addActionListener(this);
\r
3044 pasteMenu.setLabel("Paste");
\r
3045 pasteNew.setLabel("To New Alignment");
\r
3046 pasteNew.addActionListener(this);
\r
3047 pasteThis.setLabel("Add To This Alignment");
\r
3048 pasteThis.addActionListener(this);
\r
3049 applyToAllGroups.setLabel("Apply Colour To All Groups");
\r
3050 applyToAllGroups.setState(true);
\r
3051 applyToAllGroups.addItemListener(this);
\r
3052 font.setLabel("Font...");
\r
3053 font.addActionListener(this);
\r
3054 scaleAbove.setLabel("Scale Above");
\r
3055 scaleAbove.setState(true);
\r
3056 scaleAbove.setEnabled(false);
\r
3057 scaleAbove.addItemListener(this);
\r
3058 scaleLeft.setEnabled(false);
\r
3059 scaleLeft.setState(true);
\r
3060 scaleLeft.setLabel("Scale Left");
\r
3061 scaleLeft.addItemListener(this);
\r
3062 scaleRight.setEnabled(false);
\r
3063 scaleRight.setState(true);
\r
3064 scaleRight.setLabel("Scale Right");
\r
3065 scaleRight.addItemListener(this);
\r
3066 modifyPID.setLabel("Modify Identity Threshold...");
\r
3067 modifyPID.addActionListener(this);
\r
3068 modifyConservation.setLabel("Modify Conservation Threshold...");
\r
3069 modifyConservation.addActionListener(this);
\r
3070 sortByTreeMenu.setLabel("By Tree Order");
\r
3071 sort.setLabel("Sort");
\r
3072 calculate.setLabel("Calculate Tree");
\r
3073 autoCalculate.addItemListener(this);
\r
3074 sortByTree.addItemListener(this);
\r
3075 inputText.setLabel("Input from textbox");
\r
3076 inputText.addActionListener(this);
\r
3077 centreColumnLabelFlag.setLabel("Centre column labels");
\r
3078 centreColumnLabelFlag.addItemListener(this);
\r
3079 followMouseOverFlag.setLabel("Automatic Scrolling");
\r
3080 followMouseOverFlag.addItemListener(this);
\r
3081 helpMenu.setLabel("Help");
\r
3082 documentation.setLabel("Documentation");
\r
3083 documentation.addActionListener(this);
\r
3085 about.setLabel("About...");
\r
3086 about.addActionListener(this);
\r
3087 seqLimits.setState(true);
\r
3088 seqLimits.setLabel("Show Sequence Limits");
\r
3089 seqLimits.addItemListener(this);
\r
3090 featureSettings.setLabel("Feature Settings...");
\r
3091 featureSettings.addActionListener(this);
\r
3092 sequenceFeatures.setLabel("Sequence Features");
\r
3093 sequenceFeatures.addItemListener(this);
\r
3094 sequenceFeatures.setState(false);
\r
3095 annotationColour.setLabel("by Annotation...");
\r
3096 annotationColour.addActionListener(this);
\r
3097 invertSequenceMenuItem.setLabel("Invert Sequence Selection");
\r
3098 invertColSel.setLabel("Invert Column Selection");
\r
3099 menu1.setLabel("Show");
\r
3100 showColumns.setLabel("All Columns ");
\r
3101 showSeqs.setLabel("All Sequences");
\r
3102 menu2.setLabel("Hide");
\r
3103 hideColumns.setLabel("Selected Columns");
\r
3104 hideSequences.setLabel("Selected Sequences");
\r
3105 hideAllButSelection.setLabel("All but Selected Region (Shift+Ctrl+H)");
\r
3106 hideAllSelection.setLabel("Selected Region");
\r
3107 showAllHidden.setLabel("All Sequences and Columns");
\r
3108 showGroupConsensus.setLabel("Group Consensus");
\r
3109 showGroupConservation.setLabel("Group Conservation");
\r
3110 showConsensusHistogram.setLabel("Show Consensus Histogram");
\r
3111 showSequenceLogo.setLabel("Show Consensus Logo");
\r
3112 applyAutoAnnotationSettings.setLabel("Apply to all groups");
\r
3113 applyAutoAnnotationSettings.setState(true);
\r
3114 autoAnnMenu.setLabel("Autocalculated Annotation");
\r
3116 invertColSel.addActionListener(this);
\r
3117 showColumns.addActionListener(this);
\r
3118 showSeqs.addActionListener(this);
\r
3119 hideColumns.addActionListener(this);
\r
3120 hideSequences.addActionListener(this);
\r
3121 hideAllButSelection.addActionListener(this);
\r
3122 hideAllSelection.addActionListener(this);
\r
3123 showAllHidden.addActionListener(this);
\r
3124 showGroupConsensus.addItemListener(this);
\r
3125 showGroupConservation.addItemListener(this);
\r
3126 showConsensusHistogram.addItemListener(this);
\r
3127 showSequenceLogo.addItemListener(this);
\r
3128 applyAutoAnnotationSettings.addItemListener(this);
\r
3129 formatMenu.setLabel("Format");
\r
3130 selectMenu.setLabel("Select");
\r
3131 newView.setLabel("New View");
\r
3132 newView.addActionListener(this);
\r
3133 alignFrameMenuBar.add(fileMenu);
\r
3134 alignFrameMenuBar.add(editMenu);
\r
3135 alignFrameMenuBar.add(selectMenu);
\r
3136 alignFrameMenuBar.add(viewMenu);
\r
3137 alignFrameMenuBar.add(formatMenu);
\r
3138 alignFrameMenuBar.add(colourMenu);
\r
3139 alignFrameMenuBar.add(calculateMenu);
\r
3140 alignFrameMenuBar.add(helpMenu);
\r
3142 fileMenu.add(inputText);
\r
3143 fileMenu.add(loadTree);
\r
3144 fileMenu.add(loadAnnotations);
\r
3146 fileMenu.addSeparator();
\r
3147 fileMenu.add(outputTextboxMenu);
\r
3148 fileMenu.add(outputFeatures);
\r
3149 fileMenu.add(outputAnnotations);
\r
3151 if (jalviewServletURL != null)
\r
3153 fileMenu.add(loadApplication);
\r
3156 fileMenu.addSeparator();
\r
3157 fileMenu.add(closeMenuItem);
\r
3159 editMenu.add(undoMenuItem);
\r
3160 editMenu.add(redoMenuItem);
\r
3161 editMenu.add(cut);
\r
3162 editMenu.add(copy);
\r
3163 editMenu.add(pasteMenu);
\r
3164 editMenu.add(delete);
\r
3165 editMenu.addSeparator();
\r
3166 editMenu.add(remove2LeftMenuItem);
\r
3167 editMenu.add(remove2RightMenuItem);
\r
3168 editMenu.add(removeGappedColumnMenuItem);
\r
3169 editMenu.add(removeAllGapsMenuItem);
\r
3170 editMenu.add(removeRedundancyMenuItem);
\r
3171 viewMenu.add(newView);
\r
3172 viewMenu.addSeparator();
\r
3173 viewMenu.add(menu1);
\r
3174 viewMenu.add(menu2);
\r
3175 viewMenu.addSeparator();
\r
3176 viewMenu.add(followMouseOverFlag);
\r
3177 viewMenu.add(annotationPanelMenuItem);
\r
3178 autoAnnMenu.add(applyAutoAnnotationSettings);
\r
3179 autoAnnMenu.add(showConsensusHistogram);
\r
3180 autoAnnMenu.add(showSequenceLogo);
\r
3181 autoAnnMenu.addSeparator();
\r
3182 autoAnnMenu.add(showGroupConservation);
\r
3183 autoAnnMenu.add(showGroupConsensus);
\r
3184 viewMenu.add(autoAnnMenu);
\r
3185 viewMenu.addSeparator();
\r
3186 viewMenu.add(sequenceFeatures);
\r
3187 viewMenu.add(featureSettings);
\r
3188 viewMenu.addSeparator();
\r
3189 viewMenu.add(alProperties);
\r
3190 viewMenu.addSeparator();
\r
3191 viewMenu.add(overviewMenuItem);
\r
3192 colourMenu.add(applyToAllGroups);
\r
3193 colourMenu.addSeparator();
\r
3194 colourMenu.add(noColourmenuItem);
\r
3195 colourMenu.add(clustalColour);
\r
3196 colourMenu.add(BLOSUM62Colour);
\r
3197 colourMenu.add(PIDColour);
\r
3198 colourMenu.add(zappoColour);
\r
3199 colourMenu.add(taylorColour);
\r
3200 colourMenu.add(hydrophobicityColour);
\r
3201 colourMenu.add(helixColour);
\r
3202 colourMenu.add(strandColour);
\r
3203 colourMenu.add(turnColour);
\r
3204 colourMenu.add(buriedColour);
\r
3205 colourMenu.add(nucleotideColour);
\r
3206 colourMenu.add(purinePyrimidineColour);
\r
3207 colourMenu.add(userDefinedColour);
\r
3208 colourMenu.addSeparator();
\r
3209 colourMenu.add(conservationMenuItem);
\r
3210 colourMenu.add(modifyConservation);
\r
3211 colourMenu.add(abovePIDThreshold);
\r
3212 colourMenu.add(modifyPID);
\r
3213 colourMenu.add(annotationColour);
\r
3214 colourMenu.add(RNAHelixColour);
\r
3215 calculateMenu.add(sort);
\r
3216 calculateMenu.add(calculate);
\r
3217 calculateMenu.addSeparator();
\r
3218 calculateMenu.add(pairwiseAlignmentMenuItem);
\r
3219 calculateMenu.add(PCAMenuItem);
\r
3220 calculateMenu.add(autoCalculate);
\r
3221 calculateMenu.add(sortByTree);
\r
3222 this.add(statusBar, BorderLayout.SOUTH);
\r
3223 pasteMenu.add(pasteNew);
\r
3224 pasteMenu.add(pasteThis);
\r
3225 sort.add(sortIDMenuItem);
\r
3226 sort.add(sortLengthMenuItem);
\r
3227 sort.add(sortByTreeMenu);
\r
3228 sort.add(sortGroupMenuItem);
\r
3229 sort.add(sortPairwiseMenuItem);
\r
3230 calculate.add(averageDistanceTreeMenuItem);
\r
3231 calculate.add(neighbourTreeMenuItem);
\r
3232 calculate.add(avDistanceTreeBlosumMenuItem);
\r
3233 calculate.add(njTreeBlosumMenuItem);
\r
3234 helpMenu.add(documentation);
\r
3235 helpMenu.add(about);
\r
3236 menu1.add(showColumns);
\r
3237 menu1.add(showSeqs);
\r
3238 menu1.add(showAllHidden);
\r
3239 menu2.add(hideColumns);
\r
3240 menu2.add(hideSequences);
\r
3241 menu2.add(hideAllSelection);
\r
3242 menu2.add(hideAllButSelection);
\r
3243 formatMenu.add(font);
\r
3244 formatMenu.add(seqLimits);
\r
3245 formatMenu.add(wrapMenuItem);
\r
3246 formatMenu.add(scaleAbove);
\r
3247 formatMenu.add(scaleLeft);
\r
3248 formatMenu.add(scaleRight);
\r
3249 formatMenu.add(viewBoxesMenuItem);
\r
3250 formatMenu.add(viewTextMenuItem);
\r
3251 formatMenu.add(colourTextMenuItem);
\r
3252 formatMenu.add(displayNonconservedMenuItem);
\r
3253 formatMenu.add(renderGapsMenuItem);
\r
3254 formatMenu.add(centreColumnLabelFlag);
\r
3255 selectMenu.add(findMenuItem);
\r
3256 selectMenu.addSeparator();
\r
3257 selectMenu.add(selectAllSequenceMenuItem);
\r
3258 selectMenu.add(deselectAllSequenceMenuItem);
\r
3259 selectMenu.add(invertSequenceMenuItem);
\r
3260 selectMenu.add(invertColSel);
\r
3261 selectMenu.add(grpsFromSelection);
\r
3262 selectMenu.add(deleteGroups);
\r
3266 MenuItem featureSettings = new MenuItem();
\r
3268 CheckboxMenuItem sequenceFeatures = new CheckboxMenuItem();
\r
3270 MenuItem annotationColour = new MenuItem();
\r
3272 MenuItem invertColSel = new MenuItem();
\r
3274 Menu menu1 = new Menu();
\r
3276 MenuItem showColumns = new MenuItem();
\r
3278 MenuItem showSeqs = new MenuItem();
\r
3280 Menu menu2 = new Menu();
\r
3282 MenuItem hideColumns = new MenuItem();
\r
3284 MenuItem hideSequences = new MenuItem();
\r
3286 MenuItem hideAllButSelection = new MenuItem();
\r
3288 MenuItem hideAllSelection = new MenuItem();
\r
3290 MenuItem showAllHidden = new MenuItem();
\r
3292 Menu formatMenu = new Menu();
\r
3294 Menu selectMenu = new Menu();
\r
3296 MenuItem newView = new MenuItem();
\r
3299 * Attach the alignFrame panels after embedding menus, if necessary. This used
\r
3300 * to be called setEmbedded, but is now creates the dropdown menus in a
\r
3301 * platform independent manner to avoid OSX/Mac menu appendage daftness.
\r
3303 * @param reallyEmbedded
\r
3304 * true to attach the view to the applet area on the page rather than
\r
3307 public void createAlignFrameWindow(boolean reallyEmbedded, String title)
\r
3309 if (reallyEmbedded)
\r
3312 // Explicly build the embedded menu panel for the on-page applet
\r
3314 // view cannot be closed if its actually on the page
\r
3315 fileMenu.remove(closeMenuItem);
\r
3316 fileMenu.remove(3); // Remove Seperator
\r
3317 embeddedMenu = makeEmbeddedPopupMenu(alignFrameMenuBar, "Arial",
\r
3318 Font.PLAIN, 10, false); // use our own fonts.
\r
3319 // and actually add the components to the applet area
\r
3320 viewport.applet.setLayout(new BorderLayout());
\r
3321 viewport.applet.add(embeddedMenu, BorderLayout.NORTH);
\r
3322 viewport.applet.add(statusBar, BorderLayout.SOUTH);
\r
3323 alignPanel.setSize(viewport.applet.getSize().width,
\r
3324 viewport.applet.getSize().height - embeddedMenu.HEIGHT
\r
3325 - statusBar.HEIGHT);
\r
3326 viewport.applet.add(alignPanel, BorderLayout.CENTER);
\r
3327 final AlignFrame me = this;
\r
3328 viewport.applet.addFocusListener(new FocusListener()
\r
3332 public void focusLost(FocusEvent e)
\r
3334 if (me.viewport.applet.currentAlignFrame==me) {
\r
3335 me.viewport.applet.currentAlignFrame = null;
\r
3339 public void focusGained(FocusEvent e)
\r
3341 me.viewport.applet.currentAlignFrame = me;
\r
3344 viewport.applet.validate();
\r
3349 // test and embed menu bar if necessary.
\r
3351 if (embedMenuIfNeeded(alignPanel))
\r
3353 // adjust for status bar height too
\r
3354 alignPanel.setSize(getSize().width, getSize().height
\r
3355 - statusBar.HEIGHT);
\r
3357 add(statusBar, BorderLayout.SOUTH);
\r
3358 add(alignPanel, BorderLayout.CENTER);
\r
3359 // and register with the applet so it can pass external API calls to us
\r
3360 jalview.bin.JalviewLite.addFrame(this, title, DEFAULT_WIDTH,
\r
3366 * create a new binding between structures in an existing jmol viewer instance
\r
3367 * and an alignpanel with sequences that have existing PDBFile entries. Note,
\r
3368 * this does not open a new Jmol window, or modify the display of the
\r
3369 * structures in the original jmol window. Note This method doesn't work
\r
3370 * without an additional javascript library to exchange messages between the
\r
3371 * distinct applets. See http://issues.jalview.org/browse/JAL-621
\r
3374 * JmolViewer instance
\r
3375 * @param sequenceIds
\r
3376 * - sequence Ids to search for associations
\r
3378 public SequenceStructureBinding addStructureViewInstance(
\r
3379 Object jmolviewer, String[] sequenceIds)
\r
3381 org.jmol.api.JmolViewer viewer = null;
\r
3384 viewer = (org.jmol.api.JmolViewer) jmolviewer;
\r
3385 } catch (ClassCastException ex)
\r
3387 System.err.println("Unsupported viewer object :"
\r
3388 + jmolviewer.getClass());
\r
3390 if (viewer == null)
\r
3392 System.err.println("Can't use this object as a structure viewer:"
\r
3393 + jmolviewer.getClass());
\r
3396 SequenceI[] seqs = null;
\r
3397 if (sequenceIds == null || sequenceIds.length == 0)
\r
3399 seqs = viewport.getAlignment().getSequencesArray();
\r
3403 Vector sqi = new Vector();
\r
3404 AlignmentI al = viewport.getAlignment();
\r
3405 for (int sid = 0; sid < sequenceIds.length; sid++)
\r
3407 SequenceI sq = al.findName(sequenceIds[sid]);
\r
3410 sqi.addElement(sq);
\r
3413 if (sqi.size() > 0)
\r
3415 seqs = new SequenceI[sqi.size()];
\r
3416 for (int sid = 0, sSize = sqi.size(); sid < sSize; sid++)
\r
3418 seqs[sid] = (SequenceI) sqi.elementAt(sid);
\r
3426 ExtJmol jmv = null;
\r
3427 // TODO: search for a jmv that involves viewer
\r
3429 { // create a new viewer/jalview binding.
\r
3430 jmv = new ExtJmol(viewer, alignPanel, new SequenceI[][] {seqs});
\r
3436 * bind a pdb file to a sequence in the current view
\r
3438 * @param sequenceId
\r
3439 * - sequenceId within the dataset.
\r
3440 * @param pdbEntryString
\r
3441 * - the short name for the PDB file
\r
3443 * - pdb file - either a URL or a valid PDB file.
\r
3444 * @return true if binding was as success TODO: consider making an exception
\r
3445 * structure for indicating when PDB parsing or sequenceId location
\r
3448 public boolean addPdbFile(String sequenceId, String pdbEntryString,
\r
3451 SequenceI toaddpdb = viewport.getAlignment().findName(sequenceId);
\r
3452 boolean needtoadd = false;
\r
3453 if (toaddpdb != null)
\r
3455 Vector pdbe = toaddpdb.getPDBId();
\r
3456 PDBEntry pdbentry = null;
\r
3457 if (pdbe != null && pdbe.size() > 0)
\r
3459 for (int pe = 0, peSize = pdbe.size(); pe < peSize; pe++)
\r
3461 pdbentry = (PDBEntry) pdbe.elementAt(pe);
\r
3462 if (!pdbentry.getId().equals(pdbEntryString)
\r
3463 && !pdbentry.getFile().equals(pdbFile))
\r
3473 if (pdbentry == null)
\r
3475 pdbentry = new PDBEntry();
\r
3476 pdbentry.setId(pdbEntryString);
\r
3477 pdbentry.setFile(pdbFile);
\r
3478 needtoadd = true; // add this new entry to sequence.
\r
3480 // resolve data source
\r
3481 // TODO: this code should be a refactored to an io package
\r
3482 String protocol = AppletFormatAdapter.resolveProtocol(pdbFile, "PDB");
\r
3483 if (protocol == null)
\r
3489 // make a note of the access mode and add
\r
3490 if (pdbentry.getProperty() == null)
\r
3492 pdbentry.setProperty(new Hashtable());
\r
3494 pdbentry.getProperty().put("protocol", protocol);
\r
3495 toaddpdb.addPDBId(pdbentry);
\r
3501 private Object[] cleanSeqChainArrays(SequenceI[] seqs, String[] chains)
\r
3505 Vector sequences = new Vector();
\r
3506 for (int i = 0; i < seqs.length; i++)
\r
3508 if (seqs[i] != null)
\r
3510 sequences.addElement(new Object[]
\r
3511 { seqs[i], (chains != null) ? chains[i] : null });
\r
3514 seqs = new SequenceI[sequences.size()];
\r
3515 chains = new String[sequences.size()];
\r
3516 for (int i = 0, isize = sequences.size(); i < isize; i++)
\r
3518 Object[] oj = (Object[]) sequences.elementAt(i);
\r
3520 seqs[i] = (SequenceI) oj[0];
\r
3521 chains[i] = (String) oj[1];
\r
3524 return new Object[]
\r
3529 public void newStructureView(JalviewLite applet, PDBEntry pdb,
\r
3530 SequenceI[] seqs, String[] chains, String protocol)
\r
3532 // Scrub any null sequences from the array
\r
3533 Object[] sqch = cleanSeqChainArrays(seqs, chains);
\r
3534 seqs = (SequenceI[]) sqch[0];
\r
3535 chains = (String[]) sqch[1];
\r
3536 if (seqs == null || seqs.length == 0)
\r
3539 .println("JalviewLite.AlignFrame:newStructureView: No sequence to bind structure to.");
\r
3541 if (protocol == null || protocol.trim().length() == 0
\r
3542 || protocol.equals("null"))
\r
3544 protocol = (String) pdb.getProperty().get("protocol");
\r
3545 if (protocol == null)
\r
3547 System.err.println("Couldn't work out protocol to open structure: "
\r
3552 if (applet.useXtrnalSviewer)
\r
3554 // register the association(s) and quit, don't create any windows.
\r
3555 if (StructureSelectionManager.getStructureSelectionManager(applet).setMapping(seqs, chains, pdb.getFile(), protocol)==null) {
\r
3556 System.err.println("Failed to map "+pdb.getFile()+" ("+protocol+") to any sequences");
\r
3560 if (applet.isAlignPdbStructures() && applet.jmolAvailable)
\r
3562 // can only do alignments with Jmol
\r
3563 // find the last jmol window assigned to this alignment
\r
3564 jalview.appletgui.AppletJmol ajm = null, tajm;
\r
3565 Vector jmols = applet
\r
3566 .getAppletWindow(jalview.appletgui.AppletJmol.class);
\r
3567 for (int i = 0, iSize = jmols.size(); i < iSize; i++)
\r
3569 tajm = (jalview.appletgui.AppletJmol) jmols.elementAt(i);
\r
3570 if (tajm.ap.alignFrame == this)
\r
3579 .println("Incremental adding and aligning structure to existing Jmol view not yet implemented.");
\r
3580 // try and add the pdb structure
\r
3585 // otherwise, create a new window
\r
3586 if (applet.jmolAvailable)
\r
3588 new jalview.appletgui.AppletJmol(pdb, seqs, chains, alignPanel,
\r
3590 applet.lastFrameX += 40;
\r
3591 applet.lastFrameY += 40;
\r
3595 new MCview.AppletPDBViewer(pdb, seqs, chains, alignPanel, protocol);
\r
3600 public void alignedStructureView(JalviewLite applet, PDBEntry[] pdb,
\r
3601 SequenceI[][] seqs, String[][] chains, String[] protocols)
\r
3603 // TODO Auto-generated method stub
\r
3604 System.err.println("Aligned Structure View: Not yet implemented.");
\r
3608 * modify the current selection, providing the user has not made a selection already.
\r
3609 * @param sel - sequences from this alignment
\r
3610 * @param csel - columns to be selected on the alignment
\r
3612 public void select(SequenceGroup sel, ColumnSelection csel)
\r
3614 alignPanel.seqPanel.selection(sel, csel, null);
\r
3617 public void scrollTo(int row, int column)
\r
3619 alignPanel.seqPanel.scrollTo(row, column);
\r
3621 public void scrollToRow(int row)
\r
3623 alignPanel.seqPanel.scrollToRow(row);
\r
3625 public void scrollToColumn(int column)
\r
3627 alignPanel.seqPanel.scrollToColumn(column);
\r
3630 * @return the alignments unique ID.
\r
3632 public String getSequenceSetId() {
\r
3633 return viewport.getSequenceSetId();
\r