Merge branch 'develop' into features/JAL-2360colourSchemeApplicability
[jalview.git] / test / jalview / io / Jalview2xmlTests.java
index 0b72406..734bfe0 100644 (file)
@@ -45,6 +45,8 @@ 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;
@@ -64,6 +66,7 @@ import org.testng.annotations.Test;
 public class Jalview2xmlTests extends Jalview2xmlBase
 {
 
+  @Override
   @BeforeClass(alwaysRun = true)
   public void setUpJvOptionPane()
   {
@@ -77,21 +80,21 @@ public class Jalview2xmlTests extends Jalview2xmlBase
     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 "
@@ -102,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" })
@@ -111,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(),
@@ -141,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(
@@ -166,11 +169,11 @@ public class Jalview2xmlTests extends Jalview2xmlBase
     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
 
@@ -226,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);
@@ -239,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())
@@ -300,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())
@@ -340,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();
 
@@ -371,8 +374,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);
     Assert.assertNotNull(af);
     Assert.assertEquals(
             Desktop.getAlignFrames().length,
@@ -393,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();
 
@@ -436,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))
@@ -526,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
@@ -604,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))
@@ -647,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();
 
@@ -696,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];