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