package jalview.ext.ensembl;
import static org.testng.AssertJUnit.assertEquals;
+import static org.testng.AssertJUnit.assertFalse;
+import static org.testng.AssertJUnit.assertTrue;
+import jalview.analysis.AlignmentUtils;
import jalview.datamodel.Alignment;
import jalview.datamodel.AlignmentI;
import jalview.datamodel.SequenceI;
import jalview.io.AppletFormatAdapter;
import jalview.io.FastaFile;
import jalview.io.FileParse;
+import jalview.io.gff.SequenceOntologyFactory;
+import jalview.io.gff.SequenceOntologyLite;
import java.lang.reflect.Method;
import java.net.MalformedURLException;
import java.util.List;
import org.testng.Assert;
+import org.testng.annotations.AfterClass;
+import org.testng.annotations.BeforeClass;
import org.testng.annotations.DataProvider;
import org.testng.annotations.Test;
+ "NRDQIIFMVGRGYLSPDLSKVRSNCPKAMKRLMAECLKKKRDERPLFPQILASIELLARS\n"
+ "LPKIHRSASEPSLNRAGFQTEDFSLYACASPKTPIQAGGYGAFPVH" } };
- @DataProvider(name = "queries")
- public Object[][] createQueryData(Method m)
+ @BeforeClass
+ public void setUp()
{
- return new Object[][] { { "CCDS5863.1" }, { "ENSP00000288602" } };
+ SequenceOntologyFactory.setInstance(new SequenceOntologyLite());
}
- @Test(dataProvider = "queries")
- public void testIsValidReference(String query) throws Exception
+ @AfterClass
+ public void tearDown()
{
- EnsemblSequenceFetcher esq = new EnsemblProtein();
- Assert.assertTrue(esq.isValidReference(query),
- "Expected reference string " + query
- + " to be valid for regex "
- + esq.getAccessionValidator().toString());
+ SequenceOntologyFactory.setInstance(null);
}
@DataProvider(name = "ens_seqs")
: "DOWN or unreachable ******************* BAD!"));
}
- /**
- * Tests for the method that computes all peptide variants given codon
- * variants
- */
@Test(groups = "Functional")
- public void testComputePeptideVariants()
+ public void getGenomicRangesFromFeatures()
{
- String[][] codonVariants = new String[][] { { "A" }, { "G" }, { "T" } };
- /*
- * AGT codes for S - this is not included in the variants returned
- */
- List<String> variants = EnsemblSeqProxy.computePeptideVariants(codonVariants, "S");
- assertEquals("[]", variants.toString());
-
- // S is reported if it differs from the current value (A):
- variants = EnsemblSeqProxy.computePeptideVariants(codonVariants, "A");
- assertEquals("[S]", variants.toString());
-
- /*
- * synonymous variant is not reported
- */
- codonVariants = new String[][] { { "A" }, { "G" }, { "C", "T" } };
- // AGC and AGT both code for S
- variants = EnsemblSeqProxy.computePeptideVariants(codonVariants, "s");
- assertEquals("[]", variants.toString());
-
- /*
- * equivalent variants are only reported once
- */
- codonVariants = new String[][] { { "C" }, { "T" },
- { "A", "C", "G", "T" } };
- // CTA CTC CTG CTT all code for L
- variants = EnsemblSeqProxy.computePeptideVariants(codonVariants, "S");
- assertEquals("[L]", variants.toString());
-
- /*
- * vary codons 1 and 2; variant products are sorted and non-redundant
- */
- codonVariants = new String[][] { { "a", "C" }, { "g", "T" }, { "A" } };
- // aga ata cga cta code for R, I, R, L
- variants = EnsemblSeqProxy.computePeptideVariants(codonVariants, "S");
- assertEquals("[I, L, R]", variants.toString());
-
- /*
- * vary codons 2 and 3
- */
- codonVariants = new String[][] { { "a" }, { "g", "T" }, { "A", "c" } };
- // aga agc ata atc code for R, S, I, I
- variants = EnsemblSeqProxy.computePeptideVariants(codonVariants, "S");
- assertEquals("[I, R]", variants.toString());
+ }
- /*
- * vary codons 1 and 3
- */
- codonVariants = new String[][] { { "a", "t" }, { "a" }, { "t", "g" } };
- // aat aag tat tag code for N, K, Y, STOP - STOP sorted to end
- variants = EnsemblSeqProxy.computePeptideVariants(codonVariants, "S");
- assertEquals("[K, N, Y, STOP]", variants.toString());
+ @Test(groups = "Functional")
+ public void testIsTranscriptIdentifier()
+ {
+ EnsemblSeqProxy testee = new EnsemblGene();
+ assertFalse(testee.isTranscriptIdentifier(null));
+ assertFalse(testee.isTranscriptIdentifier(""));
+ assertFalse(testee.isTranscriptIdentifier("ENSG00000012345"));
+ assertTrue(testee.isTranscriptIdentifier("ENST00000012345"));
+ assertTrue(testee.isTranscriptIdentifier("ENSMUST00000012345"));
+ assertFalse(testee.isTranscriptIdentifier("enst00000012345"));
+ assertFalse(testee.isTranscriptIdentifier("ENST000000123456"));
+ assertFalse(testee.isTranscriptIdentifier("ENST0000001234"));
+ }
- /*
- * vary codons 1, 2 and 3
- */
- codonVariants = new String[][] { { "a", "t" }, { "G", "C" },
- { "t", "g" } };
- // agt agg act acg tgt tgg tct tcg code for S, R, T, T, C, W, S, S
- variants = EnsemblSeqProxy.computePeptideVariants(codonVariants, "S");
- assertEquals("[C, R, T, W]", variants.toString());
+ @Test(groups = "Functional")
+ public void testIsGeneIdentifier()
+ {
+ EnsemblSeqProxy testee = new EnsemblGene();
+ assertFalse(testee.isGeneIdentifier(null));
+ assertFalse(testee.isGeneIdentifier(""));
+ assertFalse(testee.isGeneIdentifier("ENST00000012345"));
+ assertTrue(testee.isGeneIdentifier("ENSG00000012345"));
+ assertTrue(testee.isGeneIdentifier("ENSMUSG00000012345"));
+ assertFalse(testee.isGeneIdentifier("ensg00000012345"));
+ assertFalse(testee.isGeneIdentifier("ENSG000000123456"));
+ assertFalse(testee.isGeneIdentifier("ENSG0000001234"));
}
}
\ No newline at end of file