1 |
|
|
2 |
|
|
3 |
|
|
4 |
|
|
5 |
|
|
6 |
|
|
7 |
|
|
8 |
|
|
9 |
|
|
10 |
|
|
11 |
|
|
12 |
|
|
13 |
|
|
14 |
|
|
15 |
|
|
16 |
|
|
17 |
|
|
18 |
|
|
19 |
|
|
20 |
|
|
21 |
|
package jalview.io; |
22 |
|
|
23 |
|
import static org.testng.Assert.assertEquals; |
24 |
|
import static org.testng.Assert.assertTrue; |
25 |
|
import static org.testng.AssertJUnit.assertNull; |
26 |
|
|
27 |
|
import java.io.File; |
28 |
|
import java.io.IOException; |
29 |
|
import java.net.MalformedURLException; |
30 |
|
import java.util.List; |
31 |
|
import java.util.Set; |
32 |
|
|
33 |
|
import org.testng.annotations.BeforeClass; |
34 |
|
import org.testng.annotations.Test; |
35 |
|
|
36 |
|
import jalview.bin.Console; |
37 |
|
import jalview.datamodel.DBRefEntry; |
38 |
|
import jalview.datamodel.Mapping; |
39 |
|
import jalview.datamodel.SequenceFeature; |
40 |
|
import jalview.datamodel.SequenceI; |
41 |
|
import jalview.datamodel.features.SequenceFeatures; |
42 |
|
import jalview.util.MapList; |
43 |
|
|
|
|
| 0% |
Uncovered Elements: 117 (117) |
Complexity: 2 |
Complexity Density: 0.02 |
|
44 |
|
public class GenBankFileTest |
45 |
|
{ |
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
46 |
0 |
@BeforeClass(alwaysRun = true)... |
47 |
|
public void setUp() |
48 |
|
{ |
49 |
0 |
Console.initLogger(); |
50 |
|
} |
51 |
|
|
52 |
|
|
53 |
|
|
54 |
|
|
55 |
|
|
56 |
|
@throws |
57 |
|
@throws |
58 |
|
|
|
|
| 0% |
Uncovered Elements: 114 (114) |
Complexity: 1 |
Complexity Density: 0.01 |
4-
|
|
59 |
0 |
@Test(groups = "Functional")... |
60 |
|
public void testParse() throws MalformedURLException, IOException |
61 |
|
{ |
62 |
0 |
File dataFile = new File("test/jalview/io/J03321.gb"); |
63 |
0 |
FileParse fp = new FileParse(dataFile.getAbsolutePath(), |
64 |
|
DataSourceType.FILE); |
65 |
0 |
EMBLLikeFlatFile parser = new GenBankFile(fp, "GenBankTest"); |
66 |
0 |
List<SequenceI> seqs = parser.getSeqs(); |
67 |
|
|
68 |
0 |
assertEquals(seqs.size(), 1); |
69 |
0 |
SequenceI seq = seqs.get(0); |
70 |
0 |
assertEquals(seq.getName(), "GenBankTest|J03321"); |
71 |
0 |
assertEquals(seq.getLength(), 7502); |
72 |
0 |
assertEquals(seq.getDescription(), |
73 |
|
"Chlamydia trachomatis plasmid pCHL1, complete sequence"); |
74 |
|
|
75 |
|
|
76 |
|
|
77 |
|
|
78 |
0 |
Set<String> featureTypes = seq.getFeatures().getFeatureTypes(); |
79 |
0 |
assertEquals(featureTypes.size(), 1); |
80 |
0 |
assertTrue(featureTypes.contains("CDS")); |
81 |
|
|
82 |
|
|
83 |
|
|
84 |
|
|
85 |
0 |
List<SequenceFeature> features = seq.getFeatures() |
86 |
|
.getAllFeatures("CDS"); |
87 |
0 |
SequenceFeatures.sortFeatures(features, true); |
88 |
0 |
assertEquals(features.size(), 9); |
89 |
|
|
90 |
0 |
SequenceFeature sf = features.get(0); |
91 |
0 |
assertEquals(sf.getBegin(), 1); |
92 |
0 |
assertEquals(sf.getEnd(), 437); |
93 |
0 |
assertEquals(sf.getDescription(), |
94 |
|
"Exon 2 for protein EMBLCDS:AAA91567.1"); |
95 |
0 |
assertEquals(sf.getFeatureGroup(), "GenBankTest"); |
96 |
0 |
assertEquals(sf.getEnaLocation(), "join(7022..7502,1..437)"); |
97 |
0 |
assertEquals(sf.getPhase(), "0"); |
98 |
0 |
assertEquals(sf.getStrand(), 1); |
99 |
0 |
assertEquals(sf.getValue("note"), "pGP7-D"); |
100 |
|
|
101 |
0 |
assertEquals(sf.getValue("exon number"), 2); |
102 |
0 |
assertEquals(sf.getValue("product"), "hypothetical protein"); |
103 |
0 |
assertEquals(sf.getValue("transl_table"), "11"); |
104 |
|
|
105 |
0 |
sf = features.get(1); |
106 |
0 |
assertEquals(sf.getBegin(), 488); |
107 |
0 |
assertEquals(sf.getEnd(), 1480); |
108 |
0 |
assertEquals(sf.getDescription(), |
109 |
|
"Exon 1 for protein EMBLCDS:AAA91568.1"); |
110 |
0 |
assertEquals(sf.getFeatureGroup(), "GenBankTest"); |
111 |
0 |
assertEquals(sf.getEnaLocation(), "complement(488..1480)"); |
112 |
0 |
assertEquals(sf.getPhase(), "0"); |
113 |
0 |
assertEquals(sf.getStrand(), -1); |
114 |
0 |
assertEquals(sf.getValue("note"), "pGP8-D"); |
115 |
0 |
assertEquals(sf.getValue("exon number"), 1); |
116 |
0 |
assertEquals(sf.getValue("product"), "hypothetical protein"); |
117 |
|
|
118 |
0 |
sf = features.get(7); |
119 |
0 |
assertEquals(sf.getBegin(), 6045); |
120 |
0 |
assertEquals(sf.getEnd(), 6788); |
121 |
0 |
assertEquals(sf.getDescription(), |
122 |
|
"Exon 1 for protein EMBLCDS:AAA91574.1"); |
123 |
0 |
assertEquals(sf.getFeatureGroup(), "GenBankTest"); |
124 |
0 |
assertEquals(sf.getEnaLocation(), "6045..6788"); |
125 |
0 |
assertEquals(sf.getPhase(), "0"); |
126 |
0 |
assertEquals(sf.getStrand(), 1); |
127 |
0 |
assertEquals(sf.getValue("note"), "pGP6-D (gtg start codon)"); |
128 |
0 |
assertEquals(sf.getValue("exon number"), 1); |
129 |
0 |
assertEquals(sf.getValue("product"), "hypothetical protein"); |
130 |
|
|
131 |
|
|
132 |
|
|
133 |
|
|
134 |
0 |
sf = features.get(8); |
135 |
0 |
assertEquals(sf.getBegin(), 7022); |
136 |
0 |
assertEquals(sf.getEnd(), 7502); |
137 |
0 |
assertEquals(sf.getDescription(), |
138 |
|
"Exon 1 for protein EMBLCDS:AAA91567.1"); |
139 |
0 |
assertEquals(sf.getFeatureGroup(), "GenBankTest"); |
140 |
0 |
assertEquals(sf.getEnaLocation(), "join(7022..7502,1..437)"); |
141 |
0 |
assertEquals(sf.getPhase(), "0"); |
142 |
0 |
assertEquals(sf.getStrand(), 1); |
143 |
0 |
assertEquals(sf.getValue("note"), "pGP7-D"); |
144 |
0 |
assertEquals(sf.getValue("exon number"), 1); |
145 |
0 |
assertEquals(sf.getValue("product"), "hypothetical protein"); |
146 |
|
|
147 |
|
|
148 |
|
|
149 |
|
|
150 |
|
|
151 |
|
|
152 |
|
|
153 |
0 |
List<DBRefEntry> dbrefs = seq.getDBRefs(); |
154 |
|
|
155 |
0 |
assertEquals(dbrefs.size(), 9); |
156 |
|
|
157 |
0 |
DBRefEntry selfRef = new DBRefEntry("GENBANKTEST", "1", "J03321"); |
158 |
0 |
int[] range = new int[] { 1, seq.getLength() }; |
159 |
0 |
selfRef.setMap(new Mapping(null, range, range, 1, 1)); |
160 |
0 |
assertTrue(dbrefs.contains(selfRef)); |
161 |
|
|
162 |
|
|
163 |
|
|
164 |
|
|
165 |
|
|
166 |
|
|
167 |
0 |
DBRefEntry dbref = dbrefs.get(0); |
168 |
0 |
assertEquals(dbref.getSource(), "GENBANKTEST"); |
169 |
0 |
assertEquals(dbref.getAccessionId(), "J03321"); |
170 |
0 |
Mapping mapping = dbref.getMap(); |
171 |
0 |
assertNull(mapping.getTo()); |
172 |
0 |
MapList map = mapping.getMap(); |
173 |
0 |
assertEquals(map.getFromLowest(), 1); |
174 |
0 |
assertEquals(map.getFromHighest(), 7502); |
175 |
0 |
assertEquals(map.getToLowest(), 1); |
176 |
0 |
assertEquals(map.getToHighest(), 7502); |
177 |
0 |
assertEquals(map.getFromRatio(), 1); |
178 |
0 |
assertEquals(map.getToRatio(), 1); |
179 |
|
|
180 |
|
|
181 |
0 |
dbref = dbrefs.get(1); |
182 |
0 |
assertEquals(dbref.getSource(), "EMBLCDSPROTEIN"); |
183 |
0 |
assertEquals(dbref.getAccessionId(), "AAA91567.1"); |
184 |
0 |
mapping = dbref.getMap(); |
185 |
0 |
SequenceI mapTo = mapping.getTo(); |
186 |
0 |
assertEquals(mapTo.getName(), "AAA91567.1"); |
187 |
|
|
188 |
0 |
assertEquals(mapTo.getDescription(), "hypothetical protein"); |
189 |
0 |
String seqString = mapTo.getSequenceAsString(); |
190 |
0 |
assertEquals(seqString.length(), 305); |
191 |
0 |
assertTrue(seqString.startsWith("MGSMAF")); |
192 |
0 |
assertTrue(seqString.endsWith("QTPTIL")); |
193 |
0 |
map = mapping.getMap(); |
194 |
0 |
assertEquals(map.getFromLowest(), 1); |
195 |
0 |
assertEquals(map.getFromHighest(), 7502); |
196 |
0 |
assertEquals(map.getToLowest(), 1); |
197 |
0 |
assertEquals(map.getToHighest(), 305); |
198 |
0 |
assertEquals(map.getFromRatio(), 3); |
199 |
0 |
assertEquals(map.getToRatio(), 1); |
200 |
|
|
201 |
|
|
202 |
0 |
dbref = dbrefs.get(8); |
203 |
0 |
assertEquals(dbref.getSource(), "EMBLCDSPROTEIN"); |
204 |
0 |
assertEquals(dbref.getAccessionId(), "AAA91574.1"); |
205 |
0 |
mapping = dbref.getMap(); |
206 |
0 |
mapTo = mapping.getTo(); |
207 |
0 |
assertEquals(mapTo.getName(), "AAA91574.1"); |
208 |
|
|
209 |
0 |
assertEquals(mapTo.getDescription(), "hypothetical protein"); |
210 |
0 |
seqString = mapTo.getSequenceAsString(); |
211 |
0 |
assertEquals(seqString.length(), 247); |
212 |
0 |
assertTrue(seqString.startsWith("MNKLK")); |
213 |
0 |
assertTrue(seqString.endsWith("FKQKS")); |
214 |
0 |
map = mapping.getMap(); |
215 |
0 |
assertEquals(map.getFromLowest(), 6045); |
216 |
0 |
assertEquals(map.getFromHighest(), 6785); |
217 |
0 |
assertEquals(map.getToLowest(), 1); |
218 |
0 |
assertEquals(map.getToHighest(), 247); |
219 |
0 |
assertEquals(map.getFromRatio(), 3); |
220 |
0 |
assertEquals(map.getToRatio(), 1); |
221 |
|
} |
222 |
|
} |