1 |
|
package jalview.structure; |
2 |
|
|
3 |
|
import java.awt.Color; |
4 |
|
import java.util.ArrayList; |
5 |
|
import java.util.List; |
6 |
|
import java.util.Map; |
7 |
|
import java.util.Map.Entry; |
8 |
|
|
9 |
|
|
10 |
|
|
11 |
|
|
12 |
|
|
13 |
|
@author |
14 |
|
|
15 |
|
|
|
|
| 77.5% |
Uncovered Elements: 18 (80) |
Complexity: 23 |
Complexity Density: 0.47 |
|
16 |
|
public abstract class StructureCommandsBase implements StructureCommandsI |
17 |
|
{ |
18 |
|
public static final String NAMESPACE_PREFIX = "jv_"; |
19 |
|
|
20 |
|
private static final String CMD_SEPARATOR = ";"; |
21 |
|
|
22 |
|
|
23 |
|
|
24 |
|
|
25 |
|
@return |
26 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
27 |
19 |
protected static String getCommandSeparator()... |
28 |
|
{ |
29 |
19 |
return CMD_SEPARATOR; |
30 |
|
} |
31 |
|
|
32 |
|
|
33 |
|
|
34 |
|
|
35 |
|
@return |
36 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
37 |
2 |
@Override... |
38 |
|
public int getModelStartNo() |
39 |
|
{ |
40 |
2 |
return 0; |
41 |
|
} |
42 |
|
|
43 |
|
|
44 |
|
|
45 |
|
|
46 |
|
|
47 |
|
|
48 |
|
|
49 |
|
|
50 |
|
|
51 |
|
|
52 |
|
@param |
53 |
|
@param |
54 |
|
@param |
55 |
|
@param |
56 |
|
@param |
57 |
|
@param |
58 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (7) |
Complexity: 2 |
Complexity Density: 0.4 |
|
59 |
57 |
public static final void addAtomSpecRange(Map<Object, AtomSpecModel> map,... |
60 |
|
Object value, String model, int startPos, int endPos, |
61 |
|
String chain) |
62 |
|
{ |
63 |
|
|
64 |
|
|
65 |
|
|
66 |
57 |
AtomSpecModel atomSpec = map.get(value); |
67 |
57 |
if (atomSpec == null) |
68 |
|
{ |
69 |
21 |
atomSpec = new AtomSpecModel(); |
70 |
21 |
map.put(value, atomSpec); |
71 |
|
} |
72 |
|
|
73 |
57 |
atomSpec.addRange(model, startPos, endPos, chain); |
74 |
|
} |
75 |
|
|
76 |
|
|
77 |
|
|
78 |
|
|
79 |
|
|
80 |
|
|
81 |
|
@param |
82 |
|
@return |
83 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (10) |
Complexity: 3 |
Complexity Density: 0.5 |
|
84 |
21 |
protected String makeAttributeName(String featureType)... |
85 |
|
{ |
86 |
21 |
StringBuilder sb = new StringBuilder(); |
87 |
21 |
if (featureType != null) |
88 |
|
{ |
89 |
20 |
for (char c : featureType.toCharArray()) |
90 |
|
{ |
91 |
171 |
sb.append(Character.isLetterOrDigit(c) ? c : '_'); |
92 |
|
} |
93 |
|
} |
94 |
21 |
String attName = NAMESPACE_PREFIX + sb.toString(); |
95 |
21 |
return attName; |
96 |
|
} |
97 |
|
|
98 |
|
|
99 |
|
|
100 |
|
|
101 |
|
|
102 |
|
|
103 |
|
|
104 |
|
|
105 |
|
|
106 |
|
@param |
107 |
|
@return |
108 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (15) |
Complexity: 2 |
Complexity Density: 0.15 |
|
109 |
11 |
@Override... |
110 |
|
public List<StructureCommandI> colourBySequence( |
111 |
|
Map<Object, AtomSpecModel> colourMap) |
112 |
|
{ |
113 |
11 |
List<StructureCommandI> commands = new ArrayList<>(); |
114 |
11 |
StringBuilder sb = new StringBuilder(colourMap.size() * 20); |
115 |
11 |
boolean first = true; |
116 |
11 |
for (Object key : colourMap.keySet()) |
117 |
|
{ |
118 |
11 |
Color colour = (Color) key; |
119 |
11 |
final AtomSpecModel colourData = colourMap.get(colour); |
120 |
11 |
StructureCommandI command = getColourCommand(colourData, colour); |
121 |
11 |
if (!first) |
122 |
|
{ |
123 |
2 |
sb.append(getCommandSeparator()); |
124 |
|
} |
125 |
11 |
first = false; |
126 |
11 |
sb.append(command.getCommand()); |
127 |
|
} |
128 |
|
|
129 |
11 |
commands.add(new StructureCommand(sb.toString())); |
130 |
11 |
return commands; |
131 |
|
} |
132 |
|
|
133 |
|
|
134 |
|
|
135 |
|
|
136 |
|
|
137 |
|
@param |
138 |
|
@param |
139 |
|
@return |
140 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
|
141 |
20 |
protected StructureCommandI getColourCommand(AtomSpecModel atomSpecModel,... |
142 |
|
Color colour) |
143 |
|
{ |
144 |
20 |
String atomSpec = getAtomSpec(atomSpecModel, false); |
145 |
20 |
return colourResidues(atomSpec, colour); |
146 |
|
} |
147 |
|
|
148 |
|
|
149 |
|
|
150 |
|
|
151 |
|
|
152 |
|
@param |
153 |
|
@param |
154 |
|
@return |
155 |
|
|
156 |
|
protected abstract StructureCommandI colourResidues(String atomSpec, |
157 |
|
Color colour); |
158 |
|
|
|
|
| 0% |
Uncovered Elements: 4 (4) |
Complexity: 1 |
Complexity Density: 0.25 |
|
159 |
0 |
@Override... |
160 |
|
public List<StructureCommandI> colourByResidues( |
161 |
|
Map<String, Color> colours) |
162 |
|
{ |
163 |
0 |
List<StructureCommandI> commands = new ArrayList<>(); |
164 |
0 |
for (Entry<String, Color> entry : colours.entrySet()) |
165 |
|
{ |
166 |
0 |
commands.add(colourResidue(entry.getKey(), entry.getValue())); |
167 |
|
} |
168 |
0 |
return commands; |
169 |
|
} |
170 |
|
|
|
|
| 0% |
Uncovered Elements: 2 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
|
171 |
0 |
private StructureCommandI colourResidue(String resName, Color col)... |
172 |
|
{ |
173 |
0 |
String atomSpec = getResidueSpec(resName); |
174 |
0 |
return colourResidues(atomSpec, col); |
175 |
|
} |
176 |
|
|
177 |
|
|
178 |
|
|
179 |
|
|
180 |
|
@param |
181 |
|
@param |
182 |
|
@param |
183 |
|
@param |
184 |
|
@param |
185 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (17) |
Complexity: 5 |
Complexity Density: 0.56 |
|
186 |
230 |
protected void appendRange(StringBuilder sb, int start, int end,... |
187 |
|
String chain, boolean firstPositionForModel, boolean isChimeraX) |
188 |
|
{ |
189 |
230 |
if (!firstPositionForModel) |
190 |
|
{ |
191 |
59 |
sb.append(","); |
192 |
|
} |
193 |
230 |
if (end == start) |
194 |
|
{ |
195 |
54 |
sb.append(start); |
196 |
|
} |
197 |
|
else |
198 |
|
{ |
199 |
176 |
sb.append(start).append("-").append(end); |
200 |
|
} |
201 |
|
|
202 |
230 |
if (!isChimeraX) |
203 |
|
{ |
204 |
119 |
sb.append("."); |
205 |
119 |
if (!" ".equals(chain)) |
206 |
|
{ |
207 |
117 |
sb.append(chain); |
208 |
|
} |
209 |
|
} |
210 |
|
} |
211 |
|
|
212 |
|
|
213 |
|
|
214 |
|
|
215 |
|
@param |
216 |
|
@return |
217 |
|
|
218 |
|
protected abstract String getResidueSpec(String residue); |
219 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
220 |
0 |
@Override... |
221 |
|
public List<StructureCommandI> setAttributes( |
222 |
|
Map<String, Map<Object, AtomSpecModel>> featureValues) |
223 |
|
{ |
224 |
|
|
225 |
0 |
return null; |
226 |
|
} |
227 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
228 |
0 |
@Override... |
229 |
|
public List<StructureCommandI> startNotifications(String uri) |
230 |
|
{ |
231 |
0 |
return null; |
232 |
|
} |
233 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
234 |
7 |
@Override... |
235 |
|
public List<StructureCommandI> stopNotifications() |
236 |
|
{ |
237 |
7 |
return null; |
238 |
|
} |
239 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
240 |
0 |
@Override... |
241 |
|
public StructureCommandI getSelectedResidues() |
242 |
|
{ |
243 |
0 |
return null; |
244 |
|
} |
245 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
246 |
0 |
@Override... |
247 |
|
public StructureCommandI listResidueAttributes() |
248 |
|
{ |
249 |
0 |
return null; |
250 |
|
} |
251 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
252 |
0 |
@Override... |
253 |
|
public StructureCommandI getResidueAttributes(String attName) |
254 |
|
{ |
255 |
0 |
return null; |
256 |
|
} |
257 |
|
} |