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 java.io.IOException; |
24 |
|
|
25 |
|
|
26 |
|
|
27 |
|
|
28 |
|
|
29 |
|
|
30 |
|
|
31 |
|
|
32 |
|
|
33 |
|
|
34 |
|
|
35 |
|
|
36 |
|
@author |
37 |
|
@see |
38 |
|
|
|
|
| 87.3% |
Uncovered Elements: 10 (79) |
Complexity: 22 |
Complexity Density: 0.51 |
|
39 |
|
public class GenBankFile extends EMBLLikeFlatFile |
40 |
|
{ |
41 |
|
private static final String DEFINITION = "DEFINITION"; |
42 |
|
|
43 |
|
|
44 |
|
|
45 |
|
|
46 |
|
@param |
47 |
|
@param |
48 |
|
@throws |
49 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
50 |
1 |
public GenBankFile(FileParse fp, String sourceId) throws IOException... |
51 |
|
{ |
52 |
1 |
super(fp, sourceId); |
53 |
|
} |
54 |
|
|
55 |
|
|
56 |
|
|
57 |
|
|
58 |
|
|
59 |
|
@throws |
60 |
|
@see |
61 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (35) |
Complexity: 9 |
Complexity Density: 0.47 |
|
62 |
1 |
@Override... |
63 |
|
public void parse() throws IOException |
64 |
|
{ |
65 |
1 |
String line = nextLine(); |
66 |
28 |
while (line != null) |
67 |
|
{ |
68 |
27 |
if (line.startsWith("LOCUS")) |
69 |
|
{ |
70 |
1 |
line = parseLocus(line); |
71 |
|
} |
72 |
26 |
else if (line.startsWith(DEFINITION)) |
73 |
|
{ |
74 |
1 |
line = parseDefinition(line); |
75 |
|
} |
76 |
25 |
else if (line.startsWith("ACCESSION")) |
77 |
|
{ |
78 |
1 |
this.accession = line.split(WHITESPACE)[1]; |
79 |
1 |
line = nextLine(); |
80 |
|
} |
81 |
24 |
else if (line.startsWith("VERSION")) |
82 |
|
{ |
83 |
1 |
line = parseVersion(line); |
84 |
|
} |
85 |
23 |
else if (line.startsWith("ORIGIN")) |
86 |
|
{ |
87 |
1 |
line = parseSequence(); |
88 |
|
} |
89 |
22 |
else if (line.startsWith("FEATURES")) |
90 |
|
{ |
91 |
1 |
line = nextLine(); |
92 |
19 |
while (line.startsWith(" ")) |
93 |
|
{ |
94 |
18 |
line = parseFeature(line); |
95 |
|
} |
96 |
|
} |
97 |
|
else |
98 |
|
{ |
99 |
21 |
line = nextLine(); |
100 |
|
} |
101 |
|
} |
102 |
1 |
buildSequence(); |
103 |
|
} |
104 |
|
|
105 |
|
|
106 |
|
|
107 |
|
|
108 |
|
|
109 |
|
@param |
110 |
|
@throws |
111 |
|
|
|
|
| 72.7% |
Uncovered Elements: 3 (11) |
Complexity: 4 |
Complexity Density: 0.57 |
|
112 |
1 |
String parseLocus(String line) throws IOException... |
113 |
|
{ |
114 |
1 |
String[] tokens = line.split(WHITESPACE); |
115 |
|
|
116 |
|
|
117 |
|
|
118 |
|
|
119 |
1 |
if (tokens.length < 2 || !"LOCUS".equals(tokens[0])) |
120 |
|
{ |
121 |
0 |
return nextLine(); |
122 |
|
} |
123 |
|
|
124 |
|
|
125 |
|
|
126 |
1 |
String token = tokens[1].trim(); |
127 |
1 |
if (!token.isEmpty()) |
128 |
|
{ |
129 |
1 |
this.accession = token; |
130 |
|
} |
131 |
|
|
132 |
|
|
133 |
|
|
134 |
1 |
return nextLine(); |
135 |
|
} |
136 |
|
|
137 |
|
|
138 |
|
|
139 |
|
|
140 |
|
|
141 |
|
@param |
142 |
|
@return |
143 |
|
@throws |
144 |
|
|
|
|
| 66.7% |
Uncovered Elements: 5 (15) |
Complexity: 4 |
Complexity Density: 0.44 |
|
145 |
1 |
String parseDefinition(String line) throws IOException... |
146 |
|
{ |
147 |
1 |
String desc = line.substring(DEFINITION.length()).trim(); |
148 |
1 |
if (desc.endsWith(".")) |
149 |
|
{ |
150 |
1 |
desc = desc.substring(0, desc.length() - 1); |
151 |
|
} |
152 |
|
|
153 |
|
|
154 |
|
|
155 |
|
|
156 |
? |
while ((line = nextLine()) != null) |
157 |
|
{ |
158 |
1 |
if (line.startsWith(" ")) |
159 |
|
{ |
160 |
|
|
161 |
0 |
desc += line.trim(); |
162 |
|
} |
163 |
|
else |
164 |
|
{ |
165 |
1 |
break; |
166 |
|
} |
167 |
|
} |
168 |
1 |
this.description = desc; |
169 |
|
|
170 |
1 |
return line; |
171 |
|
} |
172 |
|
|
173 |
|
|
174 |
|
|
175 |
|
|
176 |
|
|
177 |
|
|
178 |
|
|
179 |
|
|
180 |
|
|
181 |
|
|
182 |
|
@param |
183 |
|
@throws |
184 |
|
|
|
|
| 80% |
Uncovered Elements: 2 (10) |
Complexity: 3 |
Complexity Density: 0.5 |
|
185 |
1 |
String parseVersion(String line) throws IOException... |
186 |
|
{ |
187 |
|
|
188 |
|
|
189 |
|
|
190 |
|
|
191 |
1 |
String[] tokens = line.split(WHITESPACE); |
192 |
1 |
if (tokens.length > 1) |
193 |
|
{ |
194 |
1 |
tokens = tokens[1].split("\\."); |
195 |
1 |
if (tokens.length > 1) |
196 |
|
{ |
197 |
1 |
this.version = tokens[1]; |
198 |
|
} |
199 |
|
} |
200 |
|
|
201 |
1 |
return nextLine(); |
202 |
|
} |
203 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
204 |
152 |
@Override... |
205 |
|
protected boolean isFeatureContinuationLine(String line) |
206 |
|
{ |
207 |
152 |
return line.startsWith(" "); |
208 |
|
} |
209 |
|
} |