From 2ac096ecd8ee1a5c11480e864fce7cf78d661c66 Mon Sep 17 00:00:00 2001 From: jprocter Date: Thu, 29 Apr 2010 15:03:07 +0000 Subject: [PATCH] isAligned assertion (bug 0008144) --- src/jalview/appletgui/AlignFrame.java | 4 ++-- src/jalview/datamodel/Alignment.java | 23 ++++++++++++++++------- src/jalview/datamodel/AlignmentI.java | 9 +++++++-- src/jalview/gui/AlignFrame.java | 6 +++--- src/jalview/io/VamsasAppDatastore.java | 2 +- 5 files changed, 29 insertions(+), 15 deletions(-) diff --git a/src/jalview/appletgui/AlignFrame.java b/src/jalview/appletgui/AlignFrame.java index 1330cf6..1b2088e 100755 --- a/src/jalview/appletgui/AlignFrame.java +++ b/src/jalview/appletgui/AlignFrame.java @@ -2288,7 +2288,7 @@ public class AlignFrame extends EmbmenuFrame implements ActionListener, public void PCAMenuItem_actionPerformed() { // are the sequences aligned? - if (!viewport.alignment.isAligned()) + if (!viewport.alignment.isAligned(false)) { SequenceI current; int Width = viewport.getAlignment().getWidth(); @@ -2345,7 +2345,7 @@ public class AlignFrame extends EmbmenuFrame implements ActionListener, void NewTreePanel(String type, String pwType, String title) { // are the sequences aligned? - if (!viewport.alignment.isAligned()) + if (!viewport.alignment.isAligned(false)) { SequenceI current; int Width = viewport.getAlignment().getWidth(); diff --git a/src/jalview/datamodel/Alignment.java b/src/jalview/datamodel/Alignment.java index dc70c47..7fb4659 100755 --- a/src/jalview/datamodel/Alignment.java +++ b/src/jalview/datamodel/Alignment.java @@ -607,20 +607,29 @@ public class Alignment implements AlignmentI return gapCharacter; } - /** - * DOCUMENT ME! - * - * @return DOCUMENT ME! + /* (non-Javadoc) + * @see jalview.datamodel.AlignmentI#isAligned() */ public boolean isAligned() { + return isAligned(false); + } + /* (non-Javadoc) + * @see jalview.datamodel.AlignmentI#isAligned(boolean) + */ + public boolean isAligned(boolean includeHidden) { int width = getWidth(); - + if (hiddenSequences==null || hiddenSequences.getSize()==0) { + includeHidden = true; // no hidden sequences to check against. + } for (int i = 0; i < sequences.size(); i++) { - if (getSequenceAt(i).getLength() != width) + if (includeHidden || !hiddenSequences.isHidden(getSequenceAt(i))) { - return false; + if (getSequenceAt(i).getLength() != width) + { + return false; + } } } diff --git a/src/jalview/datamodel/AlignmentI.java b/src/jalview/datamodel/AlignmentI.java index 186136f..9f13342 100755 --- a/src/jalview/datamodel/AlignmentI.java +++ b/src/jalview/datamodel/AlignmentI.java @@ -40,12 +40,17 @@ public interface AlignmentI public int getWidth(); /** - * Calculates if this set of sequences is all the same length + * Calculates if this set of sequences (visible and invisible) are all the same length * * @return true if all sequences in alignment are the same length */ public boolean isAligned(); - + /** + * Calculates if this set of sequences is all the same length + * @param includeHidden optionally exclude hidden sequences from test + * @return true if all (or just visible) sequences are the same length + */ + public boolean isAligned(boolean includeHidden); /** * Gets sequences as a Vector * diff --git a/src/jalview/gui/AlignFrame.java b/src/jalview/gui/AlignFrame.java index 3e57430..f9b6413 100755 --- a/src/jalview/gui/AlignFrame.java +++ b/src/jalview/gui/AlignFrame.java @@ -3365,8 +3365,8 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener, } else { - // are the sequences aligned? - if (!viewport.alignment.isAligned()) + // are the visible sequences aligned? + if (!viewport.alignment.isAligned(false)) { JOptionPane .showMessageDialog( @@ -3635,7 +3635,7 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener, // jobs // TODO: viewport.alignment.isAligned is a global state - the local // selection may well be aligned - we preserve 2.0.8 behaviour for moment. - if (!viewport.alignment.isAligned()) + if (!viewport.alignment.isAligned(false)) { seqs.setSequences(new SeqCigar[] { seqs.getSequences()[0] }); diff --git a/src/jalview/io/VamsasAppDatastore.java b/src/jalview/io/VamsasAppDatastore.java index e313470..ac00b33 100644 --- a/src/jalview/io/VamsasAppDatastore.java +++ b/src/jalview/io/VamsasAppDatastore.java @@ -717,7 +717,7 @@ public class VamsasAppDatastore /** * very quick test to see if the viewport would be stored in the vamsas document. - * Reasons for not storing include the unaligned flag being false. + * Reasons for not storing include the unaligned flag being false (for all sequences, including the hidden ones!) * @param av * @return true if alignment associated with this view will be stored in document. */ -- 1.7.10.2