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 jalview.datamodel.Sequence; |
24 |
|
import jalview.datamodel.SequenceI; |
25 |
|
|
26 |
|
import java.io.IOException; |
27 |
|
import java.util.Vector; |
28 |
|
|
29 |
|
|
30 |
|
|
31 |
|
|
32 |
|
@author |
33 |
|
@version |
34 |
|
|
|
|
| 75.6% |
Uncovered Elements: 32 (131) |
Complexity: 34 |
Complexity Density: 0.42 |
|
35 |
|
public class BLCFile extends AlignFile |
36 |
|
{ |
37 |
|
Vector titles; |
38 |
|
|
39 |
|
|
40 |
|
|
41 |
|
|
|
|
| - |
Uncovered Elements: 0 (0) |
Complexity: 1 |
Complexity Density: - |
|
42 |
6 |
public BLCFile()... |
43 |
|
{ |
44 |
|
} |
45 |
|
|
46 |
|
|
47 |
|
|
48 |
|
|
49 |
|
@param |
50 |
|
|
51 |
|
@param |
52 |
|
|
53 |
|
|
54 |
|
@throws |
55 |
|
|
56 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
57 |
0 |
public BLCFile(String inFile, DataSourceType sourceType)... |
58 |
|
throws IOException |
59 |
|
{ |
60 |
0 |
super(inFile, sourceType); |
61 |
|
} |
62 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
63 |
1 |
public BLCFile(FileParse source) throws IOException... |
64 |
|
{ |
65 |
1 |
super(source); |
66 |
|
} |
67 |
|
|
68 |
|
|
69 |
|
|
70 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
|
71 |
7 |
@Override... |
72 |
|
public void initData() |
73 |
|
{ |
74 |
7 |
super.initData(); |
75 |
7 |
titles = new Vector(); |
76 |
|
} |
77 |
|
|
78 |
|
|
79 |
|
|
80 |
|
|
81 |
|
|
82 |
|
|
83 |
|
|
84 |
|
int iterationSkips = 0; |
85 |
|
|
86 |
|
|
87 |
|
|
88 |
|
|
89 |
|
int iterationCount = 0; |
90 |
|
|
91 |
|
|
92 |
|
|
93 |
|
|
|
|
| 69.3% |
Uncovered Elements: 27 (88) |
Complexity: 22 |
Complexity Density: 0.41 |
|
94 |
1 |
@Override... |
95 |
|
public void parse() throws IOException |
96 |
|
{ |
97 |
1 |
StringBuffer headerLines = new StringBuffer(); |
98 |
1 |
int numHeaderLines = 0; |
99 |
1 |
StringBuffer[] seqstrings = null; |
100 |
1 |
if (suffix != null) |
101 |
|
{ |
102 |
0 |
try |
103 |
|
{ |
104 |
0 |
iterationSkips = Integer.parseInt(suffix); |
105 |
|
} catch (NumberFormatException e) |
106 |
|
{ |
107 |
0 |
iterationSkips = 0; |
108 |
|
} |
109 |
|
} |
110 |
|
|
111 |
1 |
String line = null; |
112 |
|
|
113 |
1 |
do |
114 |
|
{ |
115 |
1 |
boolean idsFound = false; |
116 |
1 |
boolean newids = false; |
117 |
|
|
118 |
1 |
do |
119 |
|
{ |
120 |
16 |
line = nextLine(); |
121 |
16 |
if (line == null) |
122 |
|
{ |
123 |
0 |
break; |
124 |
|
} |
125 |
|
|
126 |
16 |
if (line.indexOf("*") > -1) |
127 |
|
{ |
128 |
1 |
idsFound = true; |
129 |
|
|
130 |
1 |
break; |
131 |
|
} |
132 |
|
|
133 |
15 |
int abracket = line.indexOf(">"); |
134 |
|
|
135 |
15 |
if (abracket > -1) |
136 |
|
{ |
137 |
|
|
138 |
15 |
if (iterationCount > 0 && !newids) |
139 |
|
{ |
140 |
|
|
141 |
0 |
newids = true; |
142 |
0 |
seqs.removeAllElements(); |
143 |
|
} |
144 |
|
|
145 |
15 |
line = line.substring(abracket + 1); |
146 |
|
|
147 |
15 |
Sequence seq = parseId(line); |
148 |
15 |
seqs.addElement(seq); |
149 |
|
} |
150 |
|
else |
151 |
|
{ |
152 |
|
|
153 |
0 |
headerLines.append(line); |
154 |
0 |
headerLines.append(newline); |
155 |
0 |
numHeaderLines++; |
156 |
|
} |
157 |
15 |
} while (!idsFound); |
158 |
1 |
if (line == null) |
159 |
|
{ |
160 |
0 |
break; |
161 |
|
} |
162 |
1 |
int starCol = line.indexOf("*"); |
163 |
1 |
seqstrings = new StringBuffer[seqs.size()]; |
164 |
|
|
165 |
16 |
for (int i = 0; i < seqs.size(); i++) |
166 |
|
{ |
167 |
15 |
if (seqstrings[i] == null) |
168 |
|
{ |
169 |
15 |
seqstrings[i] = new StringBuffer(); |
170 |
|
} |
171 |
|
} |
172 |
|
|
173 |
1 |
try |
174 |
|
{ |
175 |
1 |
line = nextLine(); |
176 |
158 |
while (line != null && line.indexOf("*") == -1) |
177 |
|
{ |
178 |
2512 |
for (int i = 0; i < seqs.size(); i++) |
179 |
|
{ |
180 |
2355 |
if (line.length() > (i + starCol)) |
181 |
|
{ |
182 |
2355 |
seqstrings[i].append(line.charAt(i + starCol)); |
183 |
|
} |
184 |
|
} |
185 |
157 |
line = nextLine(); |
186 |
|
} |
187 |
|
} catch (IOException e) |
188 |
|
{ |
189 |
0 |
if (iterationCount == 0) |
190 |
|
{ |
191 |
0 |
throw (e); |
192 |
|
} |
193 |
|
else |
194 |
|
{ |
195 |
0 |
iterationSkips = 0; |
196 |
|
} |
197 |
|
} |
198 |
1 |
iterationCount++; |
199 |
1 |
} while (--iterationSkips != -1); |
200 |
|
|
201 |
16 |
for (int i = 0; i < seqs.size(); i++) |
202 |
|
{ |
203 |
15 |
Sequence newSeq = (Sequence) seqs.elementAt(i); |
204 |
|
|
205 |
15 |
newSeq.setSequence(seqstrings[i].toString()); |
206 |
|
} |
207 |
1 |
if (seqs.size() > 0) |
208 |
|
{ |
209 |
1 |
if (headerLines.length() > 1 + numHeaderLines) |
210 |
|
{ |
211 |
|
|
212 |
0 |
setAlignmentProperty("Comments", headerLines.toString()); |
213 |
|
} |
214 |
1 |
setAlignmentProperty("iteration", "" + iterationCount); |
215 |
|
} |
216 |
|
} |
217 |
|
|
218 |
|
|
219 |
|
|
220 |
|
|
221 |
|
@param |
222 |
|
|
223 |
|
|
224 |
|
@return |
225 |
|
|
|
|
| 90.9% |
Uncovered Elements: 3 (33) |
Complexity: 8 |
Complexity Density: 0.35 |
|
226 |
6 |
@Override... |
227 |
|
public String print(SequenceI[] s, boolean jvsuffix) |
228 |
|
{ |
229 |
6 |
StringBuffer out = new StringBuffer(); |
230 |
|
|
231 |
|
|
232 |
|
|
233 |
|
|
234 |
|
|
235 |
|
|
236 |
6 |
int i = 0; |
237 |
6 |
int max = -1; |
238 |
|
|
239 |
96 |
while ((i < s.length) && (s[i] != null)) |
240 |
|
{ |
241 |
90 |
out.append(">" + printId(s[i], jvsuffix)); |
242 |
90 |
if (s[i].getDescription() != null) |
243 |
|
{ |
244 |
90 |
out.append(" " + s[i].getDescription()); |
245 |
|
} |
246 |
|
|
247 |
90 |
out.append(newline); |
248 |
|
|
249 |
90 |
max = Math.max(max, s[i].getLength()); |
250 |
|
|
251 |
90 |
i++; |
252 |
|
} |
253 |
|
|
254 |
6 |
out.append("* iteration 1"); |
255 |
6 |
out.append(newline); |
256 |
|
|
257 |
948 |
for (int j = 0; j < max; j++) |
258 |
|
{ |
259 |
942 |
i = 0; |
260 |
|
|
261 |
15072 |
while ((i < s.length) && (s[i] != null)) |
262 |
|
{ |
263 |
14130 |
if (s[i].getSequence().length > j) |
264 |
|
{ |
265 |
14130 |
out.append(s[i].getSequenceAsString(j, j + 1)); |
266 |
|
} |
267 |
|
else |
268 |
|
{ |
269 |
0 |
out.append("-"); |
270 |
|
} |
271 |
|
|
272 |
14130 |
i++; |
273 |
|
} |
274 |
|
|
275 |
942 |
out.append(newline); |
276 |
|
} |
277 |
|
|
278 |
6 |
out.append("*"); |
279 |
6 |
out.append(newline); |
280 |
|
|
281 |
6 |
return out.toString(); |
282 |
|
} |
283 |
|
} |