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.bin.Jalview;
34 import jalview.datamodel.AlignmentAnnotation;
35 import jalview.datamodel.AlignmentI;
36 import jalview.datamodel.HiddenSequences;
37 import jalview.datamodel.PDBEntry;
38 import jalview.datamodel.SequenceCollectionI;
39 import jalview.datamodel.SequenceGroup;
40 import jalview.datamodel.SequenceI;
41 import jalview.gui.AlignFrame;
42 import jalview.gui.AlignmentPanel;
43 import jalview.gui.Desktop;
44 import jalview.gui.Jalview2XML;
45 import jalview.schemes.AnnotationColourGradient;
46 import jalview.schemes.ColourSchemeI;
47 import jalview.structure.StructureImportSettings;
48 import jalview.viewmodel.AlignmentViewport;
51 import java.util.ArrayList;
52 import java.util.Date;
53 import java.util.HashMap;
54 import java.util.List;
57 import org.testng.Assert;
58 import org.testng.AssertJUnit;
59 import org.testng.annotations.AfterClass;
60 import org.testng.annotations.BeforeClass;
61 import org.testng.annotations.Test;
63 @Test(singleThreaded = true)
64 public class Jalview2xmlTests
68 * @throws java.lang.Exception
70 @BeforeClass(alwaysRun = true)
71 public static void setUpBeforeClass() throws Exception
74 * use read-only test properties file
76 Cache.loadProperties("test/jalview/io/testProps.jvprops");
79 * set news feed last read to a future time to ensure no
80 * 'unread' news item is displayed
82 Date oneHourFromNow = new Date(System.currentTimeMillis() + 3600 * 1000);
83 Cache.setDateProperty("JALVIEW_NEWS_RSS_LASTMODIFIED", oneHourFromNow);
85 Jalview.main(new String[] {});
89 * @throws java.lang.Exception
91 @AfterClass(alwaysRun = true)
92 public static void tearDownAfterClass() throws Exception
94 Desktop.instance.closeAll_actionPerformed(null);
97 int countDsAnn(jalview.viewmodel.AlignmentViewport avp)
100 for (SequenceI sq : avp.getAlignment().getDataset().getSequences())
102 if (sq.getAnnotation() != null)
104 for (AlignmentAnnotation dssa : sq.getAnnotation())
106 if (dssa.isValidStruc())
116 @Test(groups = { "Functional" })
117 public void testRNAStructureRecovery() throws Exception
119 String inFile = "examples/RF00031_folded.stk";
120 String tfile = File.createTempFile("JalviewTest", ".jvp")
122 AlignFrame af = new jalview.io.FileLoader().LoadFileWaitTillLoaded(
123 inFile, FormatAdapter.FILE);
124 assertTrue("Didn't read input file " + inFile, af != null);
125 int olddsann = countDsAnn(af.getViewport());
126 assertTrue("Didn't find any dataset annotations", olddsann > 0);
127 af.rnahelicesColour_actionPerformed(null);
129 "Couldn't apply RNA helices colourscheme",
130 af.getViewport().getGlobalColourScheme() instanceof jalview.schemes.RNAHelicesColour);
131 assertTrue("Failed to store as a project.",
132 af.saveAlignment(tfile, "Jalview"));
133 af.closeMenuItem_actionPerformed(true);
135 af = new jalview.io.FileLoader().LoadFileWaitTillLoaded(tfile,
137 assertTrue("Failed to import new project", af != null);
138 int newdsann = countDsAnn(af.getViewport());
140 "Differing numbers of dataset sequence annotation\nOriginally "
141 + olddsann + " and now " + newdsann,
142 olddsann == newdsann);
144 .println("Read in same number of annotations as originally present ("
147 "RNA helices colourscheme was not applied on import.",
148 af.getViewport().getGlobalColourScheme() instanceof jalview.schemes.RNAHelicesColour);
151 @Test(groups = { "Functional" })
152 public void testTCoffeeScores() throws Exception
154 String inFile = "examples/uniref50.fa", inAnnot = "examples/uniref50.score_ascii";
155 String tfile = File.createTempFile("JalviewTest", ".jvp")
157 AlignFrame af = new jalview.io.FileLoader().LoadFileWaitTillLoaded(
158 inFile, FormatAdapter.FILE);
159 assertTrue("Didn't read input file " + inFile, af != null);
160 af.loadJalviewDataFile(inAnnot, FormatAdapter.FILE, null, null);
162 "Didn't set T-coffee colourscheme",
163 af.getViewport().getGlobalColourScheme().getClass()
164 .equals(jalview.schemes.TCoffeeColourScheme.class));
166 "Recognise T-Coffee score from string",
167 jalview.schemes.ColourSchemeProperty.getColour(af.getViewport()
169 jalview.schemes.ColourSchemeProperty.getColourName(af
170 .getViewport().getGlobalColourScheme())) != null);
172 assertTrue("Failed to store as a project.",
173 af.saveAlignment(tfile, "Jalview"));
174 af.closeMenuItem_actionPerformed(true);
176 af = new jalview.io.FileLoader().LoadFileWaitTillLoaded(tfile,
178 assertTrue("Failed to import new project", af != null);
180 "Didn't set T-coffee colourscheme for imported project.",
181 af.getViewport().getGlobalColourScheme().getClass()
182 .equals(jalview.schemes.TCoffeeColourScheme.class));
184 .println("T-Coffee score shading successfully recovered from project.");
187 @Test(groups = { "Functional" })
188 public void testColourByAnnotScores() throws Exception
190 String inFile = "examples/uniref50.fa", inAnnot = "examples/testdata/uniref50_iupred.jva";
191 String tfile = File.createTempFile("JalviewTest", ".jvp")
193 AlignFrame af = new jalview.io.FileLoader().LoadFileWaitTillLoaded(
194 inFile, FormatAdapter.FILE);
195 assertTrue("Didn't read input file " + inFile, af != null);
196 af.loadJalviewDataFile(inAnnot, FormatAdapter.FILE, null, null);
197 AlignmentAnnotation[] aa = af.getViewport().getAlignment()
198 .getSequenceAt(0).getAnnotation("IUPredWS (Short)");
200 "Didn't find any IUPred annotation to use to shade alignment.",
201 aa != null && aa.length > 0);
202 AnnotationColourGradient cs = new jalview.schemes.AnnotationColourGradient(
203 aa[0], null, AnnotationColourGradient.ABOVE_THRESHOLD);
204 AnnotationColourGradient gcs = new jalview.schemes.AnnotationColourGradient(
205 aa[0], null, AnnotationColourGradient.BELOW_THRESHOLD);
206 cs.setSeqAssociated(true);
207 gcs.setSeqAssociated(true);
209 SequenceGroup sg = new SequenceGroup();
213 af.getViewport().getAlignment().addGroup(sg);
214 sg.addSequence(af.getViewport().getAlignment().getSequenceAt(1), false);
215 sg.addSequence(af.getViewport().getAlignment().getSequenceAt(2), true);
216 af.alignPanel.alignmentChanged();
217 assertTrue("Failed to store as a project.",
218 af.saveAlignment(tfile, "Jalview"));
219 af.closeMenuItem_actionPerformed(true);
221 af = new jalview.io.FileLoader().LoadFileWaitTillLoaded(tfile,
223 assertTrue("Failed to import new project", af != null);
225 // check for group and alignment colourschemes
227 ColourSchemeI _rcs = af.getViewport().getGlobalColourScheme();
228 ColourSchemeI _rgcs = af.getViewport().getAlignment().getGroups()
230 assertTrue("Didn't recover global colourscheme", _rcs != null);
231 assertTrue("Didn't recover annotation colour global scheme",
232 _rcs instanceof AnnotationColourGradient);
233 AnnotationColourGradient __rcs = (AnnotationColourGradient) _rcs;
234 assertTrue("Annotation colourscheme wasn't sequence associated",
235 __rcs.isSeqAssociated());
237 boolean diffseqcols = false, diffgseqcols = false;
238 SequenceI[] sqs = af.getViewport().getAlignment().getSequencesArray();
239 for (int p = 0, pSize = af.getViewport().getAlignment().getWidth(); p < pSize
240 && (!diffseqcols || !diffgseqcols); p++)
242 if (_rcs.findColour(sqs[0].getCharAt(p), p, sqs[0]) != _rcs
243 .findColour(sqs[5].getCharAt(p), p, sqs[5]))
248 assertTrue("Got Different sequence colours", diffseqcols);
250 .println("Per sequence colourscheme (Background) successfully applied and recovered.");
252 assertTrue("Didn't recover group colourscheme", _rgcs != null);
253 assertTrue("Didn't recover annotation colour group colourscheme",
254 _rgcs instanceof AnnotationColourGradient);
255 __rcs = (AnnotationColourGradient) _rgcs;
256 assertTrue("Group Annotation colourscheme wasn't sequence associated",
257 __rcs.isSeqAssociated());
259 for (int p = 0, pSize = af.getViewport().getAlignment().getWidth(); p < pSize
260 && (!diffseqcols || !diffgseqcols); p++)
262 if (_rgcs.findColour(sqs[1].getCharAt(p), p, sqs[1]) != _rgcs
263 .findColour(sqs[2].getCharAt(p), p, sqs[2]))
268 assertTrue("Got Different group sequence colours", diffgseqcols);
270 .println("Per sequence (Group) colourscheme successfully applied and recovered.");
273 @Test(groups = { "Functional" })
274 public void gatherViewsHere() throws Exception
276 int origCount = Desktop.getAlignFrames() == null ? 0 : Desktop
277 .getAlignFrames().length;
278 AlignFrame af = new jalview.io.FileLoader().LoadFileWaitTillLoaded(
279 "examples/exampleFile_2_7.jar", FormatAdapter.FILE);
280 assertTrue("Didn't read in the example file correctly.", af != null);
281 assertTrue("Didn't gather the views in the example file.",
282 Desktop.getAlignFrames().length == 1 + origCount);
286 @Test(groups = { "Functional" })
287 public void viewRefPdbAnnotation() throws Exception
289 // TODO: Make this pass without setting StructureParser.JALVIEW_PARSER
290 // StructureImportSettings
291 // .setDefaultPDBFileParser(StructureParser.JALVIEW_PARSER);
292 StructureImportSettings.setProcessSecondaryStructure(true);
293 StructureImportSettings.setVisibleChainAnnotation(true);
294 AlignFrame af = new jalview.io.FileLoader().LoadFileWaitTillLoaded(
295 "examples/exampleFile_2_7.jar", FormatAdapter.FILE);
296 assertTrue("Didn't read in the example file correctly.", af != null);
297 AlignmentViewPanel sps = null;
298 for (AlignmentViewPanel ap : af.alignPanel.alignFrame.getAlignPanels())
300 if ("Spinach Feredoxin Structure".equals(ap.getViewName()))
306 assertTrue("Couldn't find the structure view", sps != null);
307 SequenceI sq = sps.getAlignment().findName("1A70|");
308 AlignmentAnnotation refan = null;
309 for (AlignmentAnnotation ra : sps.getAlignment()
310 .getAlignmentAnnotation())
318 assertTrue("Annotation secondary structure not found.", refan != null);
319 assertTrue("Couldn't find 1a70 null chain", sq != null);
320 // compare the manually added temperature factor annotation
321 // to the track automatically transferred from the pdb structure on load
322 for (AlignmentAnnotation ala : sq.getDatasetSequence().getAnnotation())
324 AlignmentAnnotation alaa;
325 sq.addAlignmentAnnotation(alaa = new AlignmentAnnotation(ala));
326 alaa.adjustForAlignment();
327 if (ala.graph == refan.graph)
329 for (int p = 0; p < ala.annotations.length; p++)
335 "Mismatch at alignment position " + p,
336 (alaa.annotations[p] == null && refan.annotations[p] == null)
337 || alaa.annotations[p].value == refan.annotations[p].value);
338 } catch (NullPointerException q)
340 Assert.fail("Mismatch of alignment annotations at position "
341 + p + " Ref seq ann: " + refan.annotations[p]
342 + " alignment " + alaa.annotations[p]);
350 @Test(groups = { "Functional" })
351 public void testCopyViewSettings() throws Exception
353 AlignFrame af = new jalview.io.FileLoader().LoadFileWaitTillLoaded(
354 "examples/exampleFile_2_7.jar", FormatAdapter.FILE);
355 assertTrue("Didn't read in the example file correctly.", af != null);
356 AlignmentViewPanel sps = null, groups = null;
357 for (AlignmentViewPanel ap : af.alignPanel.alignFrame.getAlignPanels())
359 if ("Spinach Feredoxin Structure".equals(ap.getViewName()))
363 if (ap.getViewName().contains("MAFFT"))
368 assertTrue("Couldn't find the structure view", sps != null);
369 assertTrue("Couldn't find the MAFFT view", groups != null);
371 ViewStyleI structureStyle = sps.getAlignViewport().getViewStyle();
372 ViewStyleI groupStyle = groups.getAlignViewport().getViewStyle();
373 AssertJUnit.assertFalse(structureStyle.sameStyle(groupStyle));
375 groups.getAlignViewport().setViewStyle(structureStyle);
376 AssertJUnit.assertFalse(groupStyle.sameStyle(groups.getAlignViewport()
378 Assert.assertTrue(structureStyle.sameStyle(groups.getAlignViewport()
384 * test store and recovery of expanded views
388 @Test(groups = { "Functional" }, enabled = true)
389 public void testStoreAndRecoverExpandedviews() throws Exception
391 Desktop.instance.closeAll_actionPerformed(null);
393 AlignFrame af = new jalview.io.FileLoader().LoadFileWaitTillLoaded(
394 "examples/exampleFile_2_7.jar", FormatAdapter.FILE);
395 assertTrue("Didn't read in the example file correctly.", af != null);
396 Assert.assertEquals(Desktop.getAlignFrames().length, 1);
397 String afid = af.getViewport().getSequenceSetId();
399 // check FileLoader returned a reference to the one alignFrame that is
400 // actually on the Desktop
402 "Jalview2XML.loadAlignFrame() didn't return correct AlignFrame reference for multiple view window",
403 af == Desktop.getAlignFrameFor(af.getViewport()));
405 Desktop.explodeViews(af);
407 int oldviews = Desktop.getAlignFrames().length;
408 Assert.assertEquals(Desktop.getAlignFrames().length,
409 Desktop.getAlignmentPanels(afid).length);
410 File tfile = File.createTempFile("testStoreAndRecoverExpanded", ".jvp");
413 new Jalview2XML(false).saveState(tfile);
416 Assert.fail("Didn't save the expanded view state", e);
417 } catch (Exception e)
419 Assert.fail("Didn't save the expanded view state", e);
421 Desktop.instance.closeAll_actionPerformed(null);
422 if (Desktop.getAlignFrames() != null)
424 Assert.assertEquals(Desktop.getAlignFrames().length, 0);
426 af = new jalview.io.FileLoader().LoadFileWaitTillLoaded(
427 tfile.getAbsolutePath(), FormatAdapter.FILE);
428 Assert.assertNotNull(af);
430 Desktop.getAlignFrames().length,
431 Desktop.getAlignmentPanels(af.getViewport().getSequenceSetId()).length);
434 Desktop.getAlignmentPanels(af.getViewport().getSequenceSetId()).length);
438 * Test save and reload of a project with a different representative sequence
443 @Test(groups = { "Functional" })
444 public void testStoreAndRecoverReferenceSeqSettings() throws Exception
446 Desktop.instance.closeAll_actionPerformed(null);
447 AlignFrame af = new FileLoader().LoadFileWaitTillLoaded(
448 "examples/exampleFile_2_7.jar", FormatAdapter.FILE);
449 assertTrue("Didn't read in the example file correctly.", af != null);
450 String afid = af.getViewport().getSequenceSetId();
452 // remember reference sequence for each panel
453 Map<String, SequenceI> refseqs = new HashMap<String, SequenceI>();
456 * mark sequence 2, 3, 4.. in panels 1, 2, 3...
457 * as reference sequence for itself and the preceding sequence
460 for (AlignmentViewPanel ap : Desktop.getAlignmentPanels(afid))
462 AlignViewportI av = ap.getAlignViewport();
463 AlignmentI alignment = ap.getAlignment();
464 int repIndex = n % alignment.getHeight();
465 SequenceI rep = alignment.getSequenceAt(repIndex);
466 refseqs.put(ap.getViewName(), rep);
468 // code from mark/unmark sequence as reference in jalview.gui.PopupMenu
469 // todo refactor this to an alignment view controller
470 av.setDisplayReferenceSeq(true);
471 av.setColourByReferenceSeq(true);
472 av.getAlignment().setSeqrep(rep);
476 File tfile = File.createTempFile("testStoreAndRecoverReferenceSeq",
480 new Jalview2XML(false).saveState(tfile);
481 } catch (Throwable e)
483 Assert.fail("Didn't save the expanded view state", e);
485 Desktop.instance.closeAll_actionPerformed(null);
486 if (Desktop.getAlignFrames() != null)
488 Assert.assertEquals(Desktop.getAlignFrames().length, 0);
491 af = new FileLoader().LoadFileWaitTillLoaded(
492 tfile.getAbsolutePath(), FormatAdapter.FILE);
493 afid = af.getViewport().getSequenceSetId();
495 for (AlignmentViewPanel ap : Desktop.getAlignmentPanels(afid))
497 // check representative
498 AlignmentI alignment = ap.getAlignment();
499 SequenceI rep = alignment.getSeqrep();
500 Assert.assertNotNull(rep,
501 "Couldn't restore sequence representative from project");
502 // can't use a strong equals here, because by definition, the sequence IDs
503 // will be different.
504 // could set vamsas session save/restore flag to preserve IDs across
506 Assert.assertEquals(refseqs.get(ap.getViewName()).toString(),
508 "Representative wasn't the same when recovered.");
509 Assert.assertTrue(ap.getAlignViewport().isDisplayReferenceSeq(),
510 "Display reference sequence view setting not set.");
511 Assert.assertTrue(ap.getAlignViewport().isColourByReferenceSeq(),
512 "Colour By Reference Seq view setting not set.");
516 @Test(groups = { "Functional" })
517 public void testIsVersionStringLaterThan()
520 * No version / development / test / autobuild is leniently assumed to be
523 assertTrue(Jalview2XML.isVersionStringLaterThan(null, null));
524 assertTrue(Jalview2XML.isVersionStringLaterThan("2.8.3", null));
525 assertTrue(Jalview2XML.isVersionStringLaterThan(null, "2.8.3"));
526 assertTrue(Jalview2XML.isVersionStringLaterThan(null,
527 "Development Build"));
528 assertTrue(Jalview2XML.isVersionStringLaterThan(null,
529 "DEVELOPMENT BUILD"));
530 assertTrue(Jalview2XML.isVersionStringLaterThan("2.8.3",
531 "Development Build"));
532 assertTrue(Jalview2XML.isVersionStringLaterThan(null, "Test"));
533 assertTrue(Jalview2XML.isVersionStringLaterThan(null, "TEST"));
534 assertTrue(Jalview2XML.isVersionStringLaterThan("2.8.3", "Test"));
535 assertTrue(Jalview2XML
536 .isVersionStringLaterThan(null, "Automated Build"));
537 assertTrue(Jalview2XML.isVersionStringLaterThan("2.8.3",
539 assertTrue(Jalview2XML.isVersionStringLaterThan("2.8.3",
543 * same version returns true i.e. compatible
545 assertTrue(Jalview2XML.isVersionStringLaterThan("2.8", "2.8"));
546 assertTrue(Jalview2XML.isVersionStringLaterThan("2.8.3", "2.8.3"));
547 assertTrue(Jalview2XML.isVersionStringLaterThan("2.8.3b1", "2.8.3b1"));
548 assertTrue(Jalview2XML.isVersionStringLaterThan("2.8.3B1", "2.8.3b1"));
549 assertTrue(Jalview2XML.isVersionStringLaterThan("2.8.3b1", "2.8.3B1"));
552 * later version returns true
554 assertTrue(Jalview2XML.isVersionStringLaterThan("2.8.3", "2.8.4"));
555 assertTrue(Jalview2XML.isVersionStringLaterThan("2.8.3", "2.9"));
556 assertTrue(Jalview2XML.isVersionStringLaterThan("2.8.3", "2.9.2"));
557 assertTrue(Jalview2XML.isVersionStringLaterThan("2.8", "2.8.3"));
558 assertTrue(Jalview2XML.isVersionStringLaterThan("2.8.3", "2.8.3b1"));
561 * earlier version returns false
563 assertFalse(Jalview2XML.isVersionStringLaterThan("2.8.3", "2.8"));
564 assertFalse(Jalview2XML.isVersionStringLaterThan("2.8.4", "2.8.3"));
565 assertFalse(Jalview2XML.isVersionStringLaterThan("2.8.3b1", "2.8.3"));
566 assertFalse(Jalview2XML.isVersionStringLaterThan("2.8.3", "2.8.2b1"));
567 assertFalse(Jalview2XML.isVersionStringLaterThan("2.8.0b2", "2.8.0b1"));
571 * Test save and reload of a project with a different sequence group (and
572 * representative sequence) in each view.
576 @Test(groups = { "Functional" })
577 public void testStoreAndRecoverGroupRepSeqs() throws Exception
579 Desktop.instance.closeAll_actionPerformed(null);
580 AlignFrame af = new FileLoader().LoadFileWaitTillLoaded(
581 "examples/uniref50.fa", FormatAdapter.FILE);
582 assertTrue("Didn't read in the example file correctly.", af != null);
583 String afid = af.getViewport().getSequenceSetId();
584 // make a second view of the alignment
585 af.newView_actionPerformed(null);
588 * remember representative and hidden sequences marked
591 Map<String, SequenceI> repSeqs = new HashMap<String, SequenceI>();
592 Map<String, List<String>> hiddenSeqNames = new HashMap<String, List<String>>();
595 * mark sequence 2, 3, 4.. in panels 1, 2, 3...
596 * as reference sequence for itself and the preceding sequence
599 for (AlignmentViewPanel ap : Desktop.getAlignmentPanels(afid))
601 AlignViewportI av = ap.getAlignViewport();
602 AlignmentI alignment = ap.getAlignment();
603 int repIndex = n % alignment.getHeight();
604 // ensure at least one preceding sequence i.e. index >= 1
605 repIndex = Math.max(repIndex, 1);
606 SequenceI repSeq = alignment.getSequenceAt(repIndex);
607 repSeqs.put(ap.getViewName(), repSeq);
608 List<String> hiddenNames = new ArrayList<String>();
609 hiddenSeqNames.put(ap.getViewName(), hiddenNames);
612 * have rep sequence represent itself and the one before it
613 * this hides the group (except for the rep seq)
615 SequenceGroup sg = new SequenceGroup();
616 sg.addSequence(repSeq, false);
617 SequenceI precedingSeq = alignment.getSequenceAt(repIndex - 1);
618 sg.addSequence(precedingSeq, false);
619 sg.setSeqrep(repSeq);
620 assertTrue(sg.getSequences().contains(repSeq));
621 assertTrue(sg.getSequences().contains(precedingSeq));
622 av.setSelectionGroup(sg);
623 assertSame(repSeq, sg.getSeqrep());
626 * represent group with sequence adds to a map of hidden rep sequences
627 * (it does not create a group on the alignment)
629 ((AlignmentViewport) av).hideSequences(repSeq, true);
630 assertSame(repSeq, sg.getSeqrep());
631 assertTrue(sg.getSequences().contains(repSeq));
632 assertTrue(sg.getSequences().contains(precedingSeq));
633 assertTrue("alignment has groups", alignment.getGroups().isEmpty());
634 Map<SequenceI, SequenceCollectionI> hiddenRepSeqsMap = av.getHiddenRepSequences();
635 assertNotNull(hiddenRepSeqsMap);
636 assertEquals(1, hiddenRepSeqsMap.size());
637 assertSame(sg, hiddenRepSeqsMap.get(repSeq));
638 assertTrue(alignment.getHiddenSequences().isHidden(precedingSeq));
639 assertFalse(alignment.getHiddenSequences().isHidden(repSeq));
640 hiddenNames.add(precedingSeq.getName());
645 .createTempFile("testStoreAndRecoverGroupReps",
649 new Jalview2XML(false).saveState(tfile);
650 } catch (Throwable e)
652 Assert.fail("Didn't save the expanded view state", e);
654 Desktop.instance.closeAll_actionPerformed(null);
655 if (Desktop.getAlignFrames() != null)
657 Assert.assertEquals(Desktop.getAlignFrames().length, 0);
660 af = new FileLoader().LoadFileWaitTillLoaded(
661 tfile.getAbsolutePath(), FormatAdapter.FILE);
662 afid = af.getViewport().getSequenceSetId();
664 for (AlignmentViewPanel ap : Desktop.getAlignmentPanels(afid))
666 String viewName = ap.getViewName();
667 AlignViewportI av = ap.getAlignViewport();
668 AlignmentI alignment = ap.getAlignment();
669 List<SequenceGroup> groups = alignment.getGroups();
670 assertNotNull(groups);
671 assertTrue("Alignment has groups", groups.isEmpty());
672 Map<SequenceI, SequenceCollectionI> hiddenRepSeqsMap = av
673 .getHiddenRepSequences();
674 assertNotNull("No hidden represented sequences", hiddenRepSeqsMap);
675 assertEquals(1, hiddenRepSeqsMap.size());
676 assertEquals(repSeqs.get(viewName).getDisplayId(true),
677 hiddenRepSeqsMap.keySet().iterator().next()
678 .getDisplayId(true));
681 * verify hidden sequences in restored panel
683 List<String> hidden = hiddenSeqNames.get(ap.getViewName());
684 HiddenSequences hs = alignment.getHiddenSequences();
686 "wrong number of restored hidden sequences in "
688 hidden.size(), hs.getSize());
693 * Test save and reload of PDBEntry in Jalview project
697 @Test(groups = { "Functional" })
698 public void testStoreAndRecoverPDBEntry() throws Exception
700 Desktop.instance.closeAll_actionPerformed(null);
701 String exampleFile = "examples/3W5V.pdb";
702 AlignFrame af = new FileLoader().LoadFileWaitTillLoaded(exampleFile,
704 assertTrue("Didn't read in the example file correctly.", af != null);
705 String afid = af.getViewport().getSequenceSetId();
707 AlignmentPanel[] alignPanels = Desktop.getAlignmentPanels(afid);
708 System.out.println();
709 AlignmentViewPanel ap = alignPanels[0];
710 String tfileBase = new File(".").getAbsolutePath().replace(".", "");
711 String testFile = tfileBase + exampleFile;
712 AlignmentI alignment = ap.getAlignment();
713 System.out.println("blah");
714 SequenceI[] seqs = alignment.getSequencesArray();
715 Assert.assertNotNull(seqs[0]);
716 Assert.assertNotNull(seqs[1]);
717 Assert.assertNotNull(seqs[2]);
718 Assert.assertNotNull(seqs[3]);
719 Assert.assertNotNull(seqs[0].getDatasetSequence());
720 Assert.assertNotNull(seqs[1].getDatasetSequence());
721 Assert.assertNotNull(seqs[2].getDatasetSequence());
722 Assert.assertNotNull(seqs[3].getDatasetSequence());
723 PDBEntry[] pdbEntries = new PDBEntry[4];
724 pdbEntries[0] = new PDBEntry("3W5V", "A", null, testFile);
725 pdbEntries[1] = new PDBEntry("3W5V", "B", null, testFile);
726 pdbEntries[2] = new PDBEntry("3W5V", "C", null, testFile);
727 pdbEntries[3] = new PDBEntry("3W5V", "D", null, testFile);
728 Assert.assertTrue(seqs[0].getDatasetSequence().getAllPDBEntries()
729 .get(0).equals(pdbEntries[0]));
730 Assert.assertTrue(seqs[1].getDatasetSequence().getAllPDBEntries()
731 .get(0).equals(pdbEntries[1]));
732 Assert.assertTrue(seqs[2].getDatasetSequence().getAllPDBEntries()
733 .get(0).equals(pdbEntries[2]));
734 Assert.assertTrue(seqs[3].getDatasetSequence().getAllPDBEntries()
735 .get(0).equals(pdbEntries[3]));
737 File tfile = File.createTempFile("testStoreAndRecoverPDBEntry", ".jvp");
740 new Jalview2XML(false).saveState(tfile);
741 } catch (Throwable e)
743 Assert.fail("Didn't save the state", e);
745 Desktop.instance.closeAll_actionPerformed(null);
746 if (Desktop.getAlignFrames() != null)
748 Assert.assertEquals(Desktop.getAlignFrames().length, 0);
751 AlignFrame restoredFrame = new FileLoader().LoadFileWaitTillLoaded(
752 tfile.getAbsolutePath(), FormatAdapter.FILE);
753 String rfid = restoredFrame.getViewport().getSequenceSetId();
754 AlignmentPanel[] rAlignPanels = Desktop.getAlignmentPanels(rfid);
755 AlignmentViewPanel rap = rAlignPanels[0];
756 AlignmentI rAlignment = rap.getAlignment();
757 System.out.println("blah");
758 SequenceI[] rseqs = rAlignment.getSequencesArray();
759 Assert.assertNotNull(rseqs[0]);
760 Assert.assertNotNull(rseqs[1]);
761 Assert.assertNotNull(rseqs[2]);
762 Assert.assertNotNull(rseqs[3]);
763 Assert.assertNotNull(rseqs[0].getDatasetSequence());
764 Assert.assertNotNull(rseqs[1].getDatasetSequence());
765 Assert.assertNotNull(rseqs[2].getDatasetSequence());
766 Assert.assertNotNull(rseqs[3].getDatasetSequence());
768 // The Asserts below are expected to fail until the PDB chainCode is
769 // recoverable from a Jalview projects
770 Assert.assertTrue(rseqs[0].getDatasetSequence().getAllPDBEntries()
771 .get(0).equals(pdbEntries[0]));
772 Assert.assertTrue(rseqs[1].getDatasetSequence().getAllPDBEntries()
773 .get(0).equals(pdbEntries[1]));
774 Assert.assertTrue(rseqs[2].getDatasetSequence().getAllPDBEntries()
775 .get(0).equals(pdbEntries[2]));
776 Assert.assertTrue(rseqs[3].getDatasetSequence().getAllPDBEntries()
777 .get(0).equals(pdbEntries[3]));