X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;ds=inline;f=src%2Fjalview%2Fgui%2FAlignFrame.java;h=3aa69f17b59595c56470aad0a325b44c9ff4b360;hb=a581135c768ce6c60c38bbd47003477f8c557eea;hp=a185e2ae1ca106ad1dbd5ffc1f84a699b26f53a8;hpb=02d526244bd13a79208e28004b56066f964c6c20;p=jalview.git
diff --git a/src/jalview/gui/AlignFrame.java b/src/jalview/gui/AlignFrame.java
index a185e2a..3aa69f1 100755
--- a/src/jalview/gui/AlignFrame.java
+++ b/src/jalview/gui/AlignFrame.java
@@ -1,19 +1,19 @@
/*
- * Jalview - A Sequence Alignment Editor and Viewer
- * Copyright (C) 2007 AM Waterhouse, J Procter, G Barton, M Clamp, S Searle
- *
+ * Jalview - A Sequence Alignment Editor and Viewer (Version 2.4)
+ * Copyright (C) 2008 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 Softwarechang
+ * 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;
@@ -28,6 +28,7 @@ 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.commands.*;
@@ -44,7 +45,7 @@ import jalview.ws.*;
* @version $Revision$
*/
public class AlignFrame
- extends GAlignFrame implements DropTargetListener
+ extends GAlignFrame implements DropTargetListener, IProgressIndicator
{
/** DOCUMENT ME!! */
public static final int DEFAULT_WIDTH = 700;
@@ -58,11 +59,17 @@ public class AlignFrame
Vector alignPanels = new Vector();
- /** DOCUMENT ME!! */
+ /**
+ * Last format used to load or save alignments in this window
+ */
String currentFileFormat = null;
-
+ /**
+ * Current filename for this alignment
+ */
String fileName = null;
+
+
/**
* Creates a new AlignFrame object.
@@ -141,7 +148,7 @@ public class AlignFrame
}
setMenusFromViewport(viewport);
-
+ buildSortByAnnotationScoresMenu();
if (viewport.wrapAlignment)
{
wrapMenuItem_actionPerformed(null);
@@ -155,7 +162,12 @@ public class AlignFrame
addKeyListener();
}
-
+ /**
+ * Change the filename and format for the alignment, and
+ * enable the 'reload' button functionality.
+ * @param file valid filename
+ * @param format format of file
+ */
public void setFileName(String file, String format)
{
fileName = file;
@@ -497,7 +509,7 @@ public class AlignFrame
showTranslation.setVisible( nucleotide );
conservationMenuItem.setEnabled( !nucleotide );
modifyConservation.setEnabled( !nucleotide );
-
+
//Remember AlignFrame always starts as protein
if(!nucleotide)
{
@@ -505,6 +517,15 @@ public class AlignFrame
}
}
+
+ /**
+ * set up menus for the currently viewport.
+ * This may be called after any operation that affects the data in the current view (selection changed, etc) to update the menus to reflect the new state.
+ */
+ public void setMenusForViewport()
+ {
+ setMenusFromViewport(viewport);
+ }
/**
* Need to call this method when tabs are selected for multiple views,
* or when loading from Jalview2XML.java
@@ -518,6 +539,7 @@ public class AlignFrame
conservationMenuItem.setSelected(av.getConservationSelected());
seqLimits.setSelected(av.getShowJVSuffix());
idRightAlign.setSelected(av.rightAlignIds);
+ centreColumnLabelsMenuItem.setState(av.centreColumnLabels);
renderGapsMenuItem.setSelected(av.renderGaps);
wrapMenuItem.setSelected(av.wrapAlignment);
scaleAbove.setVisible(av.wrapAlignment);
@@ -534,11 +556,16 @@ public class AlignFrame
hiddenMarkers.setState(av.showHiddenMarkers);
applyToAllGroups.setState(av.colourAppliesToAllGroups);
+ setShowProductsEnabled();
+
updateEditMenuBar();
}
Hashtable progressBars;
+ /* (non-Javadoc)
+ * @see jalview.gui.IProgressIndicator#setProgressBar(java.lang.String, long)
+ */
public void setProgressBar(String message, long id)
{
if(progressBars == null)
@@ -576,13 +603,22 @@ public class AlignFrame
progressBars.put(new Long(id), progressPanel);
}
-
+ // update GUI
+ setMenusForViewport();
validate();
}
-
-
-
-
+ /**
+ *
+ * @return true if any progress bars are still active
+ */
+ public boolean operationInProgress()
+ {
+ if (progressBars!=null && progressBars.size()>0)
+ {
+ return true;
+ }
+ return false;
+ }
/*
Added so Castor Mapping file can obtain Jalview Version
*/
@@ -667,7 +703,7 @@ public class AlignFrame
public void save_actionPerformed(ActionEvent e)
{
if(fileName==null
- || currentFileFormat==null
+ || (currentFileFormat==null || jalview.io.AppletFormatAdapter.isValidFormat(currentFileFormat, true))
|| fileName.startsWith("http")
)
{
@@ -688,10 +724,8 @@ public class AlignFrame
{
JalviewFileChooser chooser = new JalviewFileChooser(jalview.bin.Cache.
getProperty( "LAST_DIRECTORY"),
- new String[]
- { "fa, fasta, fastq", "aln", "pfam", "msf", "pir", "blc","jar" },
- new String[]
- { "Fasta", "Clustal", "PFAM", "MSF", "PIR", "BLC", "Jalview" },
+ jalview.io.AppletFormatAdapter.WRITABLE_EXTENSIONS,
+ jalview.io.AppletFormatAdapter.WRITABLE_FNAMES,
currentFileFormat,
false);
@@ -721,7 +755,10 @@ public class AlignFrame
currentFileFormat);
jalview.bin.Cache.setProperty("LAST_DIRECTORY", fileName);
-
+ if (currentFileFormat.indexOf(" ")>-1)
+ {
+ currentFileFormat = currentFileFormat.substring(0, currentFileFormat.indexOf(" "));
+ }
saveAlignment(fileName, currentFileFormat);
}
}
@@ -748,8 +785,18 @@ public class AlignFrame
}
else
- {
-
+ {
+ if (!jalview.io.AppletFormatAdapter.isValidFormat(format, true))
+ {
+ // JBPNote need to have a raise_gui flag here
+ JOptionPane.showInternalMessageDialog(
+ this, "Cannot save file " + fileName + " using format "+format,
+ "Alignment output format not supported",
+ JOptionPane.WARNING_MESSAGE);
+ saveAs_actionPerformed(null);
+ return false;
+ }
+
String[] omitHidden = null;
if (viewport.hasHiddenColumns)
@@ -765,11 +812,11 @@ public class AlignFrame
omitHidden = viewport.getViewAsString(false);
}
}
-
- String output = new FormatAdapter().formatSequences(
+ FormatAdapter f = new FormatAdapter();
+ String output = f.formatSequences(
format,
- viewport.alignment.getSequencesArray(),
- omitHidden);
+ (Alignment) viewport.alignment, // class cast exceptions will occur in the distant future
+ omitHidden, f.getCacheSuffixDefault(format), viewport.colSel);
if (output == null)
{
@@ -840,8 +887,8 @@ public class AlignFrame
cap.setText(new FormatAdapter().formatSequences(
e.getActionCommand(),
- viewport.alignment.getSequencesArray(),
- omitHidden));
+ viewport.alignment,
+ omitHidden, viewport.colSel));
}
/**
@@ -911,7 +958,8 @@ public class AlignFrame
new AnnotationExporter().exportAnnotations(
alignPanel,
viewport.showAnnotation ? viewport.alignment.getAlignmentAnnotation() : null,
- viewport.alignment.getGroups()
+ viewport.alignment.getGroups(),
+ ((Alignment)viewport.alignment).alignmentProperties
);
}
@@ -1047,8 +1095,28 @@ public class AlignFrame
}
}
-
-
+ /**
+ *
+ * @return alignment objects for all views
+ */
+ AlignmentI[] getViewAlignments()
+ {
+ if (alignPanels!=null)
+ {
+ Enumeration e = alignPanels.elements();
+ AlignmentI[] als = new AlignmentI[alignPanels.size()];
+ for (int i=0; e.hasMoreElements(); i++)
+ {
+ als[i] = ((AlignmentPanel) e.nextElement()).av.getAlignment();
+ }
+ return als;
+ }
+ if (viewport!=null)
+ {
+ return new AlignmentI[] { viewport.alignment };
+ }
+ return null;
+ }
/**
* DOCUMENT ME!
*
@@ -1056,9 +1124,11 @@ public class AlignFrame
*/
protected void undoMenuItem_actionPerformed(ActionEvent e)
{
+ if (viewport.historyList.empty())
+ return;
CommandI command = (CommandI)viewport.historyList.pop();
viewport.redoList.push(command);
- command.undoCommand();
+ command.undoCommand(getViewAlignments());
AlignViewport originalSource = getOriginatingSource(command);
updateEditMenuBar();
@@ -1086,7 +1156,7 @@ public class AlignFrame
CommandI command = (CommandI) viewport.redoList.pop();
viewport.historyList.push(command);
- command.doCommand();
+ command.doCommand(getViewAlignments());
AlignViewport originalSource = getOriginatingSource(command);
updateEditMenuBar();
@@ -1310,7 +1380,7 @@ public class AlignFrame
return;
}
// TODO: preserve the ordering of displayed alignment annotation in any internal paste (particularly sequence associated annotation)
- SequenceI [] seqs = viewport.getSelectionAsNewSequence();
+ SequenceI [] seqs = viewport.getSelectionAsNewSequence();
String[] omitHidden = null;
if (viewport.hasHiddenColumns)
@@ -1338,20 +1408,7 @@ public class AlignFrame
}
catch (OutOfMemoryError er)
{
- er.printStackTrace();
- javax.swing.SwingUtilities.invokeLater(new Runnable()
- {
- public void run()
- {
- javax.swing.JOptionPane.showInternalMessageDialog(Desktop.desktop,
- "Out of memory copying region!!"
- +
- "\nSee help files for increasing Java Virtual Machine memory."
- , "Out of memory",
- javax.swing.JOptionPane.WARNING_MESSAGE);
- }
- });
-
+ new OOMWarning("copying region", er);
return;
}
@@ -1401,9 +1458,9 @@ public class AlignFrame
}
/**
- * DOCUMENT ME!
+ * Paste contents of Jalview clipboard
*
- * @param newAlignment DOCUMENT ME!
+ * @param newAlignment true to paste to a new alignment, otherwise add to this.
*/
void paste(boolean newAlignment)
{
@@ -1432,20 +1489,7 @@ public class AlignFrame
}
catch (OutOfMemoryError er)
{
- er.printStackTrace();
- javax.swing.SwingUtilities.invokeLater(new Runnable()
- {
- public void run()
- {
- javax.swing.JOptionPane.showInternalMessageDialog(Desktop.desktop,
- "Out of memory pasting sequences!!"
- +
- "\nSee help files for increasing Java Virtual Machine memory."
- , "Out of memory",
- javax.swing.JOptionPane.WARNING_MESSAGE);
- }
- });
-
+ new OOMWarning("Out of memory pasting sequences!!", er);
return;
}
@@ -1477,7 +1521,7 @@ public class AlignFrame
if (newAlignment)
{
-
+
if (Desktop.jalviewClipboard != null)
{
// dataset is inherited
@@ -1503,10 +1547,10 @@ public class AlignFrame
// an existing alignment
Vector newDs = (importDs) ? new Vector() : null; // used to create
// minimum dataset set
-
+
for (int i = 0; i < sequences.length; i++)
{
- if (importDs)
+ if (importDs)
{
newDs.addElement(null);
}
@@ -1516,7 +1560,7 @@ public class AlignFrame
{
if (!newDs.contains(ds))
{
- newDs.setElementAt(ds, i);
+ newDs.setElementAt(ds, i);
ds = new Sequence(ds);
// update with new dataset sequence
sequences[i].setDatasetSequence(ds);
@@ -1580,18 +1624,44 @@ public class AlignFrame
alignment.addAnnotation(sequences[i].getAnnotation()[a]); // annotation was duplicated earlier
alignment.setAnnotationIndex(sequences[i].getAnnotation()[a], a);
}
-
-
}
}
if (!newAlignment) {
+
// propagate alignment changed.
viewport.setEndSeq(alignment.getHeight());
if (annotationAdded)
{
- alignPanel.annotationPanel.adjustPanelHeight();
+ // Duplicate sequence annotation in all views.
+ AlignmentI[] alview = this.getViewAlignments();
+ for (int i = 0; i < sequences.length; i++)
+ {
+ AlignmentAnnotation sann[] = sequences[i].getAnnotation();
+ if (sann == null)
+ continue;
+ for (int avnum=0;avnum>>This is a fix for the moment, until a better solution is found!!<<<
af.alignPanel.seqPanel.seqCanvas.getFeatureRenderer().transferSettings(
alignPanel.seqPanel.seqCanvas.getFeatureRenderer());
-
+
// TODO: maintain provenance of an alignment, rather than just make the title a concatenation of operations.
if (!externalPaste) {
if (title.startsWith("Copied sequences"))
@@ -2106,6 +2176,12 @@ public class AlignFrame
alignPanel.paintAlignment(true);
}
+ public void centreColumnLabels_actionPerformed(ActionEvent e)
+ {
+ viewport.centreColumnLabels = centreColumnLabelsMenuItem.getState();
+ alignPanel.paintAlignment(true);
+ }
+
/**
@@ -2266,6 +2342,65 @@ public class AlignFrame
alignPanel.setAnnotationVisible(annotationPanelMenuItem.isSelected());
}
+ public void alignmentProperties()
+ {
+ 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; imax)
+ max = size;
+ if(sizeSequences: "+ 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()+"");
+ JInternalFrame frame = new JInternalFrame();
+ frame.getContentPane().add(new JScrollPane(editPane));
+
+ Desktop.instance.addInternalFrame(frame,"Alignment Properties: "+getTitle(),500,400);
+ }
+
+
/**
* DOCUMENT ME!
*
@@ -2740,7 +2875,7 @@ public class AlignFrame
{
SequenceI [] oldOrder = viewport.getAlignment().getSequencesArray();
AlignmentSorter.sortByPID(viewport.getAlignment(),
- viewport.getAlignment().getSequenceAt(0));
+ viewport.getAlignment().getSequenceAt(0), null);
addHistoryItem(new OrderCommand("Pairwise Sort", oldOrder,
viewport.alignment));
alignPanel.paintAlignment(true);
@@ -2772,7 +2907,6 @@ public class AlignFrame
alignPanel.paintAlignment(true);
}
-
/**
* DOCUMENT ME!
*
@@ -2990,6 +3124,73 @@ public class AlignFrame
}
});
}
+ /**
+ * Add a new sort by annotation score menu item
+ * @param sort the menu to add the option to
+ * @param scoreLabel the label used to retrieve scores for each sequence on the alignment
+ */
+ public void addSortByAnnotScoreMenuItem(JMenu sort, final String scoreLabel)
+ {
+ final JMenuItem item = new JMenuItem(scoreLabel);
+ sort.add(item);
+ item.addActionListener(new java.awt.event.ActionListener()
+ {
+ public void actionPerformed(ActionEvent e)
+ {
+ SequenceI [] oldOrder = viewport.getAlignment().getSequencesArray();
+ AlignmentSorter.sortByAnnotationScore(scoreLabel, viewport.getAlignment());//,viewport.getSelectionGroup());
+ addHistoryItem(new OrderCommand("Sort by "+scoreLabel, oldOrder, viewport.alignment));
+ alignPanel.paintAlignment(true);
+ }
+ });
+ }
+ /**
+ * last hash for alignment's annotation array - used to minimise cost of rebuild.
+ */
+ protected int _annotationScoreVectorHash;
+ /**
+ * search the alignment and rebuild the sort by annotation score submenu
+ * the last alignment annotation vector hash is stored to minimize
+ * cost of rebuilding in subsequence calls.
+ *
+ */
+ public void buildSortByAnnotationScoresMenu()
+ {
+ if(viewport.alignment.getAlignmentAnnotation()==null)
+ {
+ return;
+ }
+
+ if (viewport.alignment.getAlignmentAnnotation().hashCode()!=_annotationScoreVectorHash)
+ {
+ sortByAnnotScore.removeAll();
+ // almost certainly a quicker way to do this - but we keep it simple
+ Hashtable scoreSorts=new Hashtable();
+ AlignmentAnnotation aann[];
+ Enumeration sq = viewport.alignment.getSequences().elements();
+ while (sq.hasMoreElements())
+ {
+ aann = ((SequenceI) sq.nextElement()).getAnnotation();
+ for (int i=0;aann!=null && i0);
+ scoreSorts.clear();
+
+ _annotationScoreVectorHash =
+ viewport.alignment.getAlignmentAnnotation().hashCode();
+ }
+ }
/**
* Maintain the Order by->Displayed Tree menu.
@@ -3055,7 +3256,7 @@ public class AlignFrame
* or just the selected set will be submitted for multiple alignment.
*
*/
- private jalview.datamodel.AlignmentView gatherSequencesForAlignment()
+ public jalview.datamodel.AlignmentView gatherSequencesForAlignment()
{
// Now, check we have enough sequences
AlignmentView msa = null;
@@ -3093,12 +3294,14 @@ public class AlignFrame
}
/**
- * Decides what is submitted to a secondary structure prediction service,
- * the currently selected sequence, or the currently selected alignment
+ * Decides what is submitted to a secondary structure prediction service:
+ * the first sequence in the alignment, or in the current selection,
+ * or, if the alignment is 'aligned' (ie padded with gaps), then the
+ * currently selected region or the whole alignment.
* (where the first sequence in the set is the one that the prediction
* will be for).
*/
- AlignmentView gatherSeqOrMsaForSecStrPrediction()
+ public AlignmentView gatherSeqOrMsaForSecStrPrediction()
{
AlignmentView seqs = null;
@@ -3141,21 +3344,28 @@ public class AlignFrame
{
String choice = chooser.getSelectedFile().getPath();
jalview.bin.Cache.setProperty("LAST_DIRECTORY", choice);
-
+ jalview.io.NewickFile fin = null;
try
{
- jalview.io.NewickFile fin = new jalview.io.NewickFile(choice,
+ fin = new jalview.io.NewickFile(choice,
"File");
viewport.setCurrentTree(ShowNewickTree(fin, choice).getTree());
}
catch (Exception ex)
{
JOptionPane.showMessageDialog(Desktop.desktop,
- "Problem reading tree file",
ex.getMessage(),
+ "Problem reading tree file",
JOptionPane.WARNING_MESSAGE);
ex.printStackTrace();
}
+ if (fin!=null && fin.hasWarningMessage())
+ {
+ JOptionPane.showMessageDialog(Desktop.desktop,
+ fin.getWarningMessage(),
+ "Possible problem with tree file",
+ JOptionPane.WARNING_MESSAGE);
+ }
}
}
@@ -3220,7 +3430,7 @@ public class AlignFrame
{
ex.printStackTrace();
}
-
+
return tp;
}
@@ -3231,13 +3441,20 @@ public class AlignFrame
*/
public void BuildWebServiceMenu()
{
+ // 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.
if ( (Discoverer.services != null)
&& (Discoverer.services.size() > 0))
{
+ // 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)
Vector wsmenu = new Vector();
- final AlignFrame af = this;
+ final IProgressIndicator af = this;
if (msaws != null)
{
// Add any Multiple Sequence Alignment Services
@@ -3246,42 +3463,9 @@ public class AlignFrame
{
final ext.vamsas.ServiceHandle sh = (ext.vamsas.ServiceHandle) msaws.
get(i);
- final JMenuItem method = new JMenuItem(sh.getName());
- method.addActionListener(new ActionListener()
- {
- public void actionPerformed(ActionEvent e)
- {
- AlignmentView msa = gatherSequencesForAlignment();
- new jalview.ws.MsaWSClient(sh, title, msa,
- false, true,
- viewport.getAlignment().getDataset(),
- af);
-
- }
-
- });
- msawsmenu.add(method);
- // Deal with services that we know accept partial alignments.
- if (sh.getName().indexOf("lustal") > -1)
- {
- // We know that ClustalWS can accept partial alignments for refinement.
- final JMenuItem methodR = new JMenuItem(sh.getName()+" Realign");
- methodR.addActionListener(new ActionListener()
- {
- public void actionPerformed(ActionEvent e)
- {
- AlignmentView msa = gatherSequencesForAlignment();
- new jalview.ws.MsaWSClient(sh, title, msa,
- true, true,
- viewport.getAlignment().getDataset(),
- af);
-
- }
-
- });
- msawsmenu.add(methodR);
-
- }
+ jalview.ws.WSClient impl = jalview.ws.Discoverer.getServiceClient(sh);
+ impl.attachWSMenuEntry(msawsmenu, this);
+
}
wsmenu.add(msawsmenu);
}
@@ -3293,33 +3477,26 @@ public class AlignFrame
{
final ext.vamsas.ServiceHandle sh = (ext.vamsas.ServiceHandle)
secstrpr.get(i);
- final JMenuItem method = new JMenuItem(sh.getName());
- method.addActionListener(new ActionListener()
- {
- public void actionPerformed(ActionEvent e)
- {
- AlignmentView msa = gatherSeqOrMsaForSecStrPrediction();
- if (msa.getSequences().length == 1)
- {
- // Single Sequence prediction
- new jalview.ws.JPredClient(sh, title, false, msa, af, true);
- }
- else
- {
- if (msa.getSequences().length > 1)
- {
- // Sequence profile based prediction
- new jalview.ws.JPredClient(sh,
- title, true, msa, af, true);
- }
- }
- }
- });
- secstrmenu.add(method);
+ jalview.ws.WSClient impl = jalview.ws.Discoverer.getServiceClient(sh);
+ impl.attachWSMenuEntry(secstrmenu, this);
}
wsmenu.add(secstrmenu);
}
- this.webService.removeAll();
+ 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++)
+ {
+ final ext.vamsas.ServiceHandle sh = (ext.vamsas.ServiceHandle)
+ seqsrch.elementAt(i);
+ jalview.ws.WSClient impl = jalview.ws.Discoverer.getServiceClient(sh);
+ impl.attachWSMenuEntry(seqsrchmenu, this);
+ }
+ // finally, add the whole shebang onto the webservices menu
+ wsmenu.add(seqsrchmenu);
+ }
+ resetWebServiceMenu();
for (int i = 0, j = wsmenu.size(); i < j; i++)
{
webService.add( (JMenu) wsmenu.get(i));
@@ -3327,12 +3504,41 @@ public class AlignFrame
}
else
{
- this.webService.removeAll();
+ resetWebServiceMenu();
this.webService.add(this.webServiceNoServices);
}
- // TODO: add in rediscovery function
- // TODO: reduce code redundancy.
- // TODO: group services by location as well as function.
+ }
+
+
+ /**
+ * empty the web service menu and add any ad-hoc functions
+ * not dynamically discovered.
+ *
+ */
+ private void resetWebServiceMenu()
+ {
+ webService.removeAll();
+ // Temporary hack - DBRef Fetcher always top level ws entry.
+ JMenuItem rfetch = new JMenuItem("Fetch DB References");
+ rfetch.setToolTipText("Retrieve and parse sequence database records for the alignment or the currently selected sequences");
+ webService.add(rfetch);
+ rfetch.addActionListener(new ActionListener() {
+
+ public void actionPerformed(ActionEvent e)
+ {
+ new Thread(new Runnable() {
+
+ public void run()
+ {
+ new jalview.ws.DBRefFetcher(
+ alignPanel.av.getSequenceSelection(),
+ alignPanel.alignFrame).fetchDBRefs(false);
+ }
+ }).start();
+
+ }
+
+ });
}
/* public void vamsasStore_actionPerformed(ActionEvent e)
@@ -3353,22 +3559,180 @@ public class AlignFrame
vs.storeJalview( chooser.getSelectedFile().getAbsolutePath(), this);
}
}*/
+ /**
+ * prototype of an automatically enabled/disabled analysis function
+ *
+ */
+ protected void setShowProductsEnabled()
+ {
+ SequenceI [] selection = viewport.getSequenceSelection();
+ if (canShowProducts(selection, viewport.getSelectionGroup()!=null, viewport.getAlignment().getDataset()))
+ {
+ showProducts.setEnabled(true);
+
+ } else {
+ showProducts.setEnabled(false);
+ }
+ }
+ /**
+ * search selection for sequence xRef products and build the
+ * show products menu.
+ * @param selection
+ * @param dataset
+ * @return true if showProducts menu should be enabled.
+ */
+ public boolean canShowProducts(SequenceI[] selection, boolean isRegionSelection, Alignment dataset)
+ {
+ boolean showp=false;
+ try {
+ showProducts.removeAll();
+ final boolean dna = viewport.getAlignment().isNucleotide();
+ final Alignment ds = dataset;
+ String[] ptypes = CrossRef.findSequenceXrefTypes(dna, selection, dataset);
+ //Object[] prods = CrossRef.buildXProductsList(viewport.getAlignment().isNucleotide(), selection, dataset, true);
+ final SequenceI[] sel = selection;
+ for (int t=0; ptypes!=null && t0)
+ if (pp.getScoresFromDescription("description column", "score in description column ", "\\W*([-+eE0-9.]+)", true)>0) {
+ buildSortByAnnotationScoresMenu();
+ }
+ }
}
class PrintThread