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 |
|
import java.text.ParseException; |
25 |
|
import java.util.ArrayList; |
26 |
|
import java.util.Arrays; |
27 |
|
import java.util.HashMap; |
28 |
|
import java.util.Hashtable; |
29 |
|
import java.util.List; |
30 |
|
import java.util.Locale; |
31 |
|
import java.util.Map; |
32 |
|
import java.util.Map.Entry; |
33 |
|
import java.util.TreeMap; |
34 |
|
|
35 |
|
import jalview.bin.Console; |
36 |
|
import jalview.datamodel.DBRefEntry; |
37 |
|
import jalview.datamodel.DBRefSource; |
38 |
|
import jalview.datamodel.FeatureProperties; |
39 |
|
import jalview.datamodel.Mapping; |
40 |
|
import jalview.datamodel.Sequence; |
41 |
|
import jalview.datamodel.SequenceFeature; |
42 |
|
import jalview.datamodel.SequenceI; |
43 |
|
import jalview.util.DBRefUtils; |
44 |
|
import jalview.util.DnaUtils; |
45 |
|
import jalview.util.MapList; |
46 |
|
import jalview.util.MappingUtils; |
47 |
|
|
48 |
|
|
49 |
|
|
50 |
|
|
51 |
|
|
52 |
|
|
53 |
|
|
54 |
|
|
55 |
|
|
56 |
|
|
57 |
|
|
58 |
|
|
59 |
|
|
60 |
|
|
61 |
|
|
62 |
|
|
63 |
|
|
64 |
|
|
65 |
|
|
66 |
|
|
67 |
|
|
|
|
| 0% |
Uncovered Elements: 359 (359) |
Complexity: 81 |
Complexity Density: 0.34 |
|
68 |
|
public abstract class EMBLLikeFlatFile extends AlignFile |
69 |
|
{ |
70 |
|
protected static final String LOCATION = "location"; |
71 |
|
|
72 |
|
protected static final String QUOTE = "\""; |
73 |
|
|
74 |
|
protected static final String DOUBLED_QUOTE = QUOTE + QUOTE; |
75 |
|
|
76 |
|
protected static final String WHITESPACE = "\\s+"; |
77 |
|
|
78 |
|
|
79 |
|
|
80 |
|
|
81 |
|
|
82 |
|
|
83 |
|
@param |
84 |
|
@return |
85 |
|
|
|
|
| 0% |
Uncovered Elements: 14 (14) |
Complexity: 6 |
Complexity Density: 0.75 |
|
86 |
0 |
protected static String removeQuotes(String value)... |
87 |
|
{ |
88 |
0 |
if (value == null) |
89 |
|
{ |
90 |
0 |
return null; |
91 |
|
} |
92 |
0 |
if (value.startsWith(QUOTE) && !value.startsWith(DOUBLED_QUOTE)) |
93 |
|
{ |
94 |
0 |
value = value.substring(1); |
95 |
|
} |
96 |
0 |
if (value.endsWith(QUOTE) && !value.endsWith(DOUBLED_QUOTE)) |
97 |
|
{ |
98 |
0 |
value = value.substring(0, value.length() - 1); |
99 |
|
} |
100 |
0 |
value = value.replace(DOUBLED_QUOTE, QUOTE); |
101 |
0 |
return value; |
102 |
|
} |
103 |
|
|
104 |
|
|
105 |
|
|
106 |
|
|
107 |
|
|
108 |
|
@param |
109 |
|
@param |
110 |
|
|
111 |
|
@return |
112 |
|
|
|
|
| 0% |
Uncovered Elements: 41 (41) |
Complexity: 9 |
Complexity Density: 0.33 |
|
113 |
0 |
protected static int[] adjustForProteinLength(int proteinLength,... |
114 |
|
int[] exon) |
115 |
|
{ |
116 |
0 |
if (proteinLength <= 0 || exon == null) |
117 |
|
{ |
118 |
0 |
return exon; |
119 |
|
} |
120 |
0 |
int expectedCdsLength = proteinLength * 3; |
121 |
0 |
int exonLength = MappingUtils.getLength(Arrays.asList(exon)); |
122 |
|
|
123 |
|
|
124 |
|
|
125 |
|
|
126 |
0 |
if (expectedCdsLength >= exonLength) |
127 |
|
{ |
128 |
0 |
return exon; |
129 |
|
} |
130 |
|
|
131 |
0 |
int origxon[]; |
132 |
0 |
int sxpos = -1; |
133 |
0 |
int endxon = 0; |
134 |
0 |
origxon = new int[exon.length]; |
135 |
0 |
System.arraycopy(exon, 0, origxon, 0, exon.length); |
136 |
0 |
int cdspos = 0; |
137 |
0 |
for (int x = 0; x < exon.length; x += 2) |
138 |
|
{ |
139 |
0 |
cdspos += Math.abs(exon[x + 1] - exon[x]) + 1; |
140 |
0 |
if (expectedCdsLength <= cdspos) |
141 |
|
{ |
142 |
|
|
143 |
0 |
sxpos = x; |
144 |
0 |
if (expectedCdsLength != cdspos) |
145 |
|
{ |
146 |
|
|
147 |
|
|
148 |
|
|
149 |
|
} |
150 |
|
|
151 |
|
|
152 |
|
|
153 |
|
|
154 |
|
|
155 |
0 |
if (exon[x + 1] >= exon[x]) |
156 |
|
{ |
157 |
0 |
endxon = exon[x + 1] - cdspos + expectedCdsLength; |
158 |
|
} |
159 |
|
else |
160 |
|
{ |
161 |
0 |
endxon = exon[x + 1] + cdspos - expectedCdsLength; |
162 |
|
} |
163 |
0 |
break; |
164 |
|
} |
165 |
|
} |
166 |
|
|
167 |
0 |
if (sxpos != -1) |
168 |
|
{ |
169 |
|
|
170 |
0 |
int[] nxon = new int[sxpos + 2]; |
171 |
0 |
System.arraycopy(exon, 0, nxon, 0, sxpos + 2); |
172 |
0 |
nxon[sxpos + 1] = endxon; |
173 |
|
|
174 |
0 |
exon = nxon; |
175 |
|
} |
176 |
0 |
return exon; |
177 |
|
} |
178 |
|
|
179 |
|
|
180 |
|
|
181 |
|
|
182 |
|
|
183 |
|
protected boolean produceRna = true; |
184 |
|
|
185 |
|
|
186 |
|
|
187 |
|
|
188 |
|
protected String sourceDb; |
189 |
|
|
190 |
|
protected String accession; |
191 |
|
|
192 |
|
protected String version; |
193 |
|
|
194 |
|
protected String description; |
195 |
|
|
196 |
|
protected int length = 128; |
197 |
|
|
198 |
|
protected List<DBRefEntry> dbrefs; |
199 |
|
|
200 |
|
protected boolean sequenceStringIsRNA = false; |
201 |
|
|
202 |
|
protected String sequenceString; |
203 |
|
|
204 |
|
protected Map<String, CdsData> cds; |
205 |
|
|
206 |
|
|
207 |
|
|
208 |
|
|
209 |
|
@param |
210 |
|
@param |
211 |
|
@throws |
212 |
|
|
|
|
| 0% |
Uncovered Elements: 5 (5) |
Complexity: 1 |
Complexity Density: 0.2 |
|
213 |
0 |
public EMBLLikeFlatFile(FileParse fp, String sourceId) throws IOException... |
214 |
|
{ |
215 |
0 |
super(false, fp); |
216 |
0 |
this.sourceDb = sourceId; |
217 |
0 |
dbrefs = new ArrayList<>(); |
218 |
|
|
219 |
|
|
220 |
|
|
221 |
|
|
222 |
0 |
cds = new TreeMap<>(String.CASE_INSENSITIVE_ORDER); |
223 |
|
|
224 |
0 |
parse(); |
225 |
|
} |
226 |
|
|
227 |
|
|
228 |
|
|
229 |
|
|
230 |
|
|
231 |
|
@param |
232 |
|
@return |
233 |
|
@throws |
234 |
|
|
|
|
| 0% |
Uncovered Elements: 27 (27) |
Complexity: 6 |
Complexity Density: 0.35 |
|
235 |
0 |
private String parseSourceQualifiers(String[] tokens) throws IOException... |
236 |
|
{ |
237 |
0 |
if (!"source".equals(tokens[0])) |
238 |
|
{ |
239 |
0 |
throw (new RuntimeException("Not given a 'source' qualifier line")); |
240 |
|
} |
241 |
|
|
242 |
|
|
243 |
0 |
StringBuilder sb = new StringBuilder().append(tokens[1]); |
244 |
|
|
245 |
|
|
246 |
0 |
String line = parseFeatureQualifier(sb, false); |
247 |
0 |
while (line != null) |
248 |
|
{ |
249 |
0 |
if (!line.startsWith("FT ")) |
250 |
|
|
251 |
|
{ |
252 |
0 |
return line; |
253 |
|
} |
254 |
|
|
255 |
|
|
256 |
0 |
int p = line.indexOf("\\mol_type"); |
257 |
0 |
int qs = line.indexOf("\"", p); |
258 |
0 |
int qe = line.indexOf("\"", qs + 1); |
259 |
0 |
String qualifier = line.substring(qs, qe).toLowerCase(Locale.ROOT); |
260 |
0 |
if (qualifier.indexOf("rna") > -1) |
261 |
|
{ |
262 |
0 |
sequenceStringIsRNA = true; |
263 |
|
} |
264 |
0 |
if (qualifier.indexOf("dna") > -1) |
265 |
|
{ |
266 |
0 |
sequenceStringIsRNA = false; |
267 |
|
} |
268 |
0 |
line = parseFeatureQualifier(sb, false); |
269 |
|
} |
270 |
0 |
return line; |
271 |
|
} |
272 |
|
|
273 |
|
|
274 |
|
|
275 |
|
|
276 |
|
|
277 |
|
@param |
278 |
|
@return |
279 |
|
@throws |
280 |
|
|
|
|
| 0% |
Uncovered Elements: 71 (71) |
Complexity: 14 |
Complexity Density: 0.3 |
|
281 |
0 |
protected String parseCDSFeature(String location) throws IOException... |
282 |
|
{ |
283 |
0 |
String line; |
284 |
|
|
285 |
|
|
286 |
|
|
287 |
|
|
288 |
0 |
CdsData data = new CdsData(); |
289 |
0 |
StringBuilder sb = new StringBuilder().append(location); |
290 |
0 |
line = parseFeatureQualifier(sb, false); |
291 |
0 |
data.cdsLocation = sb.toString(); |
292 |
|
|
293 |
0 |
while (line != null) |
294 |
|
{ |
295 |
0 |
if (!isFeatureContinuationLine(line)) |
296 |
|
{ |
297 |
|
|
298 |
0 |
break; |
299 |
|
} |
300 |
|
|
301 |
|
|
302 |
|
|
303 |
|
|
304 |
|
|
305 |
|
|
306 |
|
|
307 |
0 |
int slashPos = line.indexOf('/'); |
308 |
0 |
if (slashPos == -1) |
309 |
|
{ |
310 |
0 |
Console.error("Unexpected EMBL line ignored: " + line); |
311 |
0 |
line = nextLine(); |
312 |
0 |
continue; |
313 |
|
} |
314 |
0 |
int eqPos = line.indexOf('=', slashPos + 1); |
315 |
0 |
if (eqPos == -1) |
316 |
|
{ |
317 |
|
|
318 |
0 |
line = nextLine(); |
319 |
0 |
continue; |
320 |
|
} |
321 |
0 |
String qualifier = line.substring(slashPos + 1, eqPos); |
322 |
0 |
String value = line.substring(eqPos + 1); |
323 |
0 |
value = removeQuotes(value); |
324 |
0 |
sb = new StringBuilder().append(value); |
325 |
0 |
boolean asText = !"translation".equals(qualifier); |
326 |
0 |
line = parseFeatureQualifier(sb, asText); |
327 |
0 |
String featureValue = sb.toString(); |
328 |
|
|
329 |
0 |
if ("protein_id".equals(qualifier)) |
330 |
|
{ |
331 |
0 |
data.proteinId = featureValue; |
332 |
|
} |
333 |
0 |
else if ("codon_start".equals(qualifier)) |
334 |
|
{ |
335 |
0 |
try |
336 |
|
{ |
337 |
0 |
data.codonStart = Integer.parseInt(featureValue.trim()); |
338 |
|
} catch (NumberFormatException e) |
339 |
|
{ |
340 |
0 |
Console.error("Invalid codon_start in XML for " + this.accession |
341 |
|
+ ": " + e.getMessage()); |
342 |
|
} |
343 |
|
} |
344 |
0 |
else if ("db_xref".equals(qualifier)) |
345 |
|
{ |
346 |
0 |
String[] parts = featureValue.split(":"); |
347 |
0 |
if (parts.length == 2) |
348 |
|
{ |
349 |
0 |
String db = parts[0].trim(); |
350 |
0 |
db = DBRefUtils.getCanonicalName(db); |
351 |
0 |
DBRefEntry dbref = new DBRefEntry(db, "0", parts[1].trim()); |
352 |
0 |
data.xrefs.add(dbref); |
353 |
|
} |
354 |
|
} |
355 |
0 |
else if ("product".equals(qualifier)) |
356 |
|
{ |
357 |
0 |
data.proteinName = featureValue; |
358 |
|
} |
359 |
0 |
else if ("translation".equals(qualifier)) |
360 |
|
{ |
361 |
0 |
data.translation = featureValue; |
362 |
|
} |
363 |
0 |
else if (!"".equals(featureValue)) |
364 |
|
{ |
365 |
|
|
366 |
0 |
data.cdsProps.put(qualifier, featureValue); |
367 |
|
} |
368 |
|
} |
369 |
|
|
370 |
0 |
if (data.proteinId != null) |
371 |
|
{ |
372 |
0 |
this.cds.put(data.proteinId, data); |
373 |
|
} |
374 |
|
else |
375 |
|
{ |
376 |
0 |
Console.error("Ignoring CDS feature with no protein_id for " |
377 |
|
+ sourceDb + ":" + accession); |
378 |
|
} |
379 |
|
|
380 |
0 |
return line; |
381 |
|
} |
382 |
|
|
383 |
|
protected abstract boolean isFeatureContinuationLine(String line); |
384 |
|
|
385 |
|
|
386 |
|
|
387 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
388 |
0 |
@Override... |
389 |
|
public String print(SequenceI[] seqs, boolean jvsuffix) |
390 |
|
{ |
391 |
0 |
return null; |
392 |
|
} |
393 |
|
|
394 |
|
|
395 |
|
|
396 |
|
|
|
|
| 0% |
Uncovered Elements: 25 (25) |
Complexity: 6 |
Complexity Density: 0.32 |
|
397 |
0 |
protected void buildSequence()... |
398 |
|
{ |
399 |
0 |
if (this.accession == null || this.sequenceString == null) |
400 |
|
{ |
401 |
0 |
Console.error("Failed to parse data from EMBL"); |
402 |
0 |
return; |
403 |
|
} |
404 |
|
|
405 |
0 |
String name = this.accession; |
406 |
0 |
if (this.sourceDb != null) |
407 |
|
{ |
408 |
0 |
name = this.sourceDb + "|" + name; |
409 |
|
} |
410 |
|
|
411 |
0 |
if (produceRna && sequenceStringIsRNA) |
412 |
|
{ |
413 |
0 |
sequenceString = sequenceString.replace('T', 'U').replace('t', 'u'); |
414 |
|
} |
415 |
|
|
416 |
0 |
SequenceI seq = new Sequence(name, this.sequenceString); |
417 |
0 |
seq.setDescription(this.description); |
418 |
|
|
419 |
|
|
420 |
|
|
421 |
|
|
422 |
0 |
DBRefEntry selfRef = new DBRefEntry(sourceDb, version, accession); |
423 |
0 |
int[] startEnd = new int[] { 1, seq.getLength() }; |
424 |
0 |
selfRef.setMap(new Mapping(null, startEnd, startEnd, 1, 1)); |
425 |
0 |
seq.addDBRef(selfRef); |
426 |
|
|
427 |
0 |
for (DBRefEntry dbref : this.dbrefs) |
428 |
|
{ |
429 |
0 |
seq.addDBRef(dbref); |
430 |
|
} |
431 |
|
|
432 |
0 |
processCDSFeatures(seq); |
433 |
|
|
434 |
0 |
seq.deriveSequence(); |
435 |
|
|
436 |
0 |
addSequence(seq); |
437 |
|
} |
438 |
|
|
439 |
|
|
440 |
|
|
441 |
|
|
442 |
|
|
443 |
|
@param |
444 |
|
|
|
|
| 0% |
Uncovered Elements: 3 (3) |
Complexity: 1 |
Complexity Density: 0.33 |
|
445 |
0 |
protected void processCDSFeatures(SequenceI seq)... |
446 |
|
{ |
447 |
|
|
448 |
|
|
449 |
|
|
450 |
|
|
451 |
0 |
Map<String, SequenceI> proteins = new HashMap<>(); |
452 |
0 |
for (CdsData data : cds.values()) |
453 |
|
{ |
454 |
0 |
processCDSFeature(seq, data, proteins); |
455 |
|
} |
456 |
|
} |
457 |
|
|
458 |
|
|
459 |
|
|
460 |
|
|
461 |
|
|
462 |
|
|
463 |
|
|
464 |
|
|
465 |
|
|
466 |
|
|
467 |
|
@param |
468 |
|
|
469 |
|
@param |
470 |
|
|
471 |
|
|
|
|
| 0% |
Uncovered Elements: 55 (55) |
Complexity: 7 |
Complexity Density: 0.16 |
|
472 |
0 |
void processCDSFeature(SequenceI dna, CdsData data,... |
473 |
|
Map<String, SequenceI> proteins) |
474 |
|
{ |
475 |
|
|
476 |
|
|
477 |
|
|
478 |
0 |
int[] exons = getCdsRanges(this.accession, data.cdsLocation); |
479 |
|
|
480 |
0 |
MapList maplist = buildMappingToProtein(dna, exons, data); |
481 |
|
|
482 |
0 |
int exonNumber = 0; |
483 |
|
|
484 |
0 |
for (int xint = 0; exons != null && xint < exons.length - 1; xint += 2) |
485 |
|
{ |
486 |
0 |
int exonStart = exons[xint]; |
487 |
0 |
int exonEnd = exons[xint + 1]; |
488 |
0 |
int begin = Math.min(exonStart, exonEnd); |
489 |
0 |
int end = Math.max(exonStart, exonEnd); |
490 |
0 |
exonNumber++; |
491 |
0 |
String desc = String.format("Exon %d for protein EMBLCDS:%s", |
492 |
|
exonNumber, data.proteinId); |
493 |
|
|
494 |
0 |
SequenceFeature sf = new SequenceFeature("CDS", desc, begin, end, |
495 |
|
this.sourceDb); |
496 |
0 |
for (Entry<String, String> val : data.cdsProps.entrySet()) |
497 |
|
{ |
498 |
0 |
sf.setValue(val.getKey(), val.getValue()); |
499 |
|
} |
500 |
|
|
501 |
0 |
sf.setEnaLocation(data.cdsLocation); |
502 |
0 |
boolean forwardStrand = exonStart <= exonEnd; |
503 |
0 |
sf.setStrand(forwardStrand ? "+" : "-"); |
504 |
0 |
sf.setPhase(String.valueOf(data.codonStart - 1)); |
505 |
0 |
sf.setValue(FeatureProperties.EXONPOS, exonNumber); |
506 |
0 |
sf.setValue(FeatureProperties.EXONPRODUCT, data.proteinName); |
507 |
|
|
508 |
0 |
dna.addSequenceFeature(sf); |
509 |
|
} |
510 |
|
|
511 |
0 |
boolean hasUniprotDbref = false; |
512 |
0 |
for (DBRefEntry xref : data.xrefs) |
513 |
|
{ |
514 |
0 |
dna.addDBRef(xref); |
515 |
0 |
if (xref.getSource().equals(DBRefSource.UNIPROT)) |
516 |
|
{ |
517 |
|
|
518 |
|
|
519 |
|
|
520 |
0 |
SequenceI protein = buildProteinProduct(dna, xref, data, proteins); |
521 |
0 |
Mapping map = new Mapping(protein, maplist); |
522 |
0 |
map.setMappedFromId(data.proteinId); |
523 |
0 |
xref.setMap(map); |
524 |
|
|
525 |
|
|
526 |
|
|
527 |
|
|
528 |
0 |
DBRefEntry db1 = new DBRefEntry(sourceDb, version, accession); |
529 |
0 |
db1.setMap(new Mapping(dna, maplist.getInverse())); |
530 |
0 |
protein.addDBRef(db1); |
531 |
|
|
532 |
0 |
hasUniprotDbref = true; |
533 |
|
} |
534 |
|
} |
535 |
|
|
536 |
|
|
537 |
|
|
538 |
|
|
539 |
|
|
540 |
|
|
541 |
0 |
if (!hasUniprotDbref) |
542 |
|
{ |
543 |
0 |
SequenceI protein = proteins.get(data.proteinId); |
544 |
0 |
if (protein == null) |
545 |
|
{ |
546 |
0 |
protein = new Sequence(data.proteinId, data.translation); |
547 |
0 |
protein.setDescription(data.proteinName); |
548 |
0 |
proteins.put(data.proteinId, protein); |
549 |
|
} |
550 |
|
|
551 |
0 |
DBRefEntry db1 = new DBRefEntry(DBRefSource.EMBLCDSProduct, |
552 |
|
this.version, data.proteinId); |
553 |
0 |
protein.addDBRef(db1); |
554 |
|
|
555 |
0 |
DBRefEntry dnaToEmblProteinRef = new DBRefEntry( |
556 |
|
DBRefSource.EMBLCDSProduct, this.version, data.proteinId); |
557 |
0 |
Mapping map = new Mapping(protein, maplist); |
558 |
0 |
map.setMappedFromId(data.proteinId); |
559 |
0 |
dnaToEmblProteinRef.setMap(map); |
560 |
0 |
dna.addDBRef(dnaToEmblProteinRef); |
561 |
|
} |
562 |
|
|
563 |
|
|
564 |
|
|
565 |
|
|
566 |
|
|
567 |
|
|
568 |
|
|
569 |
|
|
570 |
|
} |
571 |
|
|
572 |
|
|
573 |
|
|
574 |
|
|
575 |
|
|
576 |
|
@param |
577 |
|
@param |
578 |
|
@param |
579 |
|
@return |
580 |
|
|
|
|
| 0% |
Uncovered Elements: 27 (27) |
Complexity: 6 |
Complexity Density: 0.32 |
|
581 |
0 |
MapList buildMappingToProtein(final SequenceI dna, final int[] exons,... |
582 |
|
final CdsData data) |
583 |
|
{ |
584 |
0 |
MapList dnaToProteinMapping = null; |
585 |
0 |
int peptideLength = data.translation.length(); |
586 |
|
|
587 |
0 |
int[] proteinRange = new int[] { 1, peptideLength }; |
588 |
0 |
if (exons != null && exons.length > 0) |
589 |
|
{ |
590 |
|
|
591 |
|
|
592 |
|
|
593 |
|
|
594 |
0 |
int[] cdsRanges = adjustForProteinLength(peptideLength, exons); |
595 |
0 |
dnaToProteinMapping = new MapList(cdsRanges, proteinRange, 3, 1); |
596 |
|
} |
597 |
|
else |
598 |
|
{ |
599 |
|
|
600 |
|
|
601 |
|
|
602 |
|
|
603 |
0 |
Console.error(String.format( |
604 |
|
"Implementation Notice: EMBLCDS location '%s'not properly supported yet" |
605 |
|
+ " - Making up the CDNA region of (%s:%s)... may be incorrect", |
606 |
|
data.cdsLocation, sourceDb, this.accession)); |
607 |
|
|
608 |
0 |
int completeCodonsLength = 1 - data.codonStart + dna.getLength(); |
609 |
0 |
int mappedDnaEnd = dna.getEnd(); |
610 |
0 |
if (peptideLength * 3 == completeCodonsLength) |
611 |
|
{ |
612 |
|
|
613 |
0 |
Console.warn("Assuming no stop codon at end of cDNA fragment"); |
614 |
0 |
mappedDnaEnd = dna.getEnd(); |
615 |
|
} |
616 |
0 |
else if ((peptideLength + 1) * 3 == completeCodonsLength) |
617 |
|
{ |
618 |
0 |
Console.warn("Assuming stop codon at end of cDNA fragment"); |
619 |
0 |
mappedDnaEnd = dna.getEnd() - 3; |
620 |
|
} |
621 |
|
|
622 |
0 |
if (mappedDnaEnd != -1) |
623 |
|
{ |
624 |
0 |
int[] cdsRanges = new int[] { |
625 |
|
dna.getStart() + (data.codonStart - 1), mappedDnaEnd }; |
626 |
0 |
dnaToProteinMapping = new MapList(cdsRanges, proteinRange, 3, 1); |
627 |
|
} |
628 |
|
} |
629 |
|
|
630 |
0 |
return dnaToProteinMapping; |
631 |
|
} |
632 |
|
|
633 |
|
|
634 |
|
|
635 |
|
|
636 |
|
|
637 |
|
@param |
638 |
|
@param |
639 |
|
@param |
640 |
|
@param |
641 |
|
@return |
642 |
|
|
|
|
| 0% |
Uncovered Elements: 15 (15) |
Complexity: 5 |
Complexity Density: 0.56 |
|
643 |
0 |
SequenceI buildProteinProduct(SequenceI dna, DBRefEntry xref,... |
644 |
|
CdsData data, Map<String, SequenceI> proteins) |
645 |
|
{ |
646 |
|
|
647 |
|
|
648 |
|
|
649 |
0 |
if (data.proteinId == null || data.translation == null) |
650 |
|
{ |
651 |
0 |
return null; |
652 |
|
} |
653 |
|
|
654 |
|
|
655 |
|
|
656 |
|
|
657 |
0 |
String proteinSeqName = xref.getSource() + "|" + xref.getAccessionId(); |
658 |
0 |
SequenceI protein = proteins.get(proteinSeqName); |
659 |
0 |
if (protein == null) |
660 |
|
{ |
661 |
0 |
protein = new Sequence(proteinSeqName, data.translation, 1, |
662 |
|
data.translation.length()); |
663 |
0 |
protein.setDescription(data.proteinName != null ? data.proteinName |
664 |
|
: "Protein Product from " + sourceDb); |
665 |
0 |
proteins.put(proteinSeqName, protein); |
666 |
|
} |
667 |
|
|
668 |
0 |
return protein; |
669 |
|
} |
670 |
|
|
671 |
|
|
672 |
|
|
673 |
|
|
674 |
|
|
675 |
|
@param |
676 |
|
@param |
677 |
|
@return |
678 |
|
|
|
|
| 0% |
Uncovered Elements: 9 (9) |
Complexity: 3 |
Complexity Density: 0.43 |
|
679 |
0 |
protected int[] getCdsRanges(String accession, String location)... |
680 |
|
{ |
681 |
0 |
if (location == null) |
682 |
|
{ |
683 |
0 |
return new int[] {}; |
684 |
|
} |
685 |
|
|
686 |
0 |
try |
687 |
|
{ |
688 |
0 |
List<int[]> ranges = DnaUtils.parseLocation(location); |
689 |
0 |
return MappingUtils.rangeListToArray(ranges); |
690 |
|
} catch (ParseException e) |
691 |
|
{ |
692 |
0 |
Console.warn( |
693 |
|
String.format("Not parsing inexact CDS location %s in ENA %s", |
694 |
|
location, accession)); |
695 |
0 |
return new int[] {}; |
696 |
|
} |
697 |
|
} |
698 |
|
|
699 |
|
|
700 |
|
|
701 |
|
|
702 |
|
|
703 |
|
|
704 |
|
|
705 |
|
|
706 |
|
|
707 |
|
|
708 |
|
|
709 |
|
|
710 |
|
|
711 |
|
|
712 |
|
|
713 |
|
|
714 |
|
|
715 |
|
|
716 |
|
|
717 |
|
|
718 |
|
@param |
719 |
|
|
720 |
|
@param |
721 |
|
@return |
722 |
|
@throws |
723 |
|
|
|
|
| 0% |
Uncovered Elements: 25 (25) |
Complexity: 6 |
Complexity Density: 0.4 |
|
724 |
0 |
String parseFeatureQualifier(StringBuilder sb, boolean asText)... |
725 |
|
throws IOException |
726 |
|
{ |
727 |
0 |
String line; |
728 |
0 |
while ((line = nextLine()) != null) |
729 |
|
{ |
730 |
0 |
if (!isFeatureContinuationLine(line)) |
731 |
|
{ |
732 |
0 |
break; |
733 |
|
} |
734 |
0 |
String[] tokens = line.split(WHITESPACE); |
735 |
0 |
if (tokens.length < 2) |
736 |
|
{ |
737 |
0 |
Console.error("Ignoring bad EMBL line for " + this.accession + ": " |
738 |
|
+ line); |
739 |
0 |
break; |
740 |
|
} |
741 |
0 |
if (tokens[1].startsWith("/")) |
742 |
|
{ |
743 |
0 |
break; |
744 |
|
} |
745 |
|
|
746 |
|
|
747 |
|
|
748 |
|
|
749 |
|
|
750 |
0 |
if (asText) |
751 |
|
{ |
752 |
0 |
sb.append(" "); |
753 |
|
} |
754 |
|
|
755 |
|
|
756 |
|
|
757 |
|
|
758 |
0 |
String data = removeQuotes(tokens[1]); |
759 |
0 |
sb.append(data); |
760 |
|
} |
761 |
|
|
762 |
0 |
return line; |
763 |
|
} |
764 |
|
|
765 |
|
|
766 |
|
|
767 |
|
|
768 |
|
|
769 |
|
|
770 |
|
|
771 |
|
@throws |
772 |
|
|
|
|
| 0% |
Uncovered Elements: 16 (16) |
Complexity: 5 |
Complexity Density: 0.42 |
|
773 |
0 |
protected String parseSequence() throws IOException... |
774 |
|
{ |
775 |
0 |
StringBuilder sb = new StringBuilder(this.length); |
776 |
0 |
String line = nextLine(); |
777 |
0 |
while (line != null && line.startsWith(" ")) |
778 |
|
{ |
779 |
0 |
line = line.trim(); |
780 |
0 |
String[] blocks = line.split(WHITESPACE); |
781 |
|
|
782 |
|
|
783 |
|
|
784 |
|
|
785 |
0 |
for (int i = 0; i < blocks.length; i++) |
786 |
|
{ |
787 |
0 |
try |
788 |
|
{ |
789 |
0 |
Long.parseLong(blocks[i]); |
790 |
|
|
791 |
|
} catch (NumberFormatException e) |
792 |
|
{ |
793 |
|
|
794 |
0 |
sb.append(blocks[i]); |
795 |
|
} |
796 |
|
} |
797 |
0 |
line = nextLine(); |
798 |
|
} |
799 |
0 |
this.sequenceString = sb.toString(); |
800 |
|
|
801 |
0 |
return line; |
802 |
|
} |
803 |
|
|
804 |
|
|
805 |
|
|
806 |
|
|
807 |
|
|
808 |
|
|
809 |
|
|
810 |
|
@param |
811 |
|
|
812 |
|
|
813 |
|
@return |
814 |
|
@throws |
815 |
|
|
|
|
| 0% |
Uncovered Elements: 10 (10) |
Complexity: 5 |
Complexity Density: 0.83 |
|
816 |
0 |
protected String parseFeature(String line) throws IOException... |
817 |
|
{ |
818 |
0 |
String[] tokens = line.trim().split(WHITESPACE); |
819 |
0 |
if (tokens.length < 2 |
820 |
|
|| (!"CDS".equals(tokens[0]) && (!"source".equals(tokens[0])))) |
821 |
|
{ |
822 |
0 |
return nextLine(); |
823 |
|
} |
824 |
0 |
if (tokens[0].equals("source")) |
825 |
|
{ |
826 |
0 |
return parseSourceQualifiers(tokens); |
827 |
|
} |
828 |
0 |
return parseCDSFeature(tokens[1]); |
829 |
|
} |
830 |
|
} |
831 |
|
|
832 |
|
|
833 |
|
|
834 |
|
|
|
|
| - |
Uncovered Elements: 0 (0) |
Complexity: 0 |
Complexity Density: - |
|
835 |
|
class CdsData |
836 |
|
{ |
837 |
|
String translation; |
838 |
|
|
839 |
|
String cdsLocation; |
840 |
|
|
841 |
|
int codonStart = 1; |
842 |
|
|
843 |
|
String proteinName; |
844 |
|
|
845 |
|
String proteinId; |
846 |
|
|
847 |
|
List<DBRefEntry> xrefs = new ArrayList<>(); |
848 |
|
|
849 |
|
Map<String, String> cdsProps = new Hashtable<>(); |
850 |
|
} |