1 |
|
|
2 |
|
|
3 |
|
|
4 |
|
|
5 |
|
|
6 |
|
|
7 |
|
|
8 |
|
|
9 |
|
|
10 |
|
|
11 |
|
|
12 |
|
|
13 |
|
|
14 |
|
|
15 |
|
|
16 |
|
|
17 |
|
|
18 |
|
|
19 |
|
|
20 |
|
|
21 |
|
package jalview.datamodel.xdb.embl; |
22 |
|
|
23 |
|
import jalview.datamodel.DBRefEntry; |
24 |
|
import jalview.ws.dbsources.Uniprot; |
25 |
|
|
26 |
|
import java.io.File; |
27 |
|
import java.io.FileReader; |
28 |
|
import java.io.PrintWriter; |
29 |
|
import java.io.Reader; |
30 |
|
import java.util.Vector; |
31 |
|
|
32 |
|
import org.exolab.castor.mapping.Mapping; |
33 |
|
import org.exolab.castor.xml.Unmarshaller; |
34 |
|
|
35 |
|
|
36 |
|
|
37 |
|
|
38 |
|
|
39 |
|
|
40 |
|
|
41 |
|
@see |
42 |
|
|
|
|
| 69.6% |
Uncovered Elements: 21 (69) |
Complexity: 20 |
Complexity Density: 0.45 |
|
43 |
|
public class EmblFile |
44 |
|
{ |
45 |
|
Vector<EmblEntry> entries; |
46 |
|
|
47 |
|
Vector<EmblError> errors; |
48 |
|
|
49 |
|
String text; |
50 |
|
|
51 |
|
|
52 |
|
@return |
53 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
54 |
12 |
public Vector<EmblEntry> getEntries()... |
55 |
|
{ |
56 |
12 |
return entries; |
57 |
|
} |
58 |
|
|
59 |
|
|
60 |
|
@param |
61 |
|
|
62 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
63 |
2 |
public void setEntries(Vector<EmblEntry> entries)... |
64 |
|
{ |
65 |
2 |
this.entries = entries; |
66 |
|
} |
67 |
|
|
68 |
|
|
69 |
|
@return |
70 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
71 |
2 |
public Vector<EmblError> getErrors()... |
72 |
|
{ |
73 |
2 |
return errors; |
74 |
|
} |
75 |
|
|
76 |
|
|
77 |
|
@param |
78 |
|
|
79 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
80 |
0 |
public void setErrors(Vector<EmblError> errors)... |
81 |
|
{ |
82 |
0 |
this.errors = errors; |
83 |
|
} |
84 |
|
|
85 |
|
|
86 |
|
|
87 |
|
|
88 |
|
@param |
89 |
|
@return |
90 |
|
|
|
|
| 0% |
Uncovered Elements: 9 (9) |
Complexity: 3 |
Complexity Density: 0.43 |
|
91 |
0 |
public static EmblFile getEmblFile(File file)... |
92 |
|
{ |
93 |
0 |
if (file == null) |
94 |
|
{ |
95 |
0 |
return null; |
96 |
|
} |
97 |
0 |
try |
98 |
|
{ |
99 |
0 |
return EmblFile.getEmblFile(new FileReader(file)); |
100 |
|
} catch (Exception e) |
101 |
|
{ |
102 |
0 |
System.err.println("Exception whilst reading EMBLfile from " + file); |
103 |
0 |
e.printStackTrace(System.err); |
104 |
|
} |
105 |
0 |
return null; |
106 |
|
} |
107 |
|
|
|
|
| 85% |
Uncovered Elements: 3 (20) |
Complexity: 4 |
Complexity Density: 0.22 |
|
108 |
2 |
public static EmblFile getEmblFile(Reader file)... |
109 |
|
{ |
110 |
2 |
EmblFile record = new EmblFile(); |
111 |
2 |
try |
112 |
|
{ |
113 |
|
|
114 |
2 |
Mapping map = new Mapping(record.getClass().getClassLoader()); |
115 |
|
|
116 |
2 |
java.net.URL url = record.getClass().getResource("/embl_mapping.xml"); |
117 |
2 |
map.loadMapping(url); |
118 |
|
|
119 |
|
|
120 |
2 |
Unmarshaller unmar = new Unmarshaller(record); |
121 |
2 |
try |
122 |
|
{ |
123 |
|
|
124 |
2 |
if (jalview.bin.Cache |
125 |
|
.getDefault(jalview.bin.Cache.CASTORLOGLEVEL, "debug") |
126 |
|
.equalsIgnoreCase("DEBUG")) |
127 |
|
{ |
128 |
2 |
unmar.setDebug(jalview.bin.Cache.log.isDebugEnabled()); |
129 |
|
} |
130 |
|
} catch (Exception e) |
131 |
|
{ |
132 |
|
} |
133 |
2 |
unmar.setIgnoreExtraElements(true); |
134 |
2 |
unmar.setIgnoreExtraAttributes(true); |
135 |
2 |
unmar.setMapping(map); |
136 |
2 |
unmar.setLogWriter(new PrintWriter(System.out)); |
137 |
2 |
record = (EmblFile) unmar.unmarshal(file); |
138 |
|
|
139 |
2 |
canonicaliseDbRefs(record); |
140 |
|
} catch (Exception e) |
141 |
|
{ |
142 |
0 |
e.printStackTrace(System.err); |
143 |
0 |
record = null; |
144 |
|
} |
145 |
|
|
146 |
2 |
return record; |
147 |
|
} |
148 |
|
|
149 |
|
|
150 |
|
|
151 |
|
|
152 |
|
|
153 |
|
@param |
154 |
|
@see |
155 |
|
|
|
|
| 84% |
Uncovered Elements: 4 (25) |
Complexity: 7 |
Complexity Density: 0.54 |
|
156 |
2 |
static void canonicaliseDbRefs(EmblFile record)... |
157 |
|
{ |
158 |
2 |
if (record.getEntries() == null) |
159 |
|
{ |
160 |
0 |
return; |
161 |
|
} |
162 |
2 |
for (EmblEntry entry : record.getEntries()) |
163 |
|
{ |
164 |
2 |
if (entry.getDbRefs() != null) |
165 |
|
{ |
166 |
2 |
for (DBRefEntry dbref : entry.getDbRefs()) |
167 |
|
{ |
168 |
4 |
if ("".equals(dbref.getVersion())) |
169 |
|
{ |
170 |
2 |
dbref.setVersion("0"); |
171 |
|
} |
172 |
|
} |
173 |
|
} |
174 |
|
|
175 |
2 |
if (entry.getFeatures() != null) |
176 |
|
{ |
177 |
2 |
for (EmblFeature feature : entry.getFeatures()) |
178 |
|
{ |
179 |
6 |
if (feature.getDbRefs() != null) |
180 |
|
{ |
181 |
4 |
for (DBRefEntry dbref : feature.getDbRefs()) |
182 |
|
{ |
183 |
6 |
if ("".equals(dbref.getVersion())) |
184 |
|
{ |
185 |
4 |
dbref.setVersion("0"); |
186 |
|
} |
187 |
|
} |
188 |
|
} |
189 |
|
} |
190 |
|
} |
191 |
|
} |
192 |
|
} |
193 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
194 |
2 |
public String getText()... |
195 |
|
{ |
196 |
2 |
return text; |
197 |
|
} |
198 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
199 |
0 |
public void setText(String text)... |
200 |
|
{ |
201 |
0 |
this.text = text; |
202 |
|
} |
203 |
|
} |