X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Fgui%2FAlignFrame.java;h=21f4aace1c861507829d887dacb4df99d861b1ec;hb=3828a47f3ee9549412e04d91cbc1455cada45d01;hp=c5fb11f32b3ae2776df5064c96479eed26fb94bc;hpb=b10330c2e330e409d2fd3812f1001f9542dc1b36;p=jalview.git diff --git a/src/jalview/gui/AlignFrame.java b/src/jalview/gui/AlignFrame.java index c5fb11f..21f4aac 100644 --- a/src/jalview/gui/AlignFrame.java +++ b/src/jalview/gui/AlignFrame.java @@ -2434,7 +2434,10 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener, 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()); } @@ -2457,7 +2460,10 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener, 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(); } @@ -2484,6 +2490,9 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener, { 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()); @@ -2831,7 +2840,7 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener, @Override public void expandViews_actionPerformed(ActionEvent e) { - Desktop.instance.explodeViews(this); + Desktop.explodeViews(this); } /** @@ -4691,8 +4700,8 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener, * @param source * the database to show cross-references for */ - protected void showProductsFor(final SequenceI[] sel, final boolean _odna, - final String source) + protected void showProductsFor(final SequenceI[] sel, + final boolean _odna, final String source) { Runnable foo = new Runnable() { @@ -4711,7 +4720,7 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener, AlignmentI dataset = alignment.getDataset() == null ? alignment : alignment.getDataset(); boolean dna = alignment.isNucleotide(); - if (_odna!=dna) + if (_odna != dna) { System.err .println("Conflict: showProducts for alignment originally " @@ -4720,8 +4729,8 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener, + " now searching for " + (dna ? "DNA" : "Protein") + " Context."); } - AlignmentI xrefs = new CrossRef(sel, dataset) - .findXrefSequences(source, dna); + AlignmentI xrefs = new CrossRef(sel, dataset).findXrefSequences( + source, dna); if (xrefs == null) { return; @@ -4734,100 +4743,113 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener, AlignmentI xrefsAlignment = makeCrossReferencesAlignment(dataset, xrefs); - - AlignFrame newFrame = new AlignFrame(xrefsAlignment, DEFAULT_WIDTH, - DEFAULT_HEIGHT); - if (Cache.getDefault("HIDE_INTRONS", true)) + if (!dna) { - 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 + xrefsAlignment = AlignmentUtils.makeCdsAlignment( + xrefsAlignment.getSequencesArray(), dataset, sel); + xrefsAlignment.alignAs(alignment); } /* - * Make a copy of this alignment (sharing the same dataset + * If we are opening a splitframe, 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) + + if (Cache.getDefault(Preferences.ENABLE_SPLIT_FRAME, true)) { - copyAlignment = AlignmentUtils.makeCdsAlignment( - sequenceSelection, dataset); - if (copyAlignment.getHeight() == 0) + boolean copyAlignmentIsAligned = false; + if (dna) { - System.err.println("Failed to make CDS alignment"); - } + copyAlignment = AlignmentUtils.makeCdsAlignment(sel, dataset, + xrefsAlignment.getSequencesArray()); + if (copyAlignment.getHeight() == 0) + { + JOptionPane.showMessageDialog(AlignFrame.this, + MessageManager.getString("label.cant_map_cds"), + MessageManager.getString("label.operation_failed"), + JOptionPane.OK_OPTION); + System.err.println("Failed to make CDS alignment"); + } - /* - * 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)) + /* + * 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.alignAs(alignment); - copyAlignmentIsAligned = true; + copyAlignment = AlignmentUtils.makeCopyAlignment(sel, + xrefs.getSequencesArray(), dataset); } - } - else - { - copyAlignment = AlignmentUtils.makeCopyAlignment( - sequenceSelection, xrefs.getSequencesArray()); - } - copyAlignment.setGapCharacter(AlignFrame.this.viewport - .getGapCharacter()); + copyAlignment.setGapCharacter(AlignFrame.this.viewport + .getGapCharacter()); - StructureSelectionManager ssm = StructureSelectionManager - .getStructureSelectionManager(Desktop.instance); + StructureSelectionManager ssm = StructureSelectionManager + .getStructureSelectionManager(Desktop.instance); - /* - * register any new mappings for sequence mouseover etc - * (will not duplicate any previously registered mappings) - */ - ssm.registerMappings(dataset.getCodonFrames()); + /* + * register any new mappings for sequence mouseover etc + * (will not duplicate any previously registered mappings) + */ + ssm.registerMappings(dataset.getCodonFrames()); - if (copyAlignment.getHeight() <= 0) - { - System.err.println("No Sequences generated for xRef type " - + source); - return; + if (copyAlignment.getHeight() <= 0) + { + System.err.println("No Sequences generated for xRef type " + + source); + return; + } + /* + * align protein to dna + */ + if (dna && copyAlignmentIsAligned) + { + xrefsAlignment.alignAs(copyAlignment); + } + else + { + /* + * align cdna to protein - currently only if + * fetching and aligning Ensembl transcripts! + */ + // TODO: generalise for other sources of locus/transcript/cds data + if (dna && DBRefSource.ENSEMBL.equalsIgnoreCase(source)) + { + copyAlignment.alignAs(xrefsAlignment); + } + } } /* - * align protein to dna + * build AlignFrame(s) according to available alignment data */ - if (dna && copyAlignmentIsAligned) + AlignFrame newFrame = new AlignFrame(xrefsAlignment, + DEFAULT_WIDTH, DEFAULT_HEIGHT); + if (Cache.getDefault("HIDE_INTRONS", true)) { - xrefsAlignment.alignAs(copyAlignment); + newFrame.hideFeatureColumns(SequenceOntologyI.EXON, false); } - else + String newtitle = String.format("%s %s %s", MessageManager + .getString(dna ? "label.proteins" : "label.nucleotides"), + MessageManager.getString("label.for"), getTitle()); + newFrame.setTitle(newtitle); + + if (copyAlignment == null) { /* - * align cdna to protein - currently only if - * fetching and aligning Ensembl transcripts! + * split frame display is turned off in preferences file */ - if (DBRefSource.ENSEMBL.equalsIgnoreCase(source)) - { - copyAlignment.alignAs(xrefsAlignment); - } + Desktop.addInternalFrame(newFrame, newtitle, DEFAULT_WIDTH, + DEFAULT_HEIGHT); + return; // via finally clause } - AlignFrame copyThis = new AlignFrame(copyAlignment, AlignFrame.DEFAULT_WIDTH, AlignFrame.DEFAULT_HEIGHT); copyThis.setTitle(AlignFrame.this.getTitle()); @@ -4881,6 +4903,8 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener, * Makes an alignment containing the given sequences, and adds them to the * given dataset, which is also set as the dataset for the new alignment * + * TODO: refactor to DatasetI method + * * @param dataset * @param seqs * @return @@ -5950,8 +5974,13 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener, 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