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