import jalview.api.AlignViewportI;
import jalview.api.AlignmentViewPanel;
import jalview.api.FeatureSettingsControllerI;
-import jalview.api.FeatureSettingsModelI;
import jalview.api.SplitContainerI;
import jalview.api.ViewStyleI;
import jalview.api.analysis.ScoreModelI;
import jalview.datamodel.AlignmentOrder;
import jalview.datamodel.AlignmentView;
import jalview.datamodel.ColumnSelection;
-import jalview.datamodel.DBRefSource;
import jalview.datamodel.HiddenSequences;
import jalview.datamodel.PDBEntry;
import jalview.datamodel.SeqCigar;
import jalview.io.JalviewFileView;
import jalview.io.JnetAnnotationMaker;
import jalview.io.NewickFile;
+import jalview.io.StructureFile;
import jalview.io.TCoffeeScoreFile;
-import jalview.io.gff.SequenceOntologyI;
import jalview.jbgui.GAlignFrame;
import jalview.schemes.Blosum62ColourScheme;
import jalview.schemes.BuriedColourScheme;
import jalview.schemes.TurnColourScheme;
import jalview.schemes.UserColourScheme;
import jalview.schemes.ZappoColourScheme;
-import jalview.structure.StructureSelectionManager;
import jalview.util.MessageManager;
import jalview.viewmodel.AlignmentViewport;
import jalview.ws.DBRefFetcher;
import jalview.ws.DBRefFetcher.FetchFinishedListenerI;
-import jalview.ws.SequenceFetcher;
import jalview.ws.jws1.Discoverer;
import jalview.ws.jws2.Jws2Discoverer;
import jalview.ws.jws2.jabaws2.Jws2Instance;
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;
@Override
public void focusGained(FocusEvent e)
{
- Desktop.setCurrentAlignFrame(AlignFrame.this);
+ Jalview.setCurrentAlignFrame(AlignFrame.this);
}
});
showGroupConservation.setEnabled(!nucleotide);
rnahelicesColour.setEnabled(nucleotide);
purinePyrimidineColour.setEnabled(nucleotide);
- showComplementMenuItem.setText(MessageManager
- .getString(nucleotide ? "label.protein" : "label.nucleotide"));
+ showComplementMenuItem.setText(nucleotide ? MessageManager
+ .getString("label.protein") : MessageManager
+ .getString("label.nucleotide"));
setColourSelected(jalview.bin.Cache.getDefault(
nucleotide ? Preferences.DEFAULT_COLOUR_NUC
: Preferences.DEFAULT_COLOUR_PROT, "None"));
if (viewport.hasHiddenColumns() && !settings.isExportHiddenColumns())
{
- viewport.setExportHiddenSeqs(settings.isExportHiddenSequences());
- omitHidden = viewport.getViewAsString(false);
+ omitHidden = viewport.getViewAsString(false,
+ settings.isExportHiddenSequences());
}
int[] alignmentStartEnd = new int[2];
else
{
alignmentToExport = viewport.getAlignment();
- alignmentStartEnd = viewport.getAlignment()
- .getVisibleStartAndEndIndex(
- viewport.getColumnSelection().getHiddenColumns());
}
+ alignmentStartEnd = alignmentToExport
+ .getVisibleStartAndEndIndex(viewport.getColumnSelection()
+ .getHiddenColumns());
AlignmentExportData ed = new AlignmentExportData(alignmentToExport,
omitHidden, alignmentStartEnd, settings);
return ed;
@Override
protected void htmlMenuItem_actionPerformed(ActionEvent e)
{
- new HtmlSvgOutput(null, alignPanel);
+ HtmlSvgOutput htmlSVG = new HtmlSvgOutput(alignPanel);
+ htmlSVG.exportHTML(null);
}
@Override
public void bioJSMenuItem_actionPerformed(ActionEvent e)
{
- BioJsHTMLOutput bjs = new BioJsHTMLOutput(alignPanel, this);
- bjs.exportJalviewAlignmentAsBioJsHtmlFile();
+ BioJsHTMLOutput bjs = new BioJsHTMLOutput(alignPanel);
+ bjs.exportHTML(null);
}
public void createImageMap(File file, String image)
sg.setEndRes(viewport.getAlignment().getWidth() - 1);
viewport.setSelectionGroup(sg);
viewport.sendSelection();
- alignPanel.paintAlignment(true);
+ // JAL-2034 - should delegate to
+ // alignPanel to decide if overview needs
+ // updating.
+ alignPanel.paintAlignment(false);
PaintRefresher.Refresh(alignPanel, viewport.getSequenceSetId());
}
viewport.setSelectionGroup(null);
alignPanel.getSeqPanel().seqCanvas.highlightSearchResults(null);
alignPanel.getIdPanel().getIdCanvas().searchResults = null;
- alignPanel.paintAlignment(true);
+ // JAL-2034 - should delegate to
+ // alignPanel to decide if overview needs
+ // updating.
+ alignPanel.paintAlignment(false);
PaintRefresher.Refresh(alignPanel, viewport.getSequenceSetId());
viewport.sendSelection();
}
{
sg.addOrRemove(viewport.getAlignment().getSequenceAt(i), false);
}
+ // JAL-2034 - should delegate to
+ // alignPanel to decide if overview needs
+ // updating.
alignPanel.paintAlignment(true);
PaintRefresher.Refresh(alignPanel, viewport.getSequenceSetId());
@Override
public void expandViews_actionPerformed(ActionEvent e)
{
- Desktop.instance.explodeViews(this);
+ Desktop.explodeViews(this);
}
/**
// 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.getColumnSelection() != null
- && viewport.getColumnSelection().getSelected() != null && viewport
- .getColumnSelection().getSelected().size() > 0)
+ if (viewport.hasSelectedColumns()
|| (sg != null && sg.getSize() > 0 && sg.getStartRes() <= sg
.getEndRes()))
{
hideSelSequences_actionPerformed(null);
hide = true;
}
- else if (!(toggleCols && viewport.getColumnSelection().getSelected()
- .size() > 0))
+ else if (!(toggleCols && viewport.hasSelectedColumns()))
{
showAllSeqs_actionPerformed(null);
}
if (toggleCols)
{
- if (viewport.getColumnSelection().getSelected().size() > 0)
+ if (viewport.hasSelectedColumns())
{
hideSelColumns_actionPerformed(null);
if (!toggleSeqs)
}
/**
- * Set or clear 'Show Sequence Features'
- *
- * @param evt
- * DOCUMENT ME!
- */
- @Override
- public void showSeqFeaturesHeight_actionPerformed(ActionEvent evt)
- {
- viewport.setShowSequenceFeaturesHeight(showSeqFeaturesHeight
- .isSelected());
- if (viewport.isShowSequenceFeaturesHeight())
- {
- // ensure we're actually displaying features
- viewport.setShowSequenceFeatures(true);
- showSeqFeatures.setSelected(true);
- }
- alignPanel.paintAlignment(true);
- if (alignPanel.getOverviewPanel() != null)
- {
- alignPanel.getOverviewPanel().updateOverviewImage();
- }
- }
-
- /**
* Action on toggle of the 'Show annotations' menu item. This shows or hides
* the annotations panel as a whole.
*
@Override
public void mousePressed(MouseEvent evt)
{
- if (evt.isPopupTrigger())
+ if (evt.isPopupTrigger()) // Mac
{
- radioItem.removeActionListener(radioItem.getActionListeners()[0]);
+ offerRemoval(radioItem);
+ }
+ }
- int option = JOptionPane.showInternalConfirmDialog(
- jalview.gui.Desktop.desktop,
- MessageManager
- .getString("label.remove_from_default_list"),
- MessageManager
- .getString("label.remove_user_defined_colour"),
- JOptionPane.YES_NO_OPTION);
- if (option == JOptionPane.YES_OPTION)
- {
- jalview.gui.UserDefinedColours
- .removeColourFromDefaults(radioItem.getText());
- colourMenu.remove(radioItem);
- }
- else
+ @Override
+ public void mouseReleased(MouseEvent evt)
+ {
+ if (evt.isPopupTrigger()) // Windows
+ {
+ offerRemoval(radioItem);
+ }
+ }
+
+ /**
+ * @param radioItem
+ */
+ void offerRemoval(final JRadioButtonMenuItem radioItem)
+ {
+ radioItem.removeActionListener(radioItem.getActionListeners()[0]);
+
+ int option = JOptionPane.showInternalConfirmDialog(
+ jalview.gui.Desktop.desktop, MessageManager
+ .getString("label.remove_from_default_list"),
+ MessageManager
+ .getString("label.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()
{
- radioItem.addActionListener(new ActionListener()
+ @Override
+ public void actionPerformed(ActionEvent evt)
{
- @Override
- public void actionPerformed(ActionEvent evt)
- {
- userDefinedColour_actionPerformed(evt);
- }
- });
- }
+ userDefinedColour_actionPerformed(evt);
+ }
+ });
}
}
});
// object broker mechanism.
final Vector<JMenu> wsmenu = new Vector<JMenu>();
final IProgressIndicator af = me;
+
+ /*
+ * do not i18n these strings - they are hard-coded in class
+ * compbio.data.msa.Category, Jws2Discoverer.isRecalculable() and
+ * SequenceAnnotationWSClient.initSequenceAnnotationWSClient()
+ */
final JMenu msawsmenu = new JMenu("Alignment");
final JMenu secstrmenu = new JMenu(
"Secondary Structure Prediction");
final JMenu seqsrchmenu = new JMenu("Sequence Database Search");
final JMenu analymenu = new JMenu("Analysis");
final JMenu dismenu = new JMenu("Protein Disorder");
- // final JMenu msawsmenu = new
- // JMenu(MessageManager.getString("label.alignment"));
- // final JMenu secstrmenu = new
- // JMenu(MessageManager.getString("label.secondary_structure_prediction"));
- // final JMenu seqsrchmenu = new
- // JMenu(MessageManager.getString("label.sequence_database_search"));
- // final JMenu analymenu = new
- // JMenu(MessageManager.getString("label.analysis"));
- // final JMenu dismenu = new
- // JMenu(MessageManager.getString("label.protein_disorder"));
// JAL-940 - only show secondary structure prediction services from
// the legacy server
if (// Cache.getDefault("SHOW_JWS1_SERVICES", true)
}
/**
- * Searches selected sequences for xRef products and builds the Show
- * Cross-References menu (formerly called Show Products)
+ * Searches the alignment sequences for xRefs and builds the Show
+ * Cross-References menu (formerly called Show Products), with database
+ * sources for which cross-references are found (protein sources for a
+ * nucleotide alignment and vice versa)
*
- * @return true if Show Cross-references menu should be enabled.
+ * @return true if Show Cross-references menu should be enabled
*/
public boolean canShowProducts()
{
- SequenceI[] selection = viewport.getSequenceSelection();
+ SequenceI[] seqs = viewport.getAlignment().getSequencesArray();
AlignmentI dataset = viewport.getAlignment().getDataset();
+
+ showProducts.removeAll();
+ final boolean dna = viewport.getAlignment().isNucleotide();
+
+ if (seqs == null || seqs.length == 0)
+ {
+ // nothing to see here.
+ return false;
+ }
+
boolean showp = false;
try
{
- showProducts.removeAll();
- final boolean dna = viewport.getAlignment().isNucleotide();
- String[] ptypes = (selection == null || selection.length == 0) ? null
- : CrossRef.findSequenceXrefTypes(dna, selection, dataset);
+ List<String> ptypes = new CrossRef(seqs, dataset)
+ .findXrefSourcesForSequences(dna);
- for (int t = 0; ptypes != null && t < ptypes.length; t++)
+ for (final String source : ptypes)
{
showp = true;
final AlignFrame af = this;
- final String source = ptypes[t];
- JMenuItem xtype = new JMenuItem(ptypes[t]);
+ JMenuItem xtype = new JMenuItem(source);
xtype.addActionListener(new ActionListener()
{
-
@Override
public void actionPerformed(ActionEvent e)
{
showProductsFor(af.viewport.getSequenceSelection(), dna, source);
}
-
});
showProducts.add(xtype);
}
showProducts.setEnabled(showp);
} catch (Exception e)
{
- jalview.bin.Cache.log
+ Cache.log
.warn("canShowProducts threw an exception - please report to help@jalview.org",
e);
return false;
* @param source
* the database to show cross-references for
*/
- protected void showProductsFor(final SequenceI[] sel, final boolean dna,
- final String source)
+ protected void showProductsFor(final SequenceI[] sel,
+ final boolean _odna, final String source)
{
- Runnable foo = new Runnable()
- {
-
- @Override
- public void run()
- {
- final long sttime = System.currentTimeMillis();
- AlignFrame.this.setProgressBar(MessageManager.formatMessage(
- "status.searching_for_sequences_from",
- new Object[] { source }), sttime);
- try
- {
- AlignmentI alignment = AlignFrame.this.getViewport()
- .getAlignment();
- AlignmentI xrefs = CrossRef.findXrefSequences(sel, dna, source,
- alignment);
- if (xrefs != null)
- {
- /*
- * get display scheme (if any) to apply to features
- */
- FeatureSettingsModelI featureColourScheme = new SequenceFetcher()
- .getFeatureColourScheme(source);
-
- AlignmentI al = makeCrossReferencesAlignment(
- alignment.getDataset(), xrefs);
-
- AlignFrame newFrame = new AlignFrame(al, DEFAULT_WIDTH,
- DEFAULT_HEIGHT);
- if (Cache.getDefault("HIDE_INTRONS", true))
- {
- newFrame.hideFeatureColumns(SequenceOntologyI.EXON, false);
- }
- String newtitle = String.format("%s %s %s",
- MessageManager.getString(dna ? "label.proteins"
- : "label.nucleotides"), MessageManager
- .getString("label.for"), getTitle());
- newFrame.setTitle(newtitle);
-
- if (!Cache.getDefault(Preferences.ENABLE_SPLIT_FRAME, true))
- {
- /*
- * split frame display is turned off in preferences file
- */
- Desktop.addInternalFrame(newFrame, newtitle, DEFAULT_WIDTH,
- DEFAULT_HEIGHT);
- return; // via finally clause
- }
-
- /*
- * Make a copy of this alignment (sharing the same dataset
- * sequences). If we are DNA, drop introns and update mappings
- */
- AlignmentI copyAlignment = null;
- final SequenceI[] sequenceSelection = AlignFrame.this.viewport
- .getSequenceSelection();
- List<AlignedCodonFrame> cf = xrefs.getCodonFrames();
- boolean copyAlignmentIsAligned = false;
- if (dna)
- {
- copyAlignment = AlignmentUtils.makeCdsAlignment(
- sequenceSelection, cf, alignment);
- if (copyAlignment.getHeight() == 0)
- {
- System.err.println("Failed to make CDS alignment");
- }
- al.getCodonFrames().clear();
- al.addCodonFrames(copyAlignment.getCodonFrames());
- al.addCodonFrames(cf);
-
- /*
- * pending getting Embl transcripts to 'align',
- * we are only doing this for Ensembl
- */
- // TODO proper criteria for 'can align as cdna'
- if (DBRefSource.ENSEMBL.equalsIgnoreCase(source)
- || AlignmentUtils.looksLikeEnsembl(alignment))
- {
- copyAlignment.alignAs(alignment);
- copyAlignmentIsAligned = true;
- }
- }
- else
- {
- copyAlignment = AlignmentUtils.makeCopyAlignment(
- sequenceSelection, xrefs.getSequencesArray());
- copyAlignment.addCodonFrames(cf);
- al.addCodonFrames(copyAlignment.getCodonFrames());
- al.addCodonFrames(cf);
- }
- copyAlignment.setGapCharacter(AlignFrame.this.viewport
- .getGapCharacter());
-
- StructureSelectionManager ssm = StructureSelectionManager
- .getStructureSelectionManager(Desktop.instance);
- ssm.registerMappings(cf);
-
- if (copyAlignment.getHeight() <= 0)
- {
- System.err.println("No Sequences generated for xRef type "
- + source);
- return;
- }
- /*
- * align protein to dna
- */
- if (dna && copyAlignmentIsAligned)
- {
- al.alignAs(copyAlignment);
- }
- else
- {
- /*
- * align cdna to protein - currently only if
- * fetching and aligning Ensembl transcripts!
- */
- if (DBRefSource.ENSEMBL.equalsIgnoreCase(source))
- {
- copyAlignment.alignAs(al);
- }
- }
-
- AlignFrame copyThis = new AlignFrame(copyAlignment,
- AlignFrame.DEFAULT_WIDTH, AlignFrame.DEFAULT_HEIGHT);
- copyThis.setTitle(AlignFrame.this.getTitle());
-
- boolean showSequenceFeatures = viewport
- .isShowSequenceFeatures();
- newFrame.setShowSeqFeatures(showSequenceFeatures);
- copyThis.setShowSeqFeatures(showSequenceFeatures);
- FeatureRenderer myFeatureStyling = alignPanel.getSeqPanel().seqCanvas
- .getFeatureRenderer();
-
- /*
- * copy feature rendering settings to split frame
- */
- newFrame.alignPanel.getSeqPanel().seqCanvas
- .getFeatureRenderer()
- .transferSettings(myFeatureStyling);
- copyThis.alignPanel.getSeqPanel().seqCanvas
- .getFeatureRenderer()
- .transferSettings(myFeatureStyling);
-
- /*
- * apply 'database source' feature configuration
- * if any was found
- */
- // TODO is this the feature colouring for the original
- // alignment or the fetched xrefs? either could be Ensembl
- newFrame.getViewport().applyFeaturesStyle(featureColourScheme);
- copyThis.getViewport().applyFeaturesStyle(featureColourScheme);
-
- SplitFrame sf = new SplitFrame(dna ? copyThis : newFrame,
- dna ? newFrame : copyThis);
- newFrame.setVisible(true);
- copyThis.setVisible(true);
- String linkedTitle = MessageManager
- .getString("label.linked_view_title");
- Desktop.addInternalFrame(sf, linkedTitle, -1, -1);
- sf.adjustDivider();
- }
- } catch (Exception e)
- {
- Cache.log.error("Exception when finding crossreferences", e);
- } catch (OutOfMemoryError e)
- {
- new OOMWarning("whilst fetching crossreferences", e);
- } catch (Throwable e)
- {
- Cache.log.error("Error when finding crossreferences", e);
- } finally
- {
- AlignFrame.this.setProgressBar(MessageManager.formatMessage(
- "status.finished_searching_for_sequences_from",
- new Object[] { source }), sttime);
- }
- }
-
- /**
- * Makes an alignment containing the given sequences. If this is of the
- * same type as the given dataset (nucleotide/protein), then the new
- * alignment shares the same dataset, and its dataset sequences are added
- * to it. Otherwise a new dataset sequence is created for the
- * cross-references.
- *
- * @param dataset
- * @param seqs
- * @return
- */
- protected AlignmentI makeCrossReferencesAlignment(AlignmentI dataset,
- AlignmentI seqs)
- {
- boolean sameType = dataset.isNucleotide() == seqs.isNucleotide();
-
- SequenceI[] sprods = new SequenceI[seqs.getHeight()];
- for (int s = 0; s < sprods.length; s++)
- {
- sprods[s] = (seqs.getSequenceAt(s)).deriveSequence();
- if (sameType)
- {
- if (dataset.getSequences() == null
- || !dataset.getSequences().contains(
- sprods[s].getDatasetSequence()))
- {
- dataset.addSequence(sprods[s].getDatasetSequence());
- }
- }
- sprods[s].updatePDBIds();
- }
- Alignment al = new Alignment(sprods);
- if (sameType)
- {
- al.setDataset((Alignment) dataset);
- }
- else
- {
- al.createDatasetAlignment();
- }
- return al;
- }
-
- };
- Thread frunner = new Thread(foo);
- frunner.start();
+ new Thread(CrossRefAction.showProductsFor(sel, _odna, source, this))
+ .start();
}
/**
.getString("label.error_when_translating_sequences_submit_bug_report");
final String errorTitle = MessageManager
.getString("label.implementation_error")
- + MessageManager.getString("translation_failed");
+ + MessageManager.getString("label.translation_failed");
JOptionPane.showMessageDialog(Desktop.desktop, msg, errorTitle,
JOptionPane.ERROR_MESSAGE);
return;
@Override
public void drop(DropTargetDropEvent evt)
{
+ // JAL-1552 - acceptDrop required before getTransferable call for
+ // Java's Transferable for native dnd
+ evt.acceptDrop(DnDConstants.ACTION_COPY_OR_MOVE);
Transferable t = evt.getTransferable();
java.util.List<String> files = new ArrayList<String>(), protocols = new ArrayList<String>();
}
if (type != null)
{
- if (type.equalsIgnoreCase("PDB"))
+ if (StructureFile.isStructureFile(type))
{
filesmatched.add(new Object[] { file, protocol, mtch });
continue;
this,
MessageManager
.formatMessage(
- "label.automatically_associate_pdb_files_with_sequences_same_name",
+ "label.automatically_associate_structure_files_with_sequences_same_name",
new Object[] { Integer
.valueOf(
filesmatched
.size())
.toString() }),
MessageManager
- .getString("label.automatically_associate_pdb_files_by_name"),
+ .getString("label.automatically_associate_structure_files_by_name"),
JOptionPane.YES_NO_OPTION) == JOptionPane.YES_OPTION)
{
protected void setAnnotationsVisibility(boolean visible,
boolean forSequences, boolean forAlignment)
{
- for (AlignmentAnnotation aa : alignPanel.getAlignment()
- .getAlignmentAnnotation())
+ AlignmentAnnotation[] anns = alignPanel.getAlignment()
+ .getAlignmentAnnotation();
+ if (anns == null)
+ {
+ return;
+ }
+ for (AlignmentAnnotation aa : anns)
{
/*
* don't display non-positional annotations on an alignment
@Override
protected void runGroovy_actionPerformed()
{
- Desktop.setCurrentAlignFrame(this);
+ Jalview.setCurrentAlignFrame(this);
groovy.ui.Console console = Desktop.getGroovyConsole();
if (console != null)
{