68f02826f9d6d018398ec4defc4b7ba5a3ad483c
[jalview.git] / test / jalview / gui / AlignFrameTest.java
1 /*
2  * Jalview - A Sequence Alignment Editor and Viewer ($$Version-Rel$$)
3  * Copyright (C) $$Year-Rel$$ The Jalview Authors
4  * 
5  * This file is part of Jalview.
6  * 
7  * Jalview is free software: you can redistribute it and/or
8  * modify it under the terms of the GNU General Public License 
9  * as published by the Free Software Foundation, either version 3
10  * of the License, or (at your option) any later version.
11  *  
12  * Jalview is distributed in the hope that it will be useful, but 
13  * WITHOUT ANY WARRANTY; without even the implied warranty 
14  * of MERCHANTABILITY or FITNESS FOR A PARTICULAR 
15  * PURPOSE.  See the GNU General Public License for more details.
16  * 
17  * You should have received a copy of the GNU General Public License
18  * along with Jalview.  If not, see <http://www.gnu.org/licenses/>.
19  * The Jalview Authors are detailed in the 'AUTHORS' file.
20  */
21 package jalview.gui;
22
23 import static org.junit.Assert.assertNotEquals;
24 import static org.testng.Assert.assertEquals;
25 import static org.testng.Assert.assertFalse;
26 import static org.testng.Assert.assertNotSame;
27 import static org.testng.Assert.assertSame;
28 import static org.testng.Assert.assertTrue;
29
30 import jalview.api.FeatureColourI;
31 import jalview.bin.Cache;
32 import jalview.bin.Jalview;
33 import jalview.datamodel.Alignment;
34 import jalview.datamodel.AlignmentI;
35 import jalview.datamodel.HiddenColumns;
36 import jalview.datamodel.Sequence;
37 import jalview.datamodel.SequenceFeature;
38 import jalview.datamodel.SequenceGroup;
39 import jalview.datamodel.SequenceI;
40 import jalview.io.DataSourceType;
41 import jalview.io.FileLoader;
42 import jalview.project.Jalview2xmlTests;
43 import jalview.renderer.ResidueShaderI;
44 import jalview.schemes.BuriedColourScheme;
45 import jalview.schemes.FeatureColour;
46 import jalview.schemes.HelixColourScheme;
47 import jalview.schemes.JalviewColourScheme;
48 import jalview.schemes.StrandColourScheme;
49 import jalview.schemes.TurnColourScheme;
50 import jalview.util.MessageManager;
51
52 import java.awt.Color;
53 import java.util.Iterator;
54
55 import org.testng.annotations.AfterMethod;
56 import org.testng.annotations.BeforeClass;
57 import org.testng.annotations.BeforeMethod;
58 import org.testng.annotations.Test;
59
60 public class AlignFrameTest
61 {
62   AlignFrame af;
63
64   @BeforeClass(alwaysRun = true)
65   public void setUpJvOptionPane()
66   {
67     JvOptionPane.setInteractiveMode(false);
68     JvOptionPane.setMockResponse(JvOptionPane.CANCEL_OPTION);
69   }
70
71   @Test(groups = "Functional")
72   public void testHideFeatureColumns()
73   {
74     SequenceI seq1 = new Sequence("Seq1", "ABCDEFGHIJ");
75     SequenceI seq2 = new Sequence("Seq2", "ABCDEFGHIJ");
76     seq1.addSequenceFeature(new SequenceFeature("Metal", "", 1, 5, 0f, null));
77     seq2.addSequenceFeature(new SequenceFeature("Metal", "", 6, 10, 10f,
78             null));
79     seq1.addSequenceFeature(new SequenceFeature("Turn", "", 2, 4,
80             Float.NaN, null));
81     seq2.addSequenceFeature(new SequenceFeature("Turn", "", 7, 9,
82             Float.NaN, null));
83     AlignmentI al = new Alignment(new SequenceI[] { seq1, seq2 });
84     AlignFrame alignFrame = new AlignFrame(al, al.getWidth(),
85             al.getHeight());
86
87     /*
88      * make all features visible (select feature columns checks visibility)
89      */
90     alignFrame.getFeatureRenderer().findAllFeatures(true);
91
92     /*
93      * hiding a feature not present does nothing
94      */
95     assertFalse(alignFrame.hideFeatureColumns("exon", true));
96     assertTrue(alignFrame.getViewport().getColumnSelection().isEmpty());
97
98     assertEquals(alignFrame.getViewport().getAlignment().getHiddenColumns()
99             .getNumberOfRegions(), 0);
100
101     assertFalse(alignFrame.hideFeatureColumns("exon", false));
102     assertTrue(alignFrame.getViewport().getColumnSelection().isEmpty());
103
104     assertEquals(alignFrame.getViewport().getAlignment().getHiddenColumns()
105             .getNumberOfRegions(), 0);
106
107     /*
108      * hiding a feature in all columns does nothing
109      */
110     assertFalse(alignFrame.hideFeatureColumns("Metal", true));
111     assertTrue(alignFrame.getViewport().getColumnSelection().isEmpty());
112
113     assertEquals(alignFrame.getViewport().getAlignment().getHiddenColumns()
114             .getNumberOfRegions(), 0);
115
116
117     /*
118      * threshold Metal to hide features where score < 5
119      * seq1 feature in columns 1-5 is hidden
120      * seq2 feature in columns 6-10 is shown
121      */
122     FeatureColourI fc = new FeatureColour(null, Color.red, Color.blue, null,
123             0f, 10f);
124     fc.setAboveThreshold(true);
125     fc.setThreshold(5f);
126     alignFrame.getFeatureRenderer().setColour("Metal", fc);
127     assertTrue(alignFrame.hideFeatureColumns("Metal", true));
128     HiddenColumns hidden = alignFrame.getViewport().getAlignment().getHiddenColumns();
129     assertEquals(hidden.getNumberOfRegions(), 1);
130     Iterator<int[]> regions = hidden.iterator();
131     int[] next = regions.next();
132     assertEquals(next[0], 5);
133     assertEquals(next[1], 9);
134
135     /*
136      * hide a feature present in some columns
137      * sequence positions [2-4], [7-9] are column positions
138      * [1-3], [6-8] base zero
139      */
140     alignFrame.getViewport().showAllHiddenColumns();
141     assertTrue(alignFrame.hideFeatureColumns("Turn", true));
142     regions = alignFrame.getViewport().getAlignment()
143             .getHiddenColumns().iterator();
144     assertEquals(alignFrame.getViewport().getAlignment().getHiddenColumns()
145             .getNumberOfRegions(), 2);
146     next = regions.next();
147     assertEquals(next[0], 1);
148     assertEquals(next[1], 3);
149     next = regions.next();
150     assertEquals(next[0], 6);
151     assertEquals(next[1], 8);
152   }
153
154   @BeforeClass(alwaysRun = true)
155   public static void setUpBeforeClass() throws Exception
156   {
157     /*
158      * use read-only test properties file
159      */
160     Cache.loadProperties("test/jalview/io/testProps.jvprops");
161     Cache.setPropertyNoSave("SHOW_JWS2_SERVICES", Boolean.FALSE.toString());
162     Jalview.main(new String[] { "-nonews" });
163   }
164
165   @AfterMethod(alwaysRun = true)
166   public void tearDown()
167   {
168     Desktop.getInstance().closeAll_actionPerformed(null);
169   }
170
171   /**
172    * configure (read-only) properties for test to ensure Consensus is computed
173    * for colour Above PID testing
174    */
175   @BeforeMethod(alwaysRun = true)
176   public void setUp()
177   {
178     Cache.loadProperties("test/jalview/io/testProps.jvprops");
179     Cache.setPropertyNoSave("SHOW_IDENTITY",
180             Boolean.TRUE.toString());
181     af = new FileLoader().LoadFileWaitTillLoaded("examples/uniref50.fa",
182             DataSourceType.FILE);
183
184     /*
185      * wait for Consensus thread to complete
186      */
187     synchronized (this)
188     {
189       while (af.getViewport().getConsensusSeq() == null)
190       {
191         try
192         {
193           wait(50);
194         } catch (InterruptedException e)
195         {
196         }
197       }
198     }
199   }
200
201   /**
202    * Test that changing background (alignment) colour scheme
203    * <ul>
204    * <li>with Apply Colour to All Groups not selected, does not change group
205    * colours</li>
206    * <li>with Apply Colour to All Groups selected, does change group colours</li>
207    * <li>in neither case, changes alignment or group colour thresholds (PID or
208    * Conservation)</li>
209    * </ul>
210    */
211   @Test(groups = "Functional")
212   public void testChangeColour_background_groupsAndThresholds()
213   {
214     AlignViewport av = af.getViewport();
215     AlignmentI al = av.getAlignment();
216
217     /*
218      * Colour alignment by Buried Index
219      */
220     af.applyToAllGroups_actionPerformed(false);
221     af.changeColour_actionPerformed(JalviewColourScheme.Buried.toString());
222     assertTrue(av.getGlobalColourScheme() instanceof BuriedColourScheme);
223     assertFalse(av.getResidueShading().conservationApplied());
224     assertEquals(av.getResidueShading().getThreshold(), 0);
225
226     /*
227      * Apply Conservation 20%
228      */
229     af.conservationMenuItem_actionPerformed(true);
230     SliderPanel sp = SliderPanel.getSliderPanel();
231     assertEquals(sp.getTitle(), MessageManager.formatMessage(
232             "label.conservation_colour_increment",
233             new String[] { "Background" }));
234     assertTrue(sp.isForConservation());
235     sp.valueChanged(20);
236     assertTrue(av.getResidueShading().conservationApplied());
237     assertEquals(av.getResidueShading().getConservationInc(), 20);
238
239     /*
240      * Apply PID threshold 10% (conservation still applies as well)
241      */
242     af.abovePIDThreshold_actionPerformed(true);
243     sp = SliderPanel.getSliderPanel();
244     assertFalse(sp.isForConservation());
245     assertEquals(sp.getTitle(), MessageManager.formatMessage(
246             "label.percentage_identity_threshold",
247             new String[] { "Background" }));
248     sp.valueChanged(10);
249     assertEquals(av.getResidueShading().getThreshold(), 10);
250     assertTrue(av.getResidueShading().conservationApplied());
251     assertEquals(av.getResidueShading().getConservationInc(), 20);
252
253     /*
254      * create a group with Strand colouring, 30% Conservation
255      * and 40% PID threshold
256      */
257     SequenceGroup sg = new SequenceGroup();
258     sg.addSequence(al.getSequenceAt(0), false);
259     sg.setStartRes(15);
260     sg.setEndRes(25);
261     av.setSelectionGroup(sg);
262
263     /*
264      * apply 30% Conservation to group
265      */
266     PopupMenu popupMenu = new PopupMenu(af.alignPanel, null, null);
267     popupMenu.changeColour_actionPerformed(JalviewColourScheme.Strand
268             .toString());
269     assertTrue(sg.getColourScheme() instanceof StrandColourScheme);
270     assertEquals(al.getGroups().size(), 1);
271     assertSame(al.getGroups().get(0), sg);
272     popupMenu.conservationMenuItem_actionPerformed(true);
273     sp = SliderPanel.getSliderPanel();
274     assertTrue(sp.isForConservation());
275     assertEquals(sp.getTitle(), MessageManager.formatMessage(
276             "label.conservation_colour_increment",
277             new String[] { sg.getName() }));
278     sp.valueChanged(30);
279     assertTrue(sg.getGroupColourScheme().conservationApplied());
280     assertEquals(sg.getGroupColourScheme().getConservationInc(), 30);
281
282     /*
283      * apply 40% PID threshold to group
284      */
285     popupMenu.abovePIDColour_actionPerformed(true);
286     sp = SliderPanel.getSliderPanel();
287     assertFalse(sp.isForConservation());
288     assertEquals(sp.getTitle(), MessageManager.formatMessage(
289             "label.percentage_identity_threshold",
290             new String[] { sg.getName() }));
291     sp.valueChanged(40);
292     assertEquals(sg.getGroupColourScheme().getThreshold(), 40);
293     // conservation threshold is unchanged:
294     assertTrue(sg.getGroupColourScheme().conservationApplied());
295     assertEquals(sg.getGroupColourScheme().getConservationInc(), 30);
296
297     /*
298      * change alignment colour - group colour, and all thresholds,
299      * should be unaffected
300      */
301     af.changeColour_actionPerformed(JalviewColourScheme.Turn.toString());
302     assertTrue(av.getGlobalColourScheme() instanceof TurnColourScheme);
303     assertTrue(av.getResidueShading().conservationApplied());
304     assertEquals(av.getResidueShading().getConservationInc(), 20);
305     assertEquals(av.getResidueShading().getThreshold(), 10);
306     assertTrue(sg.getColourScheme() instanceof StrandColourScheme);
307     assertTrue(sg.getGroupColourScheme().conservationApplied());
308     assertEquals(sg.getGroupColourScheme().getConservationInc(), 30);
309     assertEquals(sg.getGroupColourScheme().getThreshold(), 40);
310
311     /*
312      * Now change alignment colour with Apply Colour To All Groups
313      * - group colour should change, but not colour thresholds
314      */
315     af.applyToAllGroups_actionPerformed(true);
316     af.changeColour_actionPerformed(JalviewColourScheme.Helix.toString());
317     assertTrue(av.getGlobalColourScheme() instanceof HelixColourScheme);
318     assertTrue(av.getResidueShading().conservationApplied());
319     assertEquals(av.getResidueShading().getConservationInc(), 20);
320     assertEquals(av.getResidueShading().getThreshold(), 10);
321     assertTrue(sg.getColourScheme() instanceof HelixColourScheme);
322     assertTrue(sg.getGroupColourScheme().conservationApplied());
323     assertEquals(sg.getGroupColourScheme().getConservationInc(), 30);
324     assertEquals(sg.getGroupColourScheme().getThreshold(), 40);
325   }
326
327   /**
328    * Test residue colouring with various options
329    * <ol>
330    * <li>no PID or Conservation threshold</li>
331    * <li>colour by Conservation applied</li>
332    * <li>colour by Conservation removed</li>
333    * <li>colour above PID - various values</li>
334    * <li>colour above PID removed</li>
335    * <li>Above PID plus By Conservation combined</li>
336    * <li>remove Above PID to leave just By Conservation</li>
337    * <li>re-add Above PID</li>
338    * <li>remove By Conservation to leave just Above PID</li>
339    * <li>remove Above PID to leave original colours</li>
340    * </ol>
341    */
342   @Test(groups = "Functional")
343   public void testColourThresholdActions()
344   {
345
346     AlignViewport av = af.getViewport();
347     AlignmentI al = av.getAlignment();
348
349     /*
350      * Colour alignment by Helix Propensity, no thresholds
351      */
352     af.applyToAllGroups_actionPerformed(false);
353     af.changeColour_actionPerformed(JalviewColourScheme.Helix.toString());
354     assertTrue(av.getGlobalColourScheme() instanceof HelixColourScheme);
355     assertFalse(av.getResidueShading().conservationApplied());
356     assertEquals(av.getResidueShading().getThreshold(), 0);
357
358     /*
359      * inspect the colour of 
360      * FER_CAPAN.9(I), column 14 (14 base 0)
361      * FER_CAPAN.10(SER), column 16 (15 base 0)
362      */
363     SequenceI ferCapan = al.findName("FER_CAPAN");
364     ResidueShaderI rs = av.getResidueShading();
365     Color c = rs.findColour('I', 14, ferCapan);
366     Color i_original = new Color(138, 117, 138);
367     assertEquals(c, i_original);
368     c = rs.findColour('S', 15, ferCapan);
369     Color s_original = new Color(54, 201, 54);
370     assertEquals(c, s_original);
371
372     /*
373      * colour by conservation with increment 10
374      */
375     af.conservationMenuItem_actionPerformed(true);
376     SliderPanel sp = SliderPanel.getSliderPanel();
377     assertTrue(sp.isForConservation());
378     assertEquals(sp.getValue(), 30); // initial slider setting
379
380     // BH 2019.08.28 this was necessary so that rs was updated
381     af.changeColour_actionPerformed(JalviewColourScheme.Helix.toString());
382
383     sp.valueChanged(10);
384
385     assertSame(rs, av.getResidueShading());
386     c = rs.findColour('I', 14, ferCapan);
387     Color i_faded = new Color(196, 186, 196);
388     assertEquals(c, i_faded);
389     c = rs.findColour('S', 15, ferCapan);
390     Color s_faded = new Color(144, 225, 144);
391     assertEquals(c, s_faded);
392
393     /*
394      * deselect By Conservation - colour should revert
395      */
396     af.conservationMenuItem_actionPerformed(false);
397     c = rs.findColour('S', 15, ferCapan);
398     assertEquals(c, s_original);
399
400     /*
401      * now Above PID, threshold = 0%
402      * should be no change
403      */
404     af.abovePIDThreshold_actionPerformed(true);
405     sp = SliderPanel.getSliderPanel();
406     assertFalse(sp.isForConservation());
407     assertEquals(sp.getValue(), 0); // initial slider setting
408     c = rs.findColour('I', 14, ferCapan);
409     assertEquals(c, i_original);
410     c = rs.findColour('S', 15, ferCapan);
411     assertEquals(c, s_original);
412
413     /*
414      * Above PID, threshold = 1%
415      * 15.I becomes White because no match to consensus (V)
416      * 16.S remains coloured as matches 66.66% consensus
417      */
418     sp.valueChanged(1);
419     c = rs.findColour('I', 14, ferCapan);
420     assertEquals(c, Color.white);
421     c = rs.findColour('S', 15, ferCapan);
422     assertEquals(c, s_original);
423
424     /*
425      * threshold 66% - no further change yet...
426      */
427     sp.valueChanged(66);
428     c = rs.findColour('I', 14, ferCapan);
429     assertEquals(c, Color.white);
430     c = rs.findColour('S', 15, ferCapan);
431     assertEquals(c, s_original);
432
433     /*
434      * threshold 67% - now both residues are white
435      */
436     sp.valueChanged(67);
437     c = rs.findColour('I', 14, ferCapan);
438     assertEquals(c, Color.white);
439     c = rs.findColour('S', 15, ferCapan);
440     assertEquals(c, Color.white);
441
442     /*
443      * deselect Above PID - colours should revert
444      */
445     af.abovePIDThreshold_actionPerformed(false);
446     c = rs.findColour('I', 14, ferCapan);
447     assertEquals(c, i_original);
448     c = rs.findColour('S', 15, ferCapan);
449     assertEquals(c, s_original);
450
451     /*
452      * Now combine Above 50% PID and By Conservation 10%
453      * 15.I is White because no match to consensus (V)
454      * 16.S is coloured but faded
455      */
456     af.abovePIDThreshold_actionPerformed(true);
457     sp = SliderPanel.getSliderPanel();
458     assertFalse(sp.isForConservation());
459     sp.valueChanged(50);
460     af.conservationMenuItem_actionPerformed(true);
461     sp = SliderPanel.getSliderPanel();
462     assertTrue(sp.isForConservation());
463     sp.valueChanged(10);
464     c = rs.findColour('I', 14, ferCapan);
465     assertEquals(c, Color.white);
466     c = rs.findColour('S', 15, ferCapan);
467     assertEquals(c, s_faded);
468
469     /*
470      * turn off Above PID - should just leave Conservation fading as before 
471      */
472     af.abovePIDThreshold_actionPerformed(false);
473     c = rs.findColour('I', 14, ferCapan);
474     assertEquals(c, i_faded);
475     c = rs.findColour('S', 15, ferCapan);
476     assertEquals(c, s_faded);
477
478     /*
479      * Now add Above 50% PID to conservation colouring
480      * - should give the same as PID followed by conservation (above)
481      */
482     af.abovePIDThreshold_actionPerformed(true);
483     SliderPanel.getSliderPanel().valueChanged(50);
484     c = rs.findColour('I', 14, ferCapan);
485     assertEquals(c, Color.white);
486     c = rs.findColour('S', 15, ferCapan);
487     assertEquals(c, s_faded);
488
489     /*
490      * turn off By Conservation
491      * should leave I white, S original (unfaded) colour
492      */
493     af.conservationMenuItem_actionPerformed(false);
494     c = rs.findColour('I', 14, ferCapan);
495     assertEquals(c, Color.white);
496     c = rs.findColour('S', 15, ferCapan);
497     assertEquals(c, s_original);
498
499     /*
500      * finally turn off Above PID to leave original colours
501      */
502     af.abovePIDThreshold_actionPerformed(false);
503     c = rs.findColour('I', 14, ferCapan);
504     assertEquals(c, i_original);
505     c = rs.findColour('S', 15, ferCapan);
506     assertEquals(c, s_original);
507   }
508
509   private void waitSome()
510   {
511
512     // just a hack
513     synchronized (this)
514     {
515       try
516       {
517         wait(250);
518       } catch (InterruptedException e)
519       {
520       }
521     }
522   }
523
524   /**
525    * Verify that making a New View transfers alignment and group colour schemes,
526    * including any thresholds, to the new view. Because New View is performed by
527    * saving and reloading a 'project' file, this is similar to verifying a
528    * project save and reload.
529    * 
530    * @see Jalview2xmlTests#testStoreAndRecoverColourThresholds()
531    */
532   @Test(groups = "Functional")
533   public void testNewView_colourThresholds()
534   {
535     AlignViewport av = af.getViewport();
536     AlignmentI al = av.getAlignment();
537
538     /*
539      * Colour alignment by Buried Index, Above 10% PID, By Conservation 20%
540      */
541     af.changeColour_actionPerformed(JalviewColourScheme.Buried.toString());
542     assertTrue(av.getGlobalColourScheme() instanceof BuriedColourScheme);
543     af.abovePIDThreshold_actionPerformed(true);
544     SliderPanel sp = SliderPanel.getSliderPanel();
545     assertFalse(sp.isForConservation());
546     sp.valueChanged(10);
547     af.conservationMenuItem_actionPerformed(true);
548     sp = SliderPanel.getSliderPanel();
549     assertTrue(sp.isForConservation());
550     sp.valueChanged(20);
551     ResidueShaderI rs = av.getResidueShading();
552     assertEquals(rs.getThreshold(), 10);
553     assertTrue(rs.conservationApplied());
554     assertEquals(rs.getConservationInc(), 20);
555
556     /*
557      * create a group with Strand colouring, 30% Conservation
558      * and 40% PID threshold
559      */
560     SequenceGroup sg = new SequenceGroup();
561     sg.addSequence(al.getSequenceAt(0), false);
562     sg.setStartRes(15);
563     sg.setEndRes(25);
564     av.setSelectionGroup(sg);
565     PopupMenu popupMenu = new PopupMenu(af.alignPanel, null, null);
566     popupMenu.changeColour_actionPerformed(JalviewColourScheme.Strand
567             .toString());
568     assertTrue(sg.getColourScheme() instanceof StrandColourScheme);
569     assertEquals(al.getGroups().size(), 1);
570     assertSame(al.getGroups().get(0), sg);
571     popupMenu.conservationMenuItem_actionPerformed(true);
572     sp = SliderPanel.getSliderPanel();
573     assertTrue(sp.isForConservation());
574     sp.valueChanged(30);
575     popupMenu.abovePIDColour_actionPerformed(true);
576     sp = SliderPanel.getSliderPanel();
577     assertFalse(sp.isForConservation());
578     sp.valueChanged(40);
579     rs = sg.getGroupColourScheme();
580     assertTrue(rs.conservationApplied());
581     assertEquals(rs.getConservationInc(), 30);
582     assertEquals(rs.getThreshold(), 40);
583
584     /*
585      * set slider panel focus to the background alignment
586      */
587     af.conservationMenuItem_actionPerformed(true);
588     sp = SliderPanel.getSliderPanel();
589     assertTrue(sp.isForConservation());
590     assertEquals(sp.getTitle(), MessageManager.formatMessage(
591             "label.conservation_colour_increment",
592             new String[] { "Background" }));
593
594     /*
595      * make a new View, verify alignment and group colour schemes
596      */
597     af.newView_actionPerformed(null);
598     assertEquals(af.alignPanel.getViewName(), "View 1");
599     AlignViewport av2 = af.getViewport();
600     assertNotSame(av, av2);
601     assertSame(av2, af.alignPanel.av);
602     rs = av2.getResidueShading();
603     assertNotSame(av.getResidueShading(), rs);
604     assertEquals(rs.getThreshold(), 10);
605     assertTrue(rs.conservationApplied(), rs.toString());
606     assertEquals(rs.getConservationInc(), 20);
607     assertEquals(av2.getAlignment().getGroups().size(), 1);
608     sg = av2.getAlignment().getGroups().get(0);
609     rs = sg.getGroupColourScheme();
610     assertTrue(rs.conservationApplied());
611     assertEquals(rs.getConservationInc(), 30);
612     assertEquals(rs.getThreshold(), 40);
613
614     /*
615      * check the Conservation SliderPanel (still open) is linked to 
616      * and updates the new view (JAL-2385)
617      */
618     sp = SliderPanel.getSliderPanel();
619     assertTrue(sp.isForConservation());
620     assertEquals(sp.getTitle(), MessageManager.formatMessage(
621             "label.conservation_colour_increment",
622             new String[] { "View 1" }));
623     sp.valueChanged(22);
624     assertEquals(av2.getResidueShading().getConservationInc(), 22);
625   }
626
627   /**
628    * Verify that making a New View preserves the dataset reference for the
629    * alignment. Otherwise, see a 'duplicate jar entry' reference when trying to
630    * save alignments with multiple views, and codon mappings will not be shared
631    * across all panels in a split frame.
632    * 
633    * @see Jalview2xmlTests#testStoreAndRecoverColourThresholds()
634    */
635   @Test(groups = "Functional")
636   public void testNewView_dsRefPreserved()
637   {
638     AlignViewport av = af.getViewport();
639     AlignmentI al = av.getAlignment();
640     AlignmentI original_ds = al.getDataset();
641     af.newView_actionPerformed(null);
642     assertNotEquals("New view didn't select the a new panel", av,
643             af.getViewport());
644     org.testng.Assert.assertEquals(original_ds,
645             af.getViewport().getAlignment().getDataset(),
646             "Dataset was not preserved in new view");
647   }
648 }