X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=test%2Fjalview%2Fext%2Fensembl%2FEnsemblGeneTest.java;h=6cfd85b4f8f69be2e027864e487451f870c6fdf7;hb=8c865b34fb48c55582c2c77609cd04f96819ceef;hp=a262c1eb6ce9c82140a876cb5cfe09decc9c0a6c;hpb=ef9282b464dc189faf9ce40a4b7420a204266668;p=jalview.git
diff --git a/test/jalview/ext/ensembl/EnsemblGeneTest.java b/test/jalview/ext/ensembl/EnsemblGeneTest.java
index a262c1e..6cfd85b 100644
--- a/test/jalview/ext/ensembl/EnsemblGeneTest.java
+++ b/test/jalview/ext/ensembl/EnsemblGeneTest.java
@@ -1,3 +1,23 @@
+/*
+ * Jalview - A Sequence Alignment Editor and Viewer ($$Version-Rel$$)
+ * Copyright (C) $$Year-Rel$$ The Jalview Authors
+ *
+ * This file is part of Jalview.
+ *
+ * Jalview is free software: you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation, either version 3
+ * of the License, or (at your option) any later version.
+ *
+ * Jalview is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty
+ * of MERCHANTABILITY or FITNESS FOR A PARTICULAR
+ * PURPOSE. See the GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with Jalview. If not, see .
+ * The Jalview Authors are detailed in the 'AUTHORS' file.
+ */
package jalview.ext.ensembl;
import static org.testng.AssertJUnit.assertEquals;
@@ -5,14 +25,16 @@ import static org.testng.AssertJUnit.assertFalse;
import static org.testng.AssertJUnit.assertSame;
import static org.testng.AssertJUnit.assertTrue;
+import jalview.api.FeatureSettingsModelI;
import jalview.datamodel.SequenceDummy;
import jalview.datamodel.SequenceFeature;
import jalview.datamodel.SequenceI;
+import jalview.gui.JvOptionPane;
import jalview.io.gff.SequenceOntologyFactory;
import jalview.io.gff.SequenceOntologyLite;
import jalview.util.MapList;
-import java.util.Arrays;
+import java.awt.Color;
import java.util.List;
import org.testng.annotations.AfterClass;
@@ -21,13 +43,21 @@ import org.testng.annotations.Test;
public class EnsemblGeneTest
{
- @BeforeClass
+
+ @BeforeClass(alwaysRun = true)
+ public void setUpJvOptionPane()
+ {
+ JvOptionPane.setInteractiveMode(false);
+ JvOptionPane.setMockResponse(JvOptionPane.CANCEL_OPTION);
+ }
+
+ @BeforeClass(alwaysRun = true)
public void setUp()
{
SequenceOntologyFactory.setInstance(new SequenceOntologyLite());
}
- @AfterClass
+ @AfterClass(alwaysRun = true)
public void tearDown()
{
SequenceOntologyFactory.setInstance(null);
@@ -134,8 +164,8 @@ public class EnsemblGeneTest
genomic.addSequenceFeature(sf1);
// transcript sub-type feature
- SequenceFeature sf2 = new SequenceFeature("snRNA", "", 20000,
- 20500, 0f, null);
+ SequenceFeature sf2 = new SequenceFeature("snRNA", "", 20000, 20500,
+ 0f, null);
sf2.setValue("Parent", "gene:" + geneId);
sf2.setValue("transcript_id", "transcript2");
genomic.addSequenceFeature(sf2);
@@ -160,21 +190,11 @@ public class EnsemblGeneTest
* with no filter
*/
List features = testee.getTranscriptFeatures(geneId,
- genomic, null);
+ genomic);
assertEquals(3, features.size());
assertSame(sf1, features.get(0));
assertSame(sf2, features.get(1));
assertSame(sf3, features.get(2));
-
- /*
- * with filter
- */
- List ids = Arrays.asList(new String[] { "transcript2",
- "transcript3" });
- features = testee.getTranscriptFeatures(geneId, genomic, ids);
- assertEquals(2, features.size());
- assertSame(sf2, features.get(0));
- assertSame(sf3, features.get(1));
}
/**
@@ -186,8 +206,8 @@ public class EnsemblGeneTest
{
String geneId = "ABC123";
EnsemblGene testee = new EnsemblGene();
- SequenceFeature sf = new SequenceFeature("gene", "", 20000,
- 20500, 0f, null);
+ SequenceFeature sf = new SequenceFeature("gene", "", 20000, 20500, 0f,
+ null);
sf.setValue("ID", "gene:" + geneId);
assertFalse(testee.retainFeature(sf, geneId));
@@ -219,29 +239,56 @@ public class EnsemblGeneTest
{
String accId = "ABC123";
EnsemblGene testee = new EnsemblGene();
-
+
// gene with no ID not valid
SequenceFeature sf = new SequenceFeature("gene", "", 1, 2, 0f, null);
assertFalse(testee.identifiesSequence(sf, accId));
-
+
// gene with wrong ID not valid
sf.setValue("ID", "gene:XYZ");
assertFalse(testee.identifiesSequence(sf, accId));
-
+
// gene with right ID is valid
sf.setValue("ID", "gene:" + accId);
assertTrue(testee.identifiesSequence(sf, accId));
-
+
// gene sub-type with right ID is valid
sf.setType("snRNA_gene");
assertTrue(testee.identifiesSequence(sf, accId));
-
+
// transcript not valid:
sf.setType("transcript");
assertFalse(testee.identifiesSequence(sf, accId));
-
+
// exon not valid:
sf.setType("exon");
assertFalse(testee.identifiesSequence(sf, accId));
}
+
+ /**
+ * Check behaviour of feature colour scheme for EnsemblGene sequences.
+ * Currently coded to display exon and sequence_variant (or sub-types) only,
+ * with sequence_variant in red above exon coloured by label.
+ */
+ @Test(groups = "Functional")
+ public void testGetFeatureColourScheme()
+ {
+ FeatureSettingsModelI fc = new EnsemblGene().getFeatureColourScheme();
+ assertTrue(fc.isFeatureDisplayed("exon"));
+ assertTrue(fc.isFeatureDisplayed("coding_exon")); // subtype of exon
+ assertTrue(fc.isFeatureDisplayed("sequence_variant"));
+ assertTrue(fc.isFeatureDisplayed("feature_variant")); // subtype
+ assertFalse(fc.isFeatureDisplayed("transcript"));
+ assertEquals(Color.RED, fc.getFeatureColour("sequence_variant")
+ .getColour());
+ assertEquals(Color.RED, fc.getFeatureColour("feature_variant")
+ .getColour());
+ assertTrue(fc.getFeatureColour("exon").isColourByLabel());
+ assertTrue(fc.getFeatureColour("coding_exon").isColourByLabel());
+ assertEquals(1, fc.compare("sequence_variant", "exon"));
+ assertEquals(-1, fc.compare("exon", "sequence_variant"));
+ assertEquals(1, fc.compare("feature_variant", "coding_exon"));
+ assertEquals(-1, fc.compare("coding_exon", "feature_variant"));
+ assertEquals(1f, fc.getTransparency());
+ }
}