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