X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=test%2Fjalview%2Fws%2Fdbsources%2FEmblXmlSourceTest.java;fp=test%2Fjalview%2Fws%2Fdbsources%2FEmblSourceTest.java;h=a0991e546ed05edcd310088bfc89b813629f88be;hb=fe3cd724aecdeb06a130a502ce3a967ad643f458;hp=5bf215c74f13cdc9a5e39da0fca65e2b59315c06;hpb=0f8122860073f97741093ded66a4938a4082408d;p=jalview.git diff --git a/test/jalview/ws/dbsources/EmblSourceTest.java b/test/jalview/ws/dbsources/EmblXmlSourceTest.java similarity index 93% rename from test/jalview/ws/dbsources/EmblSourceTest.java rename to test/jalview/ws/dbsources/EmblXmlSourceTest.java index 5bf215c..a0991e5 100644 --- a/test/jalview/ws/dbsources/EmblSourceTest.java +++ b/test/jalview/ws/dbsources/EmblXmlSourceTest.java @@ -26,6 +26,7 @@ import static org.testng.AssertJUnit.assertNull; import static org.testng.AssertJUnit.assertSame; import static org.testng.AssertJUnit.assertTrue; +import jalview.datamodel.AlignmentI; import jalview.datamodel.DBRefEntry; import jalview.datamodel.DBRefSource; import jalview.datamodel.SequenceI; @@ -40,9 +41,10 @@ import java.util.ArrayList; import java.util.Arrays; import java.util.List; +import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; -public class EmblSourceTest +public class EmblXmlSourceTest { // adapted from http://www.ebi.ac.uk/ena/data/view/X07547&display=xml @@ -95,16 +97,49 @@ public class EmblSourceTest + "ACCCCCAATATTGTGATATAATTAAAAACATAGCAT" + ""; + private EmblXmlSource testee; + + @BeforeClass(alwaysRun = true) + public void setUp() + { + testee = new EmblXmlSource() + { + + @Override + public String getDbSource() + { + return null; + } + + @Override + public String getDbName() + { + return null; + } + + @Override + public String getTestQuery() + { + return null; + } + + @Override + public AlignmentI getSequenceRecords(String queries) throws Exception + { + return null; + } + }; + } + @Test(groups = "Functional") public void testGetCdsRanges() { - EmblSource testee = new EmblSource(); - /* * Make a (CDS) Feature with 5 locations */ Feature cds = new Feature(); - cds.setLocation("join(10..20,complement(30..40),50..60,70..80,complement(110..120))"); + cds.setLocation( + "join(10..20,complement(30..40),50..60,70..80,complement(110..120))"); int[] exons = testee.getCdsRanges("EMBL", cds); assertEquals("[10, 20, 40, 30, 50, 60, 70, 80, 120, 110]", @@ -116,10 +151,9 @@ public class EmblSourceTest { // not the whole sequence but enough for this test... List peptides = new ArrayList<>(); - List entries = EmblSourceTest.getEmblEntries(); + List entries = getEmblEntries(); assertEquals(1, entries.size()); EntryType entry = entries.get(0); - EmblSource testee = new EmblSource(); String sourceDb = "EMBL"; SequenceI dna = testee.getSequence(sourceDb, entry, peptides); @@ -165,8 +199,9 @@ public class EmblSourceTest 3, 1); MapList cds2Map = new MapList(new int[] { 4, 15 }, new int[] { 1, 4 }, 3, 1); - MapList cds3Map = new MapList(new int[] { 4, 6, 10, 15 }, new int[] { - 1, 3 }, 3, 1); + MapList cds3Map = new MapList(new int[] { 4, 6, 10, 15 }, + new int[] + { 1, 3 }, 3, 1); List dbrefs = dna.getDBRefs(); assertEquals(7, dbrefs.size()); @@ -222,10 +257,12 @@ public class EmblSourceTest * - to EMBLCDS (with 1:3 mapping) * - direct (no mapping) to other protein accessions */ - MapList proteinToCdsMap1 = new MapList(new int[] { 1, 4 }, new int[] { - 1, 12 }, 1, 3); - MapList proteinToCdsMap2 = new MapList(new int[] { 1, 3 }, new int[] { - 1, 9 }, 1, 3); + MapList proteinToCdsMap1 = new MapList(new int[] { 1, 4 }, + new int[] + { 1, 12 }, 1, 3); + MapList proteinToCdsMap2 = new MapList(new int[] { 1, 3 }, + new int[] + { 1, 9 }, 1, 3); // dbrefs for first CDS EMBL product CAA30420.1 dbrefs = peptides.get(0).getDBRefs(); @@ -339,10 +376,10 @@ public class EmblSourceTest @Test(groups = { "Functional" }) public void testGetEmblEntries() { - List entries = EmblSourceTest.getEmblEntries(); + List entries = getEmblEntries(); assertEquals(1, entries.size()); EntryType entry = entries.get(0); - + assertEquals("X07547", entry.getAccession()); assertEquals("C. trachomatis plasmid", entry.getDescription()); assertEquals("STD", entry.getDataClass()); @@ -359,7 +396,7 @@ public class EmblSourceTest assertEquals(2, entry.getKeyword().size()); assertEquals("plasmid", entry.getKeyword().get(0)); assertEquals("unidentified reading frame", entry.getKeyword().get(1)); - + /* * dbrefs */ @@ -372,7 +409,7 @@ public class EmblSourceTest assertEquals("MD5", dbref.getDb()); assertEquals("ac73317", dbref.getId()); assertNull(dbref.getSecondaryId()); - + /* * three sequence features for CDS */ @@ -403,7 +440,7 @@ public class EmblSourceTest q = ef.getQualifier().get(2); assertEquals("translation", q.getName()); assertEquals("MLCF", q.getValue()); - + /* * second CDS */ @@ -422,7 +459,7 @@ public class EmblSourceTest q = ef.getQualifier().get(1); assertEquals("translation", q.getName()); assertEquals("MSSS", q.getValue()); - + /* * third CDS */ @@ -438,16 +475,14 @@ public class EmblSourceTest q = ef.getQualifier().get(1); assertEquals("translation", q.getName()); assertEquals("MSS", q.getValue()); - + /* * Sequence - raw data before removal of newlines */ String seq = entry.getSequence(); - assertEquals( - "GGTATGTCCTCTAGTACAAAC\n" - + "ACCCCCAATATTGTGATATAATTAAAAACATAGCAT", - seq); - + assertEquals("GGTATGTCCTCTAGTACAAAC\n" + + "ACCCCCAATATTGTGATATAATTAAAAACATAGCAT", seq); + /* * getSequence() converts empty DBRefEntry.version to "0" */ @@ -455,9 +490,9 @@ public class EmblSourceTest assertNull(entry.getFeature().get(0).getXref().get(1).getSecondaryId()); } - static List getEmblEntries() + List getEmblEntries() { - return new EmblSource() + return testee .getEmblEntries(new ByteArrayInputStream(TESTDATA.getBytes())); } }