X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;ds=sidebyside;f=test%2Fjalview%2Fext%2Fensembl%2FEnsemblGenomeTest.java;h=11140f9f86eaddbe668e2b739397bbb2fcf1c6dd;hb=f501ebf56839e4115d9d48d20a6c936856dc0e37;hp=daad8b162cd65c66451b2aeff08bcd694bdc67f6;hpb=e96f5e8ce137e879dd4b4f37fb5c4d134e2778e2;p=jalview.git
diff --git a/test/jalview/ext/ensembl/EnsemblGenomeTest.java b/test/jalview/ext/ensembl/EnsemblGenomeTest.java
index daad8b1..11140f9 100644
--- a/test/jalview/ext/ensembl/EnsemblGenomeTest.java
+++ b/test/jalview/ext/ensembl/EnsemblGenomeTest.java
@@ -1,12 +1,34 @@
+/*
+ * 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;
import static org.testng.AssertJUnit.assertFalse;
import static org.testng.AssertJUnit.assertTrue;
+import jalview.datamodel.Sequence;
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;
@@ -19,13 +41,21 @@ import org.testng.annotations.Test;
public class EnsemblGenomeTest
{
- @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);
@@ -43,18 +73,17 @@ public class EnsemblGenomeTest
genomic.setStart(10000);
genomic.setEnd(50000);
String transcriptId = "ABC123";
-
+
// transcript at (start+10000) length 501
SequenceFeature sf = new SequenceFeature("transcript", "", 20000,
- 20500, 0f,
- null);
- sf.setValue("ID", "transcript:" + transcriptId);
+ 20500, 0f, null);
+ sf.setValue("id", transcriptId);
sf.setStrand("+");
genomic.addSequenceFeature(sf);
-
+
// transcript (sub-type) at (start + 10500) length 101
sf = new SequenceFeature("ncRNA", "", 10500, 10600, 0f, null);
- sf.setValue("ID", "transcript:" + transcriptId);
+ sf.setValue("id", transcriptId);
sf.setStrand("+");
genomic.addSequenceFeature(sf);
@@ -62,15 +91,15 @@ public class EnsemblGenomeTest
// although strictly it is a sequence_variant in SO
sf = new SequenceFeature("NMD_transcript_variant", "", 11000, 12000,
0f, null);
- sf.setValue("ID", "transcript:" + transcriptId);
+ sf.setValue("id", transcriptId);
sf.setStrand("+");
genomic.addSequenceFeature(sf);
-
+
// transcript with a different ID doesn't count
sf = new SequenceFeature("transcript", "", 11500, 12600, 0f, null);
- sf.setValue("ID", "transcript:anotherOne");
+ sf.setValue("id", "anotherOne");
genomic.addSequenceFeature(sf);
-
+
// parent of transcript feature doesn't count
sf = new SequenceFeature("gene_member_region", "", 10000, 50000, 0f,
null);
@@ -107,23 +136,25 @@ public class EnsemblGenomeTest
SequenceFeature sf = new SequenceFeature("transcript", "", 20000,
20500, 0f, null);
assertFalse(testee.retainFeature(sf, accId));
-
- sf.setType("mature_transcript");
+
+ sf = new SequenceFeature("mature_transcript", "", 20000, 20500, 0f,
+ null);
assertFalse(testee.retainFeature(sf, accId));
-
- sf.setType("NMD_transcript_variant");
+
+ sf = new SequenceFeature("NMD_transcript_variant", "", 20000, 20500,
+ 0f, null);
assertFalse(testee.retainFeature(sf, accId));
-
+
// other feature with no parent is kept
- sf.setType("anything");
+ sf = new SequenceFeature("anything", "", 20000, 20500, 0f, null);
assertTrue(testee.retainFeature(sf, accId));
// other feature with correct parent is kept
- sf.setValue("Parent", "transcript:" + accId);
+ sf.setValue("Parent", accId);
assertTrue(testee.retainFeature(sf, accId));
// other feature with wrong parent is not kept
- sf.setValue("Parent", "transcript:XYZ");
+ sf.setValue("Parent", "XYZ");
assertFalse(testee.retainFeature(sf, accId));
}
@@ -132,39 +163,59 @@ public class EnsemblGenomeTest
* accession id as ID
*/
@Test(groups = "Functional")
- public void testIdentifiesSequence()
+ public void testGetIdentifyingFeatures()
{
String accId = "ABC123";
- EnsemblGenome testee = new EnsemblGenome();
-
+ SequenceI seq = new Sequence(accId, "HEARTS");
+
// transcript with no ID not valid
- SequenceFeature sf = new SequenceFeature("transcript", "", 1, 2, 0f,
+ SequenceFeature sf1 = new SequenceFeature("transcript", "", 1, 2, 0f,
null);
- assertFalse(testee.identifiesSequence(sf, accId));
-
+ seq.addSequenceFeature(sf1);
+
// transcript with wrong ID not valid
- sf.setValue("ID", "transcript");
- assertFalse(testee.identifiesSequence(sf, accId));
-
+ // NB change desc to avoid rejection of duplicate feature!
+ SequenceFeature sf2 = new SequenceFeature("transcript", "a", 1, 2, 0f,
+ null);
+ sf2.setValue("id", "transcript");
+ seq.addSequenceFeature(sf2);
+
// transcript with right ID is valid
- sf.setValue("ID", "transcript:" + accId);
- assertTrue(testee.identifiesSequence(sf, accId));
-
+ SequenceFeature sf3 = new SequenceFeature("transcript", "b", 1, 2, 0f,
+ null);
+ sf3.setValue("id", accId);
+ seq.addSequenceFeature(sf3);
+
// transcript sub-type with right ID is valid
- sf.setType("ncRNA");
- assertTrue(testee.identifiesSequence(sf, accId));
+ SequenceFeature sf4 = new SequenceFeature("ncRNA", "", 1, 2, 0f, null);
+ sf4.setValue("id", accId);
+ seq.addSequenceFeature(sf4);
// Ensembl treats NMD_transcript_variant as if a transcript
- sf.setType("NMD_transcript_variant");
- assertTrue(testee.identifiesSequence(sf, accId));
-
+ SequenceFeature sf5 = new SequenceFeature("NMD_transcript_variant", "",
+ 1, 2, 0f, null);
+ sf5.setValue("id", accId);
+ seq.addSequenceFeature(sf5);
+
// gene not valid:
- sf.setType("gene");
- assertFalse(testee.identifiesSequence(sf, accId));
-
+ SequenceFeature sf6 = new SequenceFeature("gene", "", 1, 2, 0f, null);
+ sf6.setValue("id", accId);
+ seq.addSequenceFeature(sf6);
+
// exon not valid:
- sf.setType("exon");
- assertFalse(testee.identifiesSequence(sf, accId));
+ SequenceFeature sf7 = new SequenceFeature("exon", "", 1, 2, 0f, null);
+ sf7.setValue("id", accId);
+ seq.addSequenceFeature(sf7);
+
+ List sfs = new EnsemblGenome()
+ .getIdentifyingFeatures(seq, accId);
+ assertFalse(sfs.contains(sf1));
+ assertFalse(sfs.contains(sf2));
+ assertTrue(sfs.contains(sf3));
+ assertTrue(sfs.contains(sf4));
+ assertTrue(sfs.contains(sf5));
+ assertFalse(sfs.contains(sf6));
+ assertFalse(sfs.contains(sf7));
}
}