From 3b239d86dc3a1bf3aa07c0ad3d38aeca57b54ada Mon Sep 17 00:00:00 2001 From: gmungoc Date: Tue, 30 May 2017 10:26:46 +0100 Subject: [PATCH] JAL-2570 don't zap group colour scheme when mapping over split frame --- src/jalview/datamodel/SequenceGroup.java | 52 +++++++++--------- test/jalview/datamodel/SequenceGroupTest.java | 73 ++++++++++++++++++++++++- 2 files changed, 98 insertions(+), 27 deletions(-) diff --git a/src/jalview/datamodel/SequenceGroup.java b/src/jalview/datamodel/SequenceGroup.java index 8c29ca5..463b909 100755 --- a/src/jalview/datamodel/SequenceGroup.java +++ b/src/jalview/datamodel/SequenceGroup.java @@ -110,13 +110,23 @@ public class SequenceGroup implements AnnotatedCollectionI */ private boolean normaliseSequenceLogo; - /** - * @return the includeAllConsSymbols + /* + * visibility of rows or represented rows covered by group */ - public boolean isShowSequenceLogo() - { - return showSequenceLogo; - } + private boolean hidereps = false; + + /* + * visibility of columns intersecting this group + */ + private boolean hidecols = false; + + AlignmentAnnotation consensus = null; + + AlignmentAnnotation conservation = null; + + private boolean showConsensusHistogram; + + private AnnotatedCollectionI context; /** * Creates a new SequenceGroup object. @@ -178,13 +188,17 @@ public class SequenceGroup implements AnnotatedCollectionI colourText = seqsel.colourText; startRes = seqsel.startRes; endRes = seqsel.endRes; - cs = seqsel.cs; + cs = new ResidueShader(seqsel.getColourScheme()); if (seqsel.description != null) { description = new String(seqsel.description); } hidecols = seqsel.hidecols; hidereps = seqsel.hidereps; + showNonconserved = seqsel.showNonconserved; + showSequenceLogo = seqsel.showSequenceLogo; + normaliseSequenceLogo = seqsel.normaliseSequenceLogo; + showConsensusHistogram = seqsel.showConsensusHistogram; idColour = seqsel.idColour; outlineColour = seqsel.outlineColour; seqrep = seqsel.seqrep; @@ -201,6 +215,11 @@ public class SequenceGroup implements AnnotatedCollectionI } } + public boolean isShowSequenceLogo() + { + return showSequenceLogo; + } + public SequenceI[] getSelectionAsNewSequences(AlignmentI align) { int iSize = sequences.size(); @@ -957,11 +976,6 @@ public class SequenceGroup implements AnnotatedCollectionI } /** - * visibility of rows or represented rows covered by group - */ - private boolean hidereps = false; - - /** * set visibility of sequences covered by (if no sequence representative is * defined) or represented by this group. * @@ -983,11 +997,6 @@ public class SequenceGroup implements AnnotatedCollectionI } /** - * visibility of columns intersecting this group - */ - private boolean hidecols = false; - - /** * set intended visibility of columns covered by this group * * @param visibility @@ -1049,13 +1058,6 @@ public class SequenceGroup implements AnnotatedCollectionI this.showNonconserved = displayNonconserved; } - AlignmentAnnotation consensus = null, conservation = null; - - /** - * flag indicating if consensus histogram should be rendered - */ - private boolean showConsensusHistogram; - /** * set this alignmentAnnotation object as the one used to render consensus * annotation @@ -1346,8 +1348,6 @@ public class SequenceGroup implements AnnotatedCollectionI } } - private AnnotatedCollectionI context; - /** * Sets the alignment or group context for this group, and whether it is * defined as a group diff --git a/test/jalview/datamodel/SequenceGroupTest.java b/test/jalview/datamodel/SequenceGroupTest.java index 7837b49..f6d4028 100644 --- a/test/jalview/datamodel/SequenceGroupTest.java +++ b/test/jalview/datamodel/SequenceGroupTest.java @@ -3,17 +3,21 @@ package jalview.datamodel; import static org.testng.Assert.assertEquals; import static org.testng.Assert.assertFalse; import static org.testng.Assert.assertNotNull; +import static org.testng.Assert.assertNotSame; import static org.testng.Assert.assertNull; import static org.testng.Assert.assertSame; import static org.testng.Assert.assertTrue; import static org.testng.Assert.fail; import jalview.schemes.NucleotideColourScheme; +import jalview.schemes.PIDColourScheme; -import org.testng.annotations.Test; +import java.awt.Color; import junit.extensions.PA; +import org.testng.annotations.Test; + public class SequenceGroupTest { @Test(groups={"Functional"}) @@ -217,6 +221,73 @@ public class SequenceGroupTest assertTrue(sg2.contains(seq2, 8)); sg2.deleteSequence(seq2, false); assertFalse(sg2.contains(seq2)); + } + + @Test(groups = { "Functional" }) + public void testCopyConstructor() + { + SequenceI seq = new Sequence("seq", "ABC"); + SequenceGroup sg = new SequenceGroup(); + sg.addSequence(seq, false); + sg.setName("g1"); + sg.setDescription("desc"); + sg.setColourScheme(new PIDColourScheme()); + sg.setDisplayBoxes(false); + sg.setDisplayText(false); + sg.setColourText(true); + sg.isDefined = true; + sg.setShowNonconserved(true); + sg.setOutlineColour(Color.red); + sg.setIdColour(Color.blue); + sg.thresholdTextColour = 1; + sg.textColour = Color.orange; + sg.textColour2 = Color.yellow; + sg.setIgnoreGapsConsensus(false); + sg.setshowSequenceLogo(true); + sg.setNormaliseSequenceLogo(true); + sg.setHidereps(true); + sg.setHideCols(true); + sg.setShowConsensusHistogram(true); + sg.setContext(new SequenceGroup()); + + SequenceGroup sg2 = new SequenceGroup(sg); + assertEquals(sg2.getName(), sg.getName()); + assertEquals(sg2.getDescription(), sg.getDescription()); + assertNotSame(sg2.getGroupColourScheme(), sg.getGroupColourScheme()); + assertSame(sg2.getColourScheme(), sg.getColourScheme()); + assertEquals(sg2.getDisplayBoxes(), sg.getDisplayBoxes()); + assertEquals(sg2.getDisplayText(), sg.getDisplayText()); + assertEquals(sg2.getColourText(), sg.getColourText()); + assertEquals(sg2.getShowNonconserved(), sg.getShowNonconserved()); + assertEquals(sg2.getOutlineColour(), sg.getOutlineColour()); + assertEquals(sg2.getIdColour(), sg.getIdColour()); + assertEquals(sg2.thresholdTextColour, sg.thresholdTextColour); + assertEquals(sg2.textColour, sg.textColour); + assertEquals(sg2.textColour2, sg.textColour2); + assertEquals(sg2.getIgnoreGapsConsensus(), sg.getIgnoreGapsConsensus()); + assertEquals(sg2.isShowSequenceLogo(), sg.isShowSequenceLogo()); + assertEquals(sg2.isNormaliseSequenceLogo(), + sg.isNormaliseSequenceLogo()); + assertEquals(sg2.isHidereps(), sg.isHidereps()); + assertEquals(sg2.isHideCols(), sg.isHideCols()); + assertEquals(sg2.isShowConsensusHistogram(), + sg.isShowConsensusHistogram()); + /* + * copy of sequences + */ + assertNotSame(sg2.getSequences(), sg.getSequences()); + assertEquals(sg2.getSequences(), sg.getSequences()); + + /* + * isDefined should only be set true when a new group is added to + * an alignment, not in the copy constructor + */ + assertFalse(sg2.isDefined()); + + /* + * context should be set explicitly, not by copy + */ + assertNull(sg2.getContext()); } } -- 1.7.10.2