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,\n"
- +"or one of the multiple sequence alignment web services.",
- "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) {