X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=test%2Fjalview%2Fio%2FJalview2xmlTests.java;h=5b99fa1ff950ea4a4fc8f057b7c12fb2e94b34ac;hb=400b50efffaa43ae2c3b4d3f653bf8215c5d1edc;hp=3d53234fc634d316e1f5ae1a105d159a410d7ff6;hpb=37de9310bec3501cbc6381e0c3dcb282fcaad812;p=jalview.git diff --git a/test/jalview/io/Jalview2xmlTests.java b/test/jalview/io/Jalview2xmlTests.java index 3d53234..5b99fa1 100644 --- a/test/jalview/io/Jalview2xmlTests.java +++ b/test/jalview/io/Jalview2xmlTests.java @@ -41,9 +41,12 @@ import jalview.gui.AlignFrame; import jalview.gui.AlignmentPanel; import jalview.gui.Desktop; import jalview.gui.Jalview2XML; +import jalview.gui.JvOptionPane; import jalview.schemes.AnnotationColourGradient; import jalview.schemes.ColourSchemeI; import jalview.schemes.ColourSchemeProperty; +import jalview.schemes.JalviewColourScheme; +import jalview.schemes.RNAHelicesColour; import jalview.schemes.TCoffeeColourScheme; import jalview.structure.StructureImportSettings; import jalview.viewmodel.AlignmentViewport; @@ -56,33 +59,42 @@ import java.util.Map; import org.testng.Assert; import org.testng.AssertJUnit; +import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; @Test(singleThreaded = true) public class Jalview2xmlTests extends Jalview2xmlBase { + @Override + @BeforeClass(alwaysRun = true) + public void setUpJvOptionPane() + { + JvOptionPane.setInteractiveMode(false); + JvOptionPane.setMockResponse(JvOptionPane.CANCEL_OPTION); + } + @Test(groups = { "Functional" }) public void testRNAStructureRecovery() throws Exception { String inFile = "examples/RF00031_folded.stk"; String tfile = File.createTempFile("JalviewTest", ".jvp") .getAbsolutePath(); - AlignFrame af = new FileLoader().LoadFileWaitTillLoaded(inFile, - FormatAdapter.FILE); - assertNotNull("Didn't read input file " + inFile, af); + AlignFrame af = new FileLoader().LoadFileWaitTillLoaded( + inFile, DataSourceType.FILE); + assertTrue("Didn't read input file " + inFile, af != null); int olddsann = countDsAnn(af.getViewport()); assertTrue("Didn't find any dataset annotations", olddsann > 0); - af.rnahelicesColour_actionPerformed(null); - assertTrue( - "Couldn't apply RNA helices colourscheme", - af.getViewport().getGlobalColourScheme() instanceof jalview.schemes.RNAHelicesColour); + af.changeColour_actionPerformed(JalviewColourScheme.RNAHelices + .toString()); + assertTrue("Couldn't apply RNA helices colourscheme", af.getViewport() + .getGlobalColourScheme() instanceof RNAHelicesColour); assertTrue("Failed to store as a project.", - af.saveAlignment(tfile, "Jalview")); + af.saveAlignment(tfile, FileFormat.Jalview)); af.closeMenuItem_actionPerformed(true); af = null; - af = new FileLoader().LoadFileWaitTillLoaded(tfile, FormatAdapter.FILE); - assertNotNull("Failed to import new project", af); + af = new FileLoader().LoadFileWaitTillLoaded(tfile, DataSourceType.FILE); + assertTrue("Failed to import new project", af != null); int newdsann = countDsAnn(af.getViewport()); assertTrue( "Differing numbers of dataset sequence annotation\nOriginally " @@ -93,7 +105,7 @@ public class Jalview2xmlTests extends Jalview2xmlBase + olddsann + ")"); assertTrue( "RNA helices colourscheme was not applied on import.", - af.getViewport().getGlobalColourScheme() instanceof jalview.schemes.RNAHelicesColour); + af.getViewport().getGlobalColourScheme() instanceof RNAHelicesColour); } @Test(groups = { "Functional" }) @@ -102,22 +114,23 @@ public class Jalview2xmlTests extends Jalview2xmlBase String inFile = "examples/uniref50.fa", inAnnot = "examples/uniref50.score_ascii"; String tfile = File.createTempFile("JalviewTest", ".jvp") .getAbsolutePath(); - AlignFrame af = new FileLoader().LoadFileWaitTillLoaded(inFile, - FormatAdapter.FILE); + AlignFrame af = new FileLoader().LoadFileWaitTillLoaded( + inFile, DataSourceType.FILE); assertNotNull("Didn't read input file " + inFile, af); - af.loadJalviewDataFile(inAnnot, FormatAdapter.FILE, null, null); + af.loadJalviewDataFile(inAnnot, DataSourceType.FILE, null, null); assertSame("Didn't set T-coffee colourscheme", af.getViewport() .getGlobalColourScheme().getClass(), TCoffeeColourScheme.class); assertNotNull("Recognise T-Coffee score from string", - jalview.schemes.ColourSchemeProperty.getColour(af.getViewport() - .getAlignment(), ColourSchemeProperty.getColourName(af - .getViewport().getGlobalColourScheme()))); + ColourSchemeProperty.getColourScheme(af.getViewport() + .getAlignment(), af.getViewport() + .getGlobalColourScheme().getSchemeName())); assertTrue("Failed to store as a project.", - af.saveAlignment(tfile, "Jalview")); + af.saveAlignment(tfile, FileFormat.Jalview)); af.closeMenuItem_actionPerformed(true); af = null; - af = new FileLoader().LoadFileWaitTillLoaded(tfile, FormatAdapter.FILE); + af = new FileLoader().LoadFileWaitTillLoaded(tfile, + DataSourceType.FILE); assertNotNull("Failed to import new project", af); assertSame("Didn't set T-coffee colourscheme for imported project.", af .getViewport().getGlobalColourScheme().getClass(), @@ -132,10 +145,9 @@ public class Jalview2xmlTests extends Jalview2xmlBase String inFile = "examples/uniref50.fa", inAnnot = "examples/testdata/uniref50_iupred.jva"; String tfile = File.createTempFile("JalviewTest", ".jvp") .getAbsolutePath(); - AlignFrame af = new FileLoader().LoadFileWaitTillLoaded(inFile, - FormatAdapter.FILE); + AlignFrame af = new FileLoader().LoadFileWaitTillLoaded(inFile, DataSourceType.FILE); assertNotNull("Didn't read input file " + inFile, af); - af.loadJalviewDataFile(inAnnot, FormatAdapter.FILE, null, null); + af.loadJalviewDataFile(inAnnot, DataSourceType.FILE, null, null); AlignmentAnnotation[] aa = af.getViewport().getAlignment() .getSequenceAt(0).getAnnotation("IUPredWS (Short)"); assertTrue( @@ -151,23 +163,23 @@ public class Jalview2xmlTests extends Jalview2xmlBase SequenceGroup sg = new SequenceGroup(); sg.setStartRes(57); sg.setEndRes(92); - sg.cs = gcs; + sg.cs.setColourScheme(gcs); af.getViewport().getAlignment().addGroup(sg); sg.addSequence(af.getViewport().getAlignment().getSequenceAt(1), false); sg.addSequence(af.getViewport().getAlignment().getSequenceAt(2), true); af.alignPanel.alignmentChanged(); assertTrue("Failed to store as a project.", - af.saveAlignment(tfile, "Jalview")); + af.saveAlignment(tfile, FileFormat.Jalview)); af.closeMenuItem_actionPerformed(true); af = null; - af = new FileLoader().LoadFileWaitTillLoaded(tfile, FormatAdapter.FILE); - assertNotNull("Failed to import new project", af); + af = new FileLoader().LoadFileWaitTillLoaded(tfile, DataSourceType.FILE); + assertTrue("Failed to import new project", af != null); // check for group and alignment colourschemes ColourSchemeI _rcs = af.getViewport().getGlobalColourScheme(); ColourSchemeI _rgcs = af.getViewport().getAlignment().getGroups() - .get(0).cs; + .get(0).getColourScheme(); assertNotNull("Didn't recover global colourscheme", _rcs); assertTrue("Didn't recover annotation colour global scheme", _rcs instanceof AnnotationColourGradient); @@ -180,8 +192,8 @@ public class Jalview2xmlTests extends Jalview2xmlBase for (int p = 0, pSize = af.getViewport().getAlignment().getWidth(); p < pSize && (!diffseqcols || !diffgseqcols); p++) { - if (_rcs.findColour(sqs[0].getCharAt(p), p, sqs[0]) != _rcs - .findColour(sqs[5].getCharAt(p), p, sqs[5])) + if (_rcs.findColour(sqs[0].getCharAt(p), p, sqs[0], null, 0f) != _rcs + .findColour(sqs[5].getCharAt(p), p, sqs[5], null, 0f)) { diffseqcols = true; } @@ -200,8 +212,8 @@ public class Jalview2xmlTests extends Jalview2xmlBase for (int p = 0, pSize = af.getViewport().getAlignment().getWidth(); p < pSize && (!diffseqcols || !diffgseqcols); p++) { - if (_rgcs.findColour(sqs[1].getCharAt(p), p, sqs[1]) != _rgcs - .findColour(sqs[2].getCharAt(p), p, sqs[2])) + if (_rgcs.findColour(sqs[1].getCharAt(p), p, sqs[1], null, 0f) != _rgcs + .findColour(sqs[2].getCharAt(p), p, sqs[2], null, 0f)) { diffgseqcols = true; } @@ -217,7 +229,7 @@ public class Jalview2xmlTests extends Jalview2xmlBase int origCount = Desktop.getAlignFrames() == null ? 0 : Desktop .getAlignFrames().length; AlignFrame af = new FileLoader().LoadFileWaitTillLoaded( - "examples/exampleFile_2_7.jar", FormatAdapter.FILE); + "examples/exampleFile_2_7.jar", DataSourceType.FILE); assertNotNull("Didn't read in the example file correctly.", af); assertTrue("Didn't gather the views in the example file.", Desktop.getAlignFrames().length == 1 + origCount); @@ -230,7 +242,7 @@ public class Jalview2xmlTests extends Jalview2xmlBase StructureImportSettings.setProcessSecondaryStructure(true); StructureImportSettings.setVisibleChainAnnotation(true); AlignFrame af = new FileLoader().LoadFileWaitTillLoaded( - "examples/exampleFile_2_7.jar", FormatAdapter.FILE); + "examples/exampleFile_2_7.jar", DataSourceType.FILE); assertNotNull("Didn't read in the example file correctly.", af); AlignmentViewPanel sps = null; for (AlignmentViewPanel ap : af.alignPanel.alignFrame.getAlignPanels()) @@ -291,7 +303,7 @@ public class Jalview2xmlTests extends Jalview2xmlBase public void testCopyViewSettings() throws Exception { AlignFrame af = new FileLoader().LoadFileWaitTillLoaded( - "examples/exampleFile_2_7.jar", FormatAdapter.FILE); + "examples/exampleFile_2_7.jar", DataSourceType.FILE); assertNotNull("Didn't read in the example file correctly.", af); AlignmentViewPanel sps = null, groups = null; for (AlignmentViewPanel ap : af.alignPanel.alignFrame.getAlignPanels()) @@ -331,7 +343,7 @@ public class Jalview2xmlTests extends Jalview2xmlBase Desktop.instance.closeAll_actionPerformed(null); AlignFrame af = new FileLoader().LoadFileWaitTillLoaded( - "examples/exampleFile_2_7.jar", FormatAdapter.FILE); + "examples/exampleFile_2_7.jar", DataSourceType.FILE); Assert.assertEquals(Desktop.getAlignFrames().length, 1); String afid = af.getViewport().getSequenceSetId(); @@ -362,15 +374,15 @@ public class Jalview2xmlTests extends Jalview2xmlBase { Assert.assertEquals(Desktop.getAlignFrames().length, 0); } - af = new FileLoader().LoadFileWaitTillLoaded(tfile.getAbsolutePath(), - FormatAdapter.FILE); + af = new FileLoader().LoadFileWaitTillLoaded( + tfile.getAbsolutePath(), DataSourceType.FILE); Assert.assertNotNull(af); Assert.assertEquals( Desktop.getAlignFrames().length, Desktop.getAlignmentPanels(af.getViewport().getSequenceSetId()).length); Assert.assertEquals( - oldviews, - Desktop.getAlignmentPanels(af.getViewport().getSequenceSetId()).length); + Desktop.getAlignmentPanels(af.getViewport().getSequenceSetId()).length, + oldviews); } /** @@ -384,7 +396,7 @@ public class Jalview2xmlTests extends Jalview2xmlBase { Desktop.instance.closeAll_actionPerformed(null); AlignFrame af = new FileLoader().LoadFileWaitTillLoaded( - "examples/exampleFile_2_7.jar", FormatAdapter.FILE); + "examples/exampleFile_2_7.jar", DataSourceType.FILE); assertNotNull("Didn't read in the example file correctly.", af); String afid = af.getViewport().getSequenceSetId(); @@ -427,8 +439,8 @@ public class Jalview2xmlTests extends Jalview2xmlBase Assert.assertEquals(Desktop.getAlignFrames().length, 0); } - af = new FileLoader().LoadFileWaitTillLoaded(tfile.getAbsolutePath(), - FormatAdapter.FILE); + af = new FileLoader().LoadFileWaitTillLoaded( + tfile.getAbsolutePath(), DataSourceType.FILE); afid = af.getViewport().getSequenceSetId(); for (AlignmentViewPanel ap : Desktop.getAlignmentPanels(afid)) @@ -517,7 +529,7 @@ public class Jalview2xmlTests extends Jalview2xmlBase { Desktop.instance.closeAll_actionPerformed(null); AlignFrame af = new FileLoader().LoadFileWaitTillLoaded( - "examples/uniref50.fa", FormatAdapter.FILE); + "examples/uniref50.fa", DataSourceType.FILE); assertNotNull("Didn't read in the example file correctly.", af); String afid = af.getViewport().getSequenceSetId(); // make a second view of the alignment @@ -595,9 +607,9 @@ public class Jalview2xmlTests extends Jalview2xmlBase { Assert.assertEquals(Desktop.getAlignFrames().length, 0); } - - af = new FileLoader().LoadFileWaitTillLoaded(tfile.getAbsolutePath(), - FormatAdapter.FILE); + + af = new FileLoader().LoadFileWaitTillLoaded( + tfile.getAbsolutePath(), DataSourceType.FILE); afid = af.getViewport().getSequenceSetId(); for (AlignmentViewPanel ap : Desktop.getAlignmentPanels(afid)) @@ -638,7 +650,7 @@ public class Jalview2xmlTests extends Jalview2xmlBase Desktop.instance.closeAll_actionPerformed(null); String exampleFile = "examples/3W5V.pdb"; AlignFrame af = new FileLoader().LoadFileWaitTillLoaded(exampleFile, - FormatAdapter.FILE); + DataSourceType.FILE); assertNotNull("Didn't read in the example file correctly.", af); String afid = af.getViewport().getSequenceSetId(); @@ -687,7 +699,7 @@ public class Jalview2xmlTests extends Jalview2xmlBase } AlignFrame restoredFrame = new FileLoader().LoadFileWaitTillLoaded( - tfile.getAbsolutePath(), FormatAdapter.FILE); + tfile.getAbsolutePath(), DataSourceType.FILE); String rfid = restoredFrame.getViewport().getSequenceSetId(); AlignmentPanel[] rAlignPanels = Desktop.getAlignmentPanels(rfid); AlignmentViewPanel rap = rAlignPanels[0];