3 import static org.testng.Assert.assertEquals;
4 import static org.testng.Assert.assertTrue;
5 import static org.testng.Assert.assertNull;
8 import java.io.IOException;
9 import java.net.MalformedURLException;
10 import java.util.List;
13 import org.testng.annotations.Test;
15 import jalview.datamodel.DBRefEntry;
16 import jalview.datamodel.SequenceFeature;
17 import jalview.datamodel.SequenceI;
18 import jalview.datamodel.features.SequenceFeatures;
20 public class EmblFlatFileTest
23 * A fairly tough test, using J03321 (circular DNA), which has 8 CDS features,
24 * one of them reverse strand
26 * @throws MalformedURLException
29 @Test(groups = "Functional")
30 public void testParse() throws MalformedURLException, IOException
32 File dataFile = new File("test/jalview/io/J03321.embl.txt");
33 FileParse fp = new FileParse(dataFile, DataSourceType.FILE);
34 EmblFlatFile parser = new EmblFlatFile(fp, "EmblTest");
36 List<SequenceI> seqs = parser.getSeqs();
38 assertEquals(seqs.size(), 1);
39 SequenceI seq = seqs.get(0);
40 assertEquals(seq.getName(), "EmblTest|J03321");
41 assertEquals(seq.getLength(), 7502);
44 * should be 9 CDS features (one is a 'join' of two exons)
46 Set<String> featureTypes = seq.getFeatures().getFeatureTypes();
47 assertEquals(featureTypes.size(), 1);
48 assertTrue(featureTypes.contains("CDS"));
51 * inspect some features (sort them for convenience of test assertions)
53 List<SequenceFeature> features = seq.getFeatures()
54 .getAllFeatures("CDS");
55 SequenceFeatures.sortFeatures(features, true);
56 assertEquals(features.size(), 9);
58 SequenceFeature sf = features.get(0);
59 assertEquals(sf.getBegin(), 1);
60 assertEquals(sf.getEnd(), 437);
61 assertEquals(sf.getDescription(),
62 "Exon 2 for protein EMBLCDS:AAA91567.1");
63 assertEquals(sf.getFeatureGroup(), "EmblTest");
64 assertEquals(sf.getEnaLocation(), "join(7022..7502,1..437)");
65 assertEquals(sf.getPhase(), "0");
66 assertEquals(sf.getStrand(), 1);
67 assertEquals(sf.getValue("note"), "pGP7-D");
68 // second exon of circular DNA!
69 assertEquals(sf.getValue("exon number"), 2);
70 assertEquals(sf.getValue("product"), "hypothetical protein");
71 assertEquals(sf.getValue("transl_table"), "11");
74 assertEquals(sf.getBegin(), 488);
75 assertEquals(sf.getEnd(), 1480);
76 assertEquals(sf.getDescription(),
77 "Exon 1 for protein EMBLCDS:AAA91568.1");
78 assertEquals(sf.getFeatureGroup(), "EmblTest");
79 assertEquals(sf.getEnaLocation(), "complement(488..1480)");
80 assertEquals(sf.getPhase(), "0");
81 assertEquals(sf.getStrand(), -1); // reverse strand!
82 assertEquals(sf.getValue("note"), "pGP8-D");
83 assertEquals(sf.getValue("exon number"), 1);
84 assertEquals(sf.getValue("product"), "hypothetical protein");
87 assertEquals(sf.getBegin(), 6045);
88 assertEquals(sf.getEnd(), 6788);
89 assertEquals(sf.getDescription(),
90 "Exon 1 for protein EMBLCDS:AAA91574.1");
91 assertEquals(sf.getFeatureGroup(), "EmblTest");
92 assertEquals(sf.getEnaLocation(), "6045..6788");
93 assertEquals(sf.getPhase(), "0");
94 assertEquals(sf.getStrand(), 1);
95 assertEquals(sf.getValue("note"), "pGP6-D (gtg start codon)");
96 assertEquals(sf.getValue("exon number"), 1);
97 assertEquals(sf.getValue("product"), "hypothetical protein");
100 * CDS at 7022-7502 is the first exon of the circular DNA CDS
102 sf = features.get(8);
103 assertEquals(sf.getBegin(), 7022);
104 assertEquals(sf.getEnd(), 7502);
105 assertEquals(sf.getDescription(),
106 "Exon 1 for protein EMBLCDS:AAA91567.1");
107 assertEquals(sf.getFeatureGroup(), "EmblTest");
108 assertEquals(sf.getEnaLocation(), "join(7022..7502,1..437)");
109 assertEquals(sf.getPhase(), "0");
110 assertEquals(sf.getStrand(), 1);
111 assertEquals(sf.getValue("note"), "pGP7-D");
112 assertEquals(sf.getValue("exon number"), 1);
113 assertEquals(sf.getValue("product"), "hypothetical protein");
116 * there are 4 'direct' (DR) dbrefs, and numerous CDS /db_xref entries,
117 * some of them (e.g. INTERPRO) duplicates; sample a few here
118 * Note DBRefEntry constructor capitalises source
120 List<DBRefEntry> dbrefs = seq.getDBRefs();
121 assertEquals(dbrefs.size(), 31);
122 // 1st DR line; note trailing period is removed
123 assertTrue(dbrefs.contains(new DBRefEntry("MD5", "0",
124 "d4c4942a634e3df4995fd5ac75c26a61")));
127 dbrefs.contains(new DBRefEntry("EuropePMC", "0", "PMC87941")));
128 // from the first CDS feature; note canonicalisation to "UNIPROT"
129 assertTrue(dbrefs.contains(new DBRefEntry("GOA", "0", "P0CE19")));
130 assertTrue(dbrefs.contains(new DBRefEntry("UNIPROT", "0", "P0CE19")));
131 // from the last CDS feature
132 assertTrue(dbrefs.contains(new DBRefEntry("INTERPRO", "0", "IPR005350")));
134 // todo: mappings to, and sequences for, UNIPROT proteins