1 |
|
|
2 |
|
|
3 |
|
|
4 |
|
|
5 |
|
|
6 |
|
|
7 |
|
|
8 |
|
|
9 |
|
|
10 |
|
|
11 |
|
|
12 |
|
|
13 |
|
|
14 |
|
|
15 |
|
|
16 |
|
|
17 |
|
|
18 |
|
|
19 |
|
|
20 |
|
|
21 |
|
package jalview.ws.dbsources; |
22 |
|
|
23 |
|
import jalview.datamodel.Alignment; |
24 |
|
import jalview.datamodel.AlignmentI; |
25 |
|
import jalview.datamodel.SequenceI; |
26 |
|
import jalview.datamodel.xdb.embl.EmblEntry; |
27 |
|
import jalview.datamodel.xdb.embl.EmblFile; |
28 |
|
import jalview.util.MessageManager; |
29 |
|
import jalview.ws.ebi.EBIFetchClient; |
30 |
|
|
31 |
|
import java.io.File; |
32 |
|
import java.util.ArrayList; |
33 |
|
import java.util.List; |
34 |
|
|
|
|
| 4.9% |
Uncovered Elements: 39 (41) |
Complexity: 12 |
Complexity Density: 0.44 |
|
35 |
|
public abstract class EmblXmlSource extends EbiFileRetrievedProxy |
36 |
|
{ |
37 |
|
|
38 |
|
|
39 |
|
|
40 |
|
private static final String EMBL_NOT_FOUND_REPLY = "ERROR 12 No entries found."; |
41 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
42 |
12 |
public EmblXmlSource()... |
43 |
|
{ |
44 |
12 |
super(); |
45 |
|
} |
46 |
|
|
47 |
|
|
48 |
|
|
49 |
|
|
50 |
|
@param |
51 |
|
|
52 |
|
|
53 |
|
@param |
54 |
|
@return |
55 |
|
@throws |
56 |
|
|
|
|
| 0% |
Uncovered Elements: 8 (8) |
Complexity: 2 |
Complexity Density: 0.25 |
|
57 |
0 |
public AlignmentI getEmblSequenceRecords(String emprefx, String query)... |
58 |
|
throws Exception |
59 |
|
{ |
60 |
0 |
startQuery(); |
61 |
0 |
EBIFetchClient dbFetch = new EBIFetchClient(); |
62 |
0 |
File reply; |
63 |
0 |
try |
64 |
|
{ |
65 |
0 |
reply = dbFetch.fetchDataAsFile( |
66 |
|
emprefx.toLowerCase() + ":" + query.trim(), "display=xml", |
67 |
|
"xml"); |
68 |
|
} catch (Exception e) |
69 |
|
{ |
70 |
0 |
stopQuery(); |
71 |
0 |
throw new Exception(MessageManager.formatMessage( |
72 |
|
"exception.ebiembl_retrieval_failed_on", new String[] |
73 |
|
{ emprefx.toLowerCase(), query.trim() }), e); |
74 |
|
} |
75 |
0 |
return getEmblSequenceRecords(emprefx, query, reply); |
76 |
|
} |
77 |
|
|
78 |
|
|
79 |
|
|
80 |
|
|
81 |
|
@param |
82 |
|
|
83 |
|
|
84 |
|
@param |
85 |
|
@param |
86 |
|
|
87 |
|
@return |
88 |
|
@throws |
89 |
|
|
|
|
| 0% |
Uncovered Elements: 27 (27) |
Complexity: 8 |
Complexity Density: 0.47 |
|
90 |
0 |
public AlignmentI getEmblSequenceRecords(String emprefx, String query,... |
91 |
|
File reply) throws Exception |
92 |
|
{ |
93 |
0 |
EmblFile efile = null; |
94 |
0 |
List<SequenceI> seqs = new ArrayList<>(); |
95 |
|
|
96 |
0 |
if (reply != null && reply.exists()) |
97 |
|
{ |
98 |
0 |
file = reply.getAbsolutePath(); |
99 |
0 |
if (reply.length() > EMBL_NOT_FOUND_REPLY.length()) |
100 |
|
{ |
101 |
0 |
efile = EmblFile.getEmblFile(reply); |
102 |
|
} |
103 |
|
} |
104 |
|
|
105 |
|
|
106 |
|
|
107 |
|
|
108 |
|
|
109 |
|
|
110 |
0 |
List<SequenceI> peptides = new ArrayList<>(); |
111 |
0 |
if (efile != null && efile.getEntries() != null) |
112 |
|
{ |
113 |
0 |
for (EmblEntry entry : efile.getEntries()) |
114 |
|
{ |
115 |
0 |
SequenceI seq = entry.getSequence(emprefx, peptides); |
116 |
0 |
if (seq != null) |
117 |
|
{ |
118 |
0 |
seqs.add(seq.deriveSequence()); |
119 |
|
|
120 |
|
} |
121 |
|
} |
122 |
|
} |
123 |
|
|
124 |
0 |
AlignmentI al = null; |
125 |
0 |
if (!seqs.isEmpty()) |
126 |
|
{ |
127 |
0 |
al = new Alignment(seqs.toArray(new SequenceI[seqs.size()])); |
128 |
|
} |
129 |
0 |
stopQuery(); |
130 |
0 |
return al; |
131 |
|
} |
132 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
133 |
0 |
@Override... |
134 |
|
public boolean isDnaCoding() |
135 |
|
{ |
136 |
0 |
return true; |
137 |
|
} |
138 |
|
|
139 |
|
} |