JAL-2386 JAL-2570 use ResidueShader copy constructor in SequenceGroup bug/JAL-2386groupConservationColouring
authorgmungoc <g.m.carstairs@dundee.ac.uk>
Thu, 8 Jun 2017 14:19:04 +0000 (15:19 +0100)
committergmungoc <g.m.carstairs@dundee.ac.uk>
Thu, 8 Jun 2017 14:19:04 +0000 (15:19 +0100)
copy constructor for 'like but yet unlike' colouring of new group

src/jalview/datamodel/SequenceGroup.java
src/jalview/renderer/ResidueShader.java
test/jalview/datamodel/SequenceGroupTest.java

index a8d0a36..46c802f 100755 (executable)
@@ -188,7 +188,7 @@ public class SequenceGroup implements AnnotatedCollectionI
       colourText = seqsel.colourText;
       startRes = seqsel.startRes;
       endRes = seqsel.endRes;
-      cs = seqsel.cs;// new ResidueShader(seqsel.getColourScheme());
+      cs = new ResidueShader((ResidueShader) seqsel.cs);
       if (seqsel.description != null)
       {
         description = new String(seqsel.description);
index b6f7fe6..8ecb2ad 100644 (file)
@@ -96,6 +96,20 @@ public class ResidueShader implements ResidueShaderI
   }
 
   /**
+   * Copy constructor
+   */
+  public ResidueShader(ResidueShader rs)
+  {
+    this.colourScheme = rs.colourScheme;
+    this.consensus = rs.consensus;
+    this.conservation = rs.conservation;
+    this.conservationColouring = rs.conservationColouring;
+    this.conservationIncrement = rs.conservationIncrement;
+    this.ignoreGaps = rs.ignoreGaps;
+    this.pidThreshold = rs.pidThreshold;
+  }
+
+  /**
    * @see jalview.renderer.ResidueShaderI#setConsensus(jalview.datamodel.ProfilesI)
    */
   @Override
index 80790ed..b0af5c8 100644 (file)
@@ -9,10 +9,12 @@ import static org.testng.Assert.assertSame;
 import static org.testng.Assert.assertTrue;
 import static org.testng.Assert.fail;
 
+import jalview.analysis.Conservation;
 import jalview.schemes.NucleotideColourScheme;
 import jalview.schemes.PIDColourScheme;
 
 import java.awt.Color;
+import java.util.Collections;
 
 import junit.extensions.PA;
 
@@ -232,6 +234,11 @@ public class SequenceGroupTest
     sg.setName("g1");
     sg.setDescription("desc");
     sg.setColourScheme(new PIDColourScheme());
+    Conservation cons = new Conservation("Cons", 2,
+            Collections.<SequenceI> emptyList(), 3, 12);
+    PA.setValue(cons, "consSequence", new Sequence("s", "abc"));
+    sg.getGroupColourScheme().setConservation(cons);
+    sg.getGroupColourScheme().setConsensus(new Profiles(null));
     sg.setDisplayBoxes(false);
     sg.setDisplayText(false);
     sg.setColourText(true);
@@ -253,8 +260,12 @@ public class SequenceGroupTest
     SequenceGroup sg2 = new SequenceGroup(sg);
     assertEquals(sg2.getName(), sg.getName());
     assertEquals(sg2.getDescription(), sg.getDescription());
-    assertSame(sg2.getGroupColourScheme(), sg.getGroupColourScheme());
+    assertNotSame(sg2.getGroupColourScheme(), sg.getGroupColourScheme());
     assertSame(sg2.getColourScheme(), sg.getColourScheme());
+    assertSame(PA.getValue(sg2.getGroupColourScheme(), "consensus"),
+            PA.getValue(sg.getGroupColourScheme(), "consensus"));
+    assertSame(PA.getValue(sg2.getGroupColourScheme(), "conservation"),
+            PA.getValue(sg.getGroupColourScheme(), "conservation"));
     assertEquals(sg2.getDisplayBoxes(), sg.getDisplayBoxes());
     assertEquals(sg2.getDisplayText(), sg.getDisplayText());
     assertEquals(sg2.getColourText(), sg.getColourText());