Clover icon

Coverage Report

  1. Project Clover database Thu Dec 4 2025 16:11:35 GMT
  2. Package jalview.gui

File AlignViewportTest.java

 

Code metrics

6
246
15
1
587
412
22
0.09
16.4
15
1.47

Classes

Class Line # Actions
AlignViewportTest 63 246 22
0.996254799.6%
 

Contributing tests

This file is covered by 11 tests. .

Source view

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.testng.AssertJUnit.assertEquals;
24    import static org.testng.AssertJUnit.assertFalse;
25    import static org.testng.AssertJUnit.assertNotNull;
26    import static org.testng.AssertJUnit.assertNotSame;
27    import static org.testng.AssertJUnit.assertSame;
28    import static org.testng.AssertJUnit.assertTrue;
29   
30    import jalview.api.AlignViewportI;
31    import java.util.ArrayList;
32    import java.util.List;
33   
34    import org.testng.Assert;
35    import org.testng.annotations.BeforeClass;
36    import org.testng.annotations.BeforeMethod;
37    import org.testng.annotations.Test;
38   
39    import jalview.bin.Cache;
40    import jalview.bin.Jalview;
41    import jalview.datamodel.AlignedCodonFrame;
42    import jalview.datamodel.Alignment;
43    import jalview.datamodel.AlignmentAnnotation;
44    import jalview.datamodel.AlignmentI;
45    import jalview.datamodel.Annotation;
46    import jalview.datamodel.ContactMatrixI;
47    import jalview.datamodel.SearchResults;
48    import jalview.datamodel.SearchResultsI;
49    import jalview.datamodel.SeqDistanceContactMatrix;
50    import jalview.datamodel.Sequence;
51    import jalview.datamodel.SequenceGroup;
52    import jalview.datamodel.SequenceI;
53    import jalview.io.DataSourceType;
54    import jalview.io.FileLoader;
55    import jalview.schemes.ClustalxColourScheme;
56    import jalview.schemes.ColourSchemeI;
57    import jalview.schemes.PIDColourScheme;
58    import jalview.structure.StructureSelectionManager;
59    import jalview.util.MapList;
60    import jalview.viewmodel.AlignmentViewport;
61    import jalview.viewmodel.ViewportRanges;
62   
 
63    public class AlignViewportTest
64    {
65   
 
66  1 toggle @BeforeClass(alwaysRun = true)
67    public void setUpJvOptionPane()
68    {
69  1 JvOptionPane.setInteractiveMode(false);
70  1 JvOptionPane.setMockResponse(JvOptionPane.CANCEL_OPTION);
71    }
72   
73    AlignmentI al;
74   
75    AlignmentViewport testee;
76   
 
77  1 toggle @BeforeClass(alwaysRun = true)
78    public static void setUpBeforeClass() throws Exception
79    {
80  1 Jalview.main(
81    new String[]
82    { "--nonews", "--props", "test/jalview/testProps.jvprops" });
83   
84    /*
85    * remove any sequence mappings left lying around by other tests
86    */
87  1 StructureSelectionManager ssm = StructureSelectionManager
88    .getStructureSelectionManager(Desktop.getInstance());
89  1 ssm.resetAll();
90    }
91   
 
92  11 toggle @BeforeMethod(alwaysRun = true)
93    public void setUp()
94    {
95  11 SequenceI seq1 = new Sequence("Seq1", "ABC");
96  11 SequenceI seq2 = new Sequence("Seq2", "ABC");
97  11 SequenceI seq3 = new Sequence("Seq3", "ABC");
98  11 SequenceI[] seqs = new SequenceI[] { seq1, seq2, seq3 };
99  11 al = new Alignment(seqs);
100  11 al.setDataset(null);
101  11 testee = new AlignViewport(al);
102    }
103   
104    /**
105    * Test that a mapping is not deregistered when a second view is closed but
106    * the first still holds a reference to the mapping
107    */
 
108  1 toggle @Test(groups = { "Functional" })
109    public void testDeregisterMapping_onCloseView()
110    {
111    /*
112    * alignment with reference to mappings
113    */
114  1 AlignFrame af1 = new FileLoader().LoadFileWaitTillLoaded(
115    ">Seq1\nCAGT\n", DataSourceType.PASTE);
116   
117  1 SequenceI s1 = af1.getViewport().getAlignment().getSequenceAt(0);
118  1 AlignedCodonFrame acf1 = new AlignedCodonFrame();
119  1 acf1.addMap(s1, s1, new MapList(new int[] { 1, 4 }, new int[] { 1, 4 },
120    1, 1));
121  1 AlignedCodonFrame acf2 = new AlignedCodonFrame();
122  1 acf2.addMap(s1, s1, new MapList(new int[] { 1, 4 }, new int[] { 4, 1 },
123    1, 1));
124   
125  1 List<AlignedCodonFrame> mappings = new ArrayList<>();
126  1 mappings.add(acf1);
127  1 mappings.add(acf2);
128  1 af1.getViewport().getAlignment().setCodonFrames(mappings);
129  1 af1.newView_actionPerformed(null);
130   
131    /*
132    * Verify that creating the alignment for the new View has registered the
133    * mappings
134    */
135  1 StructureSelectionManager ssm = StructureSelectionManager
136    .getStructureSelectionManager(Desktop.getInstance());
137  1 List<AlignedCodonFrame> sequenceMappings = ssm.getSequenceMappings();
138  1 assertEquals(2, sequenceMappings.size());
139  1 assertTrue(sequenceMappings.contains(acf1));
140  1 assertTrue(sequenceMappings.contains(acf2));
141   
142    /*
143    * Close the second view. Verify that mappings are not removed as the first
144    * view still holds a reference to them.
145    */
146  1 af1.closeMenuItem_actionPerformed(false);
147  1 assertEquals(2, sequenceMappings.size());
148  1 assertTrue(sequenceMappings.contains(acf1));
149  1 assertTrue(sequenceMappings.contains(acf2));
150    }
151   
152    /**
153    * Test that a mapping is deregistered if no alignment holds a reference to it
154    */
 
155  1 toggle @Test(groups = { "Functional" })
156    public void testDeregisterMapping_withNoReference()
157    {
158  1 Desktop d = Desktop.getInstance();
159  1 assertNotNull(d);
160  1 StructureSelectionManager ssm = StructureSelectionManager
161    .getStructureSelectionManager(Desktop.getInstance());
162  1 ssm.resetAll();
163   
164  1 AlignFrame af1 = new FileLoader().LoadFileWaitTillLoaded(
165    ">Seq1\nRSVQ\n", DataSourceType.PASTE);
166  1 AlignFrame af2 = new FileLoader().LoadFileWaitTillLoaded(
167    ">Seq2\nDGEL\n", DataSourceType.PASTE);
168  1 SequenceI cs1 = new Sequence("cseq1", "CCCGGGTTTAAA");
169  1 SequenceI cs2 = new Sequence("cseq2", "CTTGAGTCTAGA");
170  1 SequenceI s1 = af1.getViewport().getAlignment().getSequenceAt(0);
171  1 SequenceI s2 = af2.getViewport().getAlignment().getSequenceAt(0);
172    // need to be distinct
173  1 AlignedCodonFrame acf1 = new AlignedCodonFrame();
174  1 acf1.addMap(cs1, s1, new MapList(new int[] { 1, 4 },
175    new int[] { 1, 12 }, 1, 3));
176  1 AlignedCodonFrame acf2 = new AlignedCodonFrame();
177  1 acf2.addMap(cs2, s2, new MapList(new int[] { 1, 4 },
178    new int[] { 1, 12 }, 1, 3));
179  1 AlignedCodonFrame acf3 = new AlignedCodonFrame();
180  1 acf3.addMap(cs2, cs2, new MapList(new int[] { 1, 12 }, new int[] { 1,
181    12 }, 1, 1));
182   
183  1 List<AlignedCodonFrame> mappings1 = new ArrayList<>();
184  1 mappings1.add(acf1);
185  1 af1.getViewport().getAlignment().setCodonFrames(mappings1);
186   
187  1 List<AlignedCodonFrame> mappings2 = new ArrayList<>();
188  1 mappings2.add(acf2);
189  1 mappings2.add(acf3);
190  1 af2.getViewport().getAlignment().setCodonFrames(mappings2);
191   
192    /*
193    * AlignFrame1 has mapping acf1, AlignFrame2 has acf2 and acf3
194    */
195   
196  1 List<AlignedCodonFrame> ssmMappings = ssm.getSequenceMappings();
197  1 assertEquals(0, ssmMappings.size());
198  1 ssm.registerMapping(acf1);
199  1 assertEquals(1, ssmMappings.size());
200  1 ssm.registerMapping(acf2);
201  1 assertEquals(2, ssmMappings.size());
202  1 ssm.registerMapping(acf3);
203  1 assertEquals(3, ssmMappings.size());
204   
205    /*
206    * Closing AlignFrame2 should remove its mappings from
207    * StructureSelectionManager, since AlignFrame1 has no reference to them
208    */
209  1 af2.closeMenuItem_actionPerformed(true);
210  1 assertEquals(1, ssmMappings.size());
211  1 assertTrue(ssmMappings.contains(acf1));
212    }
213   
214    /**
215    * Test that a mapping is not deregistered if another alignment holds a
216    * reference to it
217    */
 
218  1 toggle @Test(groups = { "Functional" })
219    public void testDeregisterMapping_withReference()
220    {
221  1 Desktop d = Desktop.getInstance();
222  1 assertNotNull(d);
223  1 StructureSelectionManager ssm = StructureSelectionManager
224    .getStructureSelectionManager(Desktop.getInstance());
225  1 ssm.resetAll();
226   
227  1 AlignFrame af1 = new FileLoader().LoadFileWaitTillLoaded(
228    ">Seq1\nRSVQ\n", DataSourceType.PASTE);
229  1 AlignFrame af2 = new FileLoader().LoadFileWaitTillLoaded(
230    ">Seq2\nDGEL\n", DataSourceType.PASTE);
231  1 SequenceI cs1 = new Sequence("cseq1", "CCCGGGTTTAAA");
232  1 SequenceI cs2 = new Sequence("cseq2", "CTTGAGTCTAGA");
233  1 SequenceI s1 = af1.getViewport().getAlignment().getSequenceAt(0);
234  1 SequenceI s2 = af2.getViewport().getAlignment().getSequenceAt(0);
235    // need to be distinct
236  1 AlignedCodonFrame acf1 = new AlignedCodonFrame();
237  1 acf1.addMap(cs1, s1, new MapList(new int[] { 1, 4 },
238    new int[] { 1, 12 }, 1, 3));
239  1 AlignedCodonFrame acf2 = new AlignedCodonFrame();
240  1 acf2.addMap(cs2, s2, new MapList(new int[] { 1, 4 },
241    new int[] { 1, 12 }, 1, 3));
242  1 AlignedCodonFrame acf3 = new AlignedCodonFrame();
243  1 acf3.addMap(cs2, cs2, new MapList(new int[] { 1, 12 }, new int[] { 1,
244    12 }, 1, 1));
245   
246  1 List<AlignedCodonFrame> mappings1 = new ArrayList<>();
247  1 mappings1.add(acf1);
248  1 mappings1.add(acf2);
249  1 af1.getViewport().getAlignment().setCodonFrames(mappings1);
250   
251  1 List<AlignedCodonFrame> mappings2 = new ArrayList<>();
252  1 mappings2.add(acf2);
253  1 mappings2.add(acf3);
254  1 af2.getViewport().getAlignment().setCodonFrames(mappings2);
255   
256    /*
257    * AlignFrame1 has mappings acf1 and acf2, AlignFrame2 has acf2 and acf3
258    */
259   
260  1 List<AlignedCodonFrame> ssmMappings = ssm.getSequenceMappings();
261  1 assertEquals(0, ssmMappings.size());
262  1 ssm.registerMapping(acf1);
263  1 assertEquals(1, ssmMappings.size());
264  1 ssm.registerMapping(acf2);
265  1 assertEquals(2, ssmMappings.size());
266  1 ssm.registerMapping(acf3);
267  1 assertEquals(3, ssmMappings.size());
268   
269    /*
270    * Closing AlignFrame2 should remove mapping acf3 from
271    * StructureSelectionManager, but not acf2, since AlignFrame1 still has a
272    * reference to it
273    */
274  1 af2.closeMenuItem_actionPerformed(true);
275  1 assertEquals(2, ssmMappings.size());
276  1 assertTrue(ssmMappings.contains(acf1));
277  1 assertTrue(ssmMappings.contains(acf2));
278  1 assertFalse(ssmMappings.contains(acf3));
279    }
280   
281    /**
282    * Test for JAL-1306 - conservation thread should run even when only Quality
283    * (and not Conservation) is enabled in Preferences
284    */
 
285  1 toggle @Test(groups = { "Functional" }, timeOut=2000)
286    public void testUpdateConservation_qualityOnly()
287    {
288  1 Cache.setPropertyNoSave("SHOW_ANNOTATIONS",
289    Boolean.TRUE.toString());
290  1 Cache.setPropertyNoSave("SHOW_QUALITY",
291    Boolean.TRUE.toString());
292  1 Cache.setPropertyNoSave("SHOW_CONSERVATION",
293    Boolean.FALSE.toString());
294  1 Cache.setPropertyNoSave("SHOW_OCCUPANCY",
295    Boolean.FALSE.toString());
296  1 Cache.setPropertyNoSave("SHOW_IDENTITY",
297    Boolean.FALSE.toString());
298  1 AlignFrame af = new FileLoader().LoadFileWaitTillLoaded(
299    "examples/uniref50.fa", DataSourceType.FILE);
300   
301    /*
302    * wait for Conservation thread to complete
303    */
304  1 AlignViewport viewport = af.getViewport();
305  1 waitForCalculations(viewport);
306  1 AlignmentAnnotation[] anns = viewport.getAlignment()
307    .getAlignmentAnnotation();
308  1 assertNotNull("No annotations found", anns);
309  1 assertEquals("More than one annotation found", 1, anns.length);
310  1 assertTrue("Annotation is not Quality",
311    anns[0].description.startsWith("Alignment Quality"));
312  1 Annotation[] annotations = anns[0].annotations;
313  1 assertNotNull("Quality annotations are null", annotations);
314  1 assertNotNull("Quality in column 1 is null", annotations[0]);
315  1 assertTrue("No quality value in column 1", annotations[0].value > 10f);
316    }
317   
318    /**
319    * Wait for consensus etc calculation threads to complete
320    *
321    * @param viewport
322    */
 
323  2 toggle protected void waitForCalculations(AlignViewport viewport)
324    {
325  2 synchronized (this)
326    {
327  2 System.out.print("waiting...");
328  2 int n = 3;
329  8 while (--n >= 0 || viewport.getCalcManager().isWorking())
330    {
331  6 try
332    {
333  6 wait(50);
334    } catch (InterruptedException e)
335    {
336    }
337    }
338  2 System.out.println("...done");
339    }
340    }
341   
 
342  1 toggle @Test(groups = { "Functional" })
343    public void testSetGlobalColourScheme()
344    {
345    /*
346    * test for JAL-2283: don't inadvertently turn on colour by conservation
347    */
348  1 Cache.setPropertyNoSave("DEFAULT_COLOUR_PROT", "None");
349  1 Cache.setPropertyNoSave("SHOW_CONSERVATION",
350    Boolean.TRUE.toString());
351  1 AlignFrame af = new FileLoader().LoadFileWaitTillLoaded(
352    "examples/uniref50.fa", DataSourceType.FILE);
353  1 ColourSchemeI cs = new PIDColourScheme();
354  1 AlignViewport viewport = af.getViewport();
355  1 viewport.setGlobalColourScheme(cs);
356  1 assertFalse(viewport.getResidueShading()
357    .conservationApplied());
358   
359    /*
360    * JAL-3201 groups have their own ColourSchemeI instances
361    */
362  1 AlignmentI aln = viewport.getAlignment();
363  1 SequenceGroup sg1 = new SequenceGroup();
364  1 sg1.addSequence(aln.getSequenceAt(0), false);
365  1 sg1.addSequence(aln.getSequenceAt(2), false);
366  1 SequenceGroup sg2 = new SequenceGroup();
367  1 sg2.addSequence(aln.getSequenceAt(1), false);
368  1 sg2.addSequence(aln.getSequenceAt(3), false);
369  1 aln.addGroup(sg1);
370  1 aln.addGroup(sg2);
371  1 viewport.setColourAppliesToAllGroups(true);
372  1 viewport.setGlobalColourScheme(new ClustalxColourScheme());
373  1 ColourSchemeI cs0 = viewport.getGlobalColourScheme();
374  1 ColourSchemeI cs1 = sg1.getColourScheme();
375  1 ColourSchemeI cs2 = sg2.getColourScheme();
376  1 assertTrue(cs0 instanceof ClustalxColourScheme);
377  1 assertTrue(cs1 instanceof ClustalxColourScheme);
378  1 assertTrue(cs2 instanceof ClustalxColourScheme);
379  1 assertNotSame(cs0, cs1);
380  1 assertNotSame(cs0, cs2);
381  1 assertNotSame(cs1, cs2);
382    }
383   
 
384  1 toggle @Test(groups = { "Functional" })
385    public void testSetGetHasSearchResults()
386    {
387  1 AlignFrame af = new FileLoader().LoadFileWaitTillLoaded(
388    "examples/uniref50.fa", DataSourceType.FILE);
389  1 SearchResultsI sr = new SearchResults();
390  1 SequenceI s1 = af.getViewport().getAlignment().getSequenceAt(0);
391   
392    // create arbitrary range on first sequence
393  1 sr.addResult(s1, s1.getStart() + 10, s1.getStart() + 15);
394   
395    // test set
396  1 af.getViewport().setSearchResults(sr);
397    // has -> true
398  1 assertTrue(af.getViewport().hasSearchResults());
399    // get == original
400  1 assertEquals(sr, af.getViewport().getSearchResults());
401   
402    // set(null) results in has -> false
403   
404  1 af.getViewport().setSearchResults(null);
405  1 assertFalse(af.getViewport().hasSearchResults());
406    }
407   
408    /**
409    * Verify that setting the selection group has the side-effect of setting the
410    * context on the group, unless it already has one, but does not change
411    * whether the group is defined or not.
412    */
 
413  1 toggle @Test(groups = { "Functional" })
414    public void testSetSelectionGroup()
415    {
416  1 AlignFrame af = new FileLoader().LoadFileWaitTillLoaded(
417    "examples/uniref50.fa", DataSourceType.FILE);
418  1 AlignViewportI av = af.getViewport();
419  1 SequenceGroup sg1 = new SequenceGroup();
420  1 SequenceGroup sg2 = new SequenceGroup();
421  1 SequenceGroup sg3 = new SequenceGroup();
422   
423  1 av.setSelectionGroup(sg1);
424  1 assertSame(sg1.getContext(), av.getAlignment()); // context set
425  1 assertFalse(sg1.isDefined()); // group not defined
426   
427  1 sg2.setContext(sg1, false);
428  1 av.setSelectionGroup(sg2);
429  1 assertFalse(sg2.isDefined()); // unchanged
430  1 assertSame(sg2.getContext(), sg1); // unchanged
431   
432    // create a defined group
433  1 sg3.setContext(av.getAlignment(), true);
434  1 av.setSelectionGroup(sg3);
435  1 assertTrue(sg3.isDefined()); // unchanged
436    }
437    /**
438    * Verify that setting/clearing SHOW_OCCUPANCY preference adds or omits occupancy row from viewport
439    */
 
440  1 toggle @Test(groups = { "Functional" })
441    public void testShowOrDontShowOccupancy()
442    {
443    // disable occupancy
444  1 jalview.bin.Cache.setProperty("SHOW_OCCUPANCY", Boolean.FALSE.toString());
445  1 AlignFrame af = new FileLoader().LoadFileWaitTillLoaded(
446    "examples/uniref50.fa", DataSourceType.FILE);
447  1 AlignViewportI av = af.getViewport();
448  4 while (av.getCalcManager().isWorking())
449    {
450  3 try {
451  3 Thread.sleep(5);
452    } catch (InterruptedException x) {}
453    }
454  1 Assert.assertNull(av.getAlignmentGapAnnotation(),
455    "Preference did not disable occupancy row.");
456  1 int c = 0;
457  1 for (AlignmentAnnotation aa : av.getAlignment().findAnnotations(null,
458    null, "Occupancy"))
459    {
460  0 c++;
461    }
462  1 Assert.assertEquals(c, 0, "Expected zero occupancy rows.");
463   
464    // enable occupancy
465  1 jalview.bin.Cache.setProperty("SHOW_OCCUPANCY", Boolean.TRUE.toString());
466  1 af = new FileLoader().LoadFileWaitTillLoaded(
467    "examples/uniref50.fa", DataSourceType.FILE);
468   
469  1 av = af.getViewport();
470   
471  3 while (av.getCalcManager().isWorking())
472    {
473  2 try {
474  2 Thread.sleep(5);
475    } catch (InterruptedException x) {}
476    }
477  1 Assert.assertNotNull(av.getAlignmentGapAnnotation(),
478    "Preference did not enable occupancy row.");
479  1 c = 0;
480  1 for (AlignmentAnnotation aa : av.getAlignment().findAnnotations(null,
481    null, av.getAlignmentGapAnnotation().label))
482    {
483  1 c++;
484  1 Assert.assertNotNull(aa.annotations);
485    // check that an arbitrary column has an occupancy of greater than zero
486  1 Assert.assertNotNull(aa.annotations[5],
487    "Expected occupancy to be non-null in column 5");
488  1 Assert.assertNotEquals(aa.annotations[5].value, 0f,
489    "Expected occupancy to not be zero in column 5");
490   
491    }
492  1 ;
493  1 Assert.assertEquals(c, 1, "Expected to find one occupancy row.");
494    }
495   
 
496  1 toggle @Test(groups = { "Functional" })
497    public void testGetConsensusSeq()
498    {
499    /*
500    * A-C
501    * A-C
502    * A-D
503    * --D
504    * consensus expected to be A-C
505    */
506  1 String fasta = ">s1\nA-C\n>s2\nA-C\n>s3\nA-D\n>s4\n--D\n";
507  1 AlignFrame af = new FileLoader().LoadFileWaitTillLoaded(fasta,
508    DataSourceType.PASTE);
509  1 AlignViewport testme = af.getViewport();
510  1 waitForCalculations(testme);
511  1 SequenceI cons = testme.getConsensusSeq();
512  1 assertEquals("A-C", cons.getSequenceAsString());
513    }
514   
 
515  1 toggle @Test(groups = { "Functional" })
516    public void testHideRevealSequences()
517    {
518  1 ViewportRanges ranges = testee.getRanges();
519  1 assertEquals(3, al.getHeight());
520  1 assertEquals(0, ranges.getStartSeq());
521  1 assertEquals(2, ranges.getEndSeq());
522   
523    /*
524    * hide first sequence
525    */
526  1 testee.hideSequence(new SequenceI[] { al.getSequenceAt(0) });
527  1 assertEquals(2, al.getHeight());
528  1 assertEquals(0, ranges.getStartSeq());
529  1 assertEquals(1, ranges.getEndSeq());
530   
531    /*
532    * reveal hidden sequences above the first
533    */
534  1 testee.showSequence(0);
535  1 assertEquals(3, al.getHeight());
536  1 assertEquals(0, ranges.getStartSeq());
537  1 assertEquals(2, ranges.getEndSeq());
538   
539    /*
540    * hide first and third sequences
541    */
542  1 testee.hideSequence(
543    new SequenceI[]
544    { al.getSequenceAt(0), al.getSequenceAt(2) });
545  1 assertEquals(1, al.getHeight());
546  1 assertEquals(0, ranges.getStartSeq());
547  1 assertEquals(0, ranges.getEndSeq());
548   
549    /*
550    * reveal all hidden sequences
551    */
552  1 testee.showAllHiddenSeqs();
553  1 assertEquals(3, al.getHeight());
554  1 assertEquals(0, ranges.getStartSeq());
555  1 assertEquals(2, ranges.getEndSeq());
556    }
557   
 
558  1 toggle @Test(groups = { "Functional" })
559    public void testGetSelectionAsNewSequences_withContactMatrices()
560    {
561  1 SequenceI seq = new Sequence("seq", "ACADA");
562  1 ContactMatrixI cmat = new SeqDistanceContactMatrix(5);
563  1 seq.addContactList(cmat);
564  1 Alignment al = new Alignment(new SequenceI[] { seq.deriveSequence() });
565  1 al.addAnnotation(al.getSequenceAt(0).getAnnotation()[0]);
566  1 AlignFrame af = new AlignFrame(al, 500, 500);
567   
568  1 SequenceI selseqs[] = af.getViewport().getSelectionAsNewSequence();
569  1 assertNotNull(selseqs[0].getAnnotation());
570  1 assertNotNull(selseqs[0].getAnnotation()[0]);
571  1 assertEquals(cmat,
572    selseqs[0].getContactMatrixFor(selseqs[0].getAnnotation()[0]));
573   
574  1 assertNotNull(
575    selseqs[0].getContactListFor(selseqs[0].getAnnotation()[0], 2));
576   
577    // now select everything and test again
578  1 af.selectAllSequenceMenuItem_actionPerformed(null);
579  1 selseqs = af.getViewport().getSelectionAsNewSequence();
580  1 assertNotNull(selseqs[0].getAnnotation());
581  1 assertNotNull(selseqs[0].getAnnotation()[0]);
582  1 assertEquals(cmat,
583    selseqs[0].getContactMatrixFor(selseqs[0].getAnnotation()[0]));
584  1 assertNotNull(
585    selseqs[0].getContactListFor(selseqs[0].getAnnotation()[0], 2));
586    }
587    }