X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Fgui%2FAlignFrame.java;h=cb769bb0176afda5d1da366a34069b3e0ce892a3;hb=007af0c9001900071f6d8e9214143f79e10f4938;hp=5e151954e0c9378a1eda09d15149f4365f10e9a2;hpb=0611a46a5652c852426da0d024bb43e0756501c7;p=jalview.git diff --git a/src/jalview/gui/AlignFrame.java b/src/jalview/gui/AlignFrame.java index 5e15195..cb769bb 100644 --- a/src/jalview/gui/AlignFrame.java +++ b/src/jalview/gui/AlignFrame.java @@ -32,6 +32,7 @@ import jalview.api.AlignViewControllerI; 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; @@ -53,6 +54,7 @@ import jalview.datamodel.AlignmentI; 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; @@ -94,6 +96,9 @@ 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; @@ -131,7 +136,6 @@ import java.util.Deque; import java.util.Enumeration; import java.util.Hashtable; import java.util.List; -import java.util.Set; import java.util.Vector; import javax.swing.JCheckBoxMenuItem; @@ -828,6 +832,8 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener, public void setGUINucleotide(boolean nucleotide) { showTranslation.setVisible(nucleotide); + showReverse.setVisible(nucleotide); + showReverseComplement.setVisible(nucleotide); conservationMenuItem.setEnabled(!nucleotide); modifyConservation.setEnabled(!nucleotide); showGroupConservation.setEnabled(!nucleotide); @@ -903,7 +909,9 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener, rnahelicesColour.setEnabled(av.getAlignment().hasRNAStructure()); rnahelicesColour .setSelected(av.getGlobalColourScheme() instanceof jalview.schemes.RNAHelicesColour); - setShowProductsEnabled(); + + showProducts.setEnabled(canShowProducts()); + updateEditMenuBar(); } @@ -959,7 +967,7 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener, @Override public void fetchSequence_actionPerformed(ActionEvent e) { - new SequenceFetcher(this); + new jalview.gui.SequenceFetcher(this); } @Override @@ -1268,13 +1276,11 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener, AlignmentI alignmentToExport = null; AlignExportSettingI settings = exportSettings; String[] omitHidden = null; - int[] alignmentStartEnd = new int[2]; HiddenSequences hiddenSeqs = viewport.getAlignment() .getHiddenSequences(); alignmentToExport = viewport.getAlignment(); - alignmentStartEnd = new int[] { 0, alignmentToExport.getWidth() - 1 }; boolean hasHiddenSeqs = hiddenSeqs.getSize() > 0; if (settings == null) @@ -1289,6 +1295,7 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener, omitHidden = viewport.getViewAsString(false); } + int[] alignmentStartEnd = new int[2]; if (hasHiddenSeqs && settings.isExportHiddenSequences()) { alignmentToExport = hiddenSeqs.getFullAlignment(); @@ -1296,7 +1303,9 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener, else { alignmentToExport = viewport.getAlignment(); - alignmentStartEnd = getStartEnd(alignmentStartEnd, viewport + alignmentStartEnd = viewport.getAlignment() + .getVisibleStartAndEndIndex( + viewport .getColumnSelection().getHiddenColumns()); } AlignmentExportData ed = new AlignmentExportData(alignmentToExport, @@ -1304,55 +1313,6 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener, return ed; } - public static int[] getStartEnd(int[] aligmentStartEnd, - List hiddenCols) - { - int startPos = aligmentStartEnd[0]; - int endPos = aligmentStartEnd[1]; - - int[] lowestRange = new int[] { -1, -1 }; - int[] higestRange = new int[] { -1, -1 }; - - for (int[] hiddenCol : hiddenCols) - { - lowestRange = (hiddenCol[0] <= startPos) ? hiddenCol : lowestRange; - higestRange = (hiddenCol[1] >= endPos) ? hiddenCol : higestRange; - } - - if (lowestRange[0] == -1 && lowestRange[1] == -1) - { - startPos = aligmentStartEnd[0]; - } - else - { - startPos = lowestRange[1] + 1; - } - - if (higestRange[0] == -1 && higestRange[1] == -1) - { - endPos = aligmentStartEnd[1]; - } - else - { - endPos = higestRange[0] - 1; - } - - // System.out.println("Export range : " + startPos + " - " + endPos); - return new int[] { startPos, endPos }; - } - - public static void main(String[] args) - { - ArrayList hiddenCols = new ArrayList(); - hiddenCols.add(new int[] { 0, 0 }); - hiddenCols.add(new int[] { 6, 9 }); - hiddenCols.add(new int[] { 11, 12 }); - hiddenCols.add(new int[] { 33, 33 }); - hiddenCols.add(new int[] { 50, 50 }); - - int[] x = getStartEnd(new int[] { 0, 50 }, hiddenCols); - // System.out.println("Export range : " + x[0] + " - " + x[1]); - } /** * DOCUMENT ME! @@ -1369,7 +1329,7 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener, @Override public void bioJSMenuItem_actionPerformed(ActionEvent e) { - BioJsHTMLOutput bjs = new BioJsHTMLOutput(alignPanel); + BioJsHTMLOutput bjs = new BioJsHTMLOutput(alignPanel, this); bjs.exportJalviewAlignmentAsBioJsHtmlFile(); } @@ -1980,7 +1940,7 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener, return; } - format = new IdentifyFile().Identify(str, "Paste"); + format = new IdentifyFile().identify(str, "Paste"); } catch (OutOfMemoryError er) { @@ -2547,7 +2507,7 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener, ColumnSelection colSel = viewport.getColumnSelection(); int column; - if (colSel.size() > 0) + if (!colSel.isEmpty()) { if (trimLeft) { @@ -2966,6 +2926,7 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener, { viewport.showAllHiddenColumns(); repaint(); + viewport.sendSelection(); } @Override @@ -3056,6 +3017,7 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener, public void hideAllButSelection_actionPerformed(ActionEvent e) { toggleHiddenRegions(false, false); + viewport.sendSelection(); } /* @@ -3073,6 +3035,7 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener, viewport.hideAllSelectedSeqs(); viewport.hideSelectedColumns(); alignPanel.paintAlignment(true); + viewport.sendSelection(); } /* @@ -3088,6 +3051,7 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener, viewport.showAllHiddenColumns(); viewport.showAllHiddenSeqs(); alignPanel.paintAlignment(true); + viewport.sendSelection(); } @Override @@ -3095,6 +3059,7 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener, { viewport.hideSelectedColumns(); alignPanel.paintAlignment(true); + viewport.sendSelection(); } @Override @@ -4646,67 +4611,27 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener, } } - /* - * 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); } } - */ /** - * prototype of an automatically enabled/disabled analysis function + * Searches selected sequences for xRef products and builds the Show + * Cross-References menu (formerly called Show Products) * + * @return true if Show Cross-references menu should be enabled. */ - protected void setShowProductsEnabled() + public boolean canShowProducts() { SequenceI[] selection = viewport.getSequenceSelection(); - if (canShowProducts(selection, viewport.getSelectionGroup() != null, - viewport.getAlignment().getDataset())) - { - showProducts.setEnabled(true); - - } - else - { - showProducts.setEnabled(false); - } - } - - /** - * search selection for sequence xRef products and build the show products - * menu. - * - * @param selection - * @param dataset - * @return true if showProducts menu should be enabled. - */ - public boolean canShowProducts(SequenceI[] selection, - boolean isRegionSelection, Alignment dataset) - { + AlignmentI dataset = viewport.getAlignment().getDataset(); boolean showp = false; try { showProducts.removeAll(); final boolean dna = viewport.getAlignment().isNucleotide(); - final Alignment ds = dataset; String[] ptypes = (selection == null || selection.length == 0) ? null : CrossRef.findSequenceXrefTypes(dna, selection, dataset); - // Object[] prods = - // CrossRef.buildXProductsList(viewport.getAlignment().isNucleotide(), - // selection, dataset, true); - final SequenceI[] sel = selection; + for (int t = 0; ptypes != null && t < ptypes.length; t++) { showp = true; - final boolean isRegSel = isRegionSelection; final AlignFrame af = this; final String source = ptypes[t]; JMenuItem xtype = new JMenuItem(ptypes[t]); @@ -4716,9 +4641,7 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener, @Override public void actionPerformed(ActionEvent e) { - // TODO: new thread for this call with vis-delay - af.showProductsFor(af.viewport.getSequenceSelection(), - isRegSel, dna, source); + showProductsFor(af.viewport.getSequenceSelection(), dna, source); } }); @@ -4729,15 +4652,15 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener, } catch (Exception e) { jalview.bin.Cache.log - .warn("canTranslate threw an exception - please report to help@jalview.org", + .warn("canShowProducts threw an exception - please report to help@jalview.org", e); return false; } return showp; } - protected void showProductsFor(final SequenceI[] sel, - final boolean isRegSel, final boolean dna, final String source) + protected void showProductsFor(final SequenceI[] sel, final boolean dna, + final String source) { Runnable foo = new Runnable() { @@ -4751,111 +4674,208 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener, new Object[] { source }), sttime); try { - // update our local dataset reference - Alignment ds = AlignFrame.this.getViewport().getAlignment() - .getDataset(); - Alignment prods = CrossRef - .findXrefSequences(sel, dna, source, ds); - if (prods != null) + AlignmentI alignment = AlignFrame.this.getViewport() + .getAlignment(); + AlignmentI xrefs = CrossRef.findXrefSequences(sel, dna, source, + alignment); + if (xrefs != null) { - SequenceI[] sprods = new SequenceI[prods.getHeight()]; - for (int s = 0; s < sprods.length; s++) + /* + * 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); + 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)) { - sprods[s] = (prods.getSequenceAt(s)).deriveSequence(); - if (ds.getSequences() == null - || !ds.getSequences().contains( - sprods[s].getDatasetSequence())) + /* + * 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 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.getCodonFrames().addAll(copyAlignment.getCodonFrames()); + + /* + * 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)) { - ds.addSequence(sprods[s].getDatasetSequence()); + copyAlignment.alignAs(alignment); + copyAlignmentIsAligned = true; } - sprods[s].updatePDBIds(); } - Alignment al = new Alignment(sprods); - al.setDataset(ds); + else + { + copyAlignment = AlignmentUtils.makeCopyAlignment( + sequenceSelection, xrefs.getSequencesArray()); + copyAlignment.getCodonFrames().addAll(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; + } /* - * Copy dna-to-protein mappings to new alignment + * align protein to dna */ - // TODO 1: no mappings are set up for EMBL product - // TODO 2: if they were, should add them to protein alignment, not - // dna - Set cf = prods.getCodonFrames(); - for (AlignedCodonFrame acf : cf) + if (dna && copyAlignmentIsAligned) { - al.addCodonFrame(acf); + al.alignAs(copyAlignment); } - AlignFrame naf = new AlignFrame(al, DEFAULT_WIDTH, - DEFAULT_HEIGHT); - String newtitle = "" + ((dna) ? "Proteins" : "Nucleotides") - + " for " + ((isRegSel) ? "selected region of " : "") - + getTitle(); - naf.setTitle(newtitle); - - // temporary flag until SplitFrame is released - boolean asSplitFrame = Cache.getDefault( - Preferences.ENABLE_SPLIT_FRAME, true); - if (asSplitFrame) + else { /* - * Make a copy of this alignment (sharing the same dataset - * sequences). If we are DNA, drop introns and update mappings + * align cdna to protein - currently only if + * fetching and aligning Ensembl transcripts! */ - AlignmentI copyAlignment = null; - final SequenceI[] sequenceSelection = AlignFrame.this.viewport - .getSequenceSelection(); - if (dna) - { - copyAlignment = AlignmentUtils.makeExonAlignment( - sequenceSelection, cf); - al.getCodonFrames().clear(); - al.getCodonFrames().addAll(cf); - final StructureSelectionManager ssm = StructureSelectionManager - .getStructureSelectionManager(Desktop.instance); - ssm.registerMappings(cf); - } - else + if (DBRefSource.ENSEMBL.equalsIgnoreCase(source)) { - copyAlignment = new Alignment(new Alignment( - sequenceSelection)); + copyAlignment.alignAs(al); } - AlignFrame copyThis = new AlignFrame(copyAlignment, - AlignFrame.DEFAULT_WIDTH, AlignFrame.DEFAULT_HEIGHT); - copyThis.setTitle(AlignFrame.this.getTitle()); - // SplitFrame with dna above, protein below - SplitFrame sf = new SplitFrame(dna ? copyThis : naf, - dna ? naf : copyThis); - naf.setVisible(true); - copyThis.setVisible(true); - String linkedTitle = MessageManager - .getString("label.linked_view_title"); - Desktop.addInternalFrame(sf, linkedTitle, -1, -1); - } - else - { - Desktop.addInternalFrame(naf, newtitle, DEFAULT_WIDTH, - DEFAULT_HEIGHT); } - } - else - { - System.err.println("No Sequences generated for xRef type " - + source); + + 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) { - jalview.bin.Cache.log.error( + Cache.log.error( "Exception when finding crossreferences", e); } catch (OutOfMemoryError e) { new OOMWarning("whilst fetching crossreferences", e); - } catch (Error e) + } catch (Throwable e) { - jalview.bin.Cache.log.error("Error when finding crossreferences", + Cache.log.error("Error when finding crossreferences", e); + } finally + { + AlignFrame.this.setProgressBar(MessageManager.formatMessage( + "status.finished_searching_for_sequences_from", + new Object[] { source }), sttime); } - 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; } }; @@ -4863,23 +4883,6 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener, frunner.start(); } - public boolean canShowTranslationProducts(SequenceI[] selection, - AlignmentI alignment) - { - // old way - try - { - 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", - e); - return false; - } - } - /** * Construct and display a new frame containing the translation of this * frame's DNA sequences to their aligned protein (amino acid) equivalents. @@ -5097,7 +5100,7 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener, String type = null; try { - type = new IdentifyFile().Identify(file, protocol); + type = new IdentifyFile().identify(file, protocol); } catch (Exception ex) { type = null; @@ -5196,7 +5199,7 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener, /** * 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 + * it's an 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. * @@ -5210,7 +5213,7 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener, { if (protocol == null) { - protocol = jalview.io.FormatAdapter.checkProtocol(file); + protocol = FormatAdapter.checkProtocol(file); } // if the file isn't identified, or not positively identified as some // other filetype (PFAM is default unidentified alignment file type) then @@ -5271,7 +5274,7 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener, // try to parse it as a features file if (format == null) { - format = new IdentifyFile().Identify(file, protocol); + format = new IdentifyFile().identify(file, protocol); } if (format.equalsIgnoreCase("JnetFile")) { @@ -5287,42 +5290,17 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener, viewport.setColumnSelection(cs); isAnnotation = true; } - else + else if (IdentifyFile.FeaturesFile.equals(format)) { - /* - * 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 - // alignment file to load into the current view. - if (!isGroupsFile) - { - new FileLoader().LoadFile(viewport, file, protocol, format); - } - else + if (parseFeaturesFile(file, protocol)) { alignPanel.paintAlignment(true); } } + else + { + new FileLoader().LoadFile(viewport, file, protocol, format); + } } } if (isAnnotation) @@ -5344,7 +5322,6 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener, } catch (Exception x) { } - ; new OOMWarning( "loading data " + (protocol != null ? (protocol.equals(FormatAdapter.PASTE) ? "from clipboard." @@ -5527,18 +5504,23 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener, { new Thread(new Runnable() { - @Override public void run() { - boolean isNuclueotide = alignPanel.alignFrame - .getViewport().getAlignment() - .isNucleotide(); - new jalview.ws.DBRefFetcher(alignPanel.av - .getSequenceSelection(), - alignPanel.alignFrame, null, - alignPanel.alignFrame.featureSettings, - isNuclueotide) + boolean isNucleotide = alignPanel.alignFrame.getViewport() + .getAlignment().isNucleotide(); + DBRefFetcher dbRefFetcher = new DBRefFetcher(alignPanel.av + .getSequenceSelection(), alignPanel.alignFrame, null, + alignPanel.alignFrame.featureSettings, isNucleotide); + dbRefFetcher.addListener(new FetchFinishedListenerI() + { + @Override + public void finished() + { + AlignFrame.this.setMenusForViewport(); + } + }); + dbRefFetcher .fetchDBRefs(false); } }).start(); @@ -5553,7 +5535,7 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener, @Override public void run() { - final jalview.ws.SequenceFetcher sf = SequenceFetcher + final jalview.ws.SequenceFetcher sf = jalview.gui.SequenceFetcher .getSequenceFetcherSingleton(me); javax.swing.SwingUtilities.invokeLater(new Runnable() { @@ -5607,15 +5589,24 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener, @Override public void run() { - boolean isNuclueotide = alignPanel.alignFrame + boolean isNucleotide = alignPanel.alignFrame .getViewport().getAlignment() .isNucleotide(); - new jalview.ws.DBRefFetcher(alignPanel.av - .getSequenceSelection(), + DBRefFetcher dbRefFetcher = new DBRefFetcher( + alignPanel.av.getSequenceSelection(), alignPanel.alignFrame, dassource, alignPanel.alignFrame.featureSettings, - isNuclueotide) - .fetchDBRefs(false); + isNucleotide); + dbRefFetcher + .addListener(new FetchFinishedListenerI() + { + @Override + public void finished() + { + AlignFrame.this.setMenusForViewport(); + } + }); + dbRefFetcher.fetchDBRefs(false); } }).start(); } @@ -5648,15 +5639,24 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener, @Override public void run() { - boolean isNuclueotide = alignPanel.alignFrame + boolean isNucleotide = alignPanel.alignFrame .getViewport().getAlignment() .isNucleotide(); - new jalview.ws.DBRefFetcher(alignPanel.av - .getSequenceSelection(), + DBRefFetcher dbRefFetcher = new DBRefFetcher( + alignPanel.av.getSequenceSelection(), alignPanel.alignFrame, dassource, alignPanel.alignFrame.featureSettings, - isNuclueotide) - .fetchDBRefs(false); + isNucleotide); + dbRefFetcher + .addListener(new FetchFinishedListenerI() + { + @Override + public void finished() + { + AlignFrame.this.setMenusForViewport(); + } + }); + dbRefFetcher.fetchDBRefs(false); } }).start(); } @@ -5704,15 +5704,24 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener, @Override public void run() { - boolean isNuclueotide = alignPanel.alignFrame + boolean isNucleotide = alignPanel.alignFrame .getViewport().getAlignment() .isNucleotide(); - new jalview.ws.DBRefFetcher(alignPanel.av - .getSequenceSelection(), + DBRefFetcher dbRefFetcher = new DBRefFetcher( + alignPanel.av.getSequenceSelection(), alignPanel.alignFrame, dassrc, alignPanel.alignFrame.featureSettings, - isNuclueotide) - .fetchDBRefs(false); + isNucleotide); + dbRefFetcher + .addListener(new FetchFinishedListenerI() + { + @Override + public void finished() + { + AlignFrame.this.setMenusForViewport(); + } + }); + dbRefFetcher.fetchDBRefs(false); } }).start(); } @@ -6003,7 +6012,7 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener, { // TODO no longer a menu action - refactor as required final AlignmentI alignment = getViewport().getAlignment(); - Set mappings = alignment.getCodonFrames(); + List mappings = alignment.getCodonFrames(); if (mappings == null) { return; @@ -6058,6 +6067,27 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener, sf.setComplementVisible(this, show); } } + + /** + * Generate the reverse (optionally complemented) of the selected sequences, + * and add them to the alignment + */ + @Override + protected void showReverse_actionPerformed(boolean complement) + { + AlignmentI al = null; + try + { + Dna dna = new Dna(viewport, viewport.getViewAsVisibleContigs(true)); + + al = dna.reverseCdna(complement); + viewport.addAlignment(al, ""); + } catch (Exception ex) + { + System.err.println(ex.getMessage()); + return; + } + } } class PrintThread extends Thread