X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=test%2Fjalview%2Fext%2Fensembl%2FEnsemblGeneTest.java;h=6cfd85b4f8f69be2e027864e487451f870c6fdf7;hb=8c865b34fb48c55582c2c77609cd04f96819ceef;hp=1f1a84e3f1302eb691159d6ec666106d47b1e10d;hpb=e96f5e8ce137e879dd4b4f37fb5c4d134e2778e2;p=jalview.git
diff --git a/test/jalview/ext/ensembl/EnsemblGeneTest.java b/test/jalview/ext/ensembl/EnsemblGeneTest.java
index 1f1a84e..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,13 +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.awt.Color;
import java.util.List;
import org.testng.annotations.AfterClass;
@@ -20,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);
@@ -129,27 +160,35 @@ public class EnsemblGeneTest
SequenceFeature sf1 = new SequenceFeature("transcript", "", 20000,
20500, 0f, null);
sf1.setValue("Parent", "gene:" + geneId);
+ sf1.setValue("transcript_id", "transcript1");
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);
// NMD_transcript_variant treated like transcript in Ensembl
SequenceFeature sf3 = new SequenceFeature("NMD_transcript_variant", "",
20000, 20500, 0f, null);
sf3.setValue("Parent", "gene:" + geneId);
+ sf3.setValue("transcript_id", "transcript3");
genomic.addSequenceFeature(sf3);
// transcript for a different gene - ignored
SequenceFeature sf4 = new SequenceFeature("snRNA", "", 20000, 20500,
0f, null);
sf4.setValue("Parent", "gene:XYZ");
+ sf4.setValue("transcript_id", "transcript4");
genomic.addSequenceFeature(sf4);
EnsemblGene testee = new EnsemblGene();
+
+ /*
+ * with no filter
+ */
List features = testee.getTranscriptFeatures(geneId,
genomic);
assertEquals(3, features.size());
@@ -167,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));
@@ -200,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());
+ }
}