/*
* Jalview - A Sequence Alignment Editor and Viewer ($$Version-Rel$$)
* Copyright (C) $$Year-Rel$$ The Jalview Authors
- *
+ *
* This file is part of Jalview.
- *
+ *
* Jalview is free software: you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
+ * modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation, either version 3
* of the License, or (at your option) any later version.
- *
- * Jalview 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
+ *
+ * Jalview 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 Jalview. If not, see <http://www.gnu.org/licenses/>.
* The Jalview Authors are detailed in the 'AUTHORS' file.
import jalview.datamodel.SequenceI;
import jalview.gui.ColourMenuHelper.ColourChangeListener;
import jalview.gui.ViewSelectionMenu.ViewSetProvider;
+import jalview.hmmer.HMMAlign;
+import jalview.hmmer.HMMBuild;
+import jalview.hmmer.HMMERParamStore;
+import jalview.hmmer.HMMERPreset;
+import jalview.hmmer.HMMSearch;
+import jalview.hmmer.HmmerCommand;
+import jalview.hmmer.JackHMMER;
import jalview.io.AlignmentProperties;
import jalview.io.AnnotationFile;
import jalview.io.BackupFiles;
import jalview.viewmodel.ViewportRanges;
import jalview.ws.DBRefFetcher;
import jalview.ws.DBRefFetcher.FetchFinishedListenerI;
+import jalview.ws.ServiceChangeListener;
+import jalview.ws.WSDiscovererI;
+import jalview.ws.api.ServiceWithParameters;
import jalview.ws.jws1.Discoverer;
import jalview.ws.jws2.Jws2Discoverer;
-import jalview.ws.jws2.jabaws2.Jws2Instance;
+import jalview.ws.jws2.PreferredServiceRegistry;
+import jalview.ws.params.ArgumentI;
+import jalview.ws.params.ParamDatastoreI;
+import jalview.ws.params.WsParamSetI;
import jalview.ws.seqfetcher.DbSourceProxy;
+import jalview.ws2.WebServiceDiscoverer;
+import jalview.ws2.WebServiceI;
+import jalview.ws2.operations.Operation;
+import jalview.ws2.slivka.SlivkaWSDiscoverer;
+
+import java.io.IOException;
+import java.util.HashSet;
+import java.util.Set;
+
+import javax.swing.JFileChooser;
+import javax.swing.JOptionPane;
import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.print.PageFormat;
import java.awt.print.PrinterJob;
import java.beans.PropertyChangeEvent;
+import java.beans.PropertyChangeListener;
import java.io.File;
import java.io.FileWriter;
import java.io.PrintWriter;
import java.net.URL;
import java.util.ArrayList;
import java.util.Arrays;
+import java.util.Collection;
import java.util.Deque;
import java.util.Enumeration;
import java.util.Hashtable;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.SwingUtilities;
+import javax.swing.event.InternalFrameAdapter;
+import javax.swing.event.InternalFrameEvent;
import ext.vamsas.ServiceHandle;
/**
* DOCUMENT ME!
- *
+ *
* @author $author$
* @version $Revision$
*/
@SuppressWarnings("serial")
-public class AlignFrame extends GAlignFrame implements DropTargetListener,
- IProgressIndicator, AlignViewControllerGuiI, ColourChangeListener
+public class AlignFrame extends GAlignFrame
+ implements DropTargetListener, IProgressIndicator,
+ AlignViewControllerGuiI, ColourChangeListener, ServiceChangeListener,
+ WebServiceDiscoverer.ServiceChangeListener
{
public static int frameCount;
*/
String fileName = null;
+ /**
+ * TODO: remove reference to 'FileObject' in AlignFrame - not correct mapping
+ */
File fileObject;
private int id;
/**
* Creates a new AlignFrame object with specific width and height.
- *
+ *
* @param al
* @param width
* @param height
/**
* Creates a new AlignFrame object with specific width, height and
* sequenceSetId
- *
+ *
* @param al
* @param width
* @param height
/**
* Creates a new AlignFrame object with specific width, height and
* sequenceSetId
- *
+ *
* @param al
* @param width
* @param height
/**
* new alignment window with hidden columns
- *
+ *
* @param al
* AlignmentI
* @param hiddenColumns
/**
* Create alignment frame for al with hiddenColumns, a specific width and
* height, and specific sequenceId
- *
+ *
* @param al
* @param hiddenColumns
* @param width
/**
* Create alignment frame for al with hiddenColumns, a specific width and
* height, and specific sequenceId
- *
+ *
* @param al
* @param hiddenColumns
* @param width
/**
* Make a new AlignFrame from existing alignmentPanels
- *
+ *
* @param ap
* AlignmentPanel
* @param av
void init()
{
-
boolean newPanel = (alignPanel == null);
viewport.setShowAutocalculatedAbove(isShowAutoCalculatedAbove());
if (newPanel)
if (Desktop.getDesktopPane() != null)
{
this.setDropTarget(new java.awt.dnd.DropTarget(this, this));
+ addServiceListeners();
if (!Platform.isJS())
{
- addServiceListeners();
}
setGUINucleotide();
}
/**
* Change the filename and format for the alignment, and enable the 'reload'
* button functionality.
- *
+ *
* @param file
* valid filename
* @param format
}
/**
- *
+ *
* @param fileName
* @param file from SwingJS; may contain bytes -- for reload
* @param protocol from SwingJS; may be RELATIVE_URL
/**
* JavaScript will have this, maybe others. More dependable than a file name
* and maintains a reference to the actual bytes loaded.
- *
+ *
* @param file
*/
ap.av.updateConservation(ap);
ap.av.updateConsensus(ap);
ap.av.updateStrucConsensus(ap);
+ ap.av.initInformationWorker(ap);
}
}
}
return viewport;
}
- /* Set up intrinsic listeners for dynamically generated GUI bits. */
- private void addServiceListeners()
+ @Override
+ public void servicesChanged(WSDiscovererI discoverer,
+ Collection<? extends ServiceWithParameters> services)
{
- final java.beans.PropertyChangeListener thisListener;
- Desktop.getInstance().addJalviewPropertyChangeListener("services",
- thisListener = new java.beans.PropertyChangeListener()
- {
-
- @Override
- public void propertyChange(PropertyChangeEvent evt)
- {
- // // System.out.println("Discoverer property change.");
- // if (evt.getPropertyName().equals("services"))
- {
- SwingUtilities.invokeLater(new Runnable()
- {
+ buildWebServicesMenu();
+ }
- @Override
- public void run()
- {
- System.err.println(
- "Rebuild WS Menu for service change");
- BuildWebServiceMenu();
- }
+ @Override
+ public void servicesChanged(WebServiceDiscoverer discoverer,
+ Collection<? extends WebServiceI> services)
+ {
+ buildWebServicesMenu();
+ }
- });
- }
- }
- });
- addInternalFrameListener(new javax.swing.event.InternalFrameAdapter()
+ /* Set up intrinsic listeners for dynamically generated GUI bits. */
+ private void addServiceListeners()
+ {
+ if (Cache.getDefault("SHOW_SLIVKA_SERVICES", true))
+ {
+ WebServiceDiscoverer discoverer = SlivkaWSDiscoverer.getInstance();
+ discoverer.addServiceChangeListener((disc, srvcs) -> buildWebServicesMenu());
+ }
+ if (Cache.getDefault("SHOW_JWS2_SERVICES", true))
{
+ WSDiscovererI discoverer = Jws2Discoverer.getInstance();
+ discoverer.addServiceChangeListener(this);
+ }
+ // legacy event listener for compatibility with jws1
+ PropertyChangeListener legacyListener = (changeEvent) -> {
+ buildWebServicesMenu();
+ };
+ Desktop.getInstance().addJalviewPropertyChangeListener("services",legacyListener);
+ addInternalFrameListener(new InternalFrameAdapter() {
@Override
- public void internalFrameClosed(
- javax.swing.event.InternalFrameEvent evt)
- {
- // System.out.println("deregistering discoverer listener");
- Desktop.getInstance().removeJalviewPropertyChangeListener(
- "services", thisListener);
+ public void internalFrameClosed(InternalFrameEvent e) {
+ System.out.println("deregistering discoverer listener");
+// SlivkaWSDiscoverer.getInstance().removeServiceChangeListener(AlignFrame.this);
+ Jws2Discoverer.getInstance().removeServiceChangeListener(AlignFrame.this);
+ Desktop.getInstance().removeJalviewPropertyChangeListener("services", legacyListener);
closeMenuItem_actionPerformed(true);
}
});
- // Finally, build the menu once to get current service state
- new Thread(new Runnable()
- {
-
- @Override
- public void run()
- {
- BuildWebServiceMenu();
- }
- }).start();
+ buildWebServicesMenu();
}
/**
/**
* Need to call this method when tabs are selected for multiple views, or when
* loading from Jalview2XML.java
- *
+ *
* @param av
* AlignViewport
*/
showConsensusHistogram.setSelected(av.isShowConsensusHistogram());
showSequenceLogo.setSelected(av.isShowSequenceLogo());
normaliseSequenceLogo.setSelected(av.isNormaliseSequenceLogo());
+ showInformationHistogram.setSelected(av.isShowInformationHistogram());
+ showHMMSequenceLogo.setSelected(av.isShowHMMSequenceLogo());
+ normaliseHMMSequenceLogo.setSelected(av.isNormaliseHMMSequenceLogo());
ColourMenuHelper.setColourSelected(colourMenu,
av.getGlobalColourScheme());
/**
* Set the enabled state of the 'Run Groovy' option in the Calculate menu
- *
+ *
* @param b
*/
/*
* (non-Javadoc)
- *
+ *
* @see jalview.gui.IProgressIndicator#setProgressBar(java.lang.String, long)
*/
}
@Override
+ public void removeProgressBar(long id)
+ {
+ progressBar.removeProgressBar(id);
+ }
+
+ @Override
public void registerHandler(final long id,
final IProgressIndicatorHandler handler)
{
}
/**
- *
+ *
* @return true if any progress bars are still active
*/
}
@Override
+ public void hmmBuild_actionPerformed(boolean withDefaults)
+ {
+ if (!alignmentIsSufficient(1))
+ {
+ return;
+ }
+
+ /*
+ * get default parameters, and optionally show a dialog
+ * to allow them to be modified
+ */
+ ParamDatastoreI store = HMMERParamStore.forBuild(viewport);
+ List<ArgumentI> args = store.getServiceParameters();
+
+ if (!withDefaults)
+ {
+ WsParamSetI set = new HMMERPreset();
+ WsJobParameters params = new WsJobParameters(store, set, args);
+ params.showRunDialog().thenAccept((startJob) -> {
+ if (startJob)
+ {
+ var args2 = params.getJobParams();
+ new Thread(new HMMBuild(this, args2)).start();
+ }
+ });
+ }
+ else
+ {
+ new Thread(new HMMBuild(this, args)).start();
+ }
+ }
+
+ @Override
+ public void hmmAlign_actionPerformed(boolean withDefaults)
+ {
+ if (!(checkForHMM() && alignmentIsSufficient(2)))
+ {
+ return;
+ }
+
+ /*
+ * get default parameters, and optionally show a dialog
+ * to allow them to be modified
+ */
+ ParamDatastoreI store = HMMERParamStore.forAlign(viewport);
+ List<ArgumentI> args = store.getServiceParameters();
+
+ if (!withDefaults)
+ {
+ WsParamSetI set = new HMMERPreset();
+ WsJobParameters params = new WsJobParameters(store, set, args);
+ params.showRunDialog().thenAccept((startJob) -> {
+ if (startJob)
+ {
+ var args2 = params.getJobParams();
+ new Thread(new HMMAlign(this, args2)).start();
+ }
+ });
+ }
+ else
+ {
+ new Thread(new HMMAlign(this, args)).start();
+ }
+ }
+
+ @Override
+ public void hmmSearch_actionPerformed(boolean withDefaults)
+ {
+ if (!checkForHMM())
+ {
+ return;
+ }
+
+ /*
+ * get default parameters, and (if requested) show
+ * dialog to allow modification
+ */
+ ParamDatastoreI store = HMMERParamStore.forSearch(viewport);
+ List<ArgumentI> args = store.getServiceParameters();
+
+ if (!withDefaults)
+ {
+ WsParamSetI set = new HMMERPreset();
+ WsJobParameters params = new WsJobParameters(store, set, args);
+ params.showRunDialog().thenAccept((startJob) -> {
+ if (startJob)
+ {
+ var args2 = params.getJobParams();
+ new Thread(new HMMSearch(this, args2)).start();
+ alignPanel.repaint();
+ }
+ });
+ }
+ else
+ {
+ new Thread(new HMMSearch(this, args)).start();
+ alignPanel.repaint();
+ }
+ }
+
+ @Override
+ public void jackhmmer_actionPerformed(boolean withDefaults)
+ {
+
+ /*
+ * get default parameters, and (if requested) show
+ * dialog to allow modification
+ */
+
+ ParamDatastoreI store = HMMERParamStore.forJackhmmer(viewport);
+ List<ArgumentI> args = store.getServiceParameters();
+
+ if (!withDefaults)
+ {
+ WsParamSetI set = new HMMERPreset();
+ WsJobParameters params = new WsJobParameters(store, set, args);
+ params.showRunDialog().thenAccept((startJob) -> {
+ if (startJob)
+ {
+ var args2 = params.getJobParams();
+ new Thread(new JackHMMER(this, args2)).start();
+ alignPanel.repaint();
+ }
+ });
+ }
+ else
+ {
+ new Thread(new JackHMMER(this, args)).start();
+ alignPanel.repaint();
+ }
+ }
+
+ /**
+ * Checks if the alignment has at least one hidden Markov model, if not shows
+ * a dialog advising to run hmmbuild or load an HMM profile
+ *
+ * @return
+ */
+ private boolean checkForHMM()
+ {
+ if (viewport.getAlignment().getHmmSequences().isEmpty())
+ {
+ JOptionPane.showMessageDialog(this,
+ MessageManager.getString("warn.no_hmm"));
+ return false;
+ }
+ return true;
+ }
+
+ @Override
+ protected void filterByEValue_actionPerformed()
+ {
+ viewport.filterByEvalue(inputDouble("Enter E-Value Cutoff"));
+ }
+
+ @Override
+ protected void filterByScore_actionPerformed()
+ {
+ viewport.filterByScore(inputDouble("Enter Bit Score Threshold"));
+ }
+
+ private double inputDouble(String message)
+ {
+ String str = null;
+ Double d = null;
+ while (d == null || d <= 0)
+ {
+ str = JOptionPane.showInputDialog(this.alignPanel, message);
+ try
+ {
+ d = Double.valueOf(str);
+ } catch (NumberFormatException e)
+ {
+ }
+ }
+ return d;
+ }
+
+ /**
+ * Checks if the alignment contains the required number of sequences.
+ *
+ * @param required
+ * @return
+ */
+ public boolean alignmentIsSufficient(int required)
+ {
+ if (getViewport().getSequenceSelection().length < required)
+ {
+ JOptionPane.showMessageDialog(this,
+ MessageManager.getString("label.not_enough_sequences"));
+ return false;
+ }
+ return true;
+ }
+
+ /**
+ * Opens a file browser and adds the selected file, if in Fasta, Stockholm or
+ * Pfam format, to the list held under preference key "HMMSEARCH_DBS" (as a
+ * comma-separated list)
+ */
+ @Override
+ public void addDatabase_actionPerformed() throws IOException
+ {
+ if (Cache.getProperty(Preferences.HMMSEARCH_DBS) == null)
+ {
+ Cache.setProperty(Preferences.HMMSEARCH_DBS, "");
+ }
+
+ String path = openFileChooser(false);
+ if (path != null && new File(path).exists())
+ {
+ IdentifyFile identifier = new IdentifyFile();
+ FileFormatI format = identifier.identify(path, DataSourceType.FILE);
+ if (format == FileFormat.Fasta || format == FileFormat.Stockholm
+ || format == FileFormat.Pfam)
+ {
+ String currentDbPaths = Cache
+ .getProperty(Preferences.HMMSEARCH_DBS);
+ currentDbPaths += Preferences.COMMA + path;
+ Cache.setProperty(Preferences.HMMSEARCH_DBS, currentDbPaths);
+ }
+ else
+ {
+ JOptionPane.showMessageDialog(this,
+ MessageManager.getString("warn.invalid_format"));
+ }
+ }
+ }
+
+ /**
+ * Opens a file chooser, optionally restricted to selecting folders
+ * (directories) only. Answers the path to the selected file or folder, or
+ * null if none is chosen.
+ *
+ * @param
+ * @return
+ */
+ protected String openFileChooser(boolean forFolder)
+ {
+ // TODO duplicates GPreferences method - relocate to JalviewFileChooser?
+ String choice = null;
+ JFileChooser chooser = new JFileChooser();
+ if (forFolder)
+ {
+ chooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
+ }
+ chooser.setDialogTitle(
+ MessageManager.getString("label.open_local_file"));
+ chooser.setToolTipText(MessageManager.getString("action.open"));
+
+ int value = chooser.showOpenDialog(this);
+
+ if (value == JFileChooser.APPROVE_OPTION)
+ {
+ choice = chooser.getSelectedFile().getPath();
+ }
+ return choice;
+ }
+
+ @Override
public void reload_actionPerformed(ActionEvent e)
{
if (fileName == null && fileObject == null)
* alignment has hidden regions, or the format is one capable of including
* non-sequence data (features, annotations, groups), then the user may be
* prompted to specify what to include in the output.
- *
+ *
* @param file
* @param format
*/
* Outputs the alignment to textbox in the requested format, if necessary
* first prompting the user for whether to include hidden regions or
* non-sequence data
- *
+ *
* @param fileFormatName
*/
/**
* DOCUMENT ME!
- *
+ *
* @param e
* DOCUMENT ME!
*/
/**
* Creates a PNG image of the alignment and writes it to the given file. If
* the file is null, the user is prompted to choose a file.
- *
+ *
* @param f
*/
/**
* Creates an EPS image of the alignment and writes it to the given file. If
* the file is null, the user is prompted to choose a file.
- *
+ *
* @param f
*/
/**
* Creates an SVG image of the alignment and writes it to the given file. If
* the file is null, the user is prompted to choose a file.
- *
+ *
* @param f
*/
/**
* DOCUMENT ME!
- *
+ *
* @param e
* DOCUMENT ME!
*/
@Override
public void associatedData_actionPerformed(ActionEvent e)
+ throws IOException, InterruptedException
{
final JalviewFileChooser chooser = new JalviewFileChooser(
jalview.bin.Cache.getProperty("LAST_DIRECTORY"));
/**
* Close the current view or all views in the alignment frame. If the frame
* only contains one view then the alignment will be removed from memory.
- *
+ *
* @param closeAllTabs
*/
/**
* Close the specified panel and close up tabs appropriately.
- *
+ *
* @param panelToClose
*/
}
/**
- *
+ *
* @return alignment objects for all views
*/
/**
* DOCUMENT ME!
- *
+ *
* @param e
* DOCUMENT ME!
*/
/**
* DOCUMENT ME!
- *
+ *
* @param e
* DOCUMENT ME!
*/
/**
* DOCUMENT ME!
- *
+ *
* @param up
* DOCUMENT ME!
*/
/**
* DOCUMENT ME!
- *
+ *
* @param e
* DOCUMENT ME!
*/
/**
* DOCUMENT ME!
- *
+ *
* @param e
* DOCUMENT ME!
+ * @throws InterruptedException
+ * @throws IOException
*/
@Override
protected void pasteNew_actionPerformed(ActionEvent e)
+ throws IOException, InterruptedException
{
paste(true);
}
/**
* DOCUMENT ME!
- *
+ *
* @param e
* DOCUMENT ME!
+ * @throws InterruptedException
+ * @throws IOException
*/
@Override
protected void pasteThis_actionPerformed(ActionEvent e)
+ throws IOException, InterruptedException
{
paste(false);
}
/**
* Paste contents of Jalview clipboard
- *
+ *
* @param newAlignment
* true to paste to a new alignment, otherwise add to this.
+ * @throws InterruptedException
+ * @throws IOException
*/
-
- void paste(boolean newAlignment)
+ void paste(boolean newAlignment) throws IOException, InterruptedException
{
boolean externalPaste = true;
try
System.out.println("Exception whilst pasting: " + ex);
// could be anything being pasted in here
}
-
}
@Override
/**
* DOCUMENT ME!
- *
+ *
* @param e
* DOCUMENT ME!
*/
/**
* DOCUMENT ME!
- *
+ *
* @param e
* DOCUMENT ME!
*/
/**
* DOCUMENT ME!
- *
+ *
* @param e
* DOCUMENT ME!
*/
/**
* DOCUMENT ME!
- *
+ *
* @param e
* DOCUMENT ME!
*/
/**
* DOCUMENT ME!
- *
+ *
* @param e
* DOCUMENT ME!
*/
/**
* DOCUMENT ME!
- *
+ *
* @param e
* DOCUMENT ME!
*/
/**
* DOCUMENT ME!
- *
+ *
* @param e
* DOCUMENT ME!
*/
/**
* DOCUMENT ME!
- *
+ *
* @param e
* DOCUMENT ME!
*/
/**
* DOCUMENT ME!
- *
+ *
* @param e
* DOCUMENT ME!
*/
/**
* DOCUMENT ME!
- *
+ *
* @param e
* DOCUMENT ME!
*/
/**
* Creates and shows a new view of the current alignment.
- *
+ *
* @param viewTitle
* title of newly created view; if null, one will be generated
* @param copyAnnotation
* Make a new name for the view, ensuring it is unique within the current
* sequenceSetId. (This used to be essential for Jalview Project archives, but
* these now use viewId. Unique view names are still desirable for usability.)
- *
+ *
* @param viewTitle
* @return
*/
/**
* Returns a list of distinct view names found in the given list of
* components. View names are held on the viewport of an AlignmentPanel.
- *
+ *
* @param comps
* @return
*/
/**
* DOCUMENT ME!
- *
+ *
* @param e
* DOCUMENT ME!
*/
/**
* DOCUMENT ME!
- *
+ *
* @param e
* DOCUMENT ME!
*/
/*
* (non-Javadoc)
- *
+ *
* @see jalview.jbgui.GAlignFrame#followHighlight_actionPerformed()
*/
/**
* DOCUMENT ME!
- *
+ *
* @param e
* DOCUMENT ME!
*/
/**
* DOCUMENT ME!
- *
+ *
* @param e
* DOCUMENT ME!
*/
/**
* called by key handler and the hide all/show all menu items
- *
+ *
* @param toggleSeqs
* @param toggleCols
*/
/*
* (non-Javadoc)
- *
+ *
* @see
* jalview.jbgui.GAlignFrame#hideAllButSelection_actionPerformed(java.awt.
* event.ActionEvent)
/*
* (non-Javadoc)
- *
+ *
* @see
* jalview.jbgui.GAlignFrame#hideAllSelection_actionPerformed(java.awt.event
* .ActionEvent)
/*
* (non-Javadoc)
- *
+ *
* @see
* jalview.jbgui.GAlignFrame#showAllhidden_actionPerformed(java.awt.event.
* ActionEvent)
/**
* DOCUMENT ME!
- *
+ *
* @param e
* DOCUMENT ME!
*/
/**
* DOCUMENT ME!
- *
+ *
* @param e
* DOCUMENT ME!
*/
/**
* DOCUMENT ME!
- *
+ *
* @param e
* DOCUMENT ME!
*/
/**
* DOCUMENT ME!
- *
+ *
* @param e
* DOCUMENT ME!
*/
/**
* DOCUMENT ME!
- *
+ *
* @param e
* DOCUMENT ME!
*/
/**
* DOCUMENT ME!
- *
+ *
* @param e
* DOCUMENT ME!
*/
/**
* Set or clear 'Show Sequence Features'
- *
+ *
* @param evt
* DOCUMENT ME!
*/
/**
* Action on toggle of the 'Show annotations' menu item. This shows or hides
* the annotations panel as a whole.
- *
+ *
* The options to show/hide all annotations should be enabled when the panel
* is shown, and disabled when the panel is hidden.
- *
+ *
* @param e
*/
{
alignPanel.updateScrollBarsFromRanges();
}
-
+
});
}
else
/**
* Java only
- *
+ *
* @j2sIgnore
*/
{
/**
* DOCUMENT ME!
- *
+ *
* @param e
* DOCUMENT ME!
*/
* Action on the user checking or unchecking the option to apply the selected
* colour scheme to all groups. If unchecked, groups may have their own
* independent colour schemes.
- *
+ *
* @param selected
*/
/**
* Action on user selecting a colour from the colour menu
- *
+ *
* @param name
* the name (not the menu item label!) of the colour scheme
*/
/**
* Actions on setting or changing the alignment colour scheme
- *
+ *
* @param cs
*/
/**
* DOCUMENT ME!
- *
+ *
* @param e
* DOCUMENT ME!
*/
/**
* DOCUMENT ME!
- *
+ *
* @param e
* DOCUMENT ME!
*/
/**
* DOCUMENT ME!
- *
+ *
* @param e
* DOCUMENT ME!
*/
/**
* DOCUMENT ME!
- *
+ *
* @param e
* DOCUMENT ME!
*/
alignPanel.paintAlignment(true, false);
}
+ @Override
+ public void sortEValueMenuItem_actionPerformed(ActionEvent e)
+ {
+ SequenceI[] oldOrder = viewport.getAlignment().getSequencesArray();
+ AlignmentSorter.sortByEValue(viewport.getAlignment());
+ addHistoryItem(new OrderCommand("Group Sort", oldOrder,
+ viewport.getAlignment()));
+ alignPanel.paintAlignment(true, false);
+
+ }
+
+ @Override
+ public void sortBitScoreMenuItem_actionPerformed(ActionEvent e)
+ {
+ SequenceI[] oldOrder = viewport.getAlignment().getSequencesArray();
+ AlignmentSorter.sortByBitScore(viewport.getAlignment());
+ addHistoryItem(new OrderCommand("Group Sort", oldOrder,
+ viewport.getAlignment()));
+ alignPanel.paintAlignment(true, false);
+
+ }
+
/**
* DOCUMENT ME!
- *
+ *
* @param e
* DOCUMENT ME!
*/
/**
* DOCUMENT ME!
- *
+ *
* @param e
* DOCUMENT ME!
*/
/**
* Constructs a tree panel and adds it to the desktop
- *
+ *
* @param type
* tree type (NJ or AV)
* @param modelName
/**
* DOCUMENT ME!
- *
+ *
* @param title
* DOCUMENT ME!
* @param order
/**
* Add a new sort by annotation score menu item
- *
+ *
* @param sort
* the menu to add the option to
* @param scoreLabel
* 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.
- *
+ *
*/
@Override
}
if (viewport.getAlignment().getAlignmentAnnotation()
- .hashCode() != _annotationScoreVectorHash)
+ .hashCode() == _annotationScoreVectorHash)
{
- sortByAnnotScore.removeAll();
- // almost certainly a quicker way to do this - but we keep it simple
- Hashtable<String, String> scoreSorts = new Hashtable<>();
- AlignmentAnnotation aann[];
- for (SequenceI sqa : viewport.getAlignment().getSequences())
+ return;
+ }
+
+ sortByAnnotScore.removeAll();
+ Set<String> scoreSorts = new HashSet<>();
+ for (SequenceI sqa : viewport.getAlignment().getSequences())
+ {
+ AlignmentAnnotation[] anns = sqa.getAnnotation();
+ for (int i = 0; anns != null && i < anns.length; i++)
{
- aann = sqa.getAnnotation();
- for (int i = 0; aann != null && i < aann.length; i++)
+ AlignmentAnnotation aa = anns[i];
+ if (aa != null && aa.hasScore() && aa.sequenceRef != null)
{
- if (aann[i].hasScore() && aann[i].sequenceRef != null)
- {
- scoreSorts.put(aann[i].label, aann[i].label);
- }
+ scoreSorts.add(aa.label);
}
}
- Enumeration<String> labels = scoreSorts.keys();
- while (labels.hasMoreElements())
- {
- addSortByAnnotScoreMenuItem(sortByAnnotScore, labels.nextElement());
- }
- sortByAnnotScore.setVisible(scoreSorts.size() > 0);
- scoreSorts.clear();
-
- _annotationScoreVectorHash = viewport.getAlignment()
- .getAlignmentAnnotation().hashCode();
}
+ for (String label : scoreSorts)
+ {
+ addSortByAnnotScoreMenuItem(sortByAnnotScore, label);
+ }
+ sortByAnnotScore.setVisible(!scoreSorts.isEmpty());
+
+ _annotationScoreVectorHash = viewport.getAlignment()
+ .getAlignmentAnnotation().hashCode();
}
/**
- * Enable (or, if desired, make visible) the By Tree
+ * Enable (or, if desired, make visible) the By Tree
* submenu only if it has at least one element (or will have).
- *
+ *
*/
@Override
protected void enableSortMenuOptions()
List<TreePanel> treePanels = getTreePanels();
sortByTreeMenu.setEnabled(!treePanels.isEmpty());
}
-
+
/**
* Maintain the Order by->Displayed Tree menu. Creates a new menu item for a
* TreePanel with an appropriate <code>jalview.analysis.AlignmentSorter</code>
/**
* Work out whether the whole set of sequences or just the selected set will
* be submitted for multiple alignment.
- *
+ *
*/
public jalview.datamodel.AlignmentView gatherSequencesForAlignment()
/*
* SequenceGroup seqs = viewport.getSelectionGroup(); int sz; msa = new
* SequenceI[sz = seqs.getSize(false)];
- *
+ *
* for (int i = 0; i < sz; i++) { msa[i] = (SequenceI)
* seqs.getSequenceAt(i); }
*/
/**
* DOCUMENT ME!
- *
+ *
* @param e
* DOCUMENT ME!
*/
/**
* Add a treeviewer for the tree extracted from a Newick file object to the
* current alignment view
- *
+ *
* @param nf
* the tree
* @param title
return tp;
}
- private boolean buildingMenu = false;
-
/**
- * Generates menu items and listener event actions for web service clients
- *
+ * Schedule the web services menu rebuild to the event dispatch thread.
*/
-
- public void BuildWebServiceMenu()
+ public void buildWebServicesMenu()
{
- while (buildingMenu)
- {
- try
+ SwingUtilities.invokeLater(() -> {
+ Cache.log.info("Rebuiling WS menu");
+ webService.removeAll();
+ if (Cache.getDefault("SHOW_SLIVKA_SERVICES", true))
{
- System.err.println("Waiting for building menu to finish.");
- Thread.sleep(10);
- } catch (Exception e)
+ Cache.log.info("Building web service menu for slivka");
+ SlivkaWSDiscoverer discoverer = SlivkaWSDiscoverer.getInstance();
+ JMenu submenu = new JMenu("Slivka");
+ buildWebServicesMenu(discoverer, submenu);
+ webService.add(submenu);
+ }
+ if (Cache.getDefault("SHOW_JWS2_SERVICES", true))
{
+ WSDiscovererI jws2servs = Jws2Discoverer.getInstance();
+ JMenu submenu = new JMenu("JABAWS");
+ buildLegacyWebServicesMenu(submenu);
+ buildWebServicesMenu(jws2servs, submenu);
+ webService.add(submenu);
}
- }
- final AlignFrame me = this;
- buildingMenu = true;
- new Thread(new Runnable()
- {
+ build_fetchdbmenu(webService);
+ });
+ }
- @Override
- public void run()
+ private void buildLegacyWebServicesMenu(JMenu menu)
+ {
+ JMenu secstrmenu = new JMenu("Secondary Structure Prediction");
+ if (Discoverer.getServices() != null && Discoverer.getServices().size() > 0)
+ {
+ var secstrpred = Discoverer.getServices().get("SecStrPred");
+ if (secstrpred != null)
{
- final List<JMenuItem> legacyItems = new ArrayList<>();
- try
+ for (ext.vamsas.ServiceHandle sh : secstrpred)
{
- // 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<JMenu> wsmenu = new Vector<>();
- final IProgressIndicator af = me;
-
- /*
- * do not i18n these strings - they are hard-coded in class
- * compbio.data.msa.Category, Jws2Discoverer.isRecalculable() and
- * SequenceAnnotationWSClient.initSequenceAnnotationWSClient()
- */
- final JMenu msawsmenu = new JMenu("Alignment");
- final JMenu secstrmenu = new JMenu(
- "Secondary Structure Prediction");
- final JMenu seqsrchmenu = new JMenu("Sequence Database Search");
- final JMenu analymenu = new JMenu("Analysis");
- final JMenu dismenu = new JMenu("Protein Disorder");
- // JAL-940 - only show secondary structure prediction services from
- // the legacy server
- Hashtable<String, Vector<ServiceHandle>> ds = Discoverer
- .getInstance().getServices();
- if (// Cache.getDefault("SHOW_JWS1_SERVICES", true)
- // &&
- ds != null && (ds.size() > 0))
- {
- // TODO: refactor to allow list of AbstractName/Handler bindings to
- // be
- // stored or retrieved from elsewhere
- // No MSAWS used any more:
- // Vector msaws = null; // (Vector)
- // Discoverer.services.get("MsaWS");
- Vector<ServiceHandle> secstrpr = ds.get("SecStrPred");
- if (secstrpr != null)
- {
- // Add any secondary structure prediction services
- for (int i = 0, j = secstrpr.size(); i < j; i++)
- {
- final ext.vamsas.ServiceHandle sh = secstrpr.get(i);
- jalview.ws.WSMenuEntryProviderI impl = jalview.ws.jws1.Discoverer
- .getServiceClient(sh);
- int p = secstrmenu.getItemCount();
- impl.attachWSMenuEntry(secstrmenu, me);
- int q = secstrmenu.getItemCount();
- for (int litm = p; litm < q; litm++)
- {
- legacyItems.add(secstrmenu.getItem(litm));
- }
- }
- }
- }
-
- // Add all submenus in the order they should appear on the web
- // services menu
- wsmenu.add(msawsmenu);
- wsmenu.add(secstrmenu);
- wsmenu.add(dismenu);
- wsmenu.add(analymenu);
- // No search services yet
- // wsmenu.add(seqsrchmenu);
-
- javax.swing.SwingUtilities.invokeLater(new Runnable()
- {
+ var menuProvider = Discoverer.getServiceClient(sh);
+ menuProvider.attachWSMenuEntry(secstrmenu, this);
+ }
+ }
+ }
+ menu.add(secstrmenu);
+ }
- @Override
- public void run()
- {
- 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(wsmenu.get(i));
- }
- }
- else
- {
- webService.add(me.webServiceNoServices);
- }
- // TODO: move into separate menu builder class.
- // boolean new_sspred = false;
- if (Cache.getDefault("SHOW_JWS2_SERVICES", true))
- {
- Jws2Discoverer jws2servs = Jws2Discoverer.getInstance();
- if (jws2servs != null)
- {
- if (jws2servs.hasServices())
- {
- jws2servs.attachWSMenuEntry(webService, me);
- for (Jws2Instance sv : jws2servs.getServices())
- {
- if (sv.description.toLowerCase().contains("jpred"))
- {
- for (JMenuItem jmi : legacyItems)
- {
- jmi.setVisible(false);
- }
- }
- }
+ /**
+ * Constructs the web services menu for the given discoverer under the
+ * specified menu. This method must be called on the EDT
+ *
+ * @param discoverer
+ * the discoverer used to build the menu
+ * @param menu
+ * parent component which the elements will be attached to
+ */
+ private void buildWebServicesMenu(WSDiscovererI discoverer, JMenu menu)
+ {
+ if (discoverer.hasServices())
+ {
+ PreferredServiceRegistry.getRegistry().populateWSMenuEntry(
+ discoverer.getServices(), sv -> buildWebServicesMenu(), menu,
+ this, null);
+ }
+ if (discoverer.isRunning())
+ {
+ JMenuItem item = new JMenuItem("Service discovery in progress.");
+ item.setEnabled(false);
+ menu.add(item);
+ }
+ else if (!discoverer.hasServices())
+ {
+ JMenuItem item = new JMenuItem("No services available.");
+ item.setEnabled(false);
+ menu.add(item);
+ }
+ }
- }
- if (jws2servs.isRunning())
- {
- JMenuItem tm = new JMenuItem(
- "Still discovering JABA Services");
- tm.setEnabled(false);
- webService.add(tm);
- }
- }
- }
- build_urlServiceMenu(me.webService);
- build_fetchdbmenu(webService);
- for (JMenu item : wsmenu)
- {
- if (item.getItemCount() == 0)
- {
- item.setEnabled(false);
- }
- else
- {
- item.setEnabled(true);
- }
- }
- } catch (Exception e)
- {
- Cache.log.debug(
- "Exception during web service menu building process.",
- e);
- }
- }
- });
- } catch (Exception e)
+ private void buildWebServicesMenu(WebServiceDiscoverer discoverer, JMenu menu)
+ {
+ if (discoverer.hasServices())
+ {
+ for (WebServiceI service : discoverer.getServices())
+ {
+ for (Operation op : service.getOperations())
{
+ JMenu atpoint = JvSwingUtils.findOrCreateMenu(menu, op.getTypeName());
+ op.getMenuBuilder().buildMenu(atpoint, this);
}
- buildingMenu = false;
}
- }).start();
-
+ }
+ if (discoverer.isRunning())
+ {
+ JMenuItem item = new JMenuItem("Service discovery in progress.");
+ item.setEnabled(false);
+ menu.add(item);
+ }
+ else if (!discoverer.hasServices())
+ {
+ JMenuItem item = new JMenuItem("No services available.");
+ item.setEnabled(false);
+ menu.add(item);
+ }
}
/**
* construct any groupURL type service menu entries.
- *
+ *
* @param webService
*/
/*
* JMenuItem testAlView = new JMenuItem("Test AlignmentView"); final
* AlignFrame af = this; testAlView.addActionListener(new ActionListener() {
- *
+ *
* public void actionPerformed(ActionEvent e) {
* jalview.datamodel.AlignmentView
* .testSelectionViews(af.viewport.getAlignment(),
* af.viewport.getColumnSelection(), af.viewport.selectionGroup); }
- *
+ *
* }); webService.add(testAlView);
*/
// TODO: refactor to RestClient discoverer and merge menu entries for
* Cross-References menu (formerly called Show Products), with database
* sources for which cross-references are found (protein sources for a
* nucleotide alignment and vice versa)
- *
+ *
* @return true if Show Cross-references menu should be enabled
*/
/**
* Finds and displays cross-references for the selected sequences (protein
* products for nucleotide sequences, dna coding sequences for peptides).
- *
+ *
* @param sel
* the sequences to show cross-references for
* @param dna
/**
* Set the file format
- *
+ *
* @param format
*/
/**
* Try to load a features file onto the alignment.
- *
+ *
* @param file
* contents or path to retrieve file or a File object
* @param sourceType
* <li>a features file</li>
* <li>else try to interpret as an alignment file</li>
* </ul>
- *
+ *
* @param file
* either a filename or a URL string.
+ * @throws InterruptedException
+ * @throws IOException
*/
public void loadJalviewDataFile(Object file, DataSourceType sourceType,
/**
* Change the display state for the given feature groups -- Added by BH from
* JalviewLite
- *
+ *
* @param groups
* list of group strings
* @param state
/*
* (non-Javadoc)
- *
+ *
* @see
* jalview.jbgui.GAlignFrame#showDbRefs_actionPerformed(java.awt.event.ActionEvent
* )
/*
* (non-Javadoc)
- *
+ *
* @seejalview.jbgui.GAlignFrame#showNpFeats_actionPerformed(java.awt.event.
* ActionEvent)
*/
/**
* find the viewport amongst the tabs in this alignment frame and close that
* tab
- *
+ *
* @param av
*/
/*
* (non-Javadoc)
- *
+ *
* @see
* jalview.jbgui.GAlignFrame#showUnconservedMenuItem_actionPerformed(java.
* awt.event.ActionEvent)
/*
* (non-Javadoc)
- *
+ *
* @see
* jalview.jbgui.GAlignFrame#showGroupConsensus_actionPerformed(java.awt.event
* .ActionEvent)
/*
* (non-Javadoc)
- *
+ *
* @see
* jalview.jbgui.GAlignFrame#showGroupConservation_actionPerformed(java.awt
* .event.ActionEvent)
/*
* (non-Javadoc)
- *
+ *
* @see
* jalview.jbgui.GAlignFrame#showConsensusHistogram_actionPerformed(java.awt
* .event.ActionEvent)
/*
* (non-Javadoc)
- *
+ *
* @see
* jalview.jbgui.GAlignFrame#showConsensusProfile_actionPerformed(java.awt
* .event.ActionEvent)
/*
* (non-Javadoc)
- *
+ *
* @see
* jalview.jbgui.GAlignFrame#makeGrpsFromSelection_actionPerformed(java.awt
* .event.ActionEvent)
/**
* make the given alignmentPanel the currently selected tab
- *
+ *
* @param alignmentPanel
*/
/**
* Action on selection of menu options to Show or Hide annotations.
- *
+ *
* @param visible
* @param forSequences
* update sequence-related annotations
}
/**
- *
+ *
* @return alignment panels in this alignment frame
*/
/**
* Set visibility of dna/protein complement view (available when shown in a
* split frame).
- *
+ *
* @param show
*/
/**
* Hides columns containing (or not containing) a specified feature, provided
* that would not leave all columns hidden
- *
+ *
* @param featureType
* @param columnsContaining
* @return
}
}
+ /**
+ * Sets the status of the HMMER menu
+ */
+ public void updateHMMERStatus()
+ {
+ hmmerMenu.setEnabled(HmmerCommand.isHmmerAvailable());
+ }
+
@Override
protected void loadVcf_actionPerformed()
{
/**
* BH 2019 from JalviewLite
- *
+ *
* get sequence feature groups that are hidden or shown
- *
+ *
* @param visible
* true is visible
* @return list
}
/**
- *
+ *
* @return list of feature groups on the view
*/
}
}
}
+
}