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