Merge branch 'develop' into spike/JAL-4047/JAL-4048_columns_in_sequenceID
[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.FeatureColourI;
39 import jalview.bin.Cache;
40 import jalview.bin.Jalview;
41 import jalview.datamodel.Alignment;
42 import jalview.datamodel.AlignmentI;
43 import jalview.datamodel.HiddenColumns;
44 import jalview.datamodel.Sequence;
45 import jalview.datamodel.SequenceFeature;
46 import jalview.datamodel.SequenceGroup;
47 import jalview.datamodel.SequenceI;
48 import jalview.io.DataSourceType;
49 import jalview.io.FileLoader;
50 import jalview.project.Jalview2xmlTests;
51 import jalview.renderer.ResidueShaderI;
52 import jalview.schemes.BuriedColourScheme;
53 import jalview.schemes.FeatureColour;
54 import jalview.schemes.HelixColourScheme;
55 import jalview.schemes.JalviewColourScheme;
56 import jalview.schemes.StrandColourScheme;
57 import jalview.schemes.TurnColourScheme;
58 import jalview.util.MessageManager;
59
60 public class AlignFrameTest
61 {
62   AlignFrame af;
63
64   @BeforeClass(alwaysRun = true)
65   public static void setUpBeforeClass() throws Exception
66   {
67     setUpJvOptionPane();
68     /*
69      * use read-only test properties file
70      */
71     Cache.loadProperties("test/jalview/io/testProps.jvprops");
72     Jalview.main(new String[] { "-nonews" });
73   }
74
75   @AfterMethod(alwaysRun = true)
76   public void tearDown()
77   {
78     if (Desktop.instance != null)
79       Desktop.instance.closeAll_actionPerformed(null);
80   }
81
82   /**
83    * configure (read-only) properties for test to ensure Consensus is computed
84    * for colour Above PID testing
85    */
86   @BeforeMethod(alwaysRun = true)
87   public void setUp()
88   {
89     Cache.loadProperties("test/jalview/io/testProps.jvprops");
90     Cache.applicationProperties.setProperty("SHOW_IDENTITY",
91             Boolean.TRUE.toString());
92     af = new FileLoader().LoadFileWaitTillLoaded("examples/uniref50.fa",
93             DataSourceType.FILE);
94
95     /*
96      * wait for Consensus thread to complete
97      */
98     do
99     {
100       try
101       {
102         Thread.sleep(50);
103       } catch (InterruptedException x)
104       {
105       }
106     } while (af.getViewport().getCalcManager().isWorking());
107   }
108
109   public static void setUpJvOptionPane()
110   {
111     JvOptionPane.setInteractiveMode(false);
112     JvOptionPane.setMockResponse(JvOptionPane.CANCEL_OPTION);
113   }
114
115   @Test(groups = "Functional")
116   public void testHideFeatureColumns()
117   {
118     SequenceI seq1 = new Sequence("Seq1", "ABCDEFGHIJ");
119     SequenceI seq2 = new Sequence("Seq2", "ABCDEFGHIJ");
120     seq1.addSequenceFeature(
121             new SequenceFeature("Metal", "", 1, 5, 0f, null));
122     seq2.addSequenceFeature(
123             new SequenceFeature("Metal", "", 6, 10, 10f, null));
124     seq1.addSequenceFeature(
125             new SequenceFeature("Turn", "", 2, 4, Float.NaN, null));
126     seq2.addSequenceFeature(
127             new SequenceFeature("Turn", "", 7, 9, 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      * threshold Metal to hide features where score < 5
163      * seq1 feature in columns 1-5 is hidden
164      * seq2 feature in columns 6-10 is shown
165      */
166     FeatureColourI fc = new FeatureColour(null, Color.red, Color.blue, null,
167             0f, 10f);
168     fc.setAboveThreshold(true);
169     fc.setThreshold(5f);
170     alignFrame.getFeatureRenderer().setColour("Metal", fc);
171     assertTrue(alignFrame.hideFeatureColumns("Metal", true));
172     HiddenColumns hidden = alignFrame.getViewport().getAlignment()
173             .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().getHiddenColumns()
188             .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
205    * colours</li>
206    * <li>in neither case, changes alignment or group colour thresholds (PID or
207    * Conservation)</li>
208    * </ul>
209    */
210   @Test(groups = "Functional")
211   public void testChangeColour_background_groupsAndThresholds()
212   {
213     AlignViewport av = af.getViewport();
214     AlignmentI al = av.getAlignment();
215
216     /*
217      * Colour alignment by Buried Index
218      */
219     af.applyToAllGroups_actionPerformed(false);
220     af.changeColour_actionPerformed(JalviewColourScheme.Buried.toString());
221     assertTrue(av.getGlobalColourScheme() instanceof BuriedColourScheme);
222     assertFalse(av.getResidueShading().conservationApplied());
223     assertEquals(av.getResidueShading().getThreshold(), 0);
224
225     /*
226      * Apply Conservation 20%
227      */
228     af.conservationMenuItem_actionPerformed(true);
229     SliderPanel sp = SliderPanel.getSliderPanel();
230     assertEquals(sp.getTitle(), MessageManager.formatMessage(
231             "label.conservation_colour_increment", new String[]
232             { "Background" }));
233     assertTrue(sp.isForConservation());
234     sp.valueChanged(20);
235     assertTrue(av.getResidueShading().conservationApplied());
236     assertEquals(av.getResidueShading().getConservationInc(), 20);
237
238     /*
239      * Apply PID threshold 10% (conservation still applies as well)
240      */
241     af.abovePIDThreshold_actionPerformed(true);
242     sp = SliderPanel.getSliderPanel();
243     assertFalse(sp.isForConservation());
244     assertEquals(sp.getTitle(), MessageManager.formatMessage(
245             "label.percentage_identity_threshold", new String[]
246             { "Background" }));
247     sp.valueChanged(10);
248     assertEquals(av.getResidueShading().getThreshold(), 10);
249     assertTrue(av.getResidueShading().conservationApplied());
250     assertEquals(av.getResidueShading().getConservationInc(), 20);
251
252     /*
253      * create a group with Strand colouring, 30% Conservation
254      * and 40% PID threshold
255      */
256     SequenceGroup sg = new SequenceGroup();
257     sg.addSequence(al.getSequenceAt(0), false);
258     sg.setStartRes(15);
259     sg.setEndRes(25);
260     av.setSelectionGroup(sg);
261
262     /*
263      * apply 30% Conservation to group
264      * (notice menu action applies to selection group even if mouse click
265      * is at a sequence not in the group)
266      */
267     PopupMenu popupMenu = new PopupMenu(af.alignPanel, al.getSequenceAt(2),
268             null);
269     popupMenu.changeColour_actionPerformed(
270             JalviewColourScheme.Strand.toString());
271     assertTrue(sg.getColourScheme() instanceof StrandColourScheme);
272     assertEquals(al.getGroups().size(), 1);
273     assertSame(al.getGroups().get(0), sg);
274     popupMenu.conservationMenuItem_actionPerformed(true);
275     sp = SliderPanel.getSliderPanel();
276     assertTrue(sp.isForConservation());
277     assertEquals(sp.getTitle(), MessageManager.formatMessage(
278             "label.conservation_colour_increment", new String[]
279             { sg.getName() }));
280     sp.valueChanged(30);
281     assertTrue(sg.getGroupColourScheme().conservationApplied());
282     assertEquals(sg.getGroupColourScheme().getConservationInc(), 30);
283
284     /*
285      * apply 40% PID threshold to group
286      */
287     popupMenu.abovePIDColour_actionPerformed(true);
288     sp = SliderPanel.getSliderPanel();
289     assertFalse(sp.isForConservation());
290     assertEquals(sp.getTitle(), MessageManager.formatMessage(
291             "label.percentage_identity_threshold", new String[]
292             { sg.getName() }));
293     sp.valueChanged(40);
294     assertEquals(sg.getGroupColourScheme().getThreshold(), 40);
295     // conservation threshold is unchanged:
296     assertTrue(sg.getGroupColourScheme().conservationApplied());
297     assertEquals(sg.getGroupColourScheme().getConservationInc(), 30);
298
299     /*
300      * change alignment colour - group colour, and all thresholds,
301      * should be unaffected
302      */
303     af.changeColour_actionPerformed(JalviewColourScheme.Turn.toString());
304     assertTrue(av.getGlobalColourScheme() instanceof TurnColourScheme);
305     assertTrue(av.getResidueShading().conservationApplied());
306     assertEquals(av.getResidueShading().getConservationInc(), 20);
307     assertEquals(av.getResidueShading().getThreshold(), 10);
308     assertTrue(sg.getColourScheme() instanceof StrandColourScheme);
309     assertTrue(sg.getGroupColourScheme().conservationApplied());
310     assertEquals(sg.getGroupColourScheme().getConservationInc(), 30);
311     assertEquals(sg.getGroupColourScheme().getThreshold(), 40);
312
313     /*
314      * Now change alignment colour with Apply Colour To All Groups
315      * - group colour should change, but not colour thresholds
316      */
317     af.applyToAllGroups_actionPerformed(true);
318     af.changeColour_actionPerformed(JalviewColourScheme.Helix.toString());
319     assertTrue(av.getGlobalColourScheme() instanceof HelixColourScheme);
320     assertTrue(av.getResidueShading().conservationApplied());
321     assertEquals(av.getResidueShading().getConservationInc(), 20);
322     assertEquals(av.getResidueShading().getThreshold(), 10);
323     assertTrue(sg.getColourScheme() instanceof HelixColourScheme);
324     assertTrue(sg.getGroupColourScheme().conservationApplied());
325     assertEquals(sg.getGroupColourScheme().getConservationInc(), 30);
326     assertEquals(sg.getGroupColourScheme().getThreshold(), 40);
327   }
328
329   /**
330    * Test residue colouring with various options
331    * <ol>
332    * <li>no PID or Conservation threshold</li>
333    * <li>colour by Conservation applied</li>
334    * <li>colour by Conservation removed</li>
335    * <li>colour above PID - various values</li>
336    * <li>colour above PID removed</li>
337    * <li>Above PID plus By Conservation combined</li>
338    * <li>remove Above PID to leave just By Conservation</li>
339    * <li>re-add Above PID</li>
340    * <li>remove By Conservation to leave just Above PID</li>
341    * <li>remove Above PID to leave original colours</li>
342    * </ol>
343    */
344   @Test(groups = "Functional")
345   public void testColourThresholdActions()
346   {
347     AlignViewport av = af.getViewport();
348     AlignmentI al = av.getAlignment();
349
350     /*
351      * Colour alignment by Helix Propensity, no thresholds
352      */
353     af.applyToAllGroups_actionPerformed(false);
354     af.changeColour_actionPerformed(JalviewColourScheme.Helix.toString());
355     assertTrue(av.getGlobalColourScheme() instanceof HelixColourScheme);
356     assertFalse(av.getResidueShading().conservationApplied());
357     assertEquals(av.getResidueShading().getThreshold(), 0);
358
359     /*
360      * inspect the colour of 
361      * FER_CAPAN.9(I), column 15 (14 base 0)
362      * FER_CAPAN.10(SER), column 16 (15 base 0)
363      */
364     SequenceI ferCapan = al.findName("FER_CAPAN");
365     ResidueShaderI rs = av.getResidueShading();
366     Color c = rs.findColour('I', 14, ferCapan);
367     Color i_original = new Color(138, 117, 138);
368     assertEquals(c, i_original);
369     c = rs.findColour('S', 15, ferCapan);
370     Color s_original = new Color(54, 201, 54);
371     assertEquals(c, s_original);
372
373     /*
374      * colour by conservation with increment 10
375      */
376     af.conservationMenuItem_actionPerformed(true);
377     SliderPanel sp = SliderPanel.getSliderPanel();
378     assertTrue(sp.isForConservation());
379     assertEquals(sp.getValue(), 30); // initial slider setting
380     c = rs.findColour('I', 14, ferCapan);
381     Color i_faded = new Color(255, 255, 255);
382     assertEquals(c, i_faded);
383     sp.valueChanged(10);
384     assertSame(rs, av.getResidueShading());
385     assertEquals(rs.getConservationInc(), 10);
386     c = rs.findColour('I', 14, ferCapan);
387     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   /**
510    * Verify that making a New View transfers alignment and group colour schemes,
511    * including any thresholds, to the new view. Because New View is performed by
512    * saving and reloading a 'project' file, this is similar to verifying a
513    * project save and reload.
514    * 
515    * @see Jalview2xmlTests#testStoreAndRecoverColourThresholds()
516    */
517   @Test(groups = "Functional")
518   public void testNewView_colourThresholds()
519   {
520     AlignViewport av = af.getViewport();
521     AlignmentI al = av.getAlignment();
522
523     /*
524      * Colour alignment by Buried Index, Above 10% PID, By Conservation 20%
525      */
526     af.changeColour_actionPerformed(JalviewColourScheme.Buried.toString());
527     assertTrue(av.getGlobalColourScheme() instanceof BuriedColourScheme);
528     af.abovePIDThreshold_actionPerformed(true);
529     SliderPanel sp = SliderPanel.getSliderPanel();
530     assertFalse(sp.isForConservation());
531     sp.valueChanged(10);
532     af.conservationMenuItem_actionPerformed(true);
533     sp = SliderPanel.getSliderPanel();
534     assertTrue(sp.isForConservation());
535     sp.valueChanged(20);
536     ResidueShaderI rs = av.getResidueShading();
537     assertEquals(rs.getThreshold(), 10);
538     assertTrue(rs.conservationApplied());
539     assertEquals(rs.getConservationInc(), 20);
540
541     /*
542      * create a group with Strand colouring, 30% Conservation
543      * and 40% PID threshold
544      */
545     SequenceGroup sg = new SequenceGroup();
546     sg.addSequence(al.getSequenceAt(0), false);
547     sg.setStartRes(15);
548     sg.setEndRes(25);
549     av.setSelectionGroup(sg);
550     PopupMenu popupMenu = new PopupMenu(af.alignPanel, al.getSequenceAt(0),
551             null);
552     popupMenu.changeColour_actionPerformed(
553             JalviewColourScheme.Strand.toString());
554     assertTrue(sg.getColourScheme() instanceof StrandColourScheme);
555     assertEquals(al.getGroups().size(), 1);
556     assertSame(al.getGroups().get(0), sg);
557     popupMenu.conservationMenuItem_actionPerformed(true);
558     sp = SliderPanel.getSliderPanel();
559     assertTrue(sp.isForConservation());
560     sp.valueChanged(30);
561     popupMenu.abovePIDColour_actionPerformed(true);
562     sp = SliderPanel.getSliderPanel();
563     assertFalse(sp.isForConservation());
564     sp.valueChanged(40);
565     rs = sg.getGroupColourScheme();
566     assertTrue(rs.conservationApplied());
567     assertEquals(rs.getConservationInc(), 30);
568     assertEquals(rs.getThreshold(), 40);
569
570     /*
571      * set slider panel focus to the background alignment
572      */
573     af.conservationMenuItem_actionPerformed(true);
574     sp = SliderPanel.getSliderPanel();
575     assertTrue(sp.isForConservation());
576     assertEquals(sp.getTitle(), MessageManager.formatMessage(
577             "label.conservation_colour_increment", new String[]
578             { "Background" }));
579
580     /*
581      * make a new View, verify alignment and group colour schemes
582      */
583     af.newView_actionPerformed(null);
584     assertEquals(af.alignPanel.getViewName(), "View 1");
585     AlignViewport av2 = af.getViewport();
586     assertNotSame(av, av2);
587     assertSame(av2, af.alignPanel.av);
588     rs = av2.getResidueShading();
589     assertNotSame(av.getResidueShading(), rs);
590     assertEquals(rs.getThreshold(), 10);
591     assertTrue(rs.conservationApplied(), rs.toString());
592     assertEquals(rs.getConservationInc(), 20);
593     assertEquals(av2.getAlignment().getGroups().size(), 1);
594     sg = av2.getAlignment().getGroups().get(0);
595     rs = sg.getGroupColourScheme();
596     assertTrue(rs.conservationApplied());
597     assertEquals(rs.getConservationInc(), 30);
598     assertEquals(rs.getThreshold(), 40);
599
600     /*
601      * check the Conservation SliderPanel (still open) is linked to 
602      * and updates the new view (JAL-2385)
603      */
604     sp = SliderPanel.getSliderPanel();
605     assertTrue(sp.isForConservation());
606     assertEquals(sp.getTitle(), MessageManager.formatMessage(
607             "label.conservation_colour_increment", new String[]
608             { "View 1" }));
609     sp.valueChanged(22);
610     assertEquals(av2.getResidueShading().getConservationInc(), 22);
611   }
612
613   /**
614    * Verify that making a New View preserves the dataset reference for the
615    * alignment. Otherwise, see a 'duplicate jar entry' reference when trying to
616    * save alignments with multiple views, and codon mappings will not be shared
617    * across all panels in a split frame.
618    * 
619    * @see Jalview2xmlTests#testStoreAndRecoverColourThresholds()
620    */
621   @Test(groups = "Functional")
622   public void testNewView_dsRefPreserved()
623   {
624     AlignViewport av = af.getViewport();
625     AlignmentI al = av.getAlignment();
626     AlignmentI original_ds = al.getDataset();
627     af.newView_actionPerformed(null);
628     assertNotEquals("New view didn't select the a new panel", av,
629             af.getViewport());
630     org.testng.Assert.assertEquals(original_ds,
631             af.getViewport().getAlignment().getDataset(),
632             "Dataset was not preserved in new view");
633   }
634 }