- userDefinedColour_actionPerformed(evt);\r
- }\r
- });\r
- colourMenu.insert(radioItem, 15);\r
- colours.add(radioItem);\r
- }\r
- }\r
- }\r
-\r
- /**\r
- * DOCUMENT ME!\r
- *\r
- * @param e DOCUMENT ME!\r
- */\r
- public void PIDColour_actionPerformed(ActionEvent e)\r
- {\r
- changeColour(new PIDColourScheme());\r
- }\r
-\r
- /**\r
- * DOCUMENT ME!\r
- *\r
- * @param e DOCUMENT ME!\r
- */\r
- public void BLOSUM62Colour_actionPerformed(ActionEvent e)\r
- {\r
- changeColour(new Blosum62ColourScheme());\r
- }\r
-\r
- /**\r
- * DOCUMENT ME!\r
- *\r
- * @param e DOCUMENT ME!\r
- */\r
- public void sortPairwiseMenuItem_actionPerformed(ActionEvent e)\r
- {\r
- addHistoryItem(new HistoryItem("Pairwise Sort", viewport.alignment,\r
- HistoryItem.SORT));\r
- AlignmentSorter.sortByPID(viewport.getAlignment(),\r
- viewport.getAlignment().getSequenceAt(0));\r
- alignPanel.repaint();\r
- }\r
-\r
- /**\r
- * DOCUMENT ME!\r
- *\r
- * @param e DOCUMENT ME!\r
- */\r
- public void sortIDMenuItem_actionPerformed(ActionEvent e)\r
- {\r
- addHistoryItem(new HistoryItem("ID Sort", viewport.alignment,\r
- HistoryItem.SORT));\r
- AlignmentSorter.sortByID(viewport.getAlignment());\r
- alignPanel.repaint();\r
- }\r
-\r
- /**\r
- * DOCUMENT ME!\r
- *\r
- * @param e DOCUMENT ME!\r
- */\r
- public void sortGroupMenuItem_actionPerformed(ActionEvent e)\r
- {\r
- addHistoryItem(new HistoryItem("Group Sort", viewport.alignment,\r
- HistoryItem.SORT));\r
-\r
- AlignmentSorter.sortByGroup(viewport.getAlignment());\r
- alignPanel.repaint();\r
- }\r
-\r
- /**\r
- * DOCUMENT ME!\r
- *\r
- * @param e DOCUMENT ME!\r
- */\r
- public void removeRedundancyMenuItem_actionPerformed(ActionEvent e)\r
- {\r
- RedundancyPanel sp = new RedundancyPanel(alignPanel, this);\r
- JInternalFrame frame = new JInternalFrame();\r
- frame.setContentPane(sp);\r
- Desktop.addInternalFrame(frame, "Redundancy threshold selection", 400,\r
- 100, false);\r
- }\r
-\r
- /**\r
- * DOCUMENT ME!\r
- *\r
- * @param e DOCUMENT ME!\r
- */\r
- public void pairwiseAlignmentMenuItem_actionPerformed(ActionEvent e)\r
- {\r
- if ((viewport.getSelectionGroup() == null) ||\r
- (viewport.getSelectionGroup().getSize() < 2))\r
- {\r
- JOptionPane.showInternalMessageDialog(this,\r
- "You must select at least 2 sequences.", "Invalid Selection",\r
- JOptionPane.WARNING_MESSAGE);\r
- }\r
- else\r
- {\r
- JInternalFrame frame = new JInternalFrame();\r
- frame.setContentPane(new PairwiseAlignPanel(viewport));\r
- Desktop.addInternalFrame(frame, "Pairwise Alignment", 600, 500);\r
- }\r
- }\r
-\r
- /**\r
- * DOCUMENT ME!\r
- *\r
- * @param e DOCUMENT ME!\r
- */\r
- public void PCAMenuItem_actionPerformed(ActionEvent e)\r
- {\r
- if (((viewport.getSelectionGroup() != null) &&\r
- (viewport.getSelectionGroup().getSize() < 4) &&\r
- (viewport.getSelectionGroup().getSize() > 0)) ||\r
- (viewport.getAlignment().getHeight() < 4))\r
- {\r
- JOptionPane.showInternalMessageDialog(this,\r
- "Principal component analysis must take\n" +\r
- "at least 4 input sequences.",\r
- "Sequence selection insufficient", JOptionPane.WARNING_MESSAGE);\r
-\r
- return;\r
- }\r
-\r
- try\r
- {\r
- PCAPanel pcaPanel = new PCAPanel(viewport, null);\r
- JInternalFrame frame = new JInternalFrame();\r
- frame.setContentPane(pcaPanel);\r
- Desktop.addInternalFrame(frame, "Principal component analysis",\r
- 400, 400);\r
- }\r
- catch (java.lang.OutOfMemoryError ex)\r
- {\r
- JOptionPane.showInternalMessageDialog(this,\r
- "Too many sequences selected\nfor Principal Component Analysis!!",\r
- "Out of memory", JOptionPane.WARNING_MESSAGE);\r
- }\r
- }\r
-\r
- /**\r
- * DOCUMENT ME!\r
- *\r
- * @param e DOCUMENT ME!\r
- */\r
- public void averageDistanceTreeMenuItem_actionPerformed(ActionEvent e)\r
- {\r
- NewTreePanel("AV", "PID", "Average distance tree using PID");\r
- }\r
-\r
- /**\r
- * DOCUMENT ME!\r
- *\r
- * @param e DOCUMENT ME!\r
- */\r
- public void neighbourTreeMenuItem_actionPerformed(ActionEvent e)\r
- {\r
- NewTreePanel("NJ", "PID", "Neighbour joining tree using PID");\r
- }\r
-\r
- /**\r
- * DOCUMENT ME!\r
- *\r
- * @param e DOCUMENT ME!\r
- */\r
- protected void njTreeBlosumMenuItem_actionPerformed(ActionEvent e)\r
- {\r
- NewTreePanel("NJ", "BL", "Neighbour joining tree using BLOSUM62");\r
- }\r
-\r
- /**\r
- * DOCUMENT ME!\r
- *\r
- * @param e DOCUMENT ME!\r
- */\r
- protected void avTreeBlosumMenuItem_actionPerformed(ActionEvent e)\r
- {\r
- NewTreePanel("AV", "BL", "Average distance tree using BLOSUM62");\r
- }\r
-\r
- /**\r
- * DOCUMENT ME!\r
- *\r
- * @param type DOCUMENT ME!\r
- * @param pwType DOCUMENT ME!\r
- * @param title DOCUMENT ME!\r
- */\r
- void NewTreePanel(String type, String pwType, String title)\r
- {\r
- final TreePanel tp;\r
-\r
- if ((viewport.getSelectionGroup() != null) &&\r
- (viewport.getSelectionGroup().getSize() > 3))\r
- {\r
- int s = 0;\r
- SequenceGroup sg = viewport.getSelectionGroup();\r
-\r
- /* Decide if the selection is a column region */\r
- while (s < sg.sequences.size())\r
- {\r
- if (((SequenceI) sg.sequences.elementAt(s++)).getLength() < sg.getEndRes())\r
- {\r
- JOptionPane.showMessageDialog(Desktop.desktop,\r
- "The selected region to create a tree may\nonly contain residues or gaps.\n" +\r
- "Try using the Pad function in the edit menu,\n" +\r
- "or one of the multiple sequence alignment web services.",\r
- "Sequences in selection are not aligned",\r
- JOptionPane.WARNING_MESSAGE);\r
-\r
- return;\r
- }\r
- }\r
-\r
- title = title + " on region";\r
- tp = new TreePanel(viewport,\r
- viewport.getSelectionGroup().sequences, type, pwType,\r
- sg.getStartRes(), sg.getEndRes());\r
- }\r
- else\r
- {\r
- //are the sequences aligned?\r
- if (!viewport.alignment.isAligned())\r
- {\r
- JOptionPane.showMessageDialog(Desktop.desktop,\r
- "The sequences must be aligned before creating a tree.\n" +\r
- "Try using the Pad function in the edit menu,\n" +\r
- "or one of the multiple sequence alignment web services.",\r
- "Sequences not aligned", JOptionPane.WARNING_MESSAGE);\r
-\r
- return;\r
- }\r
-\r
- tp = new TreePanel(viewport,\r
- viewport.getAlignment().getSequences(), type, pwType, 0,\r
- viewport.alignment.getWidth());\r
- }\r
-\r
- addTreeMenuItem(tp, title);\r
- viewport.setCurrentTree(tp.getTree());\r
-\r
- Desktop.addInternalFrame(tp, title + " from " + this.title, 600, 500);\r
- }\r
-\r
- /**\r
- * DOCUMENT ME!\r
- *\r
- * @param title DOCUMENT ME!\r
- * @param order DOCUMENT ME!\r
- */\r
- public void addSortByOrderMenuItem(String title, final AlignmentOrder order)\r
- {\r
- final JMenuItem item = new JMenuItem("by " + title);\r
- sort.add(item);\r
- item.addActionListener(new java.awt.event.ActionListener()\r
- {\r
- public void actionPerformed(ActionEvent e)\r
- {\r
- addHistoryItem(new HistoryItem("Sort", viewport.alignment,\r
- HistoryItem.SORT));\r
-\r
- // TODO: JBPNote - have to map order entries to curent SequenceI pointers\r
- AlignmentSorter.sortBy(viewport.getAlignment(), order);\r
- alignPanel.repaint();\r
- }\r
- });\r
- }\r
-\r
- /**\r
- * DOCUMENT ME!\r
- *\r
- * @param treePanel DOCUMENT ME!\r
- * @param title DOCUMENT ME!\r
- */\r
- void addTreeMenuItem(final TreePanel treePanel, String title)\r
- {\r
- final JMenuItem item = new JMenuItem(title);\r
-\r
- treeCount++;\r
-\r
- if (treeCount == 1)\r
- {\r
- sort.add(sortByTreeMenu);\r
- }\r
-\r
- sortByTreeMenu.add(item);\r
- item.addActionListener(new java.awt.event.ActionListener()\r
- {\r
- public void actionPerformed(ActionEvent e)\r
- {\r
- addHistoryItem(new HistoryItem("Tree Sort",\r
- viewport.alignment, HistoryItem.SORT));\r
- AlignmentSorter.sortByTree(viewport.getAlignment(),\r
- treePanel.getTree());\r
- alignPanel.repaint();\r
- }\r
- });\r
-\r
- treePanel.addInternalFrameListener(new javax.swing.event.InternalFrameAdapter()\r
- {\r
- public void internalFrameClosed(\r
- javax.swing.event.InternalFrameEvent evt)\r
- {\r
- treeCount--;\r
- sortByTreeMenu.remove(item);\r
-\r
- if (treeCount == 0)\r
- {\r
- sort.remove(sortByTreeMenu);\r
- }\r
- }\r
- ;\r
- });\r
- viewport.addPropertyChangeListener(new java.beans.PropertyChangeListener()\r
- {\r
- public void propertyChange(PropertyChangeEvent evt)\r
- {\r
- if (evt.getPropertyName().equals("alignment"))\r
- {\r
- treePanel.getTree().UpdatePlaceHolders((Vector) evt.getNewValue());\r
- treePanel.repaint();\r
- }\r
- }\r
- });\r
- }\r
-\r
- /**\r
- * DOCUMENT ME!\r
- *\r
- * @param e DOCUMENT ME!\r
- */\r
- public void clustalAlignMenuItem_actionPerformed(ActionEvent e)\r
- {\r
- // TODO:resolve which menu item was actually selected\r
- // Now, check we have enough sequences\r
- SequenceI[] msa = null;\r
-\r
- if ((viewport.getSelectionGroup() != null) &&\r
- (viewport.getSelectionGroup().getSize() > 1))\r
- {\r
- // JBPNote UGLY! To prettify, make SequenceGroup and Alignment conform to some common interface!\r
- SequenceGroup seqs = viewport.getSelectionGroup();\r
- int sz;\r
- msa = new SequenceI[sz = seqs.getSize()];\r
-\r
- for (int i = 0; i < sz; i++)\r
- {\r
- msa[i] = (SequenceI) seqs.getSequenceAt(i);\r
- }\r
- }\r
- else\r
- {\r
- Vector seqs = viewport.getAlignment().getSequences();\r
-\r
- if (seqs.size() > 1)\r
- {\r
- msa = new SequenceI[seqs.size()];\r
-\r
- for (int i = 0; i < seqs.size(); i++)\r
- {\r
- msa[i] = (SequenceI) seqs.elementAt(i);\r
- }\r
- }\r
- }\r
-\r
- if (msa != null)\r
- {\r
- jalview.ws.MsaWSClient ct = new jalview.ws.MsaWSClient("ClustalWS",\r
- title, msa, false, true);\r
- }\r
- }\r
-\r
- /**\r
- * DOCUMENT ME!\r
- *\r
- * @param e DOCUMENT ME!\r
- */\r
- public void ClustalRealign_actionPerformed(ActionEvent e)\r
- {\r
- // TODO:resolve which menu item was actually selected\r
- // Now, check we have enough sequences\r
- SequenceI[] msa = null;\r
-\r
- if ((viewport.getSelectionGroup() != null) &&\r
- (viewport.getSelectionGroup().getSize() > 1))\r
- {\r
- // JBPNote UGLY! To prettify, make SequenceGroup and Alignment conform to some common interface!\r
- SequenceGroup seqs = viewport.getSelectionGroup();\r
- int sz;\r
- msa = new SequenceI[sz = seqs.getSize()];\r
-\r
- for (int i = 0; i < sz; i++)\r
- {\r
- msa[i] = (SequenceI) seqs.getSequenceAt(i);\r
- }\r
- }\r
- else\r
- {\r
- Vector seqs = viewport.getAlignment().getSequences();\r
-\r
- if (seqs.size() > 1)\r
- {\r
- msa = new SequenceI[seqs.size()];\r
-\r
- for (int i = 0; i < seqs.size(); i++)\r
- {\r
- msa[i] = (SequenceI) seqs.elementAt(i);\r
- }\r
- }\r
- }\r
-\r
- if (msa != null)\r
- {\r
- jalview.ws.MsaWSClient ct = new jalview.ws.MsaWSClient("ClustalWS",\r
- title, msa, true, true);\r
- }\r
- }\r
-\r
- /**\r
- * DOCUMENT ME!\r
- *\r
- * @param e DOCUMENT ME!\r
- */\r
- protected void jpred_actionPerformed(ActionEvent e)\r
- {\r
- SequenceI seq = null;\r
- SequenceI[] msa = null;\r
-\r
- if ((viewport.getSelectionGroup() != null) &&\r
- (viewport.getSelectionGroup().getSize() > 0))\r
- {\r
- // JBPNote UGLY! To prettify, make SequenceGroup and Alignment conform to some common interface!\r
- SequenceGroup seqs = viewport.getSelectionGroup();\r
-\r
- if ((seqs.getSize() == 1) || !viewport.alignment.isAligned())\r
- {\r
- seq = (SequenceI) seqs.getSequenceAt(0);\r
- }\r
- else\r
- {\r
- int sz;\r
- msa = new SequenceI[sz = seqs.getSize()];\r
-\r
- for (int i = 0; i < sz; i++)\r
- {\r
- msa[i] = (SequenceI) seqs.getSequenceAt(i);\r
- }\r
- }\r
- }\r
- else\r
- {\r
- Vector seqs = viewport.getAlignment().getSequences();\r
-\r
- if ((seqs.size() == 1) || !viewport.alignment.isAligned())\r
- {\r
- seq = (SequenceI) seqs.elementAt(0);\r
- }\r
- else\r
- {\r
- msa = new SequenceI[seqs.size()];\r
-\r
- for (int i = 0; i < seqs.size(); i++)\r
- {\r
- msa[i] = (SequenceI) seqs.elementAt(i);\r
- }\r
- }\r
- }\r
-\r
- if (msa != null)\r
- {\r
- JPredClient ct = new JPredClient(title, msa);\r
- }\r
- else if (seq != null)\r
- {\r
- JPredClient ct = new JPredClient(title, seq);\r
- }\r
- else\r
- {\r
- System.err.print(\r
- "JALVIEW ERROR! - Unexpected JPred selection state!\n");\r
- }\r
- }\r
-\r
- /**\r
- * DOCUMENT ME!\r
- *\r
- * @param e DOCUMENT ME!\r
- */\r
- protected void msaAlignMenuItem_actionPerformed(ActionEvent e)\r
- {\r
- // TODO:resolve which menu item was actually selected\r
- // Now, check we have enough sequences\r
- SequenceI[] msa = null;\r
-\r
- if ((viewport.getSelectionGroup() != null) &&\r
- (viewport.getSelectionGroup().getSize() > 1))\r
- {\r
- // JBPNote UGLY! To prettify, make SequenceGroup and Alignment conform to some common interface!\r
- SequenceGroup seqs = viewport.getSelectionGroup();\r
- int sz;\r
- msa = new SequenceI[sz = seqs.getSize()];\r
-\r
- for (int i = 0; i < sz; i++)\r
- {\r
- msa[i] = (SequenceI) seqs.getSequenceAt(i);\r
- }\r
- }\r
- else\r
- {\r
- Vector seqs = viewport.getAlignment().getSequences();\r
-\r
- if (seqs.size() > 1)\r
- {\r
- msa = new SequenceI[seqs.size()];\r
-\r
- for (int i = 0; i < seqs.size(); i++)\r