-/********************
- * 2004 Jalview Reengineered
- * Barton Group
- * Dundee University
- *
- * AM Waterhouse
- *******************/
-
-
-
+/*
+* Jalview - A Sequence Alignment Editor and Viewer
+* Copyright (C) 2005 AM Waterhouse, J Procter, G Barton, M Clamp, S Searle
+*
+* This program is free software; you can redistribute it and/or
+* modify it under the terms of the GNU General Public License
+* as published by the Free Software Foundation; either version 2
+* of the License, or (at your option) any later version.
+*
+* This program is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+* GNU General Public License for more details.
+*
+* You should have received a copy of the GNU General Public License
+* along with this program; if not, write to the Free Software
+* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
+*/
package jalview.gui;
if (currentFileFormat.equals("Jalview"))
{
- String shortName = title.replace('/', '_');
- title = title.replace('\\', '_');
+ String shortName = title;
+ if(shortName.indexOf(java.io.File.separatorChar)>-1)
+ shortName = shortName.substring(
+ shortName.lastIndexOf(java.io.File.separatorChar)+1);
+
String choice = chooser.getSelectedFile().getPath();
Jalview2XML.SaveState(this, choice, shortName);
// USE Jalview2XML to save this file
protected void outputText_actionPerformed(ActionEvent e)
{
CutAndPasteTransfer cap = new CutAndPasteTransfer();
- JInternalFrame frame = new JInternalFrame();
- frame.setContentPane(cap);
- Desktop.addInternalFrame(frame, "Alignment output - "+e.getActionCommand(), 600, 500);
+ Desktop.addInternalFrame(cap, "Alignment output - "+e.getActionCommand(), 600, 500);
cap.setText( FormatAdapter.formatSequences(e.getActionCommand(), viewport.getAlignment().getSequences()));
}
viewport.alignment.deleteSequence(i);
}
}
- viewport.firePropertyChange("alignment", null, viewport.getAlignment().getSequences());
updateEditMenuBar();
viewport.updateConsensus();
viewport.updateConservation();
alignPanel.repaint();
+ viewport.firePropertyChange("alignment", null, viewport.getAlignment().getSequences());
}
public void moveSelectedSequences(boolean up)
protected void delete_actionPerformed(ActionEvent e)
{
boolean seqsdeleted=false;
- addHistoryItem(new HistoryItem("Delete Sequences", viewport.alignment, HistoryItem.HIDE));
if (viewport.getSelectionGroup() == null)
return;
+ addHistoryItem(new HistoryItem("Delete Sequences", viewport.alignment, HistoryItem.HIDE));
+
SequenceGroup sg = viewport.getSelectionGroup();
for (int i=0;i < sg.sequences.size(); i++)
{
public void sortGroupMenuItem_actionPerformed(ActionEvent e)
{
addHistoryItem(new HistoryItem("Group Sort", viewport.alignment, HistoryItem.SORT));
- AlignmentSorter.sortByGroup(viewport.getAlignment());
+ // AlignmentSorter.sortByGroup(viewport.getAlignment());
AlignmentSorter.sortGroups(viewport.getAlignment());
alignPanel.repaint();
}
public void removeRedundancyMenuItem_actionPerformed(ActionEvent e)
{
- RedundancyPanel sp = new RedundancyPanel(alignPanel);
+ RedundancyPanel sp = new RedundancyPanel(alignPanel,this);
JInternalFrame frame = new JInternalFrame();
frame.setContentPane(sp);
Desktop.addInternalFrame(frame, "Redundancy threshold selection", 400, 100, false);
public void pairwiseAlignmentMenuItem_actionPerformed(ActionEvent e)
{
- if(viewport.getSelectionGroup().getSize()<2)
+ if((viewport.getSelectionGroup()==null) ||
+ viewport.getSelectionGroup().getSize()<2)
JOptionPane.showInternalMessageDialog(this, "You must select at least 2 sequences.", "Invalid Selection", JOptionPane.WARNING_MESSAGE);
else
{
void NewTreePanel(String type, String pwType, String title)
{
- //are the sequences aligned?
- if(!viewport.alignment.isAligned())
- {
- JOptionPane.showMessageDialog(Desktop.desktop, "The sequences must be aligned before creating a tree.\n"
- +"Try using the Pad function in the edit menu.",
- "Sequences not aligned", JOptionPane.WARNING_MESSAGE);
- return;
- }
-
+ String ltitle;
final TreePanel tp;
if (viewport.getSelectionGroup() != null &&
viewport.getSelectionGroup().getSize() > 3)
{
+ int s=0;
+ SequenceGroup sg = viewport.getSelectionGroup();
+
+ /* Decide if the selection is a column region */
+ while (s<sg.sequences.size()) {
+ if (((SequenceI) sg.sequences.elementAt(s++)).getLength()<sg.getEndRes()) {
+ JOptionPane.showMessageDialog(Desktop.desktop,
+ "The selected region to create a tree may\nonly contain residues or gaps.\n"
+ +"Try using the Pad function in the edit menu,\n"
+ +"or one of the multiple sequence alignment web services.",
+ "Sequences in selection are not aligned", JOptionPane.WARNING_MESSAGE);
+ return;
+ }
+
+ }
+ title=title+" on region";
tp = new TreePanel(viewport, viewport.getSelectionGroup().sequences, type,
pwType,
- 0, viewport.alignment.getWidth());
+ sg.getStartRes(), sg.getEndRes());
}
else
{
- tp = new TreePanel(viewport, viewport.getAlignment().getSequences(),
- type, pwType, 0, viewport.alignment.getWidth());
- }
+
+ //are the sequences aligned?
+ if(!viewport.alignment.isAligned())
+ {
+ JOptionPane.showMessageDialog(Desktop.desktop, "The sequences must be aligned before creating a tree.\n"
+ +"Try using the Pad function in the edit menu,\n"
+ +"or one of the multiple sequence alignment web services.",
+ "Sequences not aligned", JOptionPane.WARNING_MESSAGE);
+ return;
+ }
+ tp = new TreePanel(viewport, viewport.getAlignment().getSequences(),
+ type, pwType, 0, viewport.alignment.getWidth());
+ }
addTreeMenuItem(tp, title);
+ viewport.setCurrentTree(tp.getTree());
- Desktop.addInternalFrame(tp, title, 600, 500);
+ Desktop.addInternalFrame(tp, title+" from "+this.title, 600, 500);
}
public void addSortByOrderMenuItem(String title, final AlignmentOrder order) {
}
if (msa!=null) {
+ jalview.ws.MsaWSClient ct = new jalview.ws.MsaWSClient("ClustalWS", title, msa, false, true);
+ }
+ }
+ public void ClustalRealign_actionPerformed(ActionEvent e)
+ {
+ // TODO:resolve which menu item was actually selected
+ // Now, check we have enough sequences
+ SequenceI[] msa=null;
+ if (viewport.getSelectionGroup() != null && viewport.getSelectionGroup().getSize()>1)
+ {
+ // JBPNote UGLY! To prettify, make SequenceGroup and Alignment conform to some common interface!
+ SequenceGroup seqs = viewport.getSelectionGroup();
+ int sz;
+ msa = new SequenceI[sz=seqs.getSize()];
+ for (int i = 0; i < sz; i++)
+ {
+ msa[i] = (SequenceI) seqs.getSequenceAt(i);
+ }
+
+ }
+ else
+ {
+ Vector seqs = viewport.getAlignment().getSequences();
+
+ if (seqs.size() > 1) {
+ msa = new SequenceI[seqs.size()];
+ for (int i = 0; i < seqs.size(); i++)
+ {
+ msa[i] = (SequenceI) seqs.elementAt(i);
+ }
+
+ }
+
+ }
+ if (msa!=null) {
jalview.ws.MsaWSClient ct = new jalview.ws.MsaWSClient("ClustalWS", title, msa, true, true);
}
}
+
protected void jpred_actionPerformed(ActionEvent e)
{
SequenceI seq=null;
}
if (msa!=null) {
- MsaWSClient ct = new jalview.ws.MsaWSClient("MuscleWS",title, msa, true, true);
+ MsaWSClient ct = new jalview.ws.MsaWSClient("MuscleWS",title, msa, false, true);
}
}
protected void LoadtreeMenuItem_actionPerformed(ActionEvent e) {