2 * Jalview - A Sequence Alignment Editor and Viewer ($$Version-Rel$$)
3 * Copyright (C) $$Year-Rel$$ The Jalview Authors
5 * This file is part of Jalview.
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.
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.
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.
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.assertSame;
27 import static org.testng.AssertJUnit.assertTrue;
29 import jalview.api.AlignViewportI;
30 import jalview.api.AlignmentViewPanel;
31 import jalview.api.ViewStyleI;
32 import jalview.bin.Cache;
33 import jalview.datamodel.AlignmentAnnotation;
34 import jalview.datamodel.AlignmentI;
35 import jalview.datamodel.HiddenSequences;
36 import jalview.datamodel.SequenceCollectionI;
37 import jalview.datamodel.SequenceGroup;
38 import jalview.datamodel.SequenceI;
39 import jalview.gui.AlignFrame;
40 import jalview.gui.Desktop;
41 import jalview.gui.Jalview2XML;
42 import jalview.schemes.AnnotationColourGradient;
43 import jalview.schemes.ColourSchemeI;
44 import jalview.structure.StructureImportSettings;
45 import jalview.viewmodel.AlignmentViewport;
48 import java.time.Instant;
49 import java.util.ArrayList;
50 import java.util.Date;
51 import java.util.HashMap;
52 import java.util.List;
55 import org.testng.Assert;
56 import org.testng.AssertJUnit;
57 import org.testng.annotations.AfterClass;
58 import org.testng.annotations.BeforeClass;
59 import org.testng.annotations.Test;
61 @Test(singleThreaded = true)
62 public class Jalview2xmlTests
66 * @throws java.lang.Exception
68 @BeforeClass(alwaysRun = true)
69 public static void setUpBeforeClass() throws Exception
71 jalview.bin.Jalview.main(new String[] { "-props",
72 "test/jalview/io/testProps.jvprops" });
73 jalview.bin.Cache.setProperty("JALVIEW_NEWS_RSS_LASTMODIFIED",
74 Cache.date_format.format(Date.from(Instant.now().plusSeconds(
79 * @throws java.lang.Exception
81 @AfterClass(alwaysRun = true)
82 public static void tearDownAfterClass() throws Exception
84 jalview.gui.Desktop.instance.closeAll_actionPerformed(null);
87 int countDsAnn(jalview.viewmodel.AlignmentViewport avp)
90 for (SequenceI sq : avp.getAlignment().getDataset().getSequences())
92 if (sq.getAnnotation() != null)
94 for (AlignmentAnnotation dssa : sq.getAnnotation())
96 if (dssa.isValidStruc())
106 @Test(groups = { "Functional" })
107 public void testRNAStructureRecovery() throws Exception
109 String inFile = "examples/RF00031_folded.stk";
110 String tfile = File.createTempFile("JalviewTest", ".jvp")
112 AlignFrame af = new jalview.io.FileLoader().LoadFileWaitTillLoaded(
113 inFile, FormatAdapter.FILE);
114 assertTrue("Didn't read input file " + inFile, af != null);
115 int olddsann = countDsAnn(af.getViewport());
116 assertTrue("Didn't find any dataset annotations", olddsann > 0);
117 af.rnahelicesColour_actionPerformed(null);
119 "Couldn't apply RNA helices colourscheme",
120 af.getViewport().getGlobalColourScheme() instanceof jalview.schemes.RNAHelicesColour);
121 assertTrue("Failed to store as a project.",
122 af.saveAlignment(tfile, "Jalview"));
123 af.closeMenuItem_actionPerformed(true);
125 af = new jalview.io.FileLoader().LoadFileWaitTillLoaded(tfile,
127 assertTrue("Failed to import new project", af != null);
128 int newdsann = countDsAnn(af.getViewport());
130 "Differing numbers of dataset sequence annotation\nOriginally "
131 + olddsann + " and now " + newdsann,
132 olddsann == newdsann);
134 .println("Read in same number of annotations as originally present ("
137 "RNA helices colourscheme was not applied on import.",
138 af.getViewport().getGlobalColourScheme() instanceof jalview.schemes.RNAHelicesColour);
141 @Test(groups = { "Functional" })
142 public void testTCoffeeScores() throws Exception
144 String inFile = "examples/uniref50.fa", inAnnot = "examples/uniref50.score_ascii";
145 String tfile = File.createTempFile("JalviewTest", ".jvp")
147 AlignFrame af = new jalview.io.FileLoader().LoadFileWaitTillLoaded(
148 inFile, FormatAdapter.FILE);
149 assertTrue("Didn't read input file " + inFile, af != null);
150 af.loadJalviewDataFile(inAnnot, FormatAdapter.FILE, null, null);
152 "Didn't set T-coffee colourscheme",
153 af.getViewport().getGlobalColourScheme().getClass()
154 .equals(jalview.schemes.TCoffeeColourScheme.class));
156 "Recognise T-Coffee score from string",
157 jalview.schemes.ColourSchemeProperty.getColour(af.getViewport()
159 jalview.schemes.ColourSchemeProperty.getColourName(af
160 .getViewport().getGlobalColourScheme())) != null);
162 assertTrue("Failed to store as a project.",
163 af.saveAlignment(tfile, "Jalview"));
164 af.closeMenuItem_actionPerformed(true);
166 af = new jalview.io.FileLoader().LoadFileWaitTillLoaded(tfile,
168 assertTrue("Failed to import new project", af != null);
170 "Didn't set T-coffee colourscheme for imported project.",
171 af.getViewport().getGlobalColourScheme().getClass()
172 .equals(jalview.schemes.TCoffeeColourScheme.class));
174 .println("T-Coffee score shading successfully recovered from project.");
177 @Test(groups = { "Functional" })
178 public void testColourByAnnotScores() throws Exception
180 String inFile = "examples/uniref50.fa", inAnnot = "examples/testdata/uniref50_iupred.jva";
181 String tfile = File.createTempFile("JalviewTest", ".jvp")
183 AlignFrame af = new jalview.io.FileLoader().LoadFileWaitTillLoaded(
184 inFile, FormatAdapter.FILE);
185 assertTrue("Didn't read input file " + inFile, af != null);
186 af.loadJalviewDataFile(inAnnot, FormatAdapter.FILE, null, null);
187 AlignmentAnnotation[] aa = af.getViewport().getAlignment()
188 .getSequenceAt(0).getAnnotation("IUPredWS (Short)");
190 "Didn't find any IUPred annotation to use to shade alignment.",
191 aa != null && aa.length > 0);
192 AnnotationColourGradient cs = new jalview.schemes.AnnotationColourGradient(
193 aa[0], null, AnnotationColourGradient.ABOVE_THRESHOLD);
194 AnnotationColourGradient gcs = new jalview.schemes.AnnotationColourGradient(
195 aa[0], null, AnnotationColourGradient.BELOW_THRESHOLD);
196 cs.setSeqAssociated(true);
197 gcs.setSeqAssociated(true);
199 SequenceGroup sg = new SequenceGroup();
203 af.getViewport().getAlignment().addGroup(sg);
204 sg.addSequence(af.getViewport().getAlignment().getSequenceAt(1), false);
205 sg.addSequence(af.getViewport().getAlignment().getSequenceAt(2), true);
206 af.alignPanel.alignmentChanged();
207 assertTrue("Failed to store as a project.",
208 af.saveAlignment(tfile, "Jalview"));
209 af.closeMenuItem_actionPerformed(true);
211 af = new jalview.io.FileLoader().LoadFileWaitTillLoaded(tfile,
213 assertTrue("Failed to import new project", af != null);
215 // check for group and alignment colourschemes
217 ColourSchemeI _rcs = af.getViewport().getGlobalColourScheme();
218 ColourSchemeI _rgcs = af.getViewport().getAlignment().getGroups()
220 assertTrue("Didn't recover global colourscheme", _rcs != null);
221 assertTrue("Didn't recover annotation colour global scheme",
222 _rcs instanceof AnnotationColourGradient);
223 AnnotationColourGradient __rcs = (AnnotationColourGradient) _rcs;
224 assertTrue("Annotation colourscheme wasn't sequence associated",
225 __rcs.isSeqAssociated());
227 boolean diffseqcols = false, diffgseqcols = false;
228 SequenceI[] sqs = af.getViewport().getAlignment().getSequencesArray();
229 for (int p = 0, pSize = af.getViewport().getAlignment().getWidth(); p < pSize
230 && (!diffseqcols || !diffgseqcols); p++)
232 if (_rcs.findColour(sqs[0].getCharAt(p), p, sqs[0]) != _rcs
233 .findColour(sqs[5].getCharAt(p), p, sqs[5]))
238 assertTrue("Got Different sequence colours", diffseqcols);
240 .println("Per sequence colourscheme (Background) successfully applied and recovered.");
242 assertTrue("Didn't recover group colourscheme", _rgcs != null);
243 assertTrue("Didn't recover annotation colour group colourscheme",
244 _rgcs instanceof AnnotationColourGradient);
245 __rcs = (AnnotationColourGradient) _rgcs;
246 assertTrue("Group Annotation colourscheme wasn't sequence associated",
247 __rcs.isSeqAssociated());
249 for (int p = 0, pSize = af.getViewport().getAlignment().getWidth(); p < pSize
250 && (!diffseqcols || !diffgseqcols); p++)
252 if (_rgcs.findColour(sqs[1].getCharAt(p), p, sqs[1]) != _rgcs
253 .findColour(sqs[2].getCharAt(p), p, sqs[2]))
258 assertTrue("Got Different group sequence colours", diffgseqcols);
260 .println("Per sequence (Group) colourscheme successfully applied and recovered.");
263 @Test(groups = { "Functional" })
264 public void gatherViewsHere() throws Exception
266 int origCount = Desktop.getAlignFrames() == null ? 0 : Desktop
267 .getAlignFrames().length;
268 AlignFrame af = new jalview.io.FileLoader().LoadFileWaitTillLoaded(
269 "examples/exampleFile_2_7.jar", FormatAdapter.FILE);
270 assertTrue("Didn't read in the example file correctly.", af != null);
271 assertTrue("Didn't gather the views in the example file.",
272 Desktop.getAlignFrames().length == 1 + origCount);
276 @Test(groups = { "Functional" })
277 public void viewRefPdbAnnotation() throws Exception
279 // TODO: Make this pass without setting StructureParser.JALVIEW_PARSER
280 // StructureImportSettings
281 // .setDefaultPDBFileParser(StructureParser.JALVIEW_PARSER);
282 StructureImportSettings.setProcessSecondaryStructure(true);
283 StructureImportSettings.setVisibleChainAnnotation(true);
284 AlignFrame af = new jalview.io.FileLoader().LoadFileWaitTillLoaded(
285 "examples/exampleFile_2_7.jar", FormatAdapter.FILE);
286 assertTrue("Didn't read in the example file correctly.", af != null);
287 AlignmentViewPanel sps = null;
288 for (AlignmentViewPanel ap : af.alignPanel.alignFrame.getAlignPanels())
290 if ("Spinach Feredoxin Structure".equals(ap.getViewName()))
296 assertTrue("Couldn't find the structure view", sps != null);
297 SequenceI sq = sps.getAlignment().findName("1A70|");
298 AlignmentAnnotation refan = null;
299 for (AlignmentAnnotation ra : sps.getAlignment()
300 .getAlignmentAnnotation())
308 assertTrue("Annotation secondary structure not found.", refan != null);
309 assertTrue("Couldn't find 1a70 null chain", sq != null);
310 // compare the manually added temperature factor annotation
311 // to the track automatically transferred from the pdb structure on load
312 for (AlignmentAnnotation ala : sq.getDatasetSequence().getAnnotation())
314 AlignmentAnnotation alaa;
315 sq.addAlignmentAnnotation(alaa = new AlignmentAnnotation(ala));
316 alaa.adjustForAlignment();
317 if (ala.graph == refan.graph)
319 for (int p = 0; p < ala.annotations.length; p++)
325 "Mismatch at alignment position " + p,
326 (alaa.annotations[p] == null && refan.annotations[p] == null)
327 || alaa.annotations[p].value == refan.annotations[p].value);
328 } catch (NullPointerException q)
330 Assert.fail("Mismatch of alignment annotations at position "
331 + p + " Ref seq ann: " + refan.annotations[p]
332 + " alignment " + alaa.annotations[p]);
340 @Test(groups = { "Functional" })
341 public void testCopyViewSettings() throws Exception
343 AlignFrame af = new jalview.io.FileLoader().LoadFileWaitTillLoaded(
344 "examples/exampleFile_2_7.jar", FormatAdapter.FILE);
345 assertTrue("Didn't read in the example file correctly.", af != null);
346 AlignmentViewPanel sps = null, groups = null;
347 for (AlignmentViewPanel ap : af.alignPanel.alignFrame.getAlignPanels())
349 if ("Spinach Feredoxin Structure".equals(ap.getViewName()))
353 if (ap.getViewName().contains("MAFFT"))
358 assertTrue("Couldn't find the structure view", sps != null);
359 assertTrue("Couldn't find the MAFFT view", groups != null);
361 ViewStyleI structureStyle = sps.getAlignViewport().getViewStyle();
362 ViewStyleI groupStyle = groups.getAlignViewport().getViewStyle();
363 AssertJUnit.assertFalse(structureStyle.sameStyle(groupStyle));
365 groups.getAlignViewport().setViewStyle(structureStyle);
366 AssertJUnit.assertFalse(groupStyle.sameStyle(groups.getAlignViewport()
368 Assert.assertTrue(structureStyle.sameStyle(groups.getAlignViewport()
374 * test store and recovery of expanded views
378 @Test(groups = { "Functional" }, enabled = true)
379 public void testStoreAndRecoverExpandedviews() throws Exception
381 Desktop.instance.closeAll_actionPerformed(null);
383 AlignFrame af = new jalview.io.FileLoader().LoadFileWaitTillLoaded(
384 "examples/exampleFile_2_7.jar", FormatAdapter.FILE);
385 assertTrue("Didn't read in the example file correctly.", af != null);
386 Assert.assertEquals(Desktop.getAlignFrames().length, 1);
387 String afid = af.getViewport().getSequenceSetId();
389 // check FileLoader returned a reference to the one alignFrame that is
390 // actually on the Desktop
392 "Jalview2XML.loadAlignFrame() didn't return correct AlignFrame reference for multiple view window",
393 af == Desktop.getAlignFrameFor(af.getViewport()));
395 Desktop.explodeViews(af);
397 int oldviews = Desktop.getAlignFrames().length;
398 Assert.assertEquals(Desktop.getAlignFrames().length,
399 Desktop.getAlignmentPanels(afid).length);
400 File tfile = File.createTempFile("testStoreAndRecoverExpanded", ".jvp");
403 new Jalview2XML(false).saveState(tfile);
406 Assert.fail("Didn't save the expanded view state", e);
407 } catch (Exception e)
409 Assert.fail("Didn't save the expanded view state", e);
411 Desktop.instance.closeAll_actionPerformed(null);
412 if (Desktop.getAlignFrames() != null)
414 Assert.assertEquals(Desktop.getAlignFrames().length, 0);
416 af = new jalview.io.FileLoader().LoadFileWaitTillLoaded(
417 tfile.getAbsolutePath(), FormatAdapter.FILE);
418 Assert.assertNotNull(af);
420 Desktop.getAlignFrames().length,
421 Desktop.getAlignmentPanels(af.getViewport().getSequenceSetId()).length);
424 Desktop.getAlignmentPanels(af.getViewport().getSequenceSetId()).length);
428 * Test save and reload of a project with a different representative sequence
433 @Test(groups = { "Functional" })
434 public void testStoreAndRecoverReferenceSeqSettings() throws Exception
436 Desktop.instance.closeAll_actionPerformed(null);
437 AlignFrame af = new FileLoader().LoadFileWaitTillLoaded(
438 "examples/exampleFile_2_7.jar", FormatAdapter.FILE);
439 assertTrue("Didn't read in the example file correctly.", af != null);
440 String afid = af.getViewport().getSequenceSetId();
442 // remember reference sequence for each panel
443 Map<String, SequenceI> refseqs = new HashMap<String, SequenceI>();
446 * mark sequence 2, 3, 4.. in panels 1, 2, 3...
447 * as reference sequence for itself and the preceding sequence
450 for (AlignmentViewPanel ap : Desktop.getAlignmentPanels(afid))
452 AlignViewportI av = ap.getAlignViewport();
453 AlignmentI alignment = ap.getAlignment();
454 int repIndex = n % alignment.getHeight();
455 SequenceI rep = alignment.getSequenceAt(repIndex);
456 refseqs.put(ap.getViewName(), rep);
458 // code from mark/unmark sequence as reference in jalview.gui.PopupMenu
459 // todo refactor this to an alignment view controller
460 av.setDisplayReferenceSeq(true);
461 av.setColourByReferenceSeq(true);
462 av.getAlignment().setSeqrep(rep);
466 File tfile = File.createTempFile("testStoreAndRecoverReferenceSeq",
470 new Jalview2XML(false).saveState(tfile);
471 } catch (Throwable e)
473 Assert.fail("Didn't save the expanded view state", e);
475 Desktop.instance.closeAll_actionPerformed(null);
476 if (Desktop.getAlignFrames() != null)
478 Assert.assertEquals(Desktop.getAlignFrames().length, 0);
481 af = new FileLoader().LoadFileWaitTillLoaded(
482 tfile.getAbsolutePath(), FormatAdapter.FILE);
483 afid = af.getViewport().getSequenceSetId();
485 for (AlignmentViewPanel ap : Desktop.getAlignmentPanels(afid))
487 // check representative
488 AlignmentI alignment = ap.getAlignment();
489 SequenceI rep = alignment.getSeqrep();
490 Assert.assertNotNull(rep,
491 "Couldn't restore sequence representative from project");
492 // can't use a strong equals here, because by definition, the sequence IDs
493 // will be different.
494 // could set vamsas session save/restore flag to preserve IDs across
496 Assert.assertEquals(refseqs.get(ap.getViewName()).toString(),
498 "Representative wasn't the same when recovered.");
499 Assert.assertTrue(ap.getAlignViewport().isDisplayReferenceSeq(),
500 "Display reference sequence view setting not set.");
501 Assert.assertTrue(ap.getAlignViewport().isColourByReferenceSeq(),
502 "Colour By Reference Seq view setting not set.");
506 @Test(groups = { "Functional" })
507 public void testIsVersionStringLaterThan()
510 * No version / development / test / autobuild is leniently assumed to be
513 assertTrue(Jalview2XML.isVersionStringLaterThan(null, null));
514 assertTrue(Jalview2XML.isVersionStringLaterThan("2.8.3", null));
515 assertTrue(Jalview2XML.isVersionStringLaterThan(null, "2.8.3"));
516 assertTrue(Jalview2XML.isVersionStringLaterThan(null,
517 "Development Build"));
518 assertTrue(Jalview2XML.isVersionStringLaterThan(null,
519 "DEVELOPMENT BUILD"));
520 assertTrue(Jalview2XML.isVersionStringLaterThan("2.8.3",
521 "Development Build"));
522 assertTrue(Jalview2XML.isVersionStringLaterThan(null, "Test"));
523 assertTrue(Jalview2XML.isVersionStringLaterThan(null, "TEST"));
524 assertTrue(Jalview2XML.isVersionStringLaterThan("2.8.3", "Test"));
525 assertTrue(Jalview2XML
526 .isVersionStringLaterThan(null, "Automated Build"));
527 assertTrue(Jalview2XML.isVersionStringLaterThan("2.8.3",
529 assertTrue(Jalview2XML.isVersionStringLaterThan("2.8.3",
533 * same version returns true i.e. compatible
535 assertTrue(Jalview2XML.isVersionStringLaterThan("2.8", "2.8"));
536 assertTrue(Jalview2XML.isVersionStringLaterThan("2.8.3", "2.8.3"));
537 assertTrue(Jalview2XML.isVersionStringLaterThan("2.8.3b1", "2.8.3b1"));
538 assertTrue(Jalview2XML.isVersionStringLaterThan("2.8.3B1", "2.8.3b1"));
539 assertTrue(Jalview2XML.isVersionStringLaterThan("2.8.3b1", "2.8.3B1"));
542 * later version returns true
544 assertTrue(Jalview2XML.isVersionStringLaterThan("2.8.3", "2.8.4"));
545 assertTrue(Jalview2XML.isVersionStringLaterThan("2.8.3", "2.9"));
546 assertTrue(Jalview2XML.isVersionStringLaterThan("2.8.3", "2.9.2"));
547 assertTrue(Jalview2XML.isVersionStringLaterThan("2.8", "2.8.3"));
548 assertTrue(Jalview2XML.isVersionStringLaterThan("2.8.3", "2.8.3b1"));
551 * earlier version returns false
553 assertFalse(Jalview2XML.isVersionStringLaterThan("2.8.3", "2.8"));
554 assertFalse(Jalview2XML.isVersionStringLaterThan("2.8.4", "2.8.3"));
555 assertFalse(Jalview2XML.isVersionStringLaterThan("2.8.3b1", "2.8.3"));
556 assertFalse(Jalview2XML.isVersionStringLaterThan("2.8.3", "2.8.2b1"));
557 assertFalse(Jalview2XML.isVersionStringLaterThan("2.8.0b2", "2.8.0b1"));
561 * Test save and reload of a project with a different sequence group (and
562 * representative sequence) in each view.
566 @Test(groups = { "Functional" })
567 public void testStoreAndRecoverGroupRepSeqs() throws Exception
569 Desktop.instance.closeAll_actionPerformed(null);
570 AlignFrame af = new FileLoader().LoadFileWaitTillLoaded(
571 "examples/uniref50.fa", FormatAdapter.FILE);
572 assertTrue("Didn't read in the example file correctly.", af != null);
573 String afid = af.getViewport().getSequenceSetId();
574 // make a second view of the alignment
575 af.newView_actionPerformed(null);
578 * remember representative and hidden sequences marked
581 Map<String, SequenceI> repSeqs = new HashMap<String, SequenceI>();
582 Map<String, List<String>> hiddenSeqNames = new HashMap<String, List<String>>();
585 * mark sequence 2, 3, 4.. in panels 1, 2, 3...
586 * as reference sequence for itself and the preceding sequence
589 for (AlignmentViewPanel ap : Desktop.getAlignmentPanels(afid))
591 AlignViewportI av = ap.getAlignViewport();
592 AlignmentI alignment = ap.getAlignment();
593 int repIndex = n % alignment.getHeight();
594 // ensure at least one preceding sequence i.e. index >= 1
595 repIndex = Math.max(repIndex, 1);
596 SequenceI repSeq = alignment.getSequenceAt(repIndex);
597 repSeqs.put(ap.getViewName(), repSeq);
598 List<String> hiddenNames = new ArrayList<String>();
599 hiddenSeqNames.put(ap.getViewName(), hiddenNames);
602 * have rep sequence represent itself and the one before it
603 * this hides the group (except for the rep seq)
605 SequenceGroup sg = new SequenceGroup();
606 sg.addSequence(repSeq, false);
607 SequenceI precedingSeq = alignment.getSequenceAt(repIndex - 1);
608 sg.addSequence(precedingSeq, false);
609 sg.setSeqrep(repSeq);
610 assertTrue(sg.getSequences().contains(repSeq));
611 assertTrue(sg.getSequences().contains(precedingSeq));
612 av.setSelectionGroup(sg);
613 assertSame(repSeq, sg.getSeqrep());
616 * represent group with sequence adds to a map of hidden rep sequences
617 * (it does not create a group on the alignment)
619 ((AlignmentViewport) av).hideSequences(repSeq, true);
620 assertSame(repSeq, sg.getSeqrep());
621 assertTrue(sg.getSequences().contains(repSeq));
622 assertTrue(sg.getSequences().contains(precedingSeq));
623 assertTrue("alignment has groups", alignment.getGroups().isEmpty());
624 Map<SequenceI, SequenceCollectionI> hiddenRepSeqsMap = av.getHiddenRepSequences();
625 assertNotNull(hiddenRepSeqsMap);
626 assertEquals(1, hiddenRepSeqsMap.size());
627 assertSame(sg, hiddenRepSeqsMap.get(repSeq));
628 assertTrue(alignment.getHiddenSequences().isHidden(precedingSeq));
629 assertFalse(alignment.getHiddenSequences().isHidden(repSeq));
630 hiddenNames.add(precedingSeq.getName());
635 .createTempFile("testStoreAndRecoverGroupReps",
639 new Jalview2XML(false).saveState(tfile);
640 } catch (Throwable e)
642 Assert.fail("Didn't save the expanded view state", e);
644 Desktop.instance.closeAll_actionPerformed(null);
645 if (Desktop.getAlignFrames() != null)
647 Assert.assertEquals(Desktop.getAlignFrames().length, 0);
650 af = new FileLoader().LoadFileWaitTillLoaded(
651 tfile.getAbsolutePath(), FormatAdapter.FILE);
652 afid = af.getViewport().getSequenceSetId();
654 for (AlignmentViewPanel ap : Desktop.getAlignmentPanels(afid))
656 String viewName = ap.getViewName();
657 AlignViewportI av = ap.getAlignViewport();
658 AlignmentI alignment = ap.getAlignment();
659 List<SequenceGroup> groups = alignment.getGroups();
660 assertNotNull(groups);
661 assertTrue("Alignment has groups", groups.isEmpty());
662 Map<SequenceI, SequenceCollectionI> hiddenRepSeqsMap = av
663 .getHiddenRepSequences();
664 assertNotNull("No hidden represented sequences", hiddenRepSeqsMap);
665 assertEquals(1, hiddenRepSeqsMap.size());
666 assertEquals(repSeqs.get(viewName).getDisplayId(true),
667 hiddenRepSeqsMap.keySet().iterator().next()
668 .getDisplayId(true));
671 * verify hidden sequences in restored panel
673 List<String> hidden = hiddenSeqNames.get(ap.getViewName());
674 HiddenSequences hs = alignment.getHiddenSequences();
676 "wrong number of restored hidden sequences in "
678 hidden.size(), hs.getSize());