/*
- * Jalview - A Sequence Alignment Editor and Viewer (Development Version 2.4.1)
- * Copyright (C) 2009 AM Waterhouse, J Procter, G Barton, M Clamp, S Searle
+ * Jalview - A Sequence Alignment Editor and Viewer (Version 2.7)
+ * Copyright (C) 2011 J Procter, AM Waterhouse, 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 file is part of Jalview.
*
- * 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.
+ * Jalview 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 3 of the License, or (at your option) any later version.
*
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
+ * 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/>.
*/
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.commands.*;
-import jalview.datamodel.*;
-import jalview.io.*;
-import jalview.jbgui.*;
-import jalview.schemes.*;
-import jalview.ws.*;
+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.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.io.TCoffeeScoreFile;
+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.ResidueProperties;
+import jalview.schemes.StrandColourScheme;
+import jalview.schemes.TCoffeeColourScheme;
+import jalview.schemes.TaylorColourScheme;
+import jalview.schemes.TurnColourScheme;
+import jalview.schemes.UserColourScheme;
+import jalview.schemes.ZappoColourScheme;
+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!
AlignViewport viewport;
Vector alignPanels = new Vector();
+
+ TCoffeeScoreFile tcoffeeScoreFile;
/**
* Last format used to load or save alignments in this window
{
boolean toggleSeqs = !evt.isControlDown();
boolean toggleCols = !evt.isShiftDown();
-
- boolean hide = false;
-
- SequenceGroup sg = viewport.getSelectionGroup();
- if (toggleSeqs)
- {
- if (sg != null
- && sg.getSize() != viewport.alignment.getHeight())
- {
- hideSelSequences_actionPerformed(null);
- hide = true;
- }
- else if (!(toggleCols && viewport.colSel.getSelected().size() > 0))
- {
- showAllSeqs_actionPerformed(null);
- }
- }
-
- if (toggleCols)
- {
- if (viewport.colSel.getSelected().size() > 0)
- {
- hideSelColumns_actionPerformed(null);
- if (!toggleSeqs)
- {
- viewport.selectionGroup = sg;
- }
- }
- else if (!hide)
- {
- showAllColumns_actionPerformed(null);
- }
- }
+ toggleHiddenRegions(toggleSeqs, toggleCols);
break;
}
case KeyEvent.VK_PAGE_UP:
private void addServiceListeners()
{
final java.beans.PropertyChangeListener thisListener;
- // Do this once to get current state
- BuildWebServiceMenu();
- Desktop.discoverer
- .addPropertyChangeListener(thisListener = new java.beans.PropertyChangeListener()
+ Desktop.instance.addJalviewPropertyChangeListener("services",
+ thisListener = new java.beans.PropertyChangeListener()
{
public void propertyChange(PropertyChangeEvent evt)
{
- // System.out.println("Discoverer property change.");
- if (evt.getPropertyName().equals("services"))
+ // // System.out.println("Discoverer property change.");
+ // if (evt.getPropertyName().equals("services"))
{
- // System.out.println("Rebuilding web service menu");
- BuildWebServiceMenu();
+ SwingUtilities.invokeLater(new Runnable()
+ {
+
+ public void run()
+ {
+ System.err
+ .println("Rebuild WS Menu for service change");
+ BuildWebServiceMenu();
+ }
+
+ });
}
}
});
-
addInternalFrameListener(new javax.swing.event.InternalFrameAdapter()
{
public void internalFrameClosed(
javax.swing.event.InternalFrameEvent evt)
{
- // System.out.println("deregistering discoverer listener");
- Desktop.discoverer.removePropertyChangeListener(thisListener);
+ System.out.println("deregistering discoverer listener");
+ Desktop.instance.removeJalviewPropertyChangeListener("services",
+ thisListener);
closeMenuItem_actionPerformed(true);
};
});
+ // Finally, build the menu once to get current service state
+ new Thread(new Runnable()
+ {
+ public void run()
+ {
+ BuildWebServiceMenu();
+ }
+ }).start();
}
public void setGUINucleotide(boolean nucleotide)
showTranslation.setVisible(nucleotide);
conservationMenuItem.setEnabled(!nucleotide);
modifyConservation.setEnabled(!nucleotide);
-
+ showGroupConservation.setEnabled(!nucleotide);
// Remember AlignFrame always starts as protein
if (!nucleotide)
{
annotationPanelMenuItem.setState(av.showAnnotation);
viewBoxesMenuItem.setSelected(av.showBoxes);
viewTextMenuItem.setSelected(av.showText);
- showUnconservedMenuItem.setSelected(av.showUnconserved);
+ showNonconservedMenuItem.setSelected(av.showUnconserved);
showGroupConsensus.setSelected(av.showGroupConsensus);
showGroupConservation.setSelected(av.showGroupConservation);
+ showConsensusHistogram.setSelected(av.showConsensusHistogram);
+ showSequenceLogo.setSelected(av.showSequenceLogo);
setColourSelected(ColourSchemeProperty.getColourName(av
.getGlobalColourScheme()));
applyToAllGroups.setState(av.colourAppliesToAllGroups);
showNpFeatsMenuitem.setSelected(av.isShowNpFeats());
showDbRefsMenuitem.setSelected(av.isShowDbRefs());
-
+ autoCalculate.setSelected(av.autoCalculateConsensus);
+ sortByTree.setSelected(av.sortByTree);
+ listenToViewSelections.setSelected(av.followSelection);
+
setShowProductsEnabled();
updateEditMenuBar();
}
JPanel progressPanel;
+ Long lId = new Long(id);
GridLayout layout = (GridLayout) statusPanel.getLayout();
- if (progressBars.get(new Long(id)) != null)
+ if (progressBars.get(lId) != null)
{
progressPanel = (JPanel) progressBars.get(new Long(id));
statusPanel.remove(progressPanel);
- progressBars.remove(progressPanel);
+ progressBars.remove(lId);
progressPanel = null;
if (message != null)
{
statusBar.setText(message);
}
- if (progressBarHandlers.contains(new Long(id)))
+ if (progressBarHandlers.contains(lId))
{
- progressBarHandlers.remove(new Long(id));
+ progressBarHandlers.remove(lId);
}
layout.setRows(layout.getRows() - 1);
}
layout.setRows(layout.getRows() + 1);
statusPanel.add(progressPanel);
- progressBars.put(new Long(id), progressPanel);
+ progressBars.put(lId, progressPanel);
}
// update GUI
- setMenusForViewport();
+ // setMenusForViewport();
validate();
}
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);
{
if (fileName != null)
{
+ // TODO: work out how to recover feature settings for correct view(s) when
+ // file is reloaded.
if (currentFileFormat.equals("Jalview"))
{
JInternalFrame[] frames = Desktop.desktop.getAllFrames();
protocol, currentFileFormat);
newframe.setBounds(bounds);
-
+ if (featureSettings != null && featureSettings.isShowing())
+ {
+ final Rectangle fspos = featureSettings.frame.getBounds();
+ // TODO: need a 'show feature settings' function that takes bounds -
+ // need to refactor Desktop.addFrame
+ newframe.featureSettings_actionPerformed(null);
+ final FeatureSettings nfs = newframe.featureSettings;
+ SwingUtilities.invokeLater(new Runnable()
+ {
+ public void run()
+ {
+ nfs.frame.setBounds(fspos);
+ }
+ });
+ this.featureSettings.close();
+ this.featureSettings = null;
+ }
this.closeMenuItem_actionPerformed(true);
}
}
*/
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);
{
if (!jalview.io.AppletFormatAdapter.isValidFormat(format, true))
{
- warningMessage("Cannot save file "
- + fileName + " using format " + format,
- "Alignment output format not supported");
+ warningMessage("Cannot save file " + fileName + " using format "
+ + format, "Alignment output format not supported");
saveAs_actionPerformed(null);
// JBPNote need to have a raise_gui flag here
return false;
}
FormatAdapter f = new FormatAdapter();
String output = f.formatSequences(format,
- (Alignment) viewport.alignment, // class cast exceptions will
+ viewport.alignment, // class cast exceptions will
// occur in the distant future
omitHidden, f.getCacheSuffixDefault(format), viewport.colSel);
{
if (new jalview.util.Platform().isHeadless())
{
- System.err.println("Warning: "+title+"\nWarning: "+warning);
-
- } else {
- JOptionPane.showInternalMessageDialog(this,warning,title,JOptionPane.WARNING_MESSAGE);
+ System.err.println("Warning: " + title + "\nWarning: " + warning);
+
+ }
+ else
+ {
+ JOptionPane.showInternalMessageDialog(this, warning, title,
+ JOptionPane.WARNING_MESSAGE);
}
return;
}
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();
+ }
+
}
/**
*/
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)
public void exportAnnotations_actionPerformed(ActionEvent e)
{
- new AnnotationExporter().exportAnnotations(alignPanel,
+ new AnnotationExporter().exportAnnotations(
+ alignPanel,
viewport.showAnnotation ? viewport.alignment
.getAlignmentAnnotation() : null, viewport.alignment
.getGroups(),
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");
{
String choice = chooser.getSelectedFile().getPath();
jalview.bin.Cache.setProperty("LAST_DIRECTORY", choice);
- loadJalviewDataFile(choice);
+ loadJalviewDataFile(choice, null, null, null);
}
}
viewport.historyList.push(command);
viewport.redoList.clear();
updateEditMenuBar();
- viewport.hasHiddenColumns = viewport.colSel.getHiddenColumns() != null;
+ viewport.hasHiddenColumns = (viewport.colSel != null
+ && viewport.colSel.getHiddenColumns() != null && viewport.colSel
+ .getHiddenColumns().size() > 0);
}
}
if (originalSource != null)
{
- originalSource.hasHiddenColumns = viewport.colSel.getHiddenColumns() != null;
+ originalSource.hasHiddenColumns = (viewport.colSel != null
+ && viewport.colSel.getHiddenColumns() != null && viewport.colSel
+ .getHiddenColumns().size() > 0);
originalSource.firePropertyChange("alignment", null,
originalSource.alignment.getSequences());
}
if (originalSource != null)
{
- originalSource.hasHiddenColumns = viewport.colSel.getHiddenColumns() != null;
+ originalSource.hasHiddenColumns = (viewport.colSel != null
+ && viewport.colSel.getHiddenColumns() != null && viewport.colSel
+ .getHiddenColumns().size() > 0);
originalSource.firePropertyChange("alignment", null,
originalSource.alignment.getSequences());
}
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);
if (viewport.hasHiddenColumns)
{
hiddenColumns = new Vector();
- int hiddenOffset = viewport.getSelectionGroup().getStartRes();
+ int hiddenOffset = viewport.getSelectionGroup().getStartRes(), hiddenCutoff = viewport
+ .getSelectionGroup().getEndRes();
for (int i = 0; i < viewport.getColumnSelection().getHiddenColumns()
.size(); i++)
{
int[] region = (int[]) viewport.getColumnSelection()
.getHiddenColumns().elementAt(i);
-
- hiddenColumns.addElement(new int[]
- { region[0] - hiddenOffset, region[1] - hiddenOffset });
+ if (region[0] >= hiddenOffset && region[1] <= hiddenCutoff)
+ {
+ hiddenColumns.addElement(new int[]
+ { region[0] - hiddenOffset, region[1] - hiddenOffset });
+ }
}
}
}
buildSortByAnnotationScoresMenu();
}
- viewport.firePropertyChange("alignment", null, alignment
- .getSequences());
+ viewport.firePropertyChange("alignment", null,
+ alignment.getSequences());
}
else
alignPanel.idPanel.idCanvas.searchResults = null;
alignPanel.paintAlignment(true);
PaintRefresher.Refresh(alignPanel, viewport.getSequenceSetId());
+ viewport.sendSelection();
}
/**
}
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();
}
/**
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;
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();
while (existingNames.contains(newViewName))
{
- newViewName = "View " + (++index);
+ newViewName = viewTitle + " " + (++index);
}
newap.av.viewName = newViewName;
viewport.gatherViewsHere = true;
}
tabbedPane.setSelectedIndex(tabbedPane.getTabCount() - 1);
+ return newap;
}
public void expandViews_actionPerformed(ActionEvent e)
alignPanel.paintAlignment(true);
}
+ /**
+ * called by key handler and the hide all/show all menu items
+ *
+ * @param toggleSeqs
+ * @param toggleCols
+ */
+ private void toggleHiddenRegions(boolean toggleSeqs, boolean toggleCols)
+ {
+
+ boolean hide = false;
+ SequenceGroup sg = viewport.getSelectionGroup();
+ if (!toggleSeqs && !toggleCols)
+ {
+ // Hide everything by the current selection - this is a hack - we do the
+ // invert and then hide
+ // first check that there will be visible columns after the invert.
+ if ((viewport.colSel != null && viewport.colSel.getSelected() != null && viewport.colSel
+ .getSelected().size() > 0)
+ || (sg != null && sg.getSize() > 0 && sg.getStartRes() <= sg
+ .getEndRes()))
+ {
+ // now invert the sequence set, if required - empty selection implies
+ // that no hiding is required.
+ if (sg != null)
+ {
+ invertSequenceMenuItem_actionPerformed(null);
+ sg = viewport.getSelectionGroup();
+ toggleSeqs = true;
+
+ }
+ viewport.expandColSelection(sg, true);
+ // finally invert the column selection and get the new sequence
+ // selection.
+ invertColSel_actionPerformed(null);
+ toggleCols = true;
+ }
+ }
+
+ if (toggleSeqs)
+ {
+ if (sg != null && sg.getSize() != viewport.alignment.getHeight())
+ {
+ hideSelSequences_actionPerformed(null);
+ hide = true;
+ }
+ else if (!(toggleCols && viewport.colSel.getSelected().size() > 0))
+ {
+ showAllSeqs_actionPerformed(null);
+ }
+ }
+
+ if (toggleCols)
+ {
+ if (viewport.colSel.getSelected().size() > 0)
+ {
+ hideSelColumns_actionPerformed(null);
+ if (!toggleSeqs)
+ {
+ viewport.selectionGroup = sg;
+ }
+ }
+ else if (!hide)
+ {
+ showAllColumns_actionPerformed(null);
+ }
+ }
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see
+ * jalview.jbgui.GAlignFrame#hideAllButSelection_actionPerformed(java.awt.
+ * event.ActionEvent)
+ */
+ public void hideAllButSelection_actionPerformed(ActionEvent e)
+ {
+ toggleHiddenRegions(false, false);
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see
+ * jalview.jbgui.GAlignFrame#hideAllSelection_actionPerformed(java.awt.event
+ * .ActionEvent)
+ */
+ public void hideAllSelection_actionPerformed(ActionEvent e)
+ {
+ SequenceGroup sg = viewport.getSelectionGroup();
+ viewport.expandColSelection(sg, false);
+ viewport.hideAllSelectedSeqs();
+ viewport.hideSelectedColumns();
+ alignPanel.paintAlignment(true);
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see
+ * jalview.jbgui.GAlignFrame#showAllhidden_actionPerformed(java.awt.event.
+ * ActionEvent)
+ */
+ public void showAllhidden_actionPerformed(ActionEvent e)
+ {
+ viewport.showAllHiddenColumns();
+ viewport.showAllHiddenSeqs();
+ alignPanel.paintAlignment(true);
+ }
+
public void hideSelColumns_actionPerformed(ActionEvent e)
{
viewport.hideSelectedColumns();
featureSettings.close();
featureSettings = null;
}
+ if (!showSeqFeatures.isSelected())
+ {
+ // make sure features are actually displayed
+ showSeqFeatures.setSelected(true);
+ showSeqFeatures_actionPerformed(null);
+ }
featureSettings = new FeatureSettings(this);
}
{
JEditorPane editPane = new JEditorPane("text/html", "");
editPane.setEditable(false);
- StringBuffer contents = new StringBuffer("<html>");
-
- 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("<br>Sequences: " + viewport.alignment.getHeight());
- contents.append("<br>Minimum Sequence Length: " + min);
- contents.append("<br>Maximum Sequence Length: " + max);
- contents.append("<br>Average Length: " + (int) avg);
-
- if (((Alignment) viewport.alignment).getProperties() != null)
- {
- Hashtable props = ((Alignment) viewport.alignment).getProperties();
- Enumeration en = props.keys();
- contents.append("<br><br><table border=\"1\">");
- 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("<br>");
- }
- pos = npos + 1;
- } while (npos != -1);
- contents
- .append("<tr><td>" + key + "</td><td>" + val + "</td></tr>");
- }
- contents.append("</table>");
- }
- editPane.setText(contents.toString() + "</html>");
+ StringBuffer contents = new AlignmentProperties(viewport.alignment)
+ .formatAsHtml();
+ editPane.setText("<html>" + contents.toString() + "</html>");
JInternalFrame frame = new JInternalFrame();
frame.getContentPane().add(new JScrollPane(editPane));
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);
}
public void clustalColour_actionPerformed(ActionEvent e)
{
changeColour(new ClustalxColourScheme(
- viewport.alignment.getSequences(), viewport.alignment
- .getWidth()));
+ viewport.alignment.getSequences(),
+ viewport.alignment.getWidth()));
}
/**
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);
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)
{
{
try
{
- sg.cs = (ColourSchemeI) cs.getClass().newInstance();
+ sg.cs = cs.getClass().newInstance();
} catch (Exception ex)
{
}
{
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
{
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);
if (viewport.getAbovePIDThreshold()
&& viewport.globalColourScheme != null)
{
- SliderPanel.setPIDSliderSource(alignPanel, viewport
- .getGlobalColourScheme(), "Background");
+ SliderPanel.setPIDSliderSource(alignPanel,
+ viewport.getGlobalColourScheme(), "Background");
SliderPanel.showPIDSlider();
}
}
if (evt.isControlDown()
|| SwingUtilities.isRightMouseButton(evt))
{
- radioItem
- .removeActionListener(radioItem.getActionListeners()[0]);
+ radioItem.removeActionListener(radioItem.getActionListeners()[0]);
int option = JOptionPane.showInternalConfirmDialog(
jalview.gui.Desktop.desktop,
.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!
*
}
else
{
- // are the sequences aligned?
- if (!viewport.alignment.isAligned())
+ // are the visible sequences aligned?
+ if (!viewport.alignment.isAligned(false))
{
JOptionPane
.showMessageDialog(
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);
Enumeration labels = scoreSorts.keys();
while (labels.hasMoreElements())
{
- addSortByAnnotScoreMenuItem(sortByAnnotScore, (String) labels
- .nextElement());
+ addSortByAnnotScoreMenuItem(sortByAnnotScore,
+ (String) labels.nextElement());
}
sortByAnnotScore.setVisible(scoreSorts.size() > 0);
scoreSorts.clear();
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));
+
}
});
}
}
+ 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.
// jobs
// TODO: viewport.alignment.isAligned is a global state - the local
// selection may well be aligned - we preserve 2.0.8 behaviour for moment.
- if (!viewport.alignment.isAligned())
+ if (!viewport.alignment.isAligned(false))
{
seqs.setSequences(new SeqCigar[]
{ seqs.getSequences()[0] });
+ // TODO: if seqs.getSequences().length>1 then should really have warned
+ // user!
+
}
return seqs;
}
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");
}
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);
}
}
}
-
+
+ @Override
+ public void loadScores_actionPerformed(ActionEvent e)
+ {
+ // Pick the tree file
+ JalviewFileChooser chooser = new JalviewFileChooser(jalview.bin.Cache.getProperty("LAST_DIRECTORY"));
+ chooser.setFileView(new JalviewFileView());
+ chooser.setDialogTitle("Select a T-Coffee scores ascii file");
+ chooser.setToolTipText("Load a score file");
+
+ int value = chooser.showOpenDialog(null);
+
+ if (value == JalviewFileChooser.APPROVE_OPTION)
+ {
+ String sFilePath = chooser.getSelectedFile().getPath();
+ jalview.bin.Cache.setProperty("LAST_DIRECTORY", sFilePath);
+
+
+ try
+ {
+ TCoffeeScoreFile result = TCoffeeScoreFile.load(new File(sFilePath));
+ if( result == null ) {
+ throw new RuntimeException("The file provided does not match the T-Coffee scores file format");
+ }
+
+ /*
+ * check that the score matrix matches the alignment dimensions
+ */
+ AlignmentI aln;
+ if( (aln=viewport.alignment) != null && (aln.getHeight() != result.getHeight() || aln.getWidth() != result.getWidth()) ) {
+ throw new RuntimeException("The scores matrix does not match the alignment dimensions");
+ }
+
+ changeColour( new TCoffeeColourScheme(result) );
+ tcoffeeScoreFile = result;
+ tcoffeeColour.setEnabled(true);
+ tcoffeeColour.setSelected(true);
+
+ }
+ catch (Exception ex) {
+ JOptionPane.showMessageDialog(
+ Desktop.desktop,
+ ex.getMessage(),
+ "Problem reading tree file",
+ JOptionPane.WARNING_MESSAGE);
+
+ ex.printStackTrace();
+ }
+ }
+
+ }
+
+
+ @Override
+ protected void tcoffeeColorScheme_actionPerformed(ActionEvent e) {
+ if( tcoffeeScoreFile != null ) {
+ changeColour( new TCoffeeColourScheme(tcoffeeScoreFile) );
+ }
+ }
+
+// /**
+// * Load the (T-Coffee) score file from the specified url
+// *
+// * @param url The absolute path from where download and read the score file
+// * @throws IOException
+// */
+// public void loadScoreFile(URL url ) throws IOException {
+//
+// TCoffeeScoreFile result = new TCoffeeScoreFile();
+// result.parse( new InputStreamReader( url.openStream() ) );
+// tcoffeeScoreFile = result;
+// }
+
public TreePanel ShowNewickTree(NewickFile nf, String title)
{
return ShowNewickTree(nf, title, 600, 500, 4, 5);
return tp;
}
+ private boolean buildingMenu = false;
+
/**
* Generates menu items and listener event actions for web service clients
*
*/
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 IProgressIndicator af = this;
- if (msaws != null)
+ while (buildingMenu)
+ {
+ try
{
- // Add any Multiple Sequence Alignment Services
- 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.WSClient impl = jalview.ws.Discoverer
- .getServiceClient(sh);
- impl.attachWSMenuEntry(msawsmenu, this);
-
- }
- wsmenu.add(msawsmenu);
- }
- if (secstrpr != null)
+ System.err.println("Waiting for building menu to finish.");
+ Thread.sleep(10);
+ } catch (Exception e)
{
- // 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 ext.vamsas.ServiceHandle sh = (ext.vamsas.ServiceHandle) secstrpr
- .get(i);
- jalview.ws.WSClient impl = jalview.ws.Discoverer
- .getServiceClient(sh);
- impl.attachWSMenuEntry(secstrmenu, this);
- }
- wsmenu.add(secstrmenu);
}
- if (seqsrch != null)
+ ;
+ }
+ final AlignFrame me = this;
+ buildingMenu = true;
+ new Thread(new Runnable()
+ {
+ public void run()
{
- // Add any sequence search services
- final JMenu seqsrchmenu = new JMenu("Sequence Database Search");
- for (int i = 0, j = seqsrch.size(); i < j; i++)
+ try
+ {
+ 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");
+ final JMenu secstrmenu = new JMenu(
+ "Secondary Structure Prediction");
+ 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))
+ {
+ // 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);
+ }
+ }
+ }
+
+ // TODO: move into separate menu builder class.
+ if (Cache.getDefault("SHOW_JWS2_SERVICES", true))
+ {
+ Jws2Discoverer jws2servs = Jws2Discoverer.getDiscoverer();
+ if (jws2servs != null)
+ {
+ if (jws2servs.hasServices())
+ {
+ jws2servs.attachWSMenuEntry(msawsmenu, me);
+ }
+ }
+ }
+ // 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);
+
+ javax.swing.SwingUtilities.invokeLater(new Runnable()
+ {
+ 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((JMenu) wsmenu.get(i));
+ }
+ }
+ else
+ {
+ webService.add(me.webServiceNoServices);
+ }
+ build_urlServiceMenu(me.webService);
+ build_fetchdbmenu(webService);
+ } catch (Exception e)
+ {
+ }
+ ;
+ }
+ });
+ } catch (Exception e)
{
- 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));
+ ;
+
+ buildingMenu = false;
}
- }
- else
- {
- resetWebServiceMenu();
- this.webService.add(this.webServiceNoServices);
- }
+ }).start();
+
}
+
/**
- * empty the web service menu and add any ad-hoc functions not dynamically
- * discovered.
+ * construct any groupURL type service menu entries.
*
+ * @param webService
*/
- private void resetWebServiceMenu()
+ private void build_urlServiceMenu(JMenu webService)
{
- webService.removeAll();
- build_fetchdbmenu(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(
+ webService, this);
+ }
}
/*
} 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;
}
// 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;
}
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();
// update the min/max ranges where necessary
alignPanel.seqPanel.seqCanvas.fr.findAllFeatures(true);
}
+ if (featureSettings != null)
+ {
+ featureSettings.setTableData();
+ }
alignPanel.paintAlignment(true);
}
{
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<Object[]> filesmatched = new ArrayList<Object[]>();
+ ArrayList<String> filesnotmatched = new ArrayList<String>();
for (int i = 0; i < files.size(); i++)
{
- loadJalviewDataFile(files.get(i).toString());
+ String file = files.get(i).toString();
+ String pdbfn = "";
+ String protocol = FormatAdapter.checkProtocol(file);
+ if (protocol == jalview.io.FormatAdapter.FILE)
+ {
+ File fl = new File(file);
+ pdbfn = fl.getName();
+ }
+ else if (protocol == jalview.io.FormatAdapter.URL)
+ {
+ URL url = new URL(file);
+ pdbfn = url.getFile();
+ }
+ if (pdbfn.length() > 0)
+ {
+ // attempt to find a match in the alignment
+ SequenceI[] mtch = idm.findAllIdMatches(pdbfn);
+ int l = 0, c = pdbfn.indexOf(".");
+ while (mtch == null && c != -1)
+ {
+ do
+ {
+ l = c;
+ } while ((c = pdbfn.indexOf(".", l)) > l);
+ if (l > -1)
+ {
+ pdbfn = pdbfn.substring(0, l);
+ }
+ mtch = idm.findAllIdMatches(pdbfn);
+ }
+ if (mtch != null)
+ {
+ String type = null;
+ try
+ {
+ type = new IdentifyFile().Identify(file, protocol);
+ } catch (Exception ex)
+ {
+ type = null;
+ }
+ if (type != null)
+ {
+ if (type.equalsIgnoreCase("PDB"))
+ {
+ filesmatched.add(new Object[]
+ { file, protocol, mtch });
+ continue;
+ }
+ }
+ }
+ // File wasn't named like one of the sequences or wasn't a PDB file.
+ filesnotmatched.add(file);
+ }
+ }
+ int assocfiles = 0;
+ if (filesmatched.size() > 0)
+ {
+ if (Cache.getDefault("AUTOASSOCIATE_PDBANDSEQS", false)
+ || JOptionPane
+ .showConfirmDialog(
+ this,
+ "Do you want to automatically associate the "
+ + filesmatched.size()
+ + " PDB files with sequences in the alignment that have the same name ?",
+ "Automatically Associate PDB files by name",
+ JOptionPane.YES_NO_OPTION) == JOptionPane.YES_OPTION)
+
+ {
+ for (Object[] fm : filesmatched)
+ {
+ // try and associate
+ // TODO: may want to set a standard ID naming formalism for
+ // associating PDB files which have no IDs.
+ for (SequenceI toassoc: (SequenceI[])fm[2]) {
+ PDBEntry pe = new AssociatePdbFileWithSeq()
+ .associatePdbWithSeq((String) fm[0], (String) fm[1],
+ toassoc, false);
+ if (pe != null)
+ {
+ System.err
+ .println("Associated file : " + ((String) fm[0])
+ + " with "
+ + toassoc.getDisplayId(true));
+ assocfiles++;
+ }
+ }
+ alignPanel.paintAlignment(true);
+ }
+ }
+ }
+ if (filesnotmatched.size() > 0)
+ {
+ if (assocfiles > 0
+ && (Cache.getDefault(
+ "AUTOASSOCIATE_PDBANDSEQS_IGNOREOTHERS", false) || JOptionPane
+ .showConfirmDialog(
+ this,
+ "<html>Do you want to <em>ignore</em> the "
+ + filesnotmatched.size()
+ + " files whose names did not match any sequence IDs ?</html>",
+ "Ignore unmatched dropped files ?",
+ JOptionPane.YES_NO_OPTION) == JOptionPane.YES_OPTION))
+ {
+ return;
+ }
+ for (String fn : filesnotmatched)
+ {
+ loadJalviewDataFile(fn, null, null, null);
+ }
+
}
} catch (Exception ex)
{
}
/**
- * Attempt to load a "dropped" file or URL string: First by testing whether it's and
- * Annotation file, then a JNet file, and finally a features file. If all are
- * false then the user may have dropped an alignment file onto this
+ * Attempt to load a "dropped" file or URL string: First by testing whether
+ * it's and Annotation file, then a JNet file, and finally a features file. If
+ * all are false then the user may have dropped an alignment file onto this
* AlignFrame.
*
* @param file
* either a filename or a URL string.
*/
- public void loadJalviewDataFile(String file)
+ public void loadJalviewDataFile(String file, String protocol,
+ String format, SequenceI assocSeq)
{
try
{
- String protocol = jalview.io.FormatAdapter.FILE;
- String f=file.toLowerCase();
- if (f.indexOf("http:") == 0 || f.indexOf("https:")==0 || f.indexOf("file:") == 0)
+ if (protocol == null)
{
- protocol = jalview.io.FormatAdapter.URL;
+ protocol = jalview.io.FormatAdapter.checkProtocol(file);
}
-
- boolean isAnnotation = new AnnotationFile().readAnnotationFile(
- viewport.alignment, file, protocol);
+ // if the file isn't identified, or not positively identified as some
+ // other filetype (PFAM is default unidentified alignment file type) then
+ // try to parse as annotation.
+ boolean isAnnotation = (format == null || format
+ .equalsIgnoreCase("PFAM")) ? new AnnotationFile()
+ .readAnnotationFile(viewport.alignment, file, protocol)
+ : false;
if (!isAnnotation)
{
// try to see if its a JNet 'concise' style annotation file *before* we
// try to parse it as a features file
- String format = new IdentifyFile().Identify(file, protocol);
+ if (format == null)
+ {
+ format = new IdentifyFile().Identify(file, protocol);
+ }
if (format.equalsIgnoreCase("JnetFile"))
{
jalview.io.JPredFile predictions = new jalview.io.JPredFile(file,
protocol);
- new JnetAnnotationMaker().add_annotation(predictions, viewport
- .getAlignment(), 0, false);
+ new JnetAnnotationMaker().add_annotation(predictions,
+ viewport.getAlignment(), 0, false);
isAnnotation = true;
}
else
{
+ /*
+ * if (format.equalsIgnoreCase("PDB")) {
+ *
+ * String pdbfn = ""; // try to match up filename with sequence id try
+ * { if (protocol == jalview.io.FormatAdapter.FILE) { File fl = new
+ * File(file); pdbfn = fl.getName(); } else if (protocol ==
+ * jalview.io.FormatAdapter.URL) { URL url = new URL(file); pdbfn =
+ * url.getFile(); } } catch (Exception e) { } ; if (assocSeq == null)
+ * { SequenceIdMatcher idm = new SequenceIdMatcher(viewport
+ * .getAlignment().getSequencesArray()); if (pdbfn.length() > 0) { //
+ * attempt to find a match in the alignment SequenceI mtch =
+ * idm.findIdMatch(pdbfn); int l = 0, c = pdbfn.indexOf("."); while
+ * (mtch == null && c != -1) { while ((c = pdbfn.indexOf(".", l)) > l)
+ * { l = c; } if (l > -1) { pdbfn = pdbfn.substring(0, l); } mtch =
+ * idm.findIdMatch(pdbfn); } if (mtch != null) { // try and associate
+ * // prompt ? PDBEntry pe = new AssociatePdbFileWithSeq()
+ * .associatePdbWithSeq(file, protocol, mtch, true); if (pe != null) {
+ * System.err.println("Associated file : " + file + " with " +
+ * mtch.getDisplayId(true)); alignPanel.paintAlignment(true); } } //
+ * TODO: maybe need to load as normal otherwise return; } }
+ */
// try to parse it as a features file
boolean isGroupsFile = parseFeaturesFile(file, protocol);
// if it wasn't a features file then we just treat it as a general
// TODO We probably want to store a sequence database checklist in
// preferences and have checkboxes.. rather than individual sources selected
// here
- JMenu rfetch = new JMenu("Fetch DB References");
- rfetch
- .setToolTipText("Retrieve and parse sequence database records for the alignment or the currently selected sequences");
+ final JMenu rfetch = new JMenu("Fetch DB References");
+ rfetch.setToolTipText("Retrieve and parse sequence database records for the alignment or the currently selected sequences");
webService.add(rfetch);
JMenuItem fetchr = new JMenuItem("Standard Databases");
- fetchr
- .setToolTipText("Fetch from EMBL/EMBLCDS or Uniprot/PDB and any selected DAS sources");
+ fetchr.setToolTipText("Fetch from EMBL/EMBLCDS or Uniprot/PDB and any selected DAS sources");
fetchr.addActionListener(new ActionListener()
{
});
rfetch.add(fetchr);
- JMenu dfetch = new JMenu();
- rfetch.add(dfetch);
- jalview.ws.SequenceFetcher sf = SequenceFetcher
- .getSequenceFetcherSingleton(this);
- String[] otherdb = sf.getOrderedSupportedSources();
- // sf.getDbInstances(jalview.ws.dbsources.DasSequenceSource.class);
- // jalview.util.QuickSort.sort(otherdb, otherdb);
- int comp = 0, mcomp = 15;
- String mname = null;
- if (otherdb != null && otherdb.length > 0)
- {
- for (int i = 0; i < otherdb.length; i++)
+ final AlignFrame me = this;
+ new Thread(new Runnable()
+ {
+ public void run()
{
- String dbname = sf.getSourceProxy(otherdb[i]).getDbName();
- if (mname == null)
+ final jalview.ws.SequenceFetcher sf = SequenceFetcher
+ .getSequenceFetcherSingleton(me);
+ final String[] otherdb = sf.getOrderedSupportedSources();
+ // sf.getDbInstances(jalview.ws.dbsources.DasSequenceSource.class);
+ // jalview.util.QuickSort.sort(otherdb, otherdb);
+ javax.swing.SwingUtilities.invokeLater(new Runnable()
{
- mname = "from '" + dbname + "'";
- }
- fetchr = new JMenuItem(otherdb[i]);
- final String[] dassource = new String[]
- { otherdb[i] };
- fetchr.addActionListener(new ActionListener()
- {
-
- public void actionPerformed(ActionEvent e)
+ public void run()
{
- new Thread(new Runnable()
- {
- public void run()
+ JMenu dfetch = new JMenu();
+ JMenuItem fetchr;
+ rfetch.add(dfetch);
+ int comp = 0, mcomp = 15;
+ String mname = null;
+ if (otherdb != null && otherdb.length > 0)
+ {
+ for (int i = 0; i < otherdb.length; i++)
{
- new jalview.ws.DBRefFetcher(alignPanel.av
- .getSequenceSelection(), alignPanel.alignFrame,
- dassource).fetchDBRefs(false);
+ String dbname = sf.getSourceProxy(otherdb[i]).getDbName();
+ if (mname == null)
+ {
+ mname = "from '" + dbname + "'";
+ }
+ fetchr = new JMenuItem(otherdb[i]);
+ final String[] dassource = new String[]
+ { otherdb[i] };
+ fetchr.addActionListener(new ActionListener()
+ {
+
+ public void actionPerformed(ActionEvent e)
+ {
+ new Thread(new Runnable()
+ {
+
+ public void run()
+ {
+ new jalview.ws.DBRefFetcher(alignPanel.av
+ .getSequenceSelection(),
+ alignPanel.alignFrame, dassource)
+ .fetchDBRefs(false);
+ }
+ }).start();
+ }
+
+ });
+ fetchr.setToolTipText("Retrieve from " + dbname);
+ dfetch.add(fetchr);
+ if (comp++ == mcomp || i == (otherdb.length - 1))
+ {
+ dfetch.setText(mname + " to '" + dbname + "'");
+ rfetch.add(dfetch);
+ dfetch = new JMenu();
+ mname = null;
+ comp = 0;
+ }
}
- }).start();
+ }
}
-
});
- fetchr.setToolTipText("Retrieve from " + dbname);
- dfetch.add(fetchr);
- if (comp++ == mcomp || i == (otherdb.length - 1))
- {
- dfetch.setText(mname + " to '" + dbname + "'");
- rfetch.add(dfetch);
- dfetch = new JMenu();
- mname = null;
- comp = 0;
- }
}
- }
+ }).start();
+
}
/**
*/
protected void showUnconservedMenuItem_actionPerformed(ActionEvent e)
{
- viewport.setShowUnconserved(showUnconservedMenuItem.getState());
+ viewport.setShowUnconserved(showNonconservedMenuItem.getState());
alignPanel.paintAlignment(true);
}
- /* (non-Javadoc)
- * @see jalview.jbgui.GAlignFrame#showGroupConsensus_actionPerformed(java.awt.event.ActionEvent)
+ /*
+ * (non-Javadoc)
+ *
+ * @see
+ * jalview.jbgui.GAlignFrame#showGroupConsensus_actionPerformed(java.awt.event
+ * .ActionEvent)
*/
protected void showGroupConsensus_actionPerformed(ActionEvent e)
{
viewport.setShowGroupConsensus(showGroupConsensus.getState());
- alignPanel.updateAnnotation();
-
+ alignPanel.updateAnnotation(applyAutoAnnotationSettings.getState());
+
}
- /* (non-Javadoc)
- * @see jalview.jbgui.GAlignFrame#showGroupConservation_actionPerformed(java.awt.event.ActionEvent)
+ /*
+ * (non-Javadoc)
+ *
+ * @see
+ * jalview.jbgui.GAlignFrame#showGroupConservation_actionPerformed(java.awt
+ * .event.ActionEvent)
*/
protected void showGroupConservation_actionPerformed(ActionEvent e)
{
viewport.setShowGroupConservation(showGroupConservation.getState());
- alignPanel.updateAnnotation();
+ alignPanel.updateAnnotation(applyAutoAnnotationSettings.getState());
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see
+ * jalview.jbgui.GAlignFrame#showConsensusHistogram_actionPerformed(java.awt
+ * .event.ActionEvent)
+ */
+ protected void showConsensusHistogram_actionPerformed(ActionEvent e)
+ {
+ viewport.setShowConsensusHistogram(showConsensusHistogram.getState());
+ alignPanel.updateAnnotation(applyAutoAnnotationSettings.getState());
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see
+ * jalview.jbgui.GAlignFrame#showConsensusProfile_actionPerformed(java.awt
+ * .event.ActionEvent)
+ */
+ protected void showSequenceLogo_actionPerformed(ActionEvent e)
+ {
+ viewport.setShowSequenceLogo(showSequenceLogo.getState());
+ alignPanel.updateAnnotation(applyAutoAnnotationSettings.getState());
+ }
+
+ protected void applyAutoAnnotationSettings_actionPerformed(ActionEvent e)
+ {
+ alignPanel.updateAnnotation(applyAutoAnnotationSettings.getState());
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see
+ * jalview.jbgui.GAlignFrame#makeGrpsFromSelection_actionPerformed(java.awt
+ * .event.ActionEvent)
+ */
+ protected void makeGrpsFromSelection_actionPerformed(ActionEvent e)
+ {
+ if (viewport.getSelectionGroup() != null)
+ {
+ SequenceGroup[] gps = jalview.analysis.Grouping.makeGroupsFrom(
+ viewport.getSequenceSelection(),
+ viewport.getAlignmentView(true).getSequenceStrings(
+ viewport.getGapCharacter()),
+ viewport.alignment.getGroups());
+ viewport.alignment.deleteAllGroups();
+ viewport.sequenceColours = null;
+ viewport.setSelectionGroup(null);
+ // set view properties for each group
+ for (int g = 0; g < gps.length; g++)
+ {
+ gps[g].setShowNonconserved(viewport.getShowUnconserved());
+ gps[g].setshowSequenceLogo(viewport.isShowSequenceLogo());
+ viewport.alignment.addGroup(gps[g]);
+ Color col = new Color((int) (Math.random() * 255),
+ (int) (Math.random() * 255), (int) (Math.random() * 255));
+ col = col.brighter();
+ for (Enumeration sq = gps[g].getSequences(null).elements(); sq
+ .hasMoreElements(); viewport.setSequenceColour(
+ (SequenceI) sq.nextElement(), col))
+ ;
+ }
+ PaintRefresher.Refresh(this, viewport.getSequenceSetId());
+ alignPanel.updateAnnotation();
+ alignPanel.paintAlignment(true);
+ }
+ }
+
+ /**
+ * make the given alignmentPanel the currently selected tab
+ *
+ * @param alignmentPanel
+ */
+ public void setDisplayedView(AlignmentPanel alignmentPanel)
+ {
+ if (!viewport.getSequenceSetId().equals(
+ alignmentPanel.av.getSequenceSetId()))
+ {
+ throw new Error(
+ "Implementation error: cannot show a view from another alignment in an AlignFrame.");
+ }
+ if (tabbedPane != null
+ & alignPanels.indexOf(alignmentPanel) != tabbedPane.getSelectedIndex())
+ {
+ tabbedPane.setSelectedIndex(alignPanels.indexOf(alignmentPanel));
+ }
}
}