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;
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
+ "ACCCCCAATATTGTGATATAATTAAAAACATAGCAT"
+ "</sequence></entry></ROOT>";
+ 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]",
{
// not the whole sequence but enough for this test...
List<SequenceI> peptides = new ArrayList<>();
- List<EntryType> entries = EmblSourceTest.getEmblEntries();
+ List<EntryType> 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);
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<DBRefEntry> dbrefs = dna.getDBRefs();
assertEquals(7, dbrefs.size());
* - 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();
@Test(groups = { "Functional" })
public void testGetEmblEntries()
{
- List<EntryType> entries = EmblSourceTest.getEmblEntries();
+ List<EntryType> 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());
assertEquals(2, entry.getKeyword().size());
assertEquals("plasmid", entry.getKeyword().get(0));
assertEquals("unidentified reading frame", entry.getKeyword().get(1));
-
+
/*
* dbrefs
*/
assertEquals("MD5", dbref.getDb());
assertEquals("ac73317", dbref.getId());
assertNull(dbref.getSecondaryId());
-
+
/*
* three sequence features for CDS
*/
q = ef.getQualifier().get(2);
assertEquals("translation", q.getName());
assertEquals("MLCF", q.getValue());
-
+
/*
* second CDS
*/
q = ef.getQualifier().get(1);
assertEquals("translation", q.getName());
assertEquals("MSSS", q.getValue());
-
+
/*
* third CDS
*/
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"
*/
assertNull(entry.getFeature().get(0).getXref().get(1).getSecondaryId());
}
- static List<EntryType> getEmblEntries()
+ List<EntryType> getEmblEntries()
{
- return new EmblSource()
+ return testee
.getEmblEntries(new ByteArrayInputStream(TESTDATA.getBytes()));
}
}