import java.awt.event.*;
import java.awt.print.*;
import javax.swing.*;
+import javax.swing.event.MenuEvent;
import jalview.analysis.*;
import jalview.commands.*;
Vector alignPanels = new Vector();
+
/** DOCUMENT ME!! */
String currentFileFormat = null;
String fileName = null;
+
/**
* Creates a new AlignFrame object.
*
this(al, null, width, height);
}
+
/**
* new alignment window with hidden columns
* @param al AlignmentI
alignPanel = new AlignmentPanel(this, viewport);
- if (al.getDataset() == null)
+ if(al.getDataset()==null)
{
al.setDataset(null);
}
void init()
{
- this.setDropTarget(new java.awt.dnd.DropTarget(this, this));
-
if (viewport.conservation == null)
{
BLOSUM62Colour.setEnabled(false);
conservationMenuItem.setEnabled(false);
modifyConservation.setEnabled(false);
- // PIDColour.setEnabled(false);
- // abovePIDThreshold.setEnabled(false);
- // modifyPID.setEnabled(false);
+ // PIDColour.setEnabled(false);
+ // abovePIDThreshold.setEnabled(false);
+ // modifyPID.setEnabled(false);
}
String sortby = jalview.bin.Cache.getDefault("SORT_ALIGNMENT", "No sort");
}
if (Desktop.desktop != null)
- {
- addServiceListeners();
- setGUINucleotide(viewport.alignment.isNucleotide());
- }
-
- setMenusFromViewport(viewport);
+ {
+ this.setDropTarget(new java.awt.dnd.DropTarget(this, this));
+ addServiceListeners();
+ setGUINucleotide(viewport.alignment.isNucleotide());
+ }
- if (viewport.wrapAlignment)
- {
- wrapMenuItem_actionPerformed(null);
- }
+ setMenusFromViewport(viewport);
+ buildSortByAnnotationScoresMenu();
+ if (viewport.wrapAlignment)
+ {
+ wrapMenuItem_actionPerformed(null);
+ }
if (jalview.bin.Cache.getDefault("SHOW_OVERVIEW",false))
{
this.overviewMenuItem_actionPerformed(null);
}
- addKeyListener();
+ addKeyListener();
}
public void setFileName(String file, String format)
{
- fileName = file;
- currentFileFormat = format;
- reload.setEnabled(true);
+ fileName = file;
+ currentFileFormat = format;
+ reload.setEnabled(true);
}
void addKeyListener()
{
- addKeyListener(new KeyAdapter()
- {
- public void keyPressed(KeyEvent evt)
+ addKeyListener(new KeyAdapter()
{
- if (viewport.cursorMode
- && evt.getKeyCode() >= KeyEvent.VK_0
- && evt.getKeyCode() <= KeyEvent.VK_9)
- {
- alignPanel.seqPanel.numberPressed(evt.getKeyChar());
- }
-
- switch (evt.getKeyCode())
+ public void keyPressed(KeyEvent evt)
{
+ if (viewport.cursorMode &&
+ ( (evt.getKeyCode() >= KeyEvent.VK_0 &&
+ evt.getKeyCode() <= KeyEvent.VK_9)
+ ||
+ (evt.getKeyCode() >= KeyEvent.VK_NUMPAD0 &&
+ evt.getKeyCode() <= KeyEvent.VK_NUMPAD9)
+ )
+ && Character.isDigit(evt.getKeyChar()))
+ alignPanel.seqPanel.numberPressed(evt.getKeyChar());
+
+ switch (evt.getKeyCode())
+ {
- case 27: // escape key
- deselectAllSequenceMenuItem_actionPerformed(null);
+ case 27: // escape key
+ deselectAllSequenceMenuItem_actionPerformed(null);
- break;
+ break;
- case KeyEvent.VK_DOWN:
+ case KeyEvent.VK_DOWN:
if (evt.isAltDown() || !viewport.cursorMode)
moveSelectedSequences(false);
- if(viewport.cursorMode)
- alignPanel.seqPanel.moveCursor(0, 1);
- break;
+ if (viewport.cursorMode)
+ alignPanel.seqPanel.moveCursor(0, 1);
+ break;
- case KeyEvent.VK_UP:
+ case KeyEvent.VK_UP:
if (evt.isAltDown() || !viewport.cursorMode)
moveSelectedSequences(true);
- if(viewport.cursorMode)
- alignPanel.seqPanel.moveCursor(0, -1);
+ if (viewport.cursorMode)
+ alignPanel.seqPanel.moveCursor(0, -1);
- break;
+ break;
- case KeyEvent.VK_LEFT:
+ case KeyEvent.VK_LEFT:
if (evt.isAltDown() || !viewport.cursorMode)
slideSequences(false,
alignPanel.seqPanel.getKeyboardNo1());
else
- alignPanel.seqPanel.moveCursor( -1, 0);
+ alignPanel.seqPanel.moveCursor( -1, 0);
- break;
+ break;
- case KeyEvent.VK_RIGHT:
+ case KeyEvent.VK_RIGHT:
if (evt.isAltDown() || !viewport.cursorMode)
slideSequences(true,
alignPanel.seqPanel.getKeyboardNo1());
else
- alignPanel.seqPanel.moveCursor( 1, 0);
- break;
+ alignPanel.seqPanel.moveCursor(1, 0);
+ break;
- case KeyEvent.VK_SPACE:
- if (viewport.cursorMode)
- {
- alignPanel.seqPanel.insertGapAtCursor(evt.isControlDown()
- || evt.isShiftDown()
- || evt.isAltDown());
- }
- break;
+ case KeyEvent.VK_SPACE:
+ if (viewport.cursorMode)
+ {
+ alignPanel.seqPanel.insertGapAtCursor(evt.isControlDown()
+ || evt.isShiftDown()
+ || evt.isAltDown());
+ }
+ break;
- case KeyEvent.VK_DELETE:
- case KeyEvent.VK_BACK_SPACE:
- if (!viewport.cursorMode)
- {
- cut_actionPerformed(null);
- }
- else
+ case KeyEvent.VK_DELETE:
+ case KeyEvent.VK_BACK_SPACE:
+ if (!viewport.cursorMode)
+ {
+ cut_actionPerformed(null);
+ }
+ else
{
- alignPanel.seqPanel.deleteGapAtCursor(evt.isControlDown()
- || evt.isShiftDown()
- || evt.isAltDown());
+ alignPanel.seqPanel.deleteGapAtCursor(evt.isControlDown()
+ || evt.isShiftDown()
+ || evt.isAltDown());
}
- break;
+ break;
- case KeyEvent.VK_S:
- if (viewport.cursorMode)
- {
- alignPanel.seqPanel.setCursorRow();
- }
- break;
- case KeyEvent.VK_C:
- if (viewport.cursorMode && !evt.isControlDown())
- {
- alignPanel.seqPanel.setCursorColumn();
- }
- break;
- case KeyEvent.VK_P:
- if (viewport.cursorMode)
- {
- alignPanel.seqPanel.setCursorPosition();
- }
- break;
+ case KeyEvent.VK_S:
+ if (viewport.cursorMode)
+ {
+ alignPanel.seqPanel.setCursorRow();
+ }
+ break;
+ case KeyEvent.VK_C:
+ if (viewport.cursorMode && !evt.isControlDown())
+ {
+ alignPanel.seqPanel.setCursorColumn();
+ }
+ break;
+ case KeyEvent.VK_P:
+ if (viewport.cursorMode)
+ {
+ alignPanel.seqPanel.setCursorPosition();
+ }
+ break;
- case KeyEvent.VK_ENTER:
- case KeyEvent.VK_COMMA:
- if (viewport.cursorMode)
- {
- alignPanel.seqPanel.setCursorRowAndColumn();
- }
- break;
+ case KeyEvent.VK_ENTER:
+ case KeyEvent.VK_COMMA:
+ if (viewport.cursorMode)
+ {
+ alignPanel.seqPanel.setCursorRowAndColumn();
+ }
+ break;
- case KeyEvent.VK_Q:
- if (viewport.cursorMode)
- {
- alignPanel.seqPanel.setSelectionAreaAtCursor(true);
- }
- break;
- case KeyEvent.VK_M:
- if (viewport.cursorMode)
- {
- alignPanel.seqPanel.setSelectionAreaAtCursor(false);
- }
- break;
+ case KeyEvent.VK_Q:
+ if (viewport.cursorMode)
+ {
+ alignPanel.seqPanel.setSelectionAreaAtCursor(true);
+ }
+ break;
+ case KeyEvent.VK_M:
+ if (viewport.cursorMode)
+ {
+ alignPanel.seqPanel.setSelectionAreaAtCursor(false);
+ }
+ break;
- case KeyEvent.VK_F2:
- viewport.cursorMode = !viewport.cursorMode;
- statusBar.setText("Keyboard editing mode is " +
- (viewport.cursorMode ? "on" : "off"));
- if (viewport.cursorMode)
- {
- alignPanel.seqPanel.seqCanvas.cursorX = viewport.startRes;
- alignPanel.seqPanel.seqCanvas.cursorY = viewport.startSeq;
- }
- alignPanel.seqPanel.seqCanvas.repaint();
- break;
+ case KeyEvent.VK_F2:
+ viewport.cursorMode = !viewport.cursorMode;
+ statusBar.setText("Keyboard editing mode is " +
+ (viewport.cursorMode ? "on" : "off"));
+ if (viewport.cursorMode)
+ {
+ alignPanel.seqPanel.seqCanvas.cursorX = viewport.startRes;
+ alignPanel.seqPanel.seqCanvas.cursorY = viewport.startSeq;
+ }
+ alignPanel.seqPanel.seqCanvas.repaint();
+ break;
- case KeyEvent.VK_F1:
- try
- {
- ClassLoader cl = jalview.gui.Desktop.class.getClassLoader();
- java.net.URL url = javax.help.HelpSet.findHelpSet(cl, "help/help");
- javax.help.HelpSet hs = new javax.help.HelpSet(cl, url);
+ case KeyEvent.VK_F1:
+ try
+ {
+ ClassLoader cl = jalview.gui.Desktop.class.getClassLoader();
+ java.net.URL url = javax.help.HelpSet.findHelpSet(cl, "help/help");
+ javax.help.HelpSet hs = new javax.help.HelpSet(cl, url);
- javax.help.HelpBroker hb = hs.createHelpBroker();
- hb.setCurrentID("home");
- hb.setDisplayed(true);
- }
- catch (Exception ex)
+ javax.help.HelpBroker hb = hs.createHelpBroker();
+ hb.setCurrentID("home");
+ hb.setDisplayed(true);
+ }
+ catch (Exception ex)
+ {
+ ex.printStackTrace();
+ }
+ break
+ ;
+ case KeyEvent.VK_H:
{
- ex.printStackTrace();
- }
- break
- ;
- case KeyEvent.VK_H:
- {
- boolean toggleSeqs = !evt.isControlDown();
- boolean toggleCols = !evt.isShiftDown();
+ boolean toggleSeqs = !evt.isControlDown();
+ boolean toggleCols = !evt.isShiftDown();
- boolean hide = false;
+ boolean hide = false;
- SequenceGroup sg = viewport.getSelectionGroup();
- if (toggleSeqs)
- {
- if (sg != null && sg.getSize() != viewport.alignment.getHeight())
+ SequenceGroup sg = viewport.getSelectionGroup();
+ if (toggleSeqs)
{
- hideSelSequences_actionPerformed(null);
- hide = true;
- }
+ if (sg != null && sg.getSize() != viewport.alignment.getHeight())
+ {
+ hideSelSequences_actionPerformed(null);
+ hide = true;
+ }
else if (! (toggleCols &&
viewport.colSel.getSelected().size() > 0))
{
- showAllSeqs_actionPerformed(null);
+ showAllSeqs_actionPerformed(null);
}
}
- if (toggleCols)
- {
- if (viewport.colSel.getSelected().size() > 0)
+ if (toggleCols)
{
- hideSelColumns_actionPerformed(null);
- if (!toggleSeqs)
+ if (viewport.colSel.getSelected().size() > 0)
+ {
+ hideSelColumns_actionPerformed(null);
+ if (!toggleSeqs)
{
- viewport.selectionGroup = sg;
+ viewport.selectionGroup = sg;
}
}
- else if (!hide)
+ else if (!hide)
{
- showAllColumns_actionPerformed(null);
+ showAllColumns_actionPerformed(null);
}
}
- break;
- }
- case KeyEvent.VK_PAGE_UP:
- if (viewport.wrapAlignment)
+ break;
+ }
+ case KeyEvent.VK_PAGE_UP:
+ if (viewport.wrapAlignment)
{
- alignPanel.scrollUp(true);
+ alignPanel.scrollUp(true);
}
- else
+ else
{
- alignPanel.setScrollValues(viewport.startRes,
- viewport.startSeq
- - viewport.endSeq + viewport.startSeq);
+ alignPanel.setScrollValues(viewport.startRes,
+ viewport.startSeq
+ - viewport.endSeq + viewport.startSeq);
}
- break;
- case KeyEvent.VK_PAGE_DOWN:
- if (viewport.wrapAlignment)
+ break;
+ case KeyEvent.VK_PAGE_DOWN:
+ if (viewport.wrapAlignment)
{
- alignPanel.scrollUp(false);
+ alignPanel.scrollUp(false);
}
- else
+ else
{
- alignPanel.setScrollValues(viewport.startRes,
- viewport.startSeq
- + viewport.endSeq - viewport.startSeq);
+ alignPanel.setScrollValues(viewport.startRes,
+ viewport.startSeq
+ + viewport.endSeq - viewport.startSeq);
}
- break;
+ break;
+ }
}
- }
public void keyReleased(KeyEvent evt)
{
break;
}
}
- });
+ });
}
+
public void addAlignmentPanel(final AlignmentPanel ap,
boolean newPanel)
{
int aSize = alignPanels.size();
- tabbedPane.setVisible(aSize > 1 || ap.av.viewName != null);
+ tabbedPane.setVisible(aSize>1 || ap.av.viewName!=null);
- if (aSize == 1 && ap.av.viewName == null)
+ if (aSize == 1 && ap.av.viewName==null)
{
this.getContentPane().add(ap, BorderLayout.CENTER);
}
ap.setVisible(false);
}
- if (newPanel)
+ if(newPanel)
{
if (ap.av.padGaps)
{
gatherViews.setEnabled(true);
tabbedPane.setVisible(true);
AlignmentPanel first = (AlignmentPanel) alignPanels.firstElement();
- tabbedPane.addTab(first.av.viewName, first);
+ tabbedPane.addTab(first.av.viewName,first);
this.getContentPane().add(tabbedPane, BorderLayout.CENTER);
}
+
public AlignViewport getViewport()
{
return viewport;
public void setGUINucleotide(boolean nucleotide)
{
- showTranslation.setVisible(nucleotide);
- conservationMenuItem.setEnabled(!nucleotide);
- modifyConservation.setEnabled(!nucleotide);
+ showTranslation.setVisible( nucleotide );
+ conservationMenuItem.setEnabled( !nucleotide );
+ modifyConservation.setEnabled( !nucleotide );
//Remember AlignFrame always starts as protein
- if (!nucleotide)
+ if(!nucleotide)
{
- calculateMenu.remove(calculateMenu.getItemCount() - 2);
+ calculateMenu.remove(calculateMenu.getItemCount()-2);
}
}
updateEditMenuBar();
}
+
Hashtable progressBars;
public void setProgressBar(String message, long id)
{
- if (progressBars == null)
+ if(progressBars == null)
{
progressBars = new Hashtable();
}
JPanel progressPanel;
GridLayout layout = (GridLayout) statusPanel.getLayout();
- if (progressBars.get(new Long(id)) != null)
- {
- progressPanel = (JPanel) progressBars.get(new Long(id));
- statusPanel.remove(progressPanel);
- progressBars.remove(progressPanel);
- progressPanel = null;
- if (message != null)
+ if(progressBars.get( new Long(id) )!=null)
+ {
+ progressPanel = (JPanel)progressBars.get( new Long(id) );
+ statusPanel.remove(progressPanel);
+ progressBars.remove( progressPanel );
+ progressPanel = null;
+ if(message!=null)
{
- statusBar.setText(message);
+ statusBar.setText(message);
}
- layout.setRows(layout.getRows() - 1);
- }
+ layout.setRows(layout.getRows() - 1);
+ }
else
{
progressPanel = new JPanel(new BorderLayout(10, 5));
validate();
}
+
+
+
/*
Added so Castor Mapping file can obtain Jalview Version
- */
+ */
public String getVersion()
{
- return jalview.bin.Cache.getProperty("VERSION");
+ return jalview.bin.Cache.getProperty("VERSION");
}
public FeatureRenderer getFeatureRenderer()
return alignPanel.seqPanel.seqCanvas.getFeatureRenderer();
}
+
public void fetchSequence_actionPerformed(ActionEvent e)
{
new SequenceFetcher(this);
public void reload_actionPerformed(ActionEvent e)
{
- if (fileName != null)
+ if(fileName!=null)
{
- if (currentFileFormat.equals("Jalview"))
+ if(currentFileFormat.equals("Jalview"))
{
- JInternalFrame[] frames = Desktop.desktop.getAllFrames();
- for (int i = 0; i < frames.length; i++)
+ JInternalFrame [] frames = Desktop.desktop.getAllFrames();
+ for(int i=0; i<frames.length; i++)
{
if (frames[i] instanceof AlignFrame
&& frames[i] != this
{
frames[i].setSelected(true);
Desktop.instance.closeAssociatedWindows();
- }
+ }
catch (java.beans.PropertyVetoException ex)
{}
}
}
}
+
public void addFromText_actionPerformed(ActionEvent e)
{
Desktop.instance.inputTextboxMenuItem_actionPerformed(viewport);
Desktop.instance.inputURLMenuItem_actionPerformed(viewport);
}
+
public void save_actionPerformed(ActionEvent e)
{
- if (fileName == null
- || currentFileFormat == null
- || fileName.startsWith("http")
+ if(fileName==null
+ || currentFileFormat==null
+ || fileName.startsWith("http")
)
{
saveAs_actionPerformed(null);
else
{
saveAlignment(fileName, currentFileFormat);
- }
+ }
}
/**
public void saveAs_actionPerformed(ActionEvent e)
{
JalviewFileChooser chooser = new JalviewFileChooser(jalview.bin.Cache.
- getProperty("LAST_DIRECTORY"),
+ getProperty( "LAST_DIRECTORY"),
new String[]
- {"fa, fasta, fastq", "aln", "pfam", "msf", "pir", "blc", "jar"},
+ { "fa, fasta, fastq", "aln", "pfam", "msf", "pir", "blc","jar" },
new String[]
- {"Fasta", "Clustal", "PFAM", "MSF", "PIR", "BLC", "Jalview"},
+ { "Fasta", "Clustal", "PFAM", "MSF", "PIR", "BLC", "Jalview" },
currentFileFormat,
false);
+
chooser.setFileView(new JalviewFileView());
chooser.setDialogTitle("Save Alignment to file");
chooser.setToolTipText("Save");
if (value == JalviewFileChooser.APPROVE_OPTION)
{
- currentFileFormat = chooser.getSelectedFormat();
- if (currentFileFormat == null)
- {
- JOptionPane.showInternalMessageDialog(Desktop.desktop,
- "You must select a file format before saving!",
- "File format not specified",
- JOptionPane.WARNING_MESSAGE);
- value = chooser.showSaveDialog(this);
- return;
- }
+ currentFileFormat = chooser.getSelectedFormat();
+ if (currentFileFormat == null)
+ {
+ JOptionPane.showInternalMessageDialog(Desktop.desktop,
+ "You must select a file format before saving!",
+ "File format not specified",
+ JOptionPane.WARNING_MESSAGE);
+ value = chooser.showSaveDialog(this);
+ return;
+ }
- fileName = chooser.getSelectedFile().getPath();
+ fileName = chooser.getSelectedFile().getPath();
jalview.bin.Cache.setProperty("DEFAULT_FILE_FORMAT",
currentFileFormat);
success = new Jalview2XML().SaveAlignment(this, file, shortName);
statusBar.setText("Successfully saved to file: "
- + fileName + " in "
- + format + " format.");
+ +fileName+" in "
+ +format +" format.");
}
else
if (reply == JOptionPane.YES_OPTION)
{
omitHidden = viewport.getViewAsString(false);
- }
+ }
}
String output = new FormatAdapter().formatSequences(
*/
protected void outputText_actionPerformed(ActionEvent e)
{
- String[] omitHidden = null;
+ String [] omitHidden = null;
- if (viewport.hasHiddenColumns)
+ if(viewport.hasHiddenColumns)
{
int reply = JOptionPane.showInternalConfirmDialog(Desktop.desktop,
"The Alignment contains hidden columns."
- + "\nDo you want to output only the visible alignment?",
- "Save / Omit Hidden Columns",
- JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE);
+ +"\nDo you want to output only the visible alignment?",
+ "Save / Omit Hidden Columns",
+ JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE);
- if (reply == JOptionPane.YES_OPTION)
+ if(reply==JOptionPane.YES_OPTION)
{
omitHidden = viewport.getViewAsString(false);
}
"Alignment output - " + e.getActionCommand(), 600,
500);
+
cap.setText(new FormatAdapter().formatSequences(
e.getActionCommand(),
viewport.alignment.getSequencesArray(),
*/
protected void htmlMenuItem_actionPerformed(ActionEvent e)
{
- new HTMLOutput(viewport,
+ new HTMLOutput(alignPanel,
alignPanel.seqPanel.seqCanvas.getSequenceRenderer(),
- alignPanel.seqPanel.seqCanvas.getFeatureRenderer());
+ alignPanel.seqPanel.seqCanvas.getFeatureRenderer());
}
public void createImageMap(File file, String image)
alignPanel.makeEPS(f);
}
+
public void pageSetup_actionPerformed(ActionEvent e)
{
PrinterJob printJob = PrinterJob.getPrinterJob();
new AnnotationExporter().exportFeatures(alignPanel);
}
+
public void exportAnnotations_actionPerformed(ActionEvent e)
{
new AnnotationExporter().exportAnnotations(
- alignPanel,
+ alignPanel,
viewport.showAnnotation ? viewport.alignment.getAlignmentAnnotation() : null,
- viewport.alignment.getGroups()
+ viewport.alignment.getGroups(),
+ ((Alignment)viewport.alignment).alignmentProperties
);
}
+
public void associatedData_actionPerformed(ActionEvent e)
{
// Pick the tree file
}
+
/**
* DOCUMENT ME!
*
*/
public void closeMenuItem_actionPerformed(boolean closeAllTabs)
{
- if (alignPanels != null && alignPanels.size() < 2)
+ if(alignPanels!=null && alignPanels.size()<2)
{
closeAllTabs = true;
}
try
{
- if (alignPanels != null)
+ if(alignPanels!=null)
{
if (closeAllTabs)
{
for (int i = 0; i < alignPanels.size(); i++)
{
AlignmentPanel ap = (AlignmentPanel) alignPanels.elementAt(i);
+ jalview.structure.StructureSelectionManager.getStructureSelectionManager()
+ .removeStructureViewerListener(ap.seqPanel, null);
PaintRefresher.RemoveComponent(ap.seqPanel.seqCanvas);
PaintRefresher.RemoveComponent(ap.idPanel.idCanvas);
PaintRefresher.RemoveComponent(ap);
+ ap.av.alignment = null;
}
}
else
PaintRefresher.RemoveComponent(alignPanel.seqPanel.seqCanvas);
PaintRefresher.RemoveComponent(alignPanel.idPanel.idCanvas);
PaintRefresher.RemoveComponent(alignPanel);
+ viewport.alignment = null;
alignPanel = null;
viewport = null;
tabbedPane.removeTabAt(index);
tabbedPane.validate();
- if (index == tabbedPane.getTabCount())
+ if(index==tabbedPane.getTabCount())
{
- index--;
+ index --;
}
this.tabSelectionChanged(index);
if (closeAllTabs)
{
this.setClosed(true);
- }
+ }
}
catch (Exception ex)
{
}
}
+
/**
* DOCUMENT ME!
*/
}
}
+
public void addHistoryItem(CommandI command)
{
- if (command.getSize() > 0)
+ if(command.getSize()>0)
{
viewport.historyList.push(command);
viewport.redoList.clear();
}
}
+
+
/**
* DOCUMENT ME!
*
*/
protected void undoMenuItem_actionPerformed(ActionEvent e)
{
- CommandI command = (CommandI) viewport.historyList.pop();
+ CommandI command = (CommandI)viewport.historyList.pop();
viewport.redoList.push(command);
command.undoCommand();
AlignViewport originalSource = getOriginatingSource(command);
updateEditMenuBar();
- if (originalSource != null)
+ if(originalSource!=null)
{
originalSource.hasHiddenColumns = viewport.colSel.getHiddenColumns() != null;
originalSource.firePropertyChange("alignment",
*/
protected void redoMenuItem_actionPerformed(ActionEvent e)
{
- if (viewport.redoList.size() < 1)
+ if(viewport.redoList.size()<1)
{
return;
}
AlignViewport originalSource = getOriginatingSource(command);
updateEditMenuBar();
- if (originalSource != null)
+ if(originalSource!=null)
{
originalSource.hasHiddenColumns = viewport.colSel.getHiddenColumns() != null;
originalSource.firePropertyChange("alignment",
{
AlignViewport originalSource = null;
//For sequence removal and addition, we need to fire
- //the property change event FROM the viewport where the
- //original alignment was altered
- AlignmentI al = null;
+ //the property change event FROM the viewport where the
+ //original alignment was altered
+ AlignmentI al=null;
if (command instanceof EditCommand)
{
EditCommand editCommand = (EditCommand) command;
}
+
+
synchronized void slideSequences(boolean right, int size)
{
- if(viewport.hasHiddenColumns)
- {
- JOptionPane.showInternalMessageDialog(Desktop.desktop,
- "Slide Sequences not available with hidden columns",
- "Slide Sequence not Available",
- JOptionPane.WARNING_MESSAGE);
- return;
- }
Vector sg = new Vector();
if(viewport.cursorMode)
{
{
return;
}
-
- SequenceI[] seqs = viewport.getSelectionAsNewSequence();
+ // TODO: preserve the ordering of displayed alignment annotation in any internal paste (particularly sequence associated annotation)
+ SequenceI [] seqs = viewport.getSelectionAsNewSequence();
String[] omitHidden = null;
if (viewport.hasHiddenColumns)
{
er.printStackTrace();
javax.swing.SwingUtilities.invokeLater(new Runnable()
- {
- public void run()
- {
- javax.swing.JOptionPane.showInternalMessageDialog(Desktop.desktop,
- "Out of memory copying region!!"
- +
- "\nSee help files for increasing Java Virtual Machine memory."
- , "Out of memory",
- javax.swing.JOptionPane.WARNING_MESSAGE);
- }
- });
+ {
+ public void run()
+ {
+ javax.swing.JOptionPane.showInternalMessageDialog(Desktop.desktop,
+ "Out of memory copying region!!"
+ +
+ "\nSee help files for increasing Java Virtual Machine memory."
+ , "Out of memory",
+ javax.swing.JOptionPane.WARNING_MESSAGE);
+ }
+ });
return;
}
Vector hiddenColumns = null;
- if (viewport.hasHiddenColumns)
+ if(viewport.hasHiddenColumns)
{
- hiddenColumns = new Vector();
+ hiddenColumns =new Vector();
int hiddenOffset = viewport.getSelectionGroup().getStartRes();
for (int i = 0; i < viewport.getColumnSelection().getHiddenColumns().size();
i++)
hiddenColumns.addElement(new int[]
{region[0] - hiddenOffset,
- region[1] - hiddenOffset});
+ region[1]-hiddenOffset});
}
}
seqs,
viewport.alignment.getDataset(),
hiddenColumns};
- statusBar.setText("Copied " + seqs.length + " sequences to clipboard.");
+ statusBar.setText("Copied "+seqs.length+" sequences to clipboard.");
}
/**
*/
void paste(boolean newAlignment)
{
+ boolean externalPaste=true;
try
{
Clipboard c = Toolkit.getDefaultToolkit().getSystemClipboard();
}
SequenceI[] sequences;
-
- if (Desktop.jalviewClipboard != null)
- {
- // The clipboard was filled from within Jalview, we must use the sequences
- // And dataset from the copied alignment
- sequences = (SequenceI[]) Desktop.jalviewClipboard[0];
- }
- else
- {
- sequences = new FormatAdapter().readFile(str, "Paste", format).
- getSequencesArray();
- }
-
+ boolean annotationAdded = false;
AlignmentI alignment = null;
- if (newAlignment)
- {
- alignment = new Alignment(sequences);
-
- if (Desktop.jalviewClipboard != null)
- {
- alignment.setDataset( (Alignment) Desktop.jalviewClipboard[1]);
- }
- else
- {
- alignment.setDataset(null);
- }
- }
- else
- {
- alignment = viewport.getAlignment();
-
- //!newAlignment
- SequenceI[] newseqs = new SequenceI[sequences.length];
- for (int i = 0; i < sequences.length; i++)
- {
- newseqs[i] = new Sequence(sequences[i].getName(),
- sequences[i].getSequence(),
- sequences[i].getStart(),
- sequences[i].getEnd());
+ if(Desktop.jalviewClipboard!=null)
+ {
+ // The clipboard was filled from within Jalview, we must use the sequences
+ // And dataset from the copied alignment
+ SequenceI[] newseq = (SequenceI[])Desktop.jalviewClipboard[0];
+ // be doubly sure that we create *new* sequence objects.
+ sequences = new SequenceI[newseq.length];
+ for (int i=0;i<newseq.length;i++) {
+ sequences[i] = new Sequence(newseq[i]);
+ }
+ alignment = new Alignment(sequences);
+ externalPaste = false;
+ }
+ else
+ {
+ // parse the clipboard as an alignment.
+ alignment = new FormatAdapter().readFile(str, "Paste", format);
+ sequences = alignment.getSequencesArray();
+ }
- alignment.addSequence(newseqs[i]);
- }
+ int alwidth=0;
- /*
- //ADD HISTORY ITEM
- */
- addHistoryItem(new EditCommand(
- "Add sequences",
- EditCommand.PASTE,
- newseqs,
- 0,
- alignment.getWidth(),
- alignment)
- );
+ if (newAlignment)
+ {
- viewport.setEndSeq(alignment.getHeight());
- alignment.getWidth();
- viewport.firePropertyChange("alignment", null, alignment.getSequences());
- }
+ if (Desktop.jalviewClipboard != null)
+ {
+ // dataset is inherited
+ alignment.setDataset( (Alignment) Desktop.jalviewClipboard[1]);
+ }
+ else
+ {
+ // new dataset is constructed
+ alignment.setDataset(null);
+ }
+ alwidth = alignment.getWidth()+1;
+ }
+ else
+ {
+ AlignmentI pastedal = alignment; // preserve pasted alignment object
+ // Add pasted sequences and dataset into existing alignment.
+ alignment = viewport.getAlignment();
+ alwidth = alignment.getWidth()+1;
+ // decide if we need to import sequences from an existing dataset
+ boolean importDs = Desktop.jalviewClipboard != null
+ && Desktop.jalviewClipboard[1] != alignment.getDataset();
+ // importDs==true instructs us to copy over new dataset sequences from
+ // an existing alignment
+ Vector newDs = (importDs) ? new Vector() : null; // used to create
+ // minimum dataset set
- // Add any annotations attached to sequences
- for (int i = 0; i < sequences.length; i++)
- {
- if (sequences[i].getAnnotation() != null)
+ for (int i = 0; i < sequences.length; i++)
{
- for (int a = 0; a < sequences[i].getAnnotation().length; a++)
+ if (importDs)
{
- AlignmentAnnotation newAnnot =
- new AlignmentAnnotation(
- sequences[i].getAnnotation()[a].label,
- sequences[i].getAnnotation()[a].description,
- sequences[i].getAnnotation()[a].annotations,
- sequences[i].getAnnotation()[a].graphMin,
- sequences[i].getAnnotation()[a].graphMax,
- sequences[i].getAnnotation()[a].graph);
-
- sequences[i].getAnnotation()[a] = newAnnot;
- newAnnot.sequenceMapping = sequences[i].getAnnotation()[a].
- sequenceMapping;
- newAnnot.sequenceRef = sequences[i];
- newAnnot.adjustForAlignment();
- alignment.addAnnotation(newAnnot);
- alignment.setAnnotationIndex(newAnnot, a);
+ newDs.addElement(null);
}
-
- alignPanel.annotationPanel.adjustPanelHeight();
- }
- }
-
- if (newAlignment)
- {
- AlignFrame af = new AlignFrame(alignment, DEFAULT_WIDTH, DEFAULT_HEIGHT);
- String newtitle = new String("Copied sequences");
-
- if (Desktop.jalviewClipboard != null && Desktop.jalviewClipboard[2] != null)
- {
- Vector hc = (Vector) Desktop.jalviewClipboard[2];
- for (int i = 0; i < hc.size(); i++)
+ SequenceI ds = sequences[i].getDatasetSequence(); // null for a simple
+ // paste
+ if (importDs && ds != null)
+ {
+ if (!newDs.contains(ds))
+ {
+ newDs.setElementAt(ds, i);
+ ds = new Sequence(ds);
+ // update with new dataset sequence
+ sequences[i].setDatasetSequence(ds);
+ }
+ else
+ {
+ ds = sequences[newDs.indexOf(ds)].getDatasetSequence();
+ }
+ }
+ else
{
- int[] region = (int[]) hc.elementAt(i);
- af.viewport.hideColumns(region[0], region[1]);
+ // copy and derive new dataset sequence
+ sequences[i] = sequences[i].deriveSequence();
+ alignment.getDataset().addSequence(sequences[i].getDatasetSequence());
+ // TODO: avoid creation of duplicate dataset sequences with a
+ // 'contains' method using SequenceI.equals()/SequenceI.contains()
}
+ alignment.addSequence(sequences[i]); // merges dataset
}
-
- //>>>This is a fix for the moment, until a better solution is found!!<<<
- af.alignPanel.seqPanel.seqCanvas.getFeatureRenderer().transferSettings(
- alignPanel.seqPanel.seqCanvas.getFeatureRenderer());
-
- if (title.startsWith("Copied sequences"))
+ if (newDs != null)
{
- newtitle = title;
+ newDs.clear(); // tidy up
}
- else
- {
- newtitle = newtitle.concat("- from " + title);
+ if (pastedal.getAlignmentAnnotation()!=null) {
+ // Add any annotation attached to alignment.
+ AlignmentAnnotation[] alann = pastedal.getAlignmentAnnotation();
+ for (int i=0; i<alann.length; i++)
+ {
+ annotationAdded=true;
+ if (alann[i].sequenceRef==null && !alann[i].autoCalculated) {
+ AlignmentAnnotation newann = new AlignmentAnnotation(alann[i]);
+ newann.padAnnotation(alwidth);
+ alignment.addAnnotation(newann);
+ }
+ }
}
+ }
+ if (!newAlignment) {
+ ///////
+ // ADD HISTORY ITEM
+ //
+ addHistoryItem(new EditCommand(
+ "Add sequences",
+ EditCommand.PASTE,
+ sequences,
+ 0,
+ alignment.getWidth(),
+ alignment)
+ );
+ }
+ // Add any annotations attached to sequences
+ for (int i = 0; i < sequences.length; i++)
+ {
+ if (sequences[i].getAnnotation() != null)
+ {
+ for (int a = 0; a < sequences[i].getAnnotation().length; a++)
+ {
+ annotationAdded=true;
+ sequences[i].getAnnotation()[a].adjustForAlignment();
+ sequences[i].getAnnotation()[a].padAnnotation(alwidth);
+ alignment.addAnnotation(sequences[i].getAnnotation()[a]); // annotation was duplicated earlier
+ alignment.setAnnotationIndex(sequences[i].getAnnotation()[a], a);
+ }
+
+
+ }
+ }
+ if (!newAlignment) {
+ // propagate alignment changed.
+ viewport.setEndSeq(alignment.getHeight());
+ if (annotationAdded)
+ {
+ alignPanel.annotationPanel.adjustPanelHeight();
+ buildSortByAnnotationScoresMenu();
+ }
+ viewport.firePropertyChange("alignment", null, alignment.getSequences());
+ } else {
+ AlignFrame af = new AlignFrame(alignment, DEFAULT_WIDTH, DEFAULT_HEIGHT);
+ String newtitle = new String("Copied sequences");
+
+ if(Desktop.jalviewClipboard!=null && Desktop.jalviewClipboard[2]!=null)
+ {
+ Vector hc = (Vector)Desktop.jalviewClipboard[2];
+ for(int i=0; i<hc.size(); i++)
+ {
+ int [] region = (int[]) hc.elementAt(i);
+ af.viewport.hideColumns(region[0], region[1]);
+ }
+ }
+
+
+ //>>>This is a fix for the moment, until a better solution is found!!<<<
+ af.alignPanel.seqPanel.seqCanvas.getFeatureRenderer().transferSettings(
+ alignPanel.seqPanel.seqCanvas.getFeatureRenderer());
+
+ // TODO: maintain provenance of an alignment, rather than just make the title a concatenation of operations.
+ if (!externalPaste) {
+ if (title.startsWith("Copied sequences"))
+ {
+ newtitle = title;
+ }
+ else
+ {
+ newtitle = newtitle.concat("- from " + title);
+ }
+ } else {
+ newtitle = new String("Pasted sequences");
+ }
+
+ Desktop.addInternalFrame(af, newtitle, DEFAULT_WIDTH,
+ DEFAULT_HEIGHT);
- Desktop.addInternalFrame(af, newtitle, DEFAULT_WIDTH,
- DEFAULT_HEIGHT);
+ }
- }
}
catch (Exception ex)
{
ex.printStackTrace();
- System.out.println("Exception whilst pasting: " + ex);
- // could be anything being pasted in here
+ System.out.println("Exception whilst pasting: "+ex);
+ // could be anything being pasted in here
}
+
}
/**
seqs.addElement(seq);
}
- // If the cut affects all sequences, remove highlighted columns
- if (sg.getSize() == viewport.alignment.getHeight())
- {
- viewport.getColumnSelection().removeElements(sg.getStartRes(),
- sg.getEndRes() + 1);
- }
- SequenceI[] cut = new SequenceI[seqs.size()];
- for (int i = 0; i < seqs.size(); i++)
+ // If the cut affects all sequences, remove highlighted columns
+ if (sg.getSize() == viewport.alignment.getHeight())
+ {
+ viewport.getColumnSelection().removeElements(sg.getStartRes(),
+ sg.getEndRes() + 1);
+ }
+
+
+ SequenceI [] cut = new SequenceI[seqs.size()];
+ for(int i=0; i<seqs.size(); i++)
{
- cut[i] = (SequenceI) seqs.elementAt(i);
+ cut[i] = (SequenceI)seqs.elementAt(i);
}
+
/*
- //ADD HISTORY ITEM
- */
+ //ADD HISTORY ITEM
+ */
addHistoryItem(new EditCommand("Cut Sequences",
- EditCommand.CUT,
- cut,
- sg.getStartRes(),
- sg.getEndRes() - sg.getStartRes() + 1,
- viewport.alignment));
+ EditCommand.CUT,
+ cut,
+ sg.getStartRes(),
+ sg.getEndRes()-sg.getStartRes()+1,
+ viewport.alignment));
+
viewport.setSelectionGroup(null);
viewport.alignment.deleteGroup(sg);
viewport.firePropertyChange("alignment", null,
- viewport.getAlignment().getSequences());
+ viewport.getAlignment().getSequences());
if (viewport.getAlignment().getHeight() < 1)
{
*/
public void deselectAllSequenceMenuItem_actionPerformed(ActionEvent e)
{
- if (viewport.cursorMode)
+ if(viewport.cursorMode)
{
alignPanel.seqPanel.keyboardNo1 = null;
alignPanel.seqPanel.keyboardNo2 = null;
alignPanel.paintAlignment(true);
}
+
/**
* DOCUMENT ME!
*
*/
public void remove2RightMenuItem_actionPerformed(ActionEvent e)
{
- trimAlignment(false);
+ trimAlignment(false);
}
void trimAlignment(boolean trimLeft)
if (colSel.size() > 0)
{
- if (trimLeft)
+ if(trimLeft)
{
column = colSel.getMin();
}
column = colSel.getMax();
}
- SequenceI[] seqs;
- if (viewport.getSelectionGroup() != null)
+ SequenceI [] seqs;
+ if(viewport.getSelectionGroup()!=null)
{
seqs = viewport.getSelectionGroup().getSequencesAsArray(viewport.
hiddenRepSequences);
seqs = viewport.alignment.getSequencesArray();
}
+
TrimRegionCommand trimRegion;
- if (trimLeft)
+ if(trimLeft)
{
trimRegion = new TrimRegionCommand("Remove Left",
- TrimRegionCommand.TRIM_LEFT,
- seqs,
- column,
- viewport.alignment,
- viewport.colSel,
- viewport.selectionGroup);
+ TrimRegionCommand.TRIM_LEFT,
+ seqs,
+ column,
+ viewport.alignment,
+ viewport.colSel,
+ viewport.selectionGroup);
viewport.setStartRes(0);
}
- else
- {
- trimRegion = new TrimRegionCommand("Remove Right",
- TrimRegionCommand.TRIM_RIGHT,
- seqs,
- column,
- viewport.alignment,
- viewport.colSel,
- viewport.selectionGroup);
- }
+ else
+ {
+ trimRegion = new TrimRegionCommand("Remove Right",
+ TrimRegionCommand.TRIM_RIGHT,
+ seqs,
+ column,
+ viewport.alignment,
+ viewport.colSel,
+ viewport.selectionGroup);
+ }
+
+ statusBar.setText("Removed "+trimRegion.getSize()+" columns.");
- statusBar.setText("Removed " + trimRegion.getSize() + " columns.");
addHistoryItem(trimRegion);
*/
public void removeGappedColumnMenuItem_actionPerformed(ActionEvent e)
{
- int start = 0, end = viewport.alignment.getWidth() - 1;
+ int start = 0, end = viewport.alignment.getWidth()-1;
SequenceI[] seqs;
if (viewport.getSelectionGroup() != null)
seqs = viewport.alignment.getSequencesArray();
}
+
RemoveGapColCommand removeGapCols =
new RemoveGapColCommand("Remove Gapped Columns",
seqs,
addHistoryItem(removeGapCols);
- statusBar.setText("Removed " + removeGapCols.getSize() + " empty columns.");
+ statusBar.setText("Removed "+removeGapCols.getSize()+" empty columns.");
//This is to maintain viewport position on first residue
//of first sequence
SequenceI seq = viewport.alignment.getSequenceAt(0);
int startRes = seq.findPosition(viewport.startRes);
- // ShiftList shifts;
- // viewport.getAlignment().removeGaps(shifts=new ShiftList());
- // edit.alColumnChanges=shifts.getInverse();
- // if (viewport.hasHiddenColumns)
- // viewport.getColumnSelection().compensateForEdits(shifts);
- viewport.setStartRes(seq.findIndex(startRes) - 1);
+ // ShiftList shifts;
+ // viewport.getAlignment().removeGaps(shifts=new ShiftList());
+ // edit.alColumnChanges=shifts.getInverse();
+ // if (viewport.hasHiddenColumns)
+ // viewport.getColumnSelection().compensateForEdits(shifts);
+ viewport.setStartRes(seq.findIndex(startRes)-1);
viewport.firePropertyChange("alignment", null,
viewport.getAlignment().getSequences());
*/
public void removeAllGapsMenuItem_actionPerformed(ActionEvent e)
{
- int start = 0, end = viewport.alignment.getWidth() - 1;
+ int start = 0, end = viewport.alignment.getWidth()-1;
SequenceI[] seqs;
if (viewport.getSelectionGroup() != null)
start, end,
viewport.alignment));
- viewport.setStartRes(seq.findIndex(startRes) - 1);
+ viewport.setStartRes(seq.findIndex(startRes)-1);
viewport.firePropertyChange("alignment", null,
viewport.getAlignment().getSequences());
AlignmentPanel newap =
new Jalview2XML().copyAlignPanel(alignPanel, true);
+ newap.av.gatherViewsHere = false;
+
if (viewport.viewName == null)
{
viewport.viewName = "Original";
newap.av.redoList = viewport.redoList;
int index = Desktop.getViewCount(viewport.getSequenceSetId());
- String newViewName = "View " + index;
+ String newViewName = "View " +index;
Vector comps = (Vector) PaintRefresher.components.get(viewport.
getSequenceSetId());
Vector existingNames = new Vector();
- for (int i = 0; i < comps.size(); i++)
+ for(int i=0; i<comps.size(); i++)
{
- if (comps.elementAt(i) instanceof AlignmentPanel)
+ if(comps.elementAt(i) instanceof AlignmentPanel)
{
- AlignmentPanel ap = (AlignmentPanel) comps.elementAt(i);
- if (!existingNames.contains(ap.av.viewName))
+ AlignmentPanel ap = (AlignmentPanel)comps.elementAt(i);
+ if(!existingNames.contains(ap.av.viewName))
{
existingNames.addElement(ap.av.viewName);
- }
}
}
+ }
- while (existingNames.contains(newViewName))
+ while(existingNames.contains(newViewName))
{
- newViewName = "View " + (++index);
+ newViewName = "View "+ (++index);
}
newap.av.viewName = newViewName;
addAlignmentPanel(newap, false);
- if (alignPanels.size() == 2)
+ if(alignPanels.size()==2)
{
viewport.gatherViewsHere = true;
}
public void expandViews_actionPerformed(ActionEvent e)
{
- Desktop.instance.explodeViews(this);
+ Desktop.instance.explodeViews(this);
}
public void gatherViews_actionPerformed(ActionEvent e)
Desktop.instance.gatherViews(this);
}
+
+
/**
* DOCUMENT ME!
*
new FontChooser(alignPanel);
}
+
/**
* DOCUMENT ME!
*
alignPanel.paintAlignment(true);
}
+
+
/**
* DOCUMENT ME!
*
alignPanel.paintAlignment(true);
}
+
public FeatureSettings featureSettings;
public void featureSettings_actionPerformed(ActionEvent e)
{
- if (featureSettings != null)
+ if(featureSettings !=null )
{
featureSettings.close();
featureSettings = null;
alignPanel.setAnnotationVisible(annotationPanelMenuItem.isSelected());
}
+ public void alignmentProperties()
+ {
+ 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>");
+ JInternalFrame frame = new JInternalFrame();
+ frame.getContentPane().add(new JScrollPane(editPane));
+
+ Desktop.instance.addInternalFrame(frame,"Alignment Properties: "+getTitle(),500,400);
+ }
+
+
/**
* DOCUMENT ME!
*
new AnnotationColourChooser(viewport, alignPanel);
}
+
/**
* DOCUMENT ME!
*
{
int threshold = 0;
- if (cs != null)
+ if(cs!=null)
{
if (viewport.getAbovePIDThreshold())
{
threshold = SliderPanel.setPIDSliderSource(alignPanel, cs,
- "Background");
+ "Background");
cs.setThreshold(threshold,
viewport.getIgnoreGapsConsensus());
|| cs instanceof PIDColourScheme
|| cs instanceof Blosum62ColourScheme)
{
- sg.cs.setThreshold(threshold,
- viewport.getIgnoreGapsConsensus());
+ 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
{
sg.cs.setThreshold(0, viewport.getIgnoreGapsConsensus());
}
+
if (viewport.getConservationSelected())
{
Conservation c = new Conservation("Group",
sg.getSequences(viewport.
hiddenRepSequences),
sg.getStartRes(),
- sg.getEndRes() + 1);
+ sg.getEndRes()+1);
c.calculate();
c.verdict(false, viewport.ConsPercGaps);
sg.cs.setConservation(c);
else
{
sg.cs.setConservation(null);
- }
}
}
+ }
if (alignPanel.getOverviewPanel() != null)
{
*/
protected void modifyPID_actionPerformed(ActionEvent e)
{
- if (viewport.getAbovePIDThreshold() && viewport.globalColourScheme != null)
+ if (viewport.getAbovePIDThreshold() && viewport.globalColourScheme!=null)
{
SliderPanel.setPIDSliderSource(alignPanel,
viewport.getGlobalColourScheme(),
*/
protected void modifyConservation_actionPerformed(ActionEvent e)
{
- if (viewport.getConservationSelected() && viewport.globalColourScheme != null)
+ if (viewport.getConservationSelected() && viewport.globalColourScheme!=null)
{
SliderPanel.setConservationSlider(alignPanel,
viewport.globalColourScheme,
nextElement().toString());
radioItem.setName("USER_DEFINED");
radioItem.addMouseListener(new MouseAdapter()
- {
- public void mousePressed(MouseEvent evt)
- {
- if (evt.isControlDown() || SwingUtilities.isRightMouseButton(evt))
{
- radioItem.removeActionListener(radioItem.getActionListeners()[0]);
+ public void mousePressed(MouseEvent evt)
+ {
+ if(evt.isControlDown() || SwingUtilities.isRightMouseButton(evt))
+ {
+ radioItem.removeActionListener(radioItem.getActionListeners()[0]);
int option = JOptionPane.showInternalConfirmDialog(jalview.gui.
Desktop.desktop,
- "Remove from default list?",
- "Remove user defined colour",
- JOptionPane.YES_NO_OPTION);
- if (option == JOptionPane.YES_OPTION)
- {
+ "Remove from default list?",
+ "Remove user defined colour",
+ JOptionPane.YES_NO_OPTION);
+ if(option == JOptionPane.YES_OPTION)
+ {
jalview.gui.UserDefinedColours.removeColourFromDefaults(
radioItem.getText());
- colourMenu.remove(radioItem);
- }
- else
- {
- radioItem.addActionListener(new ActionListener()
- {
- public void actionPerformed(ActionEvent evt)
- {
- userDefinedColour_actionPerformed(evt);
+ colourMenu.remove(radioItem);
}
- });
+ else
+ {
+ radioItem.addActionListener(new ActionListener()
+ {
+ public void actionPerformed(ActionEvent evt)
+ {
+ userDefinedColour_actionPerformed(evt);
+ }
+ });
+ }
}
- }
}
- });
+ });
radioItem.addActionListener(new ActionListener()
{
public void actionPerformed(ActionEvent evt)
*/
public void sortPairwiseMenuItem_actionPerformed(ActionEvent e)
{
- SequenceI[] oldOrder = viewport.getAlignment().getSequencesArray();
+ SequenceI [] oldOrder = viewport.getAlignment().getSequencesArray();
AlignmentSorter.sortByPID(viewport.getAlignment(),
viewport.getAlignment().getSequenceAt(0));
addHistoryItem(new OrderCommand("Pairwise Sort", oldOrder,
*/
public void sortIDMenuItem_actionPerformed(ActionEvent e)
{
- SequenceI[] oldOrder = viewport.getAlignment().getSequencesArray();
+ SequenceI [] oldOrder = viewport.getAlignment().getSequencesArray();
AlignmentSorter.sortByID(viewport.getAlignment());
addHistoryItem(new OrderCommand("ID Sort", oldOrder, viewport.alignment));
alignPanel.paintAlignment(true);
*/
public void sortGroupMenuItem_actionPerformed(ActionEvent e)
{
- SequenceI[] oldOrder = viewport.getAlignment().getSequencesArray();
+ SequenceI [] oldOrder = viewport.getAlignment().getSequencesArray();
AlignmentSorter.sortByGroup(viewport.getAlignment());
addHistoryItem(new OrderCommand("Group Sort", oldOrder, viewport.alignment));
alignPanel.paintAlignment(true);
}
-
/**
* DOCUMENT ME!
*
new RedundancyPanel(alignPanel, this);
}
+
/**
* DOCUMENT ME!
*
return;
}
- new PCAPanel(alignPanel);
+ new PCAPanel(alignPanel);
}
+
public void autoCalculate_actionPerformed(ActionEvent e)
{
viewport.autoCalculateConsensus = autoCalculate.isSelected();
- if (viewport.autoCalculateConsensus)
+ if(viewport.autoCalculateConsensus)
{
viewport.firePropertyChange("alignment",
null,
}
}
+
/**
* DOCUMENT ME!
*
return;
}
- if (viewport.alignment.getHeight() < 2)
+ if(viewport.alignment.getHeight()<2)
{
return;
}
title += " from ";
- if (viewport.viewName != null)
+ if(viewport.viewName!=null)
{
- title += viewport.viewName + " of ";
+ title+= viewport.viewName+" of ";
}
title += this.title;
{
public void actionPerformed(ActionEvent e)
{
- SequenceI[] oldOrder = viewport.getAlignment().getSequencesArray();
+ SequenceI [] oldOrder = viewport.getAlignment().getSequencesArray();
// TODO: JBPNote - have to map order entries to curent SequenceI pointers
AlignmentSorter.sortBy(viewport.getAlignment(), order);
}
});
}
+ /**
+ * Add a new sort by annotation score menu item
+ * @param sort the menu to add the option to
+ * @param scoreLabel the label used to retrieve scores for each sequence on the alignment
+ */
+ public void addSortByAnnotScoreMenuItem(JMenu sort, final String scoreLabel)
+ {
+ final JMenuItem item = new JMenuItem(scoreLabel);
+ sort.add(item);
+ item.addActionListener(new java.awt.event.ActionListener()
+ {
+ public void actionPerformed(ActionEvent e)
+ {
+ SequenceI [] oldOrder = viewport.getAlignment().getSequencesArray();
+ AlignmentSorter.sortByAnnotationScore(scoreLabel, viewport.getAlignment());
+ addHistoryItem(new OrderCommand("Sort by "+scoreLabel, oldOrder, viewport.alignment));
+ alignPanel.paintAlignment(true);
+ }
+ });
+ }
+ /**
+ * last hash for alignment's annotation array - used to minimise cost of rebuild.
+ */
+ protected int _annotationScoreVectorHash;
+ /**
+ * search the alignment and rebuild the sort by annotation score submenu
+ * the last alignment annotation vector hash is stored to minimize
+ * cost of rebuilding in subsequence calls.
+ *
+ */
+ public void buildSortByAnnotationScoresMenu()
+ {
+ if (viewport.alignment.getAlignmentAnnotation().hashCode()!=_annotationScoreVectorHash)
+ {
+ sortByAnnotScore.removeAll();
+ // almost certainly a quicker way to do this - but we keep it simple
+ Hashtable scoreSorts=new Hashtable();
+ AlignmentAnnotation aann[];
+ Enumeration sq = viewport.alignment.getSequences().elements();
+ while (sq.hasMoreElements())
+ {
+ aann = ((SequenceI) sq.nextElement()).getAnnotation();
+ for (int i=0;aann!=null && i<aann.length; i++)
+ {
+ if (aann[i].hasScore() && aann[i].sequenceRef!=null)
+ {
+ scoreSorts.put(aann[i].label, aann[i].label);
+ }
+ }
+ }
+ Enumeration labels = scoreSorts.keys();
+ while (labels.hasMoreElements())
+ {
+ addSortByAnnotScoreMenuItem(sortByAnnotScore, (String) labels.nextElement());
+ }
+ sortByAnnotScore.setVisible(scoreSorts.size()>0);
+ scoreSorts.clear();
+ }
+ }
/**
* Maintain the Order by->Displayed Tree menu.
getSequenceSetId());
Vector treePanels = new Vector();
int i, iSize = comps.size();
- for (i = 0; i < iSize; i++)
+ for(i=0; i<iSize; i++)
{
- if (comps.elementAt(i) instanceof TreePanel)
+ if(comps.elementAt(i) instanceof TreePanel)
{
treePanels.add(comps.elementAt(i));
}
iSize = treePanels.size();
- if (iSize < 1)
+ if(iSize<1)
{
sortByTreeMenu.setVisible(false);
return;
sortByTreeMenu.setVisible(true);
- for (i = 0; i < treePanels.size(); i++)
+ for(i=0; i<treePanels.size(); i++)
{
- TreePanel tp = (TreePanel) treePanels.elementAt(i);
+ TreePanel tp = (TreePanel)treePanels.elementAt(i);
final JMenuItem item = new JMenuItem(tp.getTitle());
- final NJTree tree = ( (TreePanel) treePanels.elementAt(i)).getTree();
+ final NJTree tree = ((TreePanel)treePanels.elementAt(i)).getTree();
item.addActionListener(new java.awt.event.ActionListener()
{
public void actionPerformed(ActionEvent e)
{
// JBPNote UGLY! To prettify, make SequenceGroup and Alignment conform to some common interface!
/*SequenceGroup seqs = viewport.getSelectionGroup();
- int sz;
- msa = new SequenceI[sz = seqs.getSize(false)];
+ int sz;
+ msa = new SequenceI[sz = seqs.getSize(false)];
- for (int i = 0; i < sz; i++)
- {
+ for (int i = 0; i < sz; i++)
+ {
msa[i] = (SequenceI) seqs.getSequenceAt(i);
- } */
+ } */
msa = viewport.getAlignmentView(true);
}
else
{
/*Vector seqs = viewport.getAlignment().getSequences();
- if (seqs.size() > 1)
- {
+
+ if (seqs.size() > 1)
+ {
msa = new SequenceI[seqs.size()];
for (int i = 0; i < seqs.size(); i++)
{
msa[i] = (SequenceI) seqs.elementAt(i);
}
- }*/
+ }*/
msa = viewport.getAlignmentView(false);
}
return msa;
*/
AlignmentView gatherSeqOrMsaForSecStrPrediction()
{
- AlignmentView seqs = null;
+ AlignmentView seqs = null;
if ( (viewport.getSelectionGroup() != null) &&
(viewport.getSelectionGroup().getSize() > 0))
}
return seqs;
}
-
/**
* DOCUMENT ME!
*
}
}
+
public TreePanel ShowNewickTree(NewickFile nf, String title)
{
- return ShowNewickTree(nf, title, 600, 500, 4, 5);
+ return ShowNewickTree(nf,title,600,500,4,5);
}
public TreePanel ShowNewickTree(NewickFile nf, String title,
AlignmentView input)
{
- return ShowNewickTree(nf, title, input, 600, 500, 4, 5);
+ return ShowNewickTree(nf,title, input, 600,500,4,5);
}
public TreePanel ShowNewickTree(NewickFile nf, String title, int w, int h,
{
return ShowNewickTree(nf, title, null, w, h, x, y);
}
-
/**
* Add a treeviewer for the tree extracted from a newick file object to the current alignment view
*
title,
nf, input);
- tp.setSize(w, h);
+ tp.setSize(w,h);
- if (x > 0 && y > 0)
+ if(x>0 && y>0)
{
- tp.setLocation(x, y);
+ tp.setLocation(x,y);
}
+
Desktop.addInternalFrame(tp, title, w, h);
}
}
return tp;
}
+
/**
* Generates menu items and listener event actions for web service clients
*
if (sh.getName().indexOf("lustal") > -1)
{
// We know that ClustalWS can accept partial alignments for refinement.
- final JMenuItem methodR = new JMenuItem(sh.getName() + " Realign");
+ final JMenuItem methodR = new JMenuItem(sh.getName()+" Realign");
methodR.addActionListener(new ActionListener()
{
public void actionPerformed(ActionEvent e)
{
// Sequence profile based prediction
new jalview.ws.JPredClient(sh,
- title, true, msa, af, true);
+ title, true, msa, af, true);
}
}
}
}
wsmenu.add(secstrmenu);
}
- this.webService.removeAll();
+ resetWebServiceMenu();
for (int i = 0, j = wsmenu.size(); i < j; i++)
{
webService.add( (JMenu) wsmenu.get(i));
}
else
{
- this.webService.removeAll();
+ resetWebServiceMenu();
this.webService.add(this.webServiceNoServices);
}
// TODO: add in rediscovery function
// TODO: group services by location as well as function.
}
- /* public void vamsasStore_actionPerformed(ActionEvent e)
- {
- JalviewFileChooser chooser = new JalviewFileChooser(jalview.bin.Cache.
- getProperty("LAST_DIRECTORY"));
-
- chooser.setFileView(new JalviewFileView());
- chooser.setDialogTitle("Export to Vamsas file");
- chooser.setToolTipText("Export");
-
- int value = chooser.showSaveDialog(this);
- if (value == JalviewFileChooser.APPROVE_OPTION)
- {
- jalview.io.VamsasDatastore vs = new jalview.io.VamsasDatastore(viewport);
- //vs.store(chooser.getSelectedFile().getAbsolutePath() );
- vs.storeJalview( chooser.getSelectedFile().getAbsolutePath(), this);
- }
- }*/
-
-
-
-
- public void showTranslation_actionPerformed(ActionEvent e)
+ /**
+ * empty the web service menu and add any ad-hoc functions
+ * not dynamically discovered.
+ *
+ */
+ private void resetWebServiceMenu()
{
- SequenceI[] selection = viewport.getSelectionAsNewSequence();
- String[] seqstring = viewport.getViewAsString(true);
-
- int s, sSize = selection.length;
- SequenceI[] newSeq = new SequenceI[sSize];
+ webService.removeAll();
+ // Temporary hack - DBRef Fetcher always top level ws entry.
+ JMenuItem rfetch = new JMenuItem("Fetch DB References");
+ rfetch.setToolTipText("Retrieve and parse uniprot records for the alignment or the currently selected sequences");
+ webService.add(rfetch);
+ rfetch.addActionListener(new ActionListener() {
- int res, resSize;
- StringBuffer protein;
- String seq;
- for (s = 0; s < sSize; s++)
- {
- protein = new StringBuffer();
- seq = AlignSeq.extractGaps("-. ", seqstring[s]);
- resSize = seq.length();
- resSize -= resSize % 3;
-
- for (res = 0; res < resSize; res += 3)
+ public void actionPerformed(ActionEvent e)
{
- String codon = seq.substring(res, res + 3);
- codon = codon.replace('U', 'T');
- String aa = ResidueProperties.codonTranslate(codon);
- if (aa == null)
- {
- protein.append(viewport.getGapCharacter());
- }
- else if (aa.equals("STOP"))
- {
- protein.append("X");
- }
- else
- {
- protein.append(aa);
- }
+ new jalview.io.DBRefFetcher(
+ alignPanel.av.getSequenceSelection(),
+ alignPanel.alignFrame).fetchDBRefs(false);
}
- newSeq[s] = new Sequence(selection[s].getName(),
- protein.toString());
- }
-
- AlignmentI al = new Alignment(newSeq);
- al.setDataset(null);
- ////////////////////////////////
- // Copy annotations across
- jalview.datamodel.AlignmentAnnotation[] annotations
- = viewport.alignment.getAlignmentAnnotation();
- int a, aSize;
- if (annotations != null)
- {
- for (int i = 0; i < annotations.length; i++)
- {
- if (annotations[i] == viewport.quality ||
- annotations[i] == viewport.conservation ||
- annotations[i] == viewport.consensus)
- {
- System.out.println("COPT HERE");
- continue;
- }
+ });
+ }
- aSize = viewport.alignment.getWidth() / 3;
- jalview.datamodel.Annotation[] anots =
- new jalview.datamodel.Annotation[aSize];
+ /* public void vamsasStore_actionPerformed(ActionEvent e)
+ {
+ JalviewFileChooser chooser = new JalviewFileChooser(jalview.bin.Cache.
+ getProperty("LAST_DIRECTORY"));
- for (a = 0; a < viewport.alignment.getWidth(); a++)
- {
- if (annotations[i].annotations[a] == null
- || annotations[i].annotations[a] == null)
- {
- continue;
- }
+ chooser.setFileView(new JalviewFileView());
+ chooser.setDialogTitle("Export to Vamsas file");
+ chooser.setToolTipText("Export");
- anots[a / 3] = new Annotation(
- annotations[i].annotations[a].displayCharacter,
- annotations[i].annotations[a].description,
- annotations[i].annotations[a].secondaryStructure,
- annotations[i].annotations[a].value,
- annotations[i].annotations[a].colour);
- }
+ int value = chooser.showSaveDialog(this);
- jalview.datamodel.AlignmentAnnotation aa
- = new jalview.datamodel.AlignmentAnnotation(annotations[i].label,
- annotations[i].description, anots);
- al.addAnnotation(aa);
- }
+ if (value == JalviewFileChooser.APPROVE_OPTION)
+ {
+ jalview.io.VamsasDatastore vs = new jalview.io.VamsasDatastore(viewport);
+ //vs.store(chooser.getSelectedFile().getAbsolutePath() );
+ vs.storeJalview( chooser.getSelectedFile().getAbsolutePath(), this);
}
+ }*/
+
+
+public void showTranslation_actionPerformed(ActionEvent e)
+{
+ ///////////////////////////////
+ // Collect Data to be translated/transferred
+
+ SequenceI [] selection = viewport.getSequenceSelection();
+ String [] seqstring = viewport.getViewAsString(true);
+ AlignmentI al = null;
+ try {
+ al = jalview.analysis.Dna.CdnaTranslate(selection, seqstring, viewport.getViewAsVisibleContigs(true),
+ viewport.getGapCharacter(), viewport.alignment.getAlignmentAnnotation(),
+ viewport.alignment.getWidth());
+ } catch (Exception ex) {
+ al = null;
+ jalview.bin.Cache.log.debug("Exception during translation.",ex);
+ }
+ if (al==null)
+ {
+ JOptionPane.showMessageDialog(Desktop.desktop,
+ "Please select at least three bases in at least one sequence in order to perform a cDNA translation.",
+ "Translation Failed",
+ JOptionPane.WARNING_MESSAGE);
+ } else {
AlignFrame af = new AlignFrame(al, DEFAULT_WIDTH, DEFAULT_HEIGHT);
- Desktop.addInternalFrame(af, "Translation of " + this.getTitle(),
+ Desktop.addInternalFrame(af, "Translation of "+this.getTitle(),
DEFAULT_WIDTH,
DEFAULT_HEIGHT);
-
}
+}
- /**
- * DOCUMENT ME!
- *
- * @param String DOCUMENT ME!
- */
- public boolean parseFeaturesFile(String file, String type)
- {
+/**
+ * DOCUMENT ME!
+ *
+ * @param String DOCUMENT ME!
+ */
+public boolean parseFeaturesFile(String file, String type)
+{
boolean featuresFile = false;
try
{
featuresFile = new FeaturesFile(file,
type).parse(viewport.alignment.getDataset(),
- alignPanel.seqPanel.seqCanvas.
- getFeatureRenderer().featureColours,
- false);
+ alignPanel.seqPanel.seqCanvas.
+ getFeatureRenderer().featureColours,
+ false);
}
- catch (Exception ex)
+ catch(Exception ex)
{
ex.printStackTrace();
}
- if (featuresFile)
+ if(featuresFile)
{
viewport.showSequenceFeatures = true;
showSeqFeatures.setSelected(true);
}
return featuresFile;
- }
+}
- public void dragEnter(DropTargetDragEvent evt)
- {}
+public void dragEnter(DropTargetDragEvent evt)
+{}
- public void dragExit(DropTargetEvent evt)
- {}
+public void dragExit(DropTargetEvent evt)
+{}
- public void dragOver(DropTargetDragEvent evt)
- {}
+public void dragOver(DropTargetDragEvent evt)
+{}
- public void dropActionChanged(DropTargetDragEvent evt)
- {}
+public void dropActionChanged(DropTargetDragEvent evt)
+{}
- public void drop(DropTargetDropEvent evt)
- {
+public void drop(DropTargetDropEvent evt)
+{
Transferable t = evt.getTransferable();
java.util.List files = null;
ex.printStackTrace();
}
}
- }
+}
// This method will attempt to load a "dropped" file first by testing
// whether its and Annotation file, then features file. If both are
// false then the user may have dropped an alignment file onto this
// AlignFrame
- public void loadJalviewDataFile(String file)
+ public void loadJalviewDataFile(String file)
{
try
{
if (!isAnnotation)
{
- boolean isGroupsFile = parseFeaturesFile(file, protocol);
+ boolean isGroupsFile = parseFeaturesFile(file,protocol);
if (!isGroupsFile)
{
String format = new IdentifyFile().Identify(file, protocol);
- if (format.equalsIgnoreCase("JnetFile"))
+ if(format.equalsIgnoreCase("JnetFile"))
{
jalview.io.JPredFile predictions = new jalview.io.JPredFile(
file, protocol);
else
{
new FileLoader().LoadFile(viewport, file, protocol, format);
- }
}
}
+ }
else
{
// (isAnnotation)
alignPanel.adjustAnnotationHeight();
+ buildSortByAnnotationScoresMenu();
}
}
public void tabbedPane_mousePressed(MouseEvent e)
{
- if (SwingUtilities.isRightMouseButton(e))
+ if(SwingUtilities.isRightMouseButton(e))
{
String reply = JOptionPane.showInternalInputDialog(this,
"Enter View Name",
if (reply != null)
{
viewport.viewName = reply;
- tabbedPane.setTitleAt(tabbedPane.getSelectedIndex(), reply);
+ tabbedPane.setTitleAt( tabbedPane.getSelectedIndex() ,reply);
}
}
}
+
public AlignViewport getCurrentView()
{
return viewport;
}
+
+
+ /**
+ * Open the dialog for regex description parsing.
+ */
+ protected void extractScores_actionPerformed(ActionEvent e)
+ {
+ ParseProperties pp = new jalview.analysis.ParseProperties(viewport.alignment);
+ if (pp.getScoresFromDescription("col", "score column ", "\\W+([-+]?\\d*\\.?\\d*e?-?\\d*)\\W+([-+]?\\d*\\.?\\d*e?-?\\d*)")>0)
+ {
+ buildSortByAnnotationScoresMenu();
+ }
+ }
}
class PrintThread
AlignmentPanel ap;
public PrintThread(AlignmentPanel ap)
{
- this.ap = ap;
+ this.ap = ap;
}
-
static PageFormat pf;
public void run()
{