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