8d8b43c34756d80d19c7cabbc65601160e2c8d6d
[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
85    * for 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(
122             new SequenceFeature("Metal", "", 1, 5, 0f, null));
123     seq2.addSequenceFeature(
124             new SequenceFeature("Metal", "", 6, 10, 10f, null));
125     seq1.addSequenceFeature(
126             new SequenceFeature("Turn", "", 2, 4, Float.NaN, null));
127     seq2.addSequenceFeature(
128             new SequenceFeature("Turn", "", 7, 9, Float.NaN, null));
129     AlignmentI al = new Alignment(new SequenceI[] { seq1, seq2 });
130     AlignFrame alignFrame = new AlignFrame(al, al.getWidth(),
131             al.getHeight());
132
133     /*
134      * make all features visible (select feature columns checks visibility)
135      */
136     alignFrame.getFeatureRenderer().findAllFeatures(true);
137
138     /*
139      * hiding a feature not present does nothing
140      */
141     assertFalse(alignFrame.hideFeatureColumns("exon", true));
142     assertTrue(alignFrame.getViewport().getColumnSelection().isEmpty());
143
144     assertEquals(alignFrame.getViewport().getAlignment().getHiddenColumns()
145             .getNumberOfRegions(), 0);
146
147     assertFalse(alignFrame.hideFeatureColumns("exon", false));
148     assertTrue(alignFrame.getViewport().getColumnSelection().isEmpty());
149
150     assertEquals(alignFrame.getViewport().getAlignment().getHiddenColumns()
151             .getNumberOfRegions(), 0);
152
153     /*
154      * hiding a feature in all columns does nothing
155      */
156     assertFalse(alignFrame.hideFeatureColumns("Metal", true));
157     assertTrue(alignFrame.getViewport().getColumnSelection().isEmpty());
158
159     assertEquals(alignFrame.getViewport().getAlignment().getHiddenColumns()
160             .getNumberOfRegions(), 0);
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()
174             .getHiddenColumns();
175     assertEquals(hidden.getNumberOfRegions(), 1);
176     Iterator<int[]> regions = hidden.iterator();
177     int[] next = regions.next();
178     assertEquals(next[0], 5);
179     assertEquals(next[1], 9);
180
181     /*
182      * hide a feature present in some columns
183      * sequence positions [2-4], [7-9] are column positions
184      * [1-3], [6-8] base zero
185      */
186     alignFrame.getViewport().showAllHiddenColumns();
187     assertTrue(alignFrame.hideFeatureColumns("Turn", true));
188     regions = alignFrame.getViewport().getAlignment().getHiddenColumns()
189             .iterator();
190     assertEquals(alignFrame.getViewport().getAlignment().getHiddenColumns()
191             .getNumberOfRegions(), 2);
192     next = regions.next();
193     assertEquals(next[0], 1);
194     assertEquals(next[1], 3);
195     next = regions.next();
196     assertEquals(next[0], 6);
197     assertEquals(next[1], 8);
198   }
199
200   /**
201    * Test that changing background (alignment) colour scheme
202    * <ul>
203    * <li>with Apply Colour to All Groups not selected, does not change group
204    * colours</li>
205    * <li>with Apply Colour to All Groups selected, does change group
206    * 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     AlignViewportI 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", new String[]
233             { "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", new String[]
247             { "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      * (notice menu action applies to selection group even if mouse click
266      * is at a sequence not in the group)
267      */
268     PopupMenu popupMenu = new PopupMenu(af.alignPanel, al.getSequenceAt(2),
269             null);
270     popupMenu.changeColour_actionPerformed(
271             JalviewColourScheme.Strand.toString());
272     assertTrue(sg.getColourScheme() instanceof StrandColourScheme);
273     assertEquals(al.getGroups().size(), 1);
274     assertSame(al.getGroups().get(0), sg);
275     popupMenu.conservationMenuItem_actionPerformed(true);
276     sp = SliderPanel.getSliderPanel();
277     assertTrue(sp.isForConservation());
278     assertEquals(sp.getTitle(), MessageManager.formatMessage(
279             "label.conservation_colour_increment", new String[]
280             { sg.getName() }));
281     sp.valueChanged(30);
282     assertTrue(sg.getGroupColourScheme().conservationApplied());
283     assertEquals(sg.getGroupColourScheme().getConservationInc(), 30);
284
285     /*
286      * apply 40% PID threshold to group
287      */
288     popupMenu.abovePIDColour_actionPerformed(true);
289     sp = SliderPanel.getSliderPanel();
290     assertFalse(sp.isForConservation());
291     assertEquals(sp.getTitle(), MessageManager.formatMessage(
292             "label.percentage_identity_threshold", new String[]
293             { sg.getName() }));
294     sp.valueChanged(40);
295     assertEquals(sg.getGroupColourScheme().getThreshold(), 40);
296     // conservation threshold is unchanged:
297     assertTrue(sg.getGroupColourScheme().conservationApplied());
298     assertEquals(sg.getGroupColourScheme().getConservationInc(), 30);
299
300     /*
301      * change alignment colour - group colour, and all thresholds,
302      * should be unaffected
303      */
304     af.changeColour_actionPerformed(JalviewColourScheme.Turn.toString());
305     assertTrue(av.getGlobalColourScheme() instanceof TurnColourScheme);
306     assertTrue(av.getResidueShading().conservationApplied());
307     assertEquals(av.getResidueShading().getConservationInc(), 20);
308     assertEquals(av.getResidueShading().getThreshold(), 10);
309     assertTrue(sg.getColourScheme() instanceof StrandColourScheme);
310     assertTrue(sg.getGroupColourScheme().conservationApplied());
311     assertEquals(sg.getGroupColourScheme().getConservationInc(), 30);
312     assertEquals(sg.getGroupColourScheme().getThreshold(), 40);
313
314     /*
315      * Now change alignment colour with Apply Colour To All Groups
316      * - group colour should change, but not colour thresholds
317      */
318     af.applyToAllGroups_actionPerformed(true);
319     af.changeColour_actionPerformed(JalviewColourScheme.Helix.toString());
320     assertTrue(av.getGlobalColourScheme() instanceof HelixColourScheme);
321     assertTrue(av.getResidueShading().conservationApplied());
322     assertEquals(av.getResidueShading().getConservationInc(), 20);
323     assertEquals(av.getResidueShading().getThreshold(), 10);
324     assertTrue(sg.getColourScheme() instanceof HelixColourScheme);
325     assertTrue(sg.getGroupColourScheme().conservationApplied());
326     assertEquals(sg.getGroupColourScheme().getConservationInc(), 30);
327     assertEquals(sg.getGroupColourScheme().getThreshold(), 40);
328   }
329
330   /**
331    * Test residue colouring with various options
332    * <ol>
333    * <li>no PID or Conservation threshold</li>
334    * <li>colour by Conservation applied</li>
335    * <li>colour by Conservation removed</li>
336    * <li>colour above PID - various values</li>
337    * <li>colour above PID removed</li>
338    * <li>Above PID plus By Conservation combined</li>
339    * <li>remove Above PID to leave just By Conservation</li>
340    * <li>re-add Above PID</li>
341    * <li>remove By Conservation to leave just Above PID</li>
342    * <li>remove Above PID to leave original colours</li>
343    * </ol>
344    */
345   @Test(groups = "Functional")
346   public void testColourThresholdActions()
347   {
348     AlignViewportI av = af.getViewport();
349     AlignmentI al = av.getAlignment();
350
351     /*
352      * Colour alignment by Helix Propensity, no thresholds
353      */
354     af.applyToAllGroups_actionPerformed(false);
355     af.changeColour_actionPerformed(JalviewColourScheme.Helix.toString());
356     assertTrue(av.getGlobalColourScheme() instanceof HelixColourScheme);
357     assertFalse(av.getResidueShading().conservationApplied());
358     assertEquals(av.getResidueShading().getThreshold(), 0);
359
360     /*
361      * inspect the colour of 
362      * FER_CAPAN.9(I), column 15 (14 base 0)
363      * FER_CAPAN.10(SER), column 16 (15 base 0)
364      */
365     SequenceI ferCapan = al.findName("FER_CAPAN");
366     ResidueShaderI rs = av.getResidueShading();
367     Color c = rs.findColour('I', 14, ferCapan);
368     Color i_original = new Color(138, 117, 138);
369     assertEquals(c, i_original);
370     c = rs.findColour('S', 15, ferCapan);
371     Color s_original = new Color(54, 201, 54);
372     assertEquals(c, s_original);
373
374     /*
375      * colour by conservation with increment 10
376      */
377     af.conservationMenuItem_actionPerformed(true);
378     SliderPanel sp = SliderPanel.getSliderPanel();
379     assertTrue(sp.isForConservation());
380     assertEquals(sp.getValue(), 30); // initial slider setting
381     c = rs.findColour('I', 14, ferCapan);
382     Color i_faded = new Color(255, 255, 255);
383     assertEquals(c, i_faded);
384     sp.valueChanged(10);
385     assertSame(rs, av.getResidueShading());
386     assertEquals(rs.getConservationInc(), 10);
387     c = rs.findColour('I', 14, ferCapan);
388     i_faded = new Color(196, 186, 196);
389     assertEquals(c, i_faded);
390     c = rs.findColour('S', 15, ferCapan);
391     Color s_faded = new Color(144, 225, 144);
392     assertEquals(c, s_faded);
393
394     /*
395      * deselect By Conservation - colour should revert
396      */
397     af.conservationMenuItem_actionPerformed(false);
398     c = rs.findColour('S', 15, ferCapan);
399     assertEquals(c, s_original);
400
401     /*
402      * now Above PID, threshold = 0%
403      * should be no change
404      */
405     af.abovePIDThreshold_actionPerformed(true);
406     sp = SliderPanel.getSliderPanel();
407     assertFalse(sp.isForConservation());
408     assertEquals(sp.getValue(), 0); // initial slider setting
409     c = rs.findColour('I', 14, ferCapan);
410     assertEquals(c, i_original);
411     c = rs.findColour('S', 15, ferCapan);
412     assertEquals(c, s_original);
413
414     /*
415      * Above PID, threshold = 1%
416      * 15.I becomes White because no match to consensus (V)
417      * 16.S remains coloured as matches 66.66% consensus
418      */
419     sp.valueChanged(1);
420     c = rs.findColour('I', 14, ferCapan);
421     assertEquals(c, Color.white);
422     c = rs.findColour('S', 15, ferCapan);
423     assertEquals(c, s_original);
424
425     /*
426      * threshold 66% - no further change yet...
427      */
428     sp.valueChanged(66);
429     c = rs.findColour('I', 14, ferCapan);
430     assertEquals(c, Color.white);
431     c = rs.findColour('S', 15, ferCapan);
432     assertEquals(c, s_original);
433
434     /*
435      * threshold 67% - now both residues are white
436      */
437     sp.valueChanged(67);
438     c = rs.findColour('I', 14, ferCapan);
439     assertEquals(c, Color.white);
440     c = rs.findColour('S', 15, ferCapan);
441     assertEquals(c, Color.white);
442
443     /*
444      * deselect Above PID - colours should revert
445      */
446     af.abovePIDThreshold_actionPerformed(false);
447     c = rs.findColour('I', 14, ferCapan);
448     assertEquals(c, i_original);
449     c = rs.findColour('S', 15, ferCapan);
450     assertEquals(c, s_original);
451
452     /*
453      * Now combine Above 50% PID and By Conservation 10%
454      * 15.I is White because no match to consensus (V)
455      * 16.S is coloured but faded
456      */
457     af.abovePIDThreshold_actionPerformed(true);
458     sp = SliderPanel.getSliderPanel();
459     assertFalse(sp.isForConservation());
460     sp.valueChanged(50);
461     af.conservationMenuItem_actionPerformed(true);
462     sp = SliderPanel.getSliderPanel();
463     assertTrue(sp.isForConservation());
464     sp.valueChanged(10);
465     c = rs.findColour('I', 14, ferCapan);
466     assertEquals(c, Color.white);
467     c = rs.findColour('S', 15, ferCapan);
468     assertEquals(c, s_faded);
469
470     /*
471      * turn off Above PID - should just leave Conservation fading as before 
472      */
473     af.abovePIDThreshold_actionPerformed(false);
474     c = rs.findColour('I', 14, ferCapan);
475     assertEquals(c, i_faded);
476     c = rs.findColour('S', 15, ferCapan);
477     assertEquals(c, s_faded);
478
479     /*
480      * Now add Above 50% PID to conservation colouring
481      * - should give the same as PID followed by conservation (above)
482      */
483     af.abovePIDThreshold_actionPerformed(true);
484     SliderPanel.getSliderPanel().valueChanged(50);
485     c = rs.findColour('I', 14, ferCapan);
486     assertEquals(c, Color.white);
487     c = rs.findColour('S', 15, ferCapan);
488     assertEquals(c, s_faded);
489
490     /*
491      * turn off By Conservation
492      * should leave I white, S original (unfaded) colour
493      */
494     af.conservationMenuItem_actionPerformed(false);
495     c = rs.findColour('I', 14, ferCapan);
496     assertEquals(c, Color.white);
497     c = rs.findColour('S', 15, ferCapan);
498     assertEquals(c, s_original);
499
500     /*
501      * finally turn off Above PID to leave original colours
502      */
503     af.abovePIDThreshold_actionPerformed(false);
504     c = rs.findColour('I', 14, ferCapan);
505     assertEquals(c, i_original);
506     c = rs.findColour('S', 15, ferCapan);
507     assertEquals(c, s_original);
508   }
509
510   /**
511    * Verify that making a New View transfers alignment and group colour schemes,
512    * including any thresholds, to the new view. Because New View is performed by
513    * saving and reloading a 'project' file, this is similar to verifying a
514    * project save and reload.
515    * 
516    * @see Jalview2xmlTests#testStoreAndRecoverColourThresholds()
517    */
518   @Test(groups = "Functional")
519   public void testNewView_colourThresholds()
520   {
521     AlignViewportI av = af.getViewport();
522     AlignmentI al = av.getAlignment();
523
524     /*
525      * Colour alignment by Buried Index, Above 10% PID, By Conservation 20%
526      */
527     af.changeColour_actionPerformed(JalviewColourScheme.Buried.toString());
528     assertTrue(av.getGlobalColourScheme() instanceof BuriedColourScheme);
529     af.abovePIDThreshold_actionPerformed(true);
530     SliderPanel sp = SliderPanel.getSliderPanel();
531     assertFalse(sp.isForConservation());
532     sp.valueChanged(10);
533     af.conservationMenuItem_actionPerformed(true);
534     sp = SliderPanel.getSliderPanel();
535     assertTrue(sp.isForConservation());
536     sp.valueChanged(20);
537     ResidueShaderI rs = av.getResidueShading();
538     assertEquals(rs.getThreshold(), 10);
539     assertTrue(rs.conservationApplied());
540     assertEquals(rs.getConservationInc(), 20);
541
542     /*
543      * create a group with Strand colouring, 30% Conservation
544      * and 40% PID threshold
545      */
546     SequenceGroup sg = new SequenceGroup();
547     sg.addSequence(al.getSequenceAt(0), false);
548     sg.setStartRes(15);
549     sg.setEndRes(25);
550     av.setSelectionGroup(sg);
551     PopupMenu popupMenu = new PopupMenu(af.alignPanel, al.getSequenceAt(0),
552             null);
553     popupMenu.changeColour_actionPerformed(
554             JalviewColourScheme.Strand.toString());
555     assertTrue(sg.getColourScheme() instanceof StrandColourScheme);
556     assertEquals(al.getGroups().size(), 1);
557     assertSame(al.getGroups().get(0), sg);
558     popupMenu.conservationMenuItem_actionPerformed(true);
559     sp = SliderPanel.getSliderPanel();
560     assertTrue(sp.isForConservation());
561     sp.valueChanged(30);
562     popupMenu.abovePIDColour_actionPerformed(true);
563     sp = SliderPanel.getSliderPanel();
564     assertFalse(sp.isForConservation());
565     sp.valueChanged(40);
566     rs = sg.getGroupColourScheme();
567     assertTrue(rs.conservationApplied());
568     assertEquals(rs.getConservationInc(), 30);
569     assertEquals(rs.getThreshold(), 40);
570
571     /*
572      * set slider panel focus to the background alignment
573      */
574     af.conservationMenuItem_actionPerformed(true);
575     sp = SliderPanel.getSliderPanel();
576     assertTrue(sp.isForConservation());
577     assertEquals(sp.getTitle(), MessageManager.formatMessage(
578             "label.conservation_colour_increment", new String[]
579             { "Background" }));
580
581     /*
582      * make a new View, verify alignment and group colour schemes
583      */
584     af.newView_actionPerformed(null);
585     assertEquals(af.alignPanel.getViewName(), "View 1");
586     AlignmentViewport av2 = af.getViewport();
587     assertNotSame(av, av2);
588     assertSame(av2, af.alignPanel.av);
589     rs = av2.getResidueShading();
590     assertNotSame(av.getResidueShading(), rs);
591     assertEquals(rs.getThreshold(), 10);
592     assertTrue(rs.conservationApplied(), rs.toString());
593     assertEquals(rs.getConservationInc(), 20);
594     assertEquals(av2.getAlignment().getGroups().size(), 1);
595     sg = av2.getAlignment().getGroups().get(0);
596     rs = sg.getGroupColourScheme();
597     assertTrue(rs.conservationApplied());
598     assertEquals(rs.getConservationInc(), 30);
599     assertEquals(rs.getThreshold(), 40);
600
601     /*
602      * check the Conservation SliderPanel (still open) is linked to 
603      * and updates the new view (JAL-2385)
604      */
605     sp = SliderPanel.getSliderPanel();
606     assertTrue(sp.isForConservation());
607     assertEquals(sp.getTitle(), MessageManager.formatMessage(
608             "label.conservation_colour_increment", new String[]
609             { "View 1" }));
610     sp.valueChanged(22);
611     assertEquals(av2.getResidueShading().getConservationInc(), 22);
612   }
613
614   /**
615    * Verify that making a New View preserves the dataset reference for the
616    * alignment. Otherwise, see a 'duplicate jar entry' reference when trying to
617    * save alignments with multiple views, and codon mappings will not be shared
618    * across all panels in a split frame.
619    * 
620    * @see Jalview2xmlTests#testStoreAndRecoverColourThresholds()
621    */
622   @Test(groups = "Functional")
623   public void testNewView_dsRefPreserved()
624   {
625     AlignViewport av = af.getViewport();
626     AlignmentI al = av.getAlignment();
627     AlignmentI original_ds = al.getDataset();
628     af.newView_actionPerformed(null);
629     assertNotEquals("New view didn't select the a new panel", av,
630             af.getViewport());
631     org.testng.Assert.assertEquals(original_ds,
632             af.getViewport().getAlignment().getDataset(),
633             "Dataset was not preserved in new view");
634   }
635 }