X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Fgui%2FAlignFrame.java;h=9b91255f50ba15bc43994c328c9457f6738509c0;hb=797df64fa2a0a30773d0f48f5494d4155e5a8be3;hp=3ac30ae907aa42ff9b0601c37da200dc7bd17dde;hpb=1ce2a2cae40ea74d2f76b924bf60cc8322a73607;p=jalview.git
diff --git a/src/jalview/gui/AlignFrame.java b/src/jalview/gui/AlignFrame.java
index 3ac30ae..9b91255 100755
--- a/src/jalview/gui/AlignFrame.java
+++ b/src/jalview/gui/AlignFrame.java
@@ -1,6 +1,6 @@
/*
- * Jalview - A Sequence Alignment Editor and Viewer (Version 2.5)
- * Copyright (C) 2010 J Procter, AM Waterhouse, G Barton, M Clamp, S Searle
+ * Jalview - A Sequence Alignment Editor and Viewer (Version 2.7)
+ * Copyright (C) 2011 J Procter, AM Waterhouse, J Engelhardt, LM Lui, G Barton, M Clamp, S Searle
*
* This file is part of Jalview.
*
@@ -17,29 +17,110 @@
*/
package jalview.gui;
-import java.beans.*;
-import java.io.*;
-import java.util.*;
-
-import java.awt.*;
-import java.awt.datatransfer.*;
-import java.awt.dnd.*;
-import java.awt.event.*;
-import java.awt.print.*;
-import javax.swing.*;
-import javax.swing.event.MenuEvent;
-
-import jalview.analysis.*;
+import jalview.analysis.AAFrequency;
+import jalview.analysis.AlignmentSorter;
+import jalview.analysis.Conservation;
+import jalview.analysis.CrossRef;
+import jalview.analysis.NJTree;
+import jalview.analysis.ParseProperties;
+import jalview.analysis.SequenceIdMatcher;
import jalview.bin.Cache;
-import jalview.commands.*;
-import jalview.datamodel.*;
-import jalview.io.*;
-import jalview.jbgui.*;
-import jalview.schemes.*;
-import jalview.ws.*;
+import jalview.commands.CommandI;
+import jalview.commands.EditCommand;
+import jalview.commands.OrderCommand;
+import jalview.commands.RemoveGapColCommand;
+import jalview.commands.RemoveGapsCommand;
+import jalview.commands.SlideSequencesCommand;
+import jalview.commands.TrimRegionCommand;
+import jalview.datamodel.AlignedCodonFrame;
+import jalview.datamodel.Alignment;
+import jalview.datamodel.AlignmentAnnotation;
+import jalview.datamodel.AlignmentI;
+import jalview.datamodel.AlignmentOrder;
+import jalview.datamodel.AlignmentView;
+import jalview.datamodel.ColumnSelection;
+import jalview.datamodel.PDBEntry;
+import jalview.datamodel.SeqCigar;
+import jalview.datamodel.Sequence;
+import jalview.datamodel.SequenceGroup;
+import jalview.datamodel.SequenceI;
+import jalview.io.AlignmentProperties;
+import jalview.io.AnnotationFile;
+import jalview.io.FeaturesFile;
+import jalview.io.FileLoader;
+import jalview.io.FormatAdapter;
+import jalview.io.HTMLOutput;
+import jalview.io.IdentifyFile;
+import jalview.io.JalviewFileChooser;
+import jalview.io.JalviewFileView;
+import jalview.io.JnetAnnotationMaker;
+import jalview.io.NewickFile;
+import jalview.jbgui.GAlignFrame;
+import jalview.schemes.Blosum62ColourScheme;
+import jalview.schemes.BuriedColourScheme;
+import jalview.schemes.ClustalxColourScheme;
+import jalview.schemes.ColourSchemeI;
+import jalview.schemes.ColourSchemeProperty;
+import jalview.schemes.HelixColourScheme;
+import jalview.schemes.HydrophobicColourScheme;
+import jalview.schemes.NucleotideColourScheme;
+import jalview.schemes.PIDColourScheme;
+import jalview.schemes.PurinePyrimidineColourScheme;
+import jalview.schemes.ResidueProperties;
+import jalview.schemes.StrandColourScheme;
+import jalview.schemes.TaylorColourScheme;
+import jalview.schemes.TurnColourScheme;
+import jalview.schemes.UserColourScheme;
+import jalview.schemes.ZappoColourScheme;
+import jalview.ws.WSMenuEntryProviderI;
import jalview.ws.jws1.Discoverer;
import jalview.ws.jws2.Jws2Discoverer;
+import java.awt.BorderLayout;
+import java.awt.Color;
+import java.awt.Component;
+import java.awt.GridLayout;
+import java.awt.Rectangle;
+import java.awt.Toolkit;
+import java.awt.datatransfer.Clipboard;
+import java.awt.datatransfer.DataFlavor;
+import java.awt.datatransfer.StringSelection;
+import java.awt.datatransfer.Transferable;
+import java.awt.dnd.DnDConstants;
+import java.awt.dnd.DropTargetDragEvent;
+import java.awt.dnd.DropTargetDropEvent;
+import java.awt.dnd.DropTargetEvent;
+import java.awt.dnd.DropTargetListener;
+import java.awt.event.ActionEvent;
+import java.awt.event.ActionListener;
+import java.awt.event.KeyAdapter;
+import java.awt.event.KeyEvent;
+import java.awt.event.MouseAdapter;
+import java.awt.event.MouseEvent;
+import java.awt.print.PageFormat;
+import java.awt.print.PrinterJob;
+import java.beans.PropertyChangeEvent;
+import java.io.File;
+import java.net.URL;
+import java.util.ArrayList;
+import java.util.Enumeration;
+import java.util.Hashtable;
+import java.util.Vector;
+
+import javax.swing.JButton;
+import javax.swing.JEditorPane;
+import javax.swing.JInternalFrame;
+import javax.swing.JLabel;
+import javax.swing.JLayeredPane;
+import javax.swing.JMenu;
+import javax.swing.JMenuItem;
+import javax.swing.JOptionPane;
+import javax.swing.JPanel;
+import javax.swing.JProgressBar;
+import javax.swing.JRadioButtonMenuItem;
+import javax.swing.JScrollPane;
+import javax.swing.SwingUtilities;
+
/**
* DOCUMENT ME!
*
@@ -321,7 +402,22 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener,
|| evt.isShiftDown() || evt.isAltDown());
}
break;
-
+
+ //case KeyEvent.VK_A:
+ // if (viewport.cursorMode)
+ // {
+ // alignPanel.seqPanel.insertNucAtCursor(false,"A");
+ // //System.out.println("A");
+ // }
+ // break;
+ /*
+ case KeyEvent.VK_CLOSE_BRACKET:
+ if (viewport.cursorMode)
+ {
+ System.out.println("closing bracket");
+ }
+ break;
+ */
case KeyEvent.VK_DELETE:
case KeyEvent.VK_BACK_SPACE:
if (!viewport.cursorMode)
@@ -494,6 +590,7 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener,
}
ap.av.updateConservation(ap);
ap.av.updateConsensus(ap);
+ ap.av.updateStrucConsensus(ap);
}
}
@@ -550,9 +647,13 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener,
};
});
// Finally, build the menu once to get current service state
- javax.swing.SwingUtilities.invokeLater(new Runnable() {
- public void run() { BuildWebServiceMenu();}
- });
+ new Thread(new Runnable()
+ {
+ public void run()
+ {
+ BuildWebServiceMenu();
+ }
+ }).start();
}
public void setGUINucleotide(boolean nucleotide)
@@ -561,11 +662,14 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener,
conservationMenuItem.setEnabled(!nucleotide);
modifyConservation.setEnabled(!nucleotide);
showGroupConservation.setEnabled(!nucleotide);
+ rnahelicesColour.setEnabled(nucleotide);
+ purinePyrimidineColour.setEnabled(nucleotide);
// Remember AlignFrame always starts as protein
- if (!nucleotide)
- {
- calculateMenu.remove(calculateMenu.getItemCount() - 2);
- }
+ //if (!nucleotide)
+ // {
+ // showTr
+ // calculateMenu.remove(calculateMenu.getItemCount() - 2);
+ // }
}
/**
@@ -615,7 +719,11 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener,
applyToAllGroups.setState(av.colourAppliesToAllGroups);
showNpFeatsMenuitem.setSelected(av.isShowNpFeats());
showDbRefsMenuitem.setSelected(av.isShowDbRefs());
-
+ autoCalculate.setSelected(av.autoCalculateConsensus);
+ sortByTree.setSelected(av.sortByTree);
+ listenToViewSelections.setSelected(av.followSelection);
+ rnahelicesColour.setEnabled(av.alignment.hasRNAStructure());
+ rnahelicesColour.setSelected(av.getGlobalColourScheme() instanceof jalview.schemes.RNAHelicesColour);
setShowProductsEnabled();
updateEditMenuBar();
@@ -671,7 +779,7 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener,
progressBars.put(lId, progressPanel);
}
// update GUI
- setMenusForViewport();
+ // setMenusForViewport();
validate();
}
@@ -695,8 +803,10 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener,
public void actionPerformed(ActionEvent e)
{
handler.cancelActivity(id);
- us.setProgressBar("Cancelled "
- + ((JLabel) progressPanel.getComponent(0)).getText(), id);
+ us.setProgressBar(
+ "Cancelled "
+ + ((JLabel) progressPanel.getComponent(0))
+ .getText(), id);
}
});
progressPanel.add(cancel, BorderLayout.EAST);
@@ -834,8 +944,8 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener,
*/
public void saveAs_actionPerformed(ActionEvent e)
{
- JalviewFileChooser chooser = new JalviewFileChooser(jalview.bin.Cache
- .getProperty("LAST_DIRECTORY"),
+ JalviewFileChooser chooser = new JalviewFileChooser(
+ jalview.bin.Cache.getProperty("LAST_DIRECTORY"),
jalview.io.AppletFormatAdapter.WRITABLE_EXTENSIONS,
jalview.io.AppletFormatAdapter.WRITABLE_FNAMES,
currentFileFormat, false);
@@ -1005,11 +1115,19 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener,
CutAndPasteTransfer cap = new CutAndPasteTransfer();
cap.setForInput(null);
- Desktop.addInternalFrame(cap, "Alignment output - "
- + e.getActionCommand(), 600, 500);
- cap.setText(new FormatAdapter().formatSequences(e.getActionCommand(),
- viewport.alignment, omitHidden, viewport.colSel));
+ try
+ {
+ cap.setText(new FormatAdapter().formatSequences(e.getActionCommand(),
+ viewport.alignment, omitHidden, viewport.colSel));
+ Desktop.addInternalFrame(cap,
+ "Alignment output - " + e.getActionCommand(), 600, 500);
+ } catch (OutOfMemoryError oom)
+ {
+ new OOMWarning("Outputting alignment as " + e.getActionCommand(), oom);
+ cap.dispose();
+ }
+
}
/**
@@ -1020,9 +1138,9 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener,
*/
protected void htmlMenuItem_actionPerformed(ActionEvent e)
{
- new HTMLOutput(alignPanel, alignPanel.seqPanel.seqCanvas
- .getSequenceRenderer(), alignPanel.seqPanel.seqCanvas
- .getFeatureRenderer());
+ new HTMLOutput(alignPanel,
+ alignPanel.seqPanel.seqCanvas.getSequenceRenderer(),
+ alignPanel.seqPanel.seqCanvas.getFeatureRenderer());
}
public void createImageMap(File file, String image)
@@ -1078,7 +1196,8 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener,
public void exportAnnotations_actionPerformed(ActionEvent e)
{
- new AnnotationExporter().exportAnnotations(alignPanel,
+ new AnnotationExporter().exportAnnotations(
+ alignPanel,
viewport.showAnnotation ? viewport.alignment
.getAlignmentAnnotation() : null, viewport.alignment
.getGroups(),
@@ -1088,8 +1207,8 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener,
public void associatedData_actionPerformed(ActionEvent e)
{
// Pick the tree file
- JalviewFileChooser chooser = new JalviewFileChooser(jalview.bin.Cache
- .getProperty("LAST_DIRECTORY"));
+ JalviewFileChooser chooser = new JalviewFileChooser(
+ jalview.bin.Cache.getProperty("LAST_DIRECTORY"));
chooser.setFileView(new JalviewFileView());
chooser.setDialogTitle("Load Jalview Annotations or Features File");
chooser.setToolTipText("Load Jalview Annotations / Features file");
@@ -1100,7 +1219,7 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener,
{
String choice = chooser.getSelectedFile().getPath();
jalview.bin.Cache.setProperty("LAST_DIRECTORY", choice);
- loadJalviewDataFile(choice);
+ loadJalviewDataFile(choice, null, null, null);
}
}
@@ -1529,11 +1648,11 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener,
jalview.gui.Desktop.internalCopy = true;
// Its really worth setting the clipboard contents
// to empty before setting the large StringSelection!!
- Toolkit.getDefaultToolkit().getSystemClipboard().setContents(
- new StringSelection(""), null);
+ Toolkit.getDefaultToolkit().getSystemClipboard()
+ .setContents(new StringSelection(""), null);
- Toolkit.getDefaultToolkit().getSystemClipboard().setContents(ss,
- Desktop.instance);
+ Toolkit.getDefaultToolkit().getSystemClipboard()
+ .setContents(ss, Desktop.instance);
} catch (OutOfMemoryError er)
{
new OOMWarning("copying region", er);
@@ -1796,8 +1915,8 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener,
}
buildSortByAnnotationScoresMenu();
}
- viewport.firePropertyChange("alignment", null, alignment
- .getSequences());
+ viewport.firePropertyChange("alignment", null,
+ alignment.getSequences());
}
else
@@ -1985,6 +2104,7 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener,
alignPanel.idPanel.idCanvas.searchResults = null;
alignPanel.paintAlignment(true);
PaintRefresher.Refresh(alignPanel, viewport.getSequenceSetId());
+ viewport.sendSelection();
}
/**
@@ -2010,14 +2130,15 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener,
}
alignPanel.paintAlignment(true);
- viewport.sendSelection();
PaintRefresher.Refresh(alignPanel, viewport.getSequenceSetId());
+ viewport.sendSelection();
}
public void invertColSel_actionPerformed(ActionEvent e)
{
viewport.invertColumnSelection();
alignPanel.paintAlignment(true);
+ viewport.sendSelection();
}
/**
@@ -2228,8 +2349,57 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener,
public void newView_actionPerformed(ActionEvent e)
{
+ newView(true);
+ }
+
+ /**
+ *
+ * @param copyAnnotation
+ * if true then duplicate all annnotation, groups and settings
+ * @return new alignment panel, already displayed.
+ */
+ public AlignmentPanel newView(boolean copyAnnotation)
+ {
+ return newView(null, copyAnnotation);
+ }
+
+ /**
+ *
+ * @param viewTitle
+ * title of newly created view
+ * @return new alignment panel, already displayed.
+ */
+ public AlignmentPanel newView(String viewTitle)
+ {
+ return newView(viewTitle, true);
+ }
+
+ /**
+ *
+ * @param viewTitle
+ * title of newly created view
+ * @param copyAnnotation
+ * if true then duplicate all annnotation, groups and settings
+ * @return new alignment panel, already displayed.
+ */
+ public AlignmentPanel newView(String viewTitle, boolean copyAnnotation)
+ {
AlignmentPanel newap = new Jalview2XML().copyAlignPanel(alignPanel,
true);
+ if (!copyAnnotation)
+ {
+ // just remove all the current annotation except for the automatic stuff
+ newap.av.alignment.deleteAllGroups();
+ for (AlignmentAnnotation alan : newap.av.alignment
+ .getAlignmentAnnotation())
+ {
+ if (!alan.autoCalculated)
+ {
+ newap.av.alignment.deleteAnnotation(alan);
+ }
+ ;
+ }
+ }
newap.av.gatherViewsHere = false;
@@ -2242,8 +2412,19 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener,
newap.av.redoList = viewport.redoList;
int index = Desktop.getViewCount(viewport.getSequenceSetId());
- String newViewName = "View " + index;
-
+ // make sure the new view has a unique name - this is essential for Jalview
+ // 2 archives
+ boolean addFirstIndex = false;
+ if (viewTitle == null || viewTitle.trim().length() == 0)
+ {
+ viewTitle = "View";
+ addFirstIndex = true;
+ }
+ else
+ {
+ index = 1;// we count from 1 if given a specific name
+ }
+ String newViewName = viewTitle + ((addFirstIndex) ? " " + index : "");
Vector comps = (Vector) PaintRefresher.components.get(viewport
.getSequenceSetId());
Vector existingNames = new Vector();
@@ -2261,7 +2442,7 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener,
while (existingNames.contains(newViewName))
{
- newViewName = "View " + (++index);
+ newViewName = viewTitle + " " + (++index);
}
newap.av.viewName = newViewName;
@@ -2273,6 +2454,7 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener,
viewport.gatherViewsHere = true;
}
tabbedPane.setSelectedIndex(tabbedPane.getTabCount() - 1);
+ return newap;
}
public void expandViews_actionPerformed(ActionEvent e)
@@ -2648,58 +2830,9 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener,
{
JEditorPane editPane = new JEditorPane("text/html", "");
editPane.setEditable(false);
- StringBuffer contents = new StringBuffer("");
-
- float avg = 0;
- int min = Integer.MAX_VALUE, max = 0;
- for (int i = 0; i < viewport.alignment.getHeight(); i++)
- {
- int size = viewport.alignment.getSequenceAt(i).getEnd()
- - viewport.alignment.getSequenceAt(i).getStart();
- avg += size;
- if (size > max)
- max = size;
- if (size < min)
- min = size;
- }
- avg = avg / (float) viewport.alignment.getHeight();
-
- contents.append("
Sequences: " + viewport.alignment.getHeight());
- contents.append("
Minimum Sequence Length: " + min);
- contents.append("
Maximum Sequence Length: " + max);
- contents.append("
Average Length: " + (int) avg);
-
- if (((Alignment) viewport.alignment).getProperties() != null)
- {
- Hashtable props = ((Alignment) viewport.alignment).getProperties();
- Enumeration en = props.keys();
- contents.append("
");
- while (en.hasMoreElements())
- {
- String key = en.nextElement().toString();
- StringBuffer val = new StringBuffer();
- String vals = props.get(key).toString();
- int pos = 0, npos;
- do
- {
- npos = vals.indexOf("\n", pos);
- if (npos == -1)
- {
- val.append(vals.substring(pos));
- }
- else
- {
- val.append(vals.substring(pos, npos));
- val.append("
");
- }
- pos = npos + 1;
- } while (npos != -1);
- contents
- .append("" + key + " | " + val + " |
");
- }
- contents.append("
");
- }
- editPane.setText(contents.toString() + "");
+ StringBuffer contents = new AlignmentProperties(viewport.alignment)
+ .formatAsHtml();
+ editPane.setText("" + contents.toString() + "");
JInternalFrame frame = new JInternalFrame();
frame.getContentPane().add(new JScrollPane(editPane));
@@ -2723,19 +2856,18 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener,
JInternalFrame frame = new JInternalFrame();
OverviewPanel overview = new OverviewPanel(alignPanel);
frame.setContentPane(overview);
- Desktop.addInternalFrame(frame, "Overview " + this.getTitle(), frame
- .getWidth(), frame.getHeight());
+ Desktop.addInternalFrame(frame, "Overview " + this.getTitle(),
+ frame.getWidth(), frame.getHeight());
frame.pack();
frame.setLayer(JLayeredPane.PALETTE_LAYER);
- frame
- .addInternalFrameListener(new javax.swing.event.InternalFrameAdapter()
- {
- public void internalFrameClosed(
- javax.swing.event.InternalFrameEvent evt)
- {
- alignPanel.setOverviewPanel(null);
- };
- });
+ frame.addInternalFrameListener(new javax.swing.event.InternalFrameAdapter()
+ {
+ public void internalFrameClosed(
+ javax.swing.event.InternalFrameEvent evt)
+ {
+ alignPanel.setOverviewPanel(null);
+ };
+ });
alignPanel.setOverviewPanel(overview);
}
@@ -2765,8 +2897,8 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener,
public void clustalColour_actionPerformed(ActionEvent e)
{
changeColour(new ClustalxColourScheme(
- viewport.alignment.getSequences(), viewport.alignment
- .getWidth()));
+ viewport.alignment.getSequences(),
+ viewport.alignment.getWidth()));
}
/**
@@ -2857,10 +2989,25 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener,
changeColour(new NucleotideColourScheme());
}
+ public void purinePyrimidineColour_actionPerformed(ActionEvent e)
+ {
+ changeColour(new PurinePyrimidineColourScheme());
+ }
+ /*
+ public void covariationColour_actionPerformed(ActionEvent e)
+ {
+ changeColour(new CovariationColourScheme(viewport.alignment.getAlignmentAnnotation()[0]));
+ }
+ */
public void annotationColour_actionPerformed(ActionEvent e)
{
new AnnotationColourChooser(viewport, alignPanel);
}
+
+ public void rnahelicesColour_actionPerformed(ActionEvent e)
+ {
+ new RNAHelicesColourChooser(viewport, alignPanel);
+ }
/**
* DOCUMENT ME!
@@ -2904,8 +3051,8 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener,
Alignment al = (Alignment) viewport.alignment;
Conservation c = new Conservation("All",
- ResidueProperties.propHash, 3, al.getSequences(), 0, al
- .getWidth() - 1);
+ ResidueProperties.propHash, 3, al.getSequences(), 0,
+ al.getWidth() - 1);
c.calculate();
c.verdict(false, viewport.ConsPercGaps);
@@ -2941,8 +3088,9 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener,
if (cs instanceof ClustalxColourScheme)
{
- sg.cs = new ClustalxColourScheme(sg
- .getSequences(viewport.hiddenRepSequences), sg.getWidth());
+ sg.cs = new ClustalxColourScheme(
+ sg.getSequences(viewport.hiddenRepSequences),
+ sg.getWidth());
}
else if (cs instanceof UserColourScheme)
{
@@ -2964,9 +3112,9 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener,
{
sg.cs.setThreshold(threshold, viewport.getIgnoreGapsConsensus());
- sg.cs.setConsensus(AAFrequency.calculate(sg
- .getSequences(viewport.hiddenRepSequences), sg
- .getStartRes(), sg.getEndRes() + 1));
+ sg.cs.setConsensus(AAFrequency.calculate(
+ sg.getSequences(viewport.hiddenRepSequences),
+ sg.getStartRes(), sg.getEndRes() + 1));
}
else
{
@@ -2976,9 +3124,9 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener,
if (viewport.getConservationSelected())
{
Conservation c = new Conservation("Group",
- ResidueProperties.propHash, 3, sg
- .getSequences(viewport.hiddenRepSequences), sg
- .getStartRes(), sg.getEndRes() + 1);
+ ResidueProperties.propHash, 3,
+ sg.getSequences(viewport.hiddenRepSequences),
+ sg.getStartRes(), sg.getEndRes() + 1);
c.calculate();
c.verdict(false, viewport.ConsPercGaps);
sg.cs.setConservation(c);
@@ -3009,8 +3157,8 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener,
if (viewport.getAbovePIDThreshold()
&& viewport.globalColourScheme != null)
{
- SliderPanel.setPIDSliderSource(alignPanel, viewport
- .getGlobalColourScheme(), "Background");
+ SliderPanel.setPIDSliderSource(alignPanel,
+ viewport.getGlobalColourScheme(), "Background");
SliderPanel.showPIDSlider();
}
}
@@ -3120,8 +3268,7 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener,
if (evt.isControlDown()
|| SwingUtilities.isRightMouseButton(evt))
{
- radioItem
- .removeActionListener(radioItem.getActionListeners()[0]);
+ radioItem.removeActionListener(radioItem.getActionListeners()[0]);
int option = JOptionPane.showInternalConfirmDialog(
jalview.gui.Desktop.desktop,
@@ -3312,7 +3459,16 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener,
.getAlignment().getSequences());
}
}
+ public void sortByTreeOption_actionPerformed(ActionEvent e)
+ {
+ viewport.sortByTree = sortByTree.isSelected();
+ }
+ @Override
+ protected void listenToViewSelections_actionPerformed(ActionEvent e)
+ {
+ viewport.followSelection = listenToViewSelections.isSelected();
+ }
/**
* DOCUMENT ME!
*
@@ -3495,8 +3651,8 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener,
public void actionPerformed(ActionEvent e)
{
SequenceI[] oldOrder = viewport.getAlignment().getSequencesArray();
- AlignmentSorter.sortByAnnotationScore(scoreLabel, viewport
- .getAlignment());// ,viewport.getSelectionGroup());
+ AlignmentSorter.sortByAnnotationScore(scoreLabel,
+ viewport.getAlignment());// ,viewport.getSelectionGroup());
addHistoryItem(new OrderCommand("Sort by " + scoreLabel, oldOrder,
viewport.alignment));
alignPanel.paintAlignment(true);
@@ -3544,8 +3700,8 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener,
Enumeration labels = scoreSorts.keys();
while (labels.hasMoreElements())
{
- addSortByAnnotScoreMenuItem(sortByAnnotScore, (String) labels
- .nextElement());
+ addSortByAnnotScoreMenuItem(sortByAnnotScore,
+ (String) labels.nextElement());
}
sortByAnnotScore.setVisible(scoreSorts.size() > 0);
scoreSorts.clear();
@@ -3595,21 +3751,16 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener,
for (i = 0; i < treePanels.size(); i++)
{
- TreePanel tp = (TreePanel) treePanels.elementAt(i);
+ final TreePanel tp = (TreePanel) treePanels.elementAt(i);
final JMenuItem item = new JMenuItem(tp.getTitle());
final NJTree tree = ((TreePanel) treePanels.elementAt(i)).getTree();
item.addActionListener(new java.awt.event.ActionListener()
{
public void actionPerformed(ActionEvent e)
{
- SequenceI[] oldOrder = viewport.getAlignment()
- .getSequencesArray();
- AlignmentSorter.sortByTree(viewport.getAlignment(), tree);
-
- addHistoryItem(new OrderCommand("Tree Sort", oldOrder,
- viewport.alignment));
-
- alignPanel.paintAlignment(true);
+ tp.sortByTree_actionPerformed(null);
+ addHistoryItem(tp.sortAlignmentIn(alignPanel));
+
}
});
@@ -3617,6 +3768,19 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener,
}
}
+ public boolean sortBy(AlignmentOrder alorder, String undoname)
+ {
+ SequenceI[] oldOrder = viewport.getAlignment().getSequencesArray();
+ AlignmentSorter.sortBy(viewport.getAlignment(), alorder);
+ if (undoname != null)
+ {
+ addHistoryItem(new OrderCommand(undoname, oldOrder,
+ viewport.alignment));
+ }
+ alignPanel.paintAlignment(true);
+ return true;
+ }
+
/**
* Work out whether the whole set of sequences or just the selected set will
* be submitted for multiple alignment.
@@ -3700,8 +3864,8 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener,
protected void LoadtreeMenuItem_actionPerformed(ActionEvent e)
{
// Pick the tree file
- JalviewFileChooser chooser = new JalviewFileChooser(jalview.bin.Cache
- .getProperty("LAST_DIRECTORY"));
+ JalviewFileChooser chooser = new JalviewFileChooser(
+ jalview.bin.Cache.getProperty("LAST_DIRECTORY"));
chooser.setFileView(new JalviewFileView());
chooser.setDialogTitle("Select a newick-like tree file");
chooser.setToolTipText("Load a tree file");
@@ -3725,8 +3889,8 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener,
}
if (fin != null && fin.hasWarningMessage())
{
- JOptionPane.showMessageDialog(Desktop.desktop, fin
- .getWarningMessage(), "Possible problem with tree file",
+ JOptionPane.showMessageDialog(Desktop.desktop,
+ fin.getWarningMessage(), "Possible problem with tree file",
JOptionPane.WARNING_MESSAGE);
}
}
@@ -3818,129 +3982,149 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener,
}
;
}
+ final AlignFrame me = this;
buildingMenu = true;
- try
+ new Thread(new Runnable()
{
- System.err
- .println("Building ws menu again " + Thread.currentThread());
- // TODO: add support for context dependent disabling of services based on
- // alignment and current selection
- // TODO: add additional serviceHandle parameter to specify abstract
- // handler
- // class independently of AbstractName
- // TODO: add in rediscovery GUI function to restart discoverer
- // TODO: group services by location as well as function and/or introduce
- // object broker mechanism.
- Vector wsmenu = new Vector();
- final IProgressIndicator af = this;
- if (Cache.getDefault("SHOW_JWS1_SERVICES", true)
- && Discoverer.services != null
- && (Discoverer.services.size() > 0))
+ public void run()
{
- // TODO: refactor to allow list of AbstractName/Handler bindings to be
- // stored or retrieved from elsewhere
- Vector msaws = (Vector) Discoverer.services.get("MsaWS");
- Vector secstrpr = (Vector) Discoverer.services.get("SecStrPred");
- Vector seqsrch = (Vector) Discoverer.services.get("SeqSearch");
- // TODO: move GUI generation code onto service implementation - so a
- // client instance attaches itself to the GUI with method call like
- // jalview.ws.MsaWSClient.bind(servicehandle, Desktop.instance,
- // alignframe)
- if (msaws != null)
+ try
{
- // Add any Multiple Sequence Alignment Services
+ System.err.println("Building ws menu again "
+ + Thread.currentThread());
+ // TODO: add support for context dependent disabling of services based
+ // on
+ // alignment and current selection
+ // TODO: add additional serviceHandle parameter to specify abstract
+ // handler
+ // class independently of AbstractName
+ // TODO: add in rediscovery GUI function to restart discoverer
+ // TODO: group services by location as well as function and/or
+ // introduce
+ // object broker mechanism.
+ final Vector wsmenu = new Vector();
+ final IProgressIndicator af = me;
final JMenu msawsmenu = new JMenu("Alignment");
- for (int i = 0, j = msaws.size(); i < j; i++)
- {
- final ext.vamsas.ServiceHandle sh = (ext.vamsas.ServiceHandle) msaws
- .get(i);
- jalview.ws.WSMenuEntryProviderI impl = jalview.ws.jws1.Discoverer
- .getServiceClient(sh);
- impl.attachWSMenuEntry(msawsmenu, this);
-
- }
- wsmenu.add(msawsmenu);
- }
- if (secstrpr != null)
- {
- // Add any secondary structure prediction services
final JMenu secstrmenu = new JMenu(
"Secondary Structure Prediction");
- for (int i = 0, j = secstrpr.size(); i < j; i++)
+ final JMenu seqsrchmenu = new JMenu(
+ "Sequence Database Search");
+ final JMenu analymenu = new JMenu(
+ "Analysis");
+ // JAL-940 - only show secondary structure prediction services from the legacy server
+ if (// Cache.getDefault("SHOW_JWS1_SERVICES", true)
+ // &&
+ Discoverer.services != null
+ && (Discoverer.services.size() > 0))
{
- final ext.vamsas.ServiceHandle sh = (ext.vamsas.ServiceHandle) secstrpr
- .get(i);
- jalview.ws.WSMenuEntryProviderI impl = jalview.ws.jws1.Discoverer
- .getServiceClient(sh);
- impl.attachWSMenuEntry(secstrmenu, this);
+ // TODO: refactor to allow list of AbstractName/Handler bindings to
+ // be
+ // stored or retrieved from elsewhere
+ Vector msaws = null; // (Vector) Discoverer.services.get("MsaWS");
+ Vector secstrpr = (Vector) Discoverer.services
+ .get("SecStrPred");
+ Vector seqsrch = null; // (Vector) Discoverer.services.get("SeqSearch");
+ // TODO: move GUI generation code onto service implementation - so a
+ // client instance attaches itself to the GUI with method call like
+ // jalview.ws.MsaWSClient.bind(servicehandle, Desktop.instance,
+ // alignframe)
+ if (msaws != null)
+ {
+ // Add any Multiple Sequence Alignment Services
+ for (int i = 0, j = msaws.size(); i < j; i++)
+ {
+ final ext.vamsas.ServiceHandle sh = (ext.vamsas.ServiceHandle) msaws
+ .get(i);
+ jalview.ws.WSMenuEntryProviderI impl = jalview.ws.jws1.Discoverer
+ .getServiceClient(sh);
+ impl.attachWSMenuEntry(msawsmenu, me);
+
+ }
+ }
+ if (secstrpr != null)
+ {
+ // Add any secondary structure prediction services
+ for (int i = 0, j = secstrpr.size(); i < j; i++)
+ {
+ final ext.vamsas.ServiceHandle sh = (ext.vamsas.ServiceHandle) secstrpr
+ .get(i);
+ jalview.ws.WSMenuEntryProviderI impl = jalview.ws.jws1.Discoverer
+ .getServiceClient(sh);
+ impl.attachWSMenuEntry(secstrmenu, me);
+ }
+ }
+ if (seqsrch != null)
+ {
+ // Add any sequence search services
+ for (int i = 0, j = seqsrch.size(); i < j; i++)
+ {
+ final ext.vamsas.ServiceHandle sh = (ext.vamsas.ServiceHandle) seqsrch
+ .elementAt(i);
+ jalview.ws.WSMenuEntryProviderI impl = jalview.ws.jws1.Discoverer
+ .getServiceClient(sh);
+ impl.attachWSMenuEntry(seqsrchmenu, me);
+ }
+ }
}
- wsmenu.add(secstrmenu);
- }
- if (seqsrch != null)
- {
- // Add any sequence search services
- final JMenu seqsrchmenu = new JMenu("Sequence Database Search");
- for (int i = 0, j = seqsrch.size(); i < j; i++)
+
+ // TODO: move into separate menu builder class.
+ if (Cache.getDefault("SHOW_JWS2_SERVICES", true))
{
- final ext.vamsas.ServiceHandle sh = (ext.vamsas.ServiceHandle) seqsrch
- .elementAt(i);
- jalview.ws.WSMenuEntryProviderI impl = jalview.ws.jws1.Discoverer
- .getServiceClient(sh);
- impl.attachWSMenuEntry(seqsrchmenu, this);
+ Jws2Discoverer jws2servs = Jws2Discoverer.getDiscoverer();
+ if (jws2servs != null)
+ {
+ if (jws2servs.hasServices())
+ {
+ jws2servs.attachWSMenuEntry(msawsmenu, me);
+ }
+ }
}
- wsmenu.add(seqsrchmenu);
- }
- }
+ // Add all submenus in the order they should appear on the web services menu
+ wsmenu.add(msawsmenu);
+ wsmenu.add(secstrmenu);
+ wsmenu.add(analymenu);
+ // No search services yet
+ // wsmenu.add(seqsrchmenu);
- // TODO: move into separate menu builder class.
- if (Cache.getDefault("SHOW_JWS2_SERVICES", true))
- {
- Jws2Discoverer jws2servs = Jws2Discoverer.getDiscoverer();
- if (jws2servs != null)
- {
- if (jws2servs.hasServices())
+ javax.swing.SwingUtilities.invokeLater(new Runnable()
{
- JMenu jws2men = new JMenu("Jalview 2 Services");
- jws2servs.attachWSMenuEntry(jws2men, this);
- for (int i = 0, iSize = jws2men.getMenuComponentCount(); i < iSize; i++)
+ public void run()
{
- wsmenu.add(jws2men.getMenuComponent(i));
+ try
+ {
+ webService.removeAll();
+ // first, add discovered services onto the webservices menu
+ if (wsmenu.size() > 0)
+ {
+ for (int i = 0, j = wsmenu.size(); i < j; i++)
+ {
+ webService.add((JMenu) wsmenu.get(i));
+ }
+ }
+ else
+ {
+ webService.add(me.webServiceNoServices);
+ }
+ build_urlServiceMenu(me.webService);
+ build_fetchdbmenu(webService);
+ } catch (Exception e)
+ {
+ }
+ ;
}
- }
- }
- }
- resetWebServiceMenu();
- // finally, add the whole shebang onto the webservices menu
- if (wsmenu.size() > 0)
- {
- for (int i = 0, j = wsmenu.size(); i < j; i++)
+ });
+ } catch (Exception e)
{
- webService.add((JMenu) wsmenu.get(i));
}
+ ;
+
+ buildingMenu = false;
}
- else
- {
- this.webService.add(this.webServiceNoServices);
- }
- } catch (Exception e)
- {
- }
- ;
- buildingMenu = false;
- }
+ }).start();
- /**
- * empty the web service menu and add any ad-hoc functions not dynamically
- * discovered.
- *
- */
- private void resetWebServiceMenu()
- {
- webService.removeAll();
- build_fetchdbmenu(webService);
- build_urlServiceMenu(webService);
}
+
/**
* construct any groupURL type service menu entries.
*
@@ -3948,6 +4132,27 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener,
*/
private void build_urlServiceMenu(JMenu webService)
{
+ // TODO: remove this code when 2.7 is released
+ // DEBUG - alignmentView
+ /*
+ * JMenuItem testAlView = new JMenuItem("Test AlignmentView"); final
+ * AlignFrame af = this; testAlView.addActionListener(new ActionListener() {
+ *
+ * @Override public void actionPerformed(ActionEvent e) {
+ * jalview.datamodel.AlignmentView.testSelectionViews(af.viewport.alignment,
+ * af.viewport.colSel, af.viewport.selectionGroup); }
+ *
+ * }); webService.add(testAlView);
+ */
+ // TODO: refactor to RestClient discoverer and merge menu entries for
+ // rest-style services with other types of analysis/calculation service
+ // SHmmr test client - still being implemented.
+ // DEBUG - alignmentView
+
+ for (jalview.ws.rest.RestClient client: jalview.ws.rest.RestClient.getRestClients()) {
+ client.attachWSMenuEntry(JvSwingUtils.findOrCreateMenu(webService, client.getAction()), this);
+ }
+
if (Cache.getDefault("SHOW_ENFIN_SERVICES", true))
{
jalview.ws.EnfinEnvision2OneWay.getInstance().attachWSMenuEntry(
@@ -4037,8 +4242,7 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener,
} catch (Exception e)
{
jalview.bin.Cache.log
- .warn(
- "canTranslate threw an exception - please report to help@jalview.org",
+ .warn("canTranslate threw an exception - please report to help@jalview.org",
e);
return false;
}
@@ -4128,13 +4332,12 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener,
// old way
try
{
- return (jalview.analysis.Dna.canTranslate(selection, viewport
- .getViewAsVisibleContigs(true)));
+ return (jalview.analysis.Dna.canTranslate(selection,
+ viewport.getViewAsVisibleContigs(true)));
} catch (Exception e)
{
jalview.bin.Cache.log
- .warn(
- "canTranslate threw an exception - please report to help@jalview.org",
+ .warn("canTranslate threw an exception - please report to help@jalview.org",
e);
return false;
}
@@ -4223,9 +4426,11 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener,
boolean featuresFile = false;
try
{
- featuresFile = new FeaturesFile(file, type).parse(viewport.alignment
- .getDataset(), alignPanel.seqPanel.seqCanvas
- .getFeatureRenderer().featureColours, false);
+ featuresFile = new FeaturesFile(file, type)
+ .parse(viewport.alignment.getDataset(),
+ alignPanel.seqPanel.seqCanvas.getFeatureRenderer().featureColours,
+ false, jalview.bin.Cache.getDefault(
+ "RELAXEDSEQIDMATCHING", false));
} catch (Exception ex)
{
ex.printStackTrace();
@@ -4320,10 +4525,127 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener,
{
try
{
-
+ // check to see if any of these files have names matching sequences in
+ // the alignment
+ SequenceIdMatcher idm = new SequenceIdMatcher(viewport
+ .getAlignment().getSequencesArray());
+ /**
+ * Object[] { String,SequenceI}
+ */
+ ArrayList