Merge branch 'features/JAL-1956_featureStyles' into merge_JAL-1956
[jalview.git] / test / jalview / io / FeaturesFileTest.java
index 29bd567..2f5d0c5 100644 (file)
@@ -26,6 +26,7 @@ import static org.testng.AssertJUnit.assertNotNull;
 import static org.testng.AssertJUnit.assertNull;
 import static org.testng.AssertJUnit.assertTrue;
 
+import jalview.api.FeatureColourI;
 import jalview.api.FeatureRenderer;
 import jalview.datamodel.Alignment;
 import jalview.datamodel.AlignmentI;
@@ -33,8 +34,6 @@ import jalview.datamodel.SequenceDummy;
 import jalview.datamodel.SequenceFeature;
 import jalview.datamodel.SequenceI;
 import jalview.gui.AlignFrame;
-import jalview.schemes.AnnotationColourGradient;
-import jalview.schemes.GraduatedColor;
 
 import java.awt.Color;
 import java.io.File;
@@ -54,7 +53,7 @@ public class FeaturesFileTest
     File f = new File("examples/uniref50.fa");
     AlignmentI al = readAlignmentFile(f);
     AlignFrame af = new AlignFrame(al, 500, 500);
-    Map<String, Object> colours = af.getFeatureRenderer()
+    Map<String, FeatureColourI> colours = af.getFeatureRenderer()
             .getFeatureColours();
     FeaturesFile featuresFile = new FeaturesFile(
             "examples/exampleFeatures.txt", FormatAdapter.FILE);
@@ -68,8 +67,8 @@ public class FeaturesFileTest
      */
     colours = af.getFeatureRenderer().getFeatureColours();
     assertEquals("26 feature group colours not found", 26, colours.size());
-    assertEquals(colours.get("Cath"), new Color(0x93b1d1));
-    assertEquals(colours.get("ASX-MOTIF"), new Color(0x6addbb));
+    assertEquals(colours.get("Cath").getColour(), new Color(0x93b1d1));
+    assertEquals(colours.get("ASX-MOTIF").getColour(), new Color(0x6addbb));
 
     /*
      * verify (some) features on sequences
@@ -151,7 +150,7 @@ public class FeaturesFileTest
     File f = new File("examples/uniref50.fa");
     AlignmentI al = readAlignmentFile(f);
     AlignFrame af = new AlignFrame(al, 500, 500);
-    Map<String, Object> colours = af.getFeatureRenderer()
+    Map<String, FeatureColourI> colours = af.getFeatureRenderer()
             .getFeatureColours();
     // GFF2 uses space as name/value separator in column 9
     String gffData = "METAL\tcc9900\n" + "GFF\n"
@@ -165,7 +164,7 @@ public class FeaturesFileTest
     // verify colours read or synthesized
     colours = af.getFeatureRenderer().getFeatureColours();
     assertEquals("1 feature group colours not found", 1, colours.size());
-    assertEquals(colours.get("METAL"), new Color(0xcc9900));
+    assertEquals(colours.get("METAL").getColour(), new Color(0xcc9900));
 
     // verify feature on FER_CAPAA
     SequenceFeature[] sfs = al.getSequenceAt(0).getDatasetSequence()
@@ -206,45 +205,6 @@ public class FeaturesFileTest
   }
 
   /**
-   * Test various ways of describing a feature colour scheme
-   * 
-   * @throws Exception
-   */
-  @Test(groups = { "Functional" })
-  public void testParseGraduatedColourScheme() throws Exception
-  {
-    FeaturesFile ff = new FeaturesFile();
-
-    // colour by label:
-    GraduatedColor gc = ff.parseGraduatedColourScheme(
-            "BETA-TURN-IR\t9a6a94", "label");
-    assertTrue(gc.isColourByLabel());
-    assertEquals(Color.white, gc.getMinColor());
-    assertEquals(Color.black, gc.getMaxColor());
-    assertTrue(gc.isAutoScale());
-
-    // using colour name, rgb, etc:
-    String spec = "blue|255,0,255|absolute|20.0|95.0|below|66.0";
-    gc = ff.parseGraduatedColourScheme("BETA-TURN-IR\t" + spec, spec);
-    assertFalse(gc.isColourByLabel());
-    assertEquals(Color.blue, gc.getMinColor());
-    assertEquals(new Color(255, 0, 255), gc.getMaxColor());
-    assertFalse(gc.isAutoScale());
-    assertFalse(gc.getTolow());
-    assertEquals(20.0f, gc.getMin(), 0.001f);
-    assertEquals(95.0f, gc.getMax(), 0.001f);
-    assertEquals(AnnotationColourGradient.BELOW_THRESHOLD,
-            gc.getThreshType());
-    assertEquals(66.0f, gc.getThresh(), 0.001f);
-
-    // inverse gradient high to low:
-    spec = "blue|255,0,255|95.0|20.0|below|66.0";
-    gc = ff.parseGraduatedColourScheme("BETA-TURN-IR\t" + spec, spec);
-    assertTrue(gc.isAutoScale());
-    assertTrue(gc.getTolow());
-  }
-
-  /**
    * Test parsing a features file with GFF formatted content only
    * 
    * @throws Exception
@@ -255,7 +215,7 @@ public class FeaturesFileTest
     File f = new File("examples/uniref50.fa");
     AlignmentI al = readAlignmentFile(f);
     AlignFrame af = new AlignFrame(al, 500, 500);
-    Map<String, Object> colours = af.getFeatureRenderer()
+    Map<String, FeatureColourI> colours = af.getFeatureRenderer()
             .getFeatureColours();
     // GFF3 uses '=' separator for name/value pairs in colum 9
     String gffData = "##gff-version 3\n"
@@ -307,7 +267,7 @@ public class FeaturesFileTest
     File f = new File("examples/uniref50.fa");
     AlignmentI al = readAlignmentFile(f);
     AlignFrame af = new AlignFrame(al, 500, 500);
-    Map<String, Object> colours = af.getFeatureRenderer()
+    Map<String, FeatureColourI> colours = af.getFeatureRenderer()
             .getFeatureColours();
 
     /*
@@ -430,7 +390,7 @@ public class FeaturesFileTest
     File f = new File("examples/uniref50.fa");
     AlignmentI al = readAlignmentFile(f);
     AlignFrame af = new AlignFrame(al, 500, 500);
-    Map<String, Object> colours = af.getFeatureRenderer()
+    Map<String, FeatureColourI> colours = af.getFeatureRenderer()
             .getFeatureColours();
     String features = "METAL\tcc9900\n"
             + "GAMMA-TURN\tred|0,255,255|20.0|95.0|below|66.0\n"
@@ -448,7 +408,7 @@ public class FeaturesFileTest
      * first with no features displayed
      */
     FeatureRenderer fr = af.alignPanel.getFeatureRenderer();
-    Map<String, Object> visible = fr
+    Map<String, FeatureColourI> visible = fr
             .getDisplayedFeatureCols();
     String exported = featuresFile.printJalviewFormat(
             al.getSequencesArray(), visible);