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