From: tcofoegbu Date: Fri, 19 Aug 2016 14:13:01 +0000 (+0100) Subject: JAL-1803 unit test for PDB chainCode save/restore from Jalview project X-Git-Tag: Release_2_10_0~101 X-Git-Url: http://source.jalview.org/gitweb/?a=commitdiff_plain;h=7e73e392838bbaaaff162532ef8e3e251b11f94a;p=jalview.git JAL-1803 unit test for PDB chainCode save/restore from Jalview project --- diff --git a/test/jalview/io/Jalview2xmlTests.java b/test/jalview/io/Jalview2xmlTests.java index c2e3a66..784f3dd 100644 --- a/test/jalview/io/Jalview2xmlTests.java +++ b/test/jalview/io/Jalview2xmlTests.java @@ -34,10 +34,12 @@ import jalview.bin.Jalview; import jalview.datamodel.AlignmentAnnotation; import jalview.datamodel.AlignmentI; import jalview.datamodel.HiddenSequences; +import jalview.datamodel.PDBEntry; import jalview.datamodel.SequenceCollectionI; import jalview.datamodel.SequenceGroup; import jalview.datamodel.SequenceI; import jalview.gui.AlignFrame; +import jalview.gui.AlignmentPanel; import jalview.gui.Desktop; import jalview.gui.Jalview2XML; import jalview.schemes.AnnotationColourGradient; @@ -686,4 +688,92 @@ public class Jalview2xmlTests hidden.size(), hs.getSize()); } } + + /** + * Test save and reload of PDBEntry in Jalview project + * + * @throws Exception + */ + @Test(groups = { "Functional" }) + public void testStoreAndRecoverPDBEntry() throws Exception + { + Desktop.instance.closeAll_actionPerformed(null); + String exampleFile = "examples/3W5V.pdb"; + AlignFrame af = new FileLoader().LoadFileWaitTillLoaded(exampleFile, + FormatAdapter.FILE); + assertTrue("Didn't read in the example file correctly.", af != null); + String afid = af.getViewport().getSequenceSetId(); + + AlignmentPanel[] alignPanels = Desktop.getAlignmentPanels(afid); + System.out.println(); + AlignmentViewPanel ap = alignPanels[0]; + String tfileBase = new File(".").getAbsolutePath().replace(".", ""); + String testFile = tfileBase + exampleFile; + AlignmentI alignment = ap.getAlignment(); + System.out.println("blah"); + SequenceI[] seqs = alignment.getSequencesArray(); + Assert.assertNotNull(seqs[0]); + Assert.assertNotNull(seqs[1]); + Assert.assertNotNull(seqs[2]); + Assert.assertNotNull(seqs[3]); + Assert.assertNotNull(seqs[0].getDatasetSequence()); + Assert.assertNotNull(seqs[1].getDatasetSequence()); + Assert.assertNotNull(seqs[2].getDatasetSequence()); + Assert.assertNotNull(seqs[3].getDatasetSequence()); + PDBEntry[] pdbEntries = new PDBEntry[4]; + pdbEntries[0] = new PDBEntry("3W5V", "A", null, testFile); + pdbEntries[1] = new PDBEntry("3W5V", "B", null, testFile); + pdbEntries[2] = new PDBEntry("3W5V", "C", null, testFile); + pdbEntries[3] = new PDBEntry("3W5V", "D", null, testFile); + Assert.assertTrue(seqs[0].getDatasetSequence().getAllPDBEntries() + .get(0).equals(pdbEntries[0])); + Assert.assertTrue(seqs[1].getDatasetSequence().getAllPDBEntries() + .get(0).equals(pdbEntries[1])); + Assert.assertTrue(seqs[2].getDatasetSequence().getAllPDBEntries() + .get(0).equals(pdbEntries[2])); + Assert.assertTrue(seqs[3].getDatasetSequence().getAllPDBEntries() + .get(0).equals(pdbEntries[3])); + + File tfile = File.createTempFile("testStoreAndRecoverPDBEntry", ".jvp"); + try + { + new Jalview2XML(false).saveState(tfile); + } catch (Throwable e) + { + Assert.fail("Didn't save the state", e); + } + Desktop.instance.closeAll_actionPerformed(null); + if (Desktop.getAlignFrames() != null) + { + Assert.assertEquals(Desktop.getAlignFrames().length, 0); + } + + AlignFrame restoredFrame = new FileLoader().LoadFileWaitTillLoaded( + tfile.getAbsolutePath(), FormatAdapter.FILE); + String rfid = restoredFrame.getViewport().getSequenceSetId(); + AlignmentPanel[] rAlignPanels = Desktop.getAlignmentPanels(rfid); + AlignmentViewPanel rap = rAlignPanels[0]; + AlignmentI rAlignment = rap.getAlignment(); + System.out.println("blah"); + SequenceI[] rseqs = rAlignment.getSequencesArray(); + Assert.assertNotNull(rseqs[0]); + Assert.assertNotNull(rseqs[1]); + Assert.assertNotNull(rseqs[2]); + Assert.assertNotNull(rseqs[3]); + Assert.assertNotNull(rseqs[0].getDatasetSequence()); + Assert.assertNotNull(rseqs[1].getDatasetSequence()); + Assert.assertNotNull(rseqs[2].getDatasetSequence()); + Assert.assertNotNull(rseqs[3].getDatasetSequence()); + + // The Asserts below are expected to fail until the PDB chainCode is + // recoverable from a Jalview projects + Assert.assertTrue(rseqs[0].getDatasetSequence().getAllPDBEntries() + .get(0).equals(pdbEntries[0])); + Assert.assertTrue(rseqs[1].getDatasetSequence().getAllPDBEntries() + .get(0).equals(pdbEntries[1])); + Assert.assertTrue(rseqs[2].getDatasetSequence().getAllPDBEntries() + .get(0).equals(pdbEntries[2])); + Assert.assertTrue(rseqs[3].getDatasetSequence().getAllPDBEntries() + .get(0).equals(pdbEntries[3])); + } }