1 |
|
|
2 |
|
|
3 |
|
|
4 |
|
|
5 |
|
|
6 |
|
|
7 |
|
|
8 |
|
|
9 |
|
|
10 |
|
|
11 |
|
|
12 |
|
|
13 |
|
|
14 |
|
|
15 |
|
|
16 |
|
|
17 |
|
|
18 |
|
|
19 |
|
|
20 |
|
|
21 |
|
package jalview.ext.jmol; |
22 |
|
|
23 |
|
import jalview.api.AlignViewportI; |
24 |
|
import jalview.api.AlignmentViewPanel; |
25 |
|
import jalview.api.FeatureRenderer; |
26 |
|
import jalview.api.SequenceRenderer; |
27 |
|
import jalview.datamodel.AlignmentI; |
28 |
|
import jalview.datamodel.HiddenColumns; |
29 |
|
import jalview.datamodel.SequenceI; |
30 |
|
import jalview.renderer.seqfeatures.FeatureColourFinder; |
31 |
|
import jalview.structure.StructureMapping; |
32 |
|
import jalview.structure.StructureMappingcommandSet; |
33 |
|
import jalview.structure.StructureSelectionManager; |
34 |
|
|
35 |
|
import java.awt.Color; |
36 |
|
import java.util.ArrayList; |
37 |
|
import java.util.List; |
38 |
|
|
39 |
|
|
40 |
|
|
41 |
|
|
42 |
|
|
43 |
|
@author |
44 |
|
|
45 |
|
|
|
|
| 81% |
Uncovered Elements: 19 (100) |
Complexity: 26 |
Complexity Density: 0.42 |
|
46 |
|
public class JmolCommands |
47 |
|
{ |
48 |
|
|
49 |
|
|
50 |
|
|
51 |
|
|
52 |
|
|
53 |
|
|
54 |
|
|
55 |
|
|
|
|
| 78.2% |
Uncovered Elements: 17 (78) |
Complexity: 21 |
Complexity Density: 0.44 |
|
56 |
11 |
public static StructureMappingcommandSet[] getColourBySequenceCommand(... |
57 |
|
StructureSelectionManager ssm, String[] files, |
58 |
|
SequenceI[][] sequence, SequenceRenderer sr, |
59 |
|
AlignmentViewPanel viewPanel) |
60 |
|
{ |
61 |
11 |
FeatureRenderer fr = viewPanel.getFeatureRenderer(); |
62 |
11 |
FeatureColourFinder finder = new FeatureColourFinder(fr); |
63 |
11 |
AlignViewportI viewport = viewPanel.getAlignViewport(); |
64 |
11 |
HiddenColumns cs = viewport.getAlignment().getHiddenColumns(); |
65 |
11 |
AlignmentI al = viewport.getAlignment(); |
66 |
11 |
List<StructureMappingcommandSet> cset = new ArrayList<StructureMappingcommandSet>(); |
67 |
|
|
68 |
26 |
for (int pdbfnum = 0; pdbfnum < files.length; pdbfnum++) |
69 |
|
{ |
70 |
15 |
StructureMapping[] mapping = ssm.getMapping(files[pdbfnum]); |
71 |
15 |
StringBuffer command = new StringBuffer(); |
72 |
15 |
StructureMappingcommandSet smc; |
73 |
15 |
ArrayList<String> str = new ArrayList<String>(); |
74 |
|
|
75 |
15 |
if (mapping == null || mapping.length < 1) |
76 |
|
{ |
77 |
2 |
continue; |
78 |
|
} |
79 |
|
|
80 |
26 |
for (int s = 0; s < sequence[pdbfnum].length; s++) |
81 |
|
{ |
82 |
27 |
for (int sp, m = 0; m < mapping.length; m++) |
83 |
|
{ |
84 |
? |
if (mapping[m].getSequence() == sequence[pdbfnum][s] |
85 |
|
&& (sp = al.findIndex(sequence[pdbfnum][s])) > -1) |
86 |
|
{ |
87 |
13 |
int lastPos = StructureMapping.UNASSIGNED_VALUE; |
88 |
13 |
SequenceI asp = al.getSequenceAt(sp); |
89 |
3291 |
for (int r = 0; r < asp.getLength(); r++) |
90 |
|
{ |
91 |
|
|
92 |
3278 |
if (jalview.util.Comparison.isGap(asp.getCharAt(r))) |
93 |
|
{ |
94 |
0 |
continue; |
95 |
|
} |
96 |
3278 |
int pos = mapping[m].getPDBResNum(asp.findPosition(r)); |
97 |
|
|
98 |
3278 |
if (pos == lastPos) |
99 |
|
{ |
100 |
0 |
continue; |
101 |
|
} |
102 |
3278 |
if (pos == StructureMapping.UNASSIGNED_VALUE) |
103 |
|
{ |
104 |
|
|
105 |
0 |
if (command.length() > 0 |
106 |
|
&& command.charAt(command.length() - 1) != ';') |
107 |
|
{ |
108 |
0 |
command.append(";"); |
109 |
|
} |
110 |
|
|
111 |
0 |
lastPos = StructureMapping.UNASSIGNED_VALUE; |
112 |
0 |
continue; |
113 |
|
} |
114 |
|
|
115 |
3278 |
lastPos = pos; |
116 |
|
|
117 |
3278 |
Color col = sr.getResidueColour(sequence[pdbfnum][s], r, |
118 |
|
finder); |
119 |
|
|
120 |
|
|
121 |
|
|
122 |
|
|
123 |
3278 |
if (!cs.isVisible(r)) |
124 |
|
{ |
125 |
6 |
col = Color.GRAY; |
126 |
|
} |
127 |
|
|
128 |
3278 |
String newSelcom = (mapping[m].getChain() != " " |
129 |
|
? ":" + mapping[m].getChain() |
130 |
|
: "") + "/" + (pdbfnum + 1) + ".1" + ";color[" |
131 |
|
+ col.getRed() + "," + col.getGreen() + "," |
132 |
|
+ col.getBlue() + "]"; |
133 |
3278 |
if (command.length() > newSelcom.length() && command |
134 |
|
.substring(command.length() - newSelcom.length()) |
135 |
|
.equals(newSelcom)) |
136 |
|
{ |
137 |
3259 |
command = JmolCommands.condenseCommand(command, pos); |
138 |
3259 |
continue; |
139 |
|
} |
140 |
|
|
141 |
|
|
142 |
|
|
143 |
19 |
if (command.length() > 0 |
144 |
|
&& command.charAt(command.length() - 1) != ';') |
145 |
|
{ |
146 |
6 |
command.append(";"); |
147 |
|
} |
148 |
|
|
149 |
19 |
if (command.length() > 51200) |
150 |
|
{ |
151 |
|
|
152 |
0 |
str.add(command.toString()); |
153 |
0 |
command.setLength(0); |
154 |
|
} |
155 |
19 |
command.append("select " + pos); |
156 |
19 |
command.append(newSelcom); |
157 |
|
} |
158 |
|
|
159 |
|
} |
160 |
|
} |
161 |
|
} |
162 |
|
{ |
163 |
|
|
164 |
13 |
str.add(command.toString()); |
165 |
13 |
command.setLength(0); |
166 |
|
} |
167 |
|
|
168 |
13 |
cset.add(new StructureMappingcommandSet(JmolCommands.class, |
169 |
|
files[pdbfnum], str.toArray(new String[str.size()]))); |
170 |
|
|
171 |
|
} |
172 |
11 |
return cset.toArray(new StructureMappingcommandSet[cset.size()]); |
173 |
|
} |
174 |
|
|
|
|
| 90% |
Uncovered Elements: 2 (20) |
Complexity: 5 |
Complexity Density: 0.36 |
|
175 |
3259 |
public static StringBuffer condenseCommand(StringBuffer command, int pos)... |
176 |
|
{ |
177 |
|
|
178 |
|
|
179 |
3259 |
int p = command.length(), q = p; |
180 |
3259 |
do |
181 |
|
{ |
182 |
22792 |
p -= 6; |
183 |
22792 |
if (p < 1) |
184 |
|
{ |
185 |
3247 |
p = 0; |
186 |
|
} |
187 |
22792 |
; |
188 |
? |
} while ((q = command.indexOf("select", p)) == -1 && p > 0); |
189 |
|
|
190 |
3259 |
StringBuffer sb = new StringBuffer(command.substring(0, q + 7)); |
191 |
|
|
192 |
3259 |
command = command.delete(0, q + 7); |
193 |
|
|
194 |
3259 |
String start; |
195 |
|
|
196 |
3259 |
if (command.indexOf("-") > -1) |
197 |
|
{ |
198 |
3244 |
start = command.substring(0, command.indexOf("-")); |
199 |
|
} |
200 |
|
else |
201 |
|
{ |
202 |
15 |
start = command.substring(0, command.indexOf(":")); |
203 |
|
} |
204 |
|
|
205 |
3259 |
sb.append(start + "-" + pos + command.substring(command.indexOf(":"))); |
206 |
|
|
207 |
3259 |
return sb; |
208 |
|
} |
209 |
|
|
210 |
|
} |