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