1 |
|
|
2 |
|
|
3 |
|
|
4 |
|
|
5 |
|
|
6 |
|
|
7 |
|
|
8 |
|
|
9 |
|
|
10 |
|
|
11 |
|
|
12 |
|
|
13 |
|
|
14 |
|
|
15 |
|
|
16 |
|
|
17 |
|
|
18 |
|
|
19 |
|
|
20 |
|
|
21 |
|
package jalview.analysis; |
22 |
|
|
23 |
|
import jalview.datamodel.AlignmentAnnotation; |
24 |
|
import jalview.datamodel.SequenceI; |
25 |
|
import jalview.renderer.AnnotationRenderer; |
26 |
|
|
27 |
|
import java.util.ArrayList; |
28 |
|
import java.util.Arrays; |
29 |
|
import java.util.BitSet; |
30 |
|
import java.util.Collections; |
31 |
|
import java.util.HashMap; |
32 |
|
import java.util.List; |
33 |
|
import java.util.Map; |
34 |
|
|
|
|
| 0% |
Uncovered Elements: 91 (91) |
Complexity: 27 |
Complexity Density: 0.52 |
|
35 |
|
public class AlignmentAnnotationUtils |
36 |
|
{ |
37 |
|
|
38 |
|
|
39 |
|
|
40 |
|
|
41 |
|
|
42 |
|
|
43 |
|
|
44 |
|
|
45 |
|
|
46 |
|
|
47 |
|
|
48 |
|
|
49 |
|
|
50 |
|
|
51 |
|
|
52 |
|
|
53 |
|
|
54 |
|
@param |
55 |
|
|
56 |
|
|
57 |
|
|
58 |
|
@param |
59 |
|
|
60 |
|
@param |
61 |
|
|
62 |
|
@param |
63 |
|
|
64 |
|
|
|
|
| 0% |
Uncovered Elements: 74 (74) |
Complexity: 21 |
Complexity Density: 0.48 |
|
65 |
0 |
public static void getShownHiddenTypes(... |
66 |
|
Map<String, List<List<String>>> shownTypes, |
67 |
|
Map<String, List<List<String>>> hiddenTypes, |
68 |
|
List<AlignmentAnnotation> annotations, |
69 |
|
List<SequenceI> forSequences) |
70 |
|
{ |
71 |
0 |
BitSet visibleGraphGroups = AlignmentAnnotationUtils |
72 |
|
.getVisibleLineGraphGroups(annotations); |
73 |
|
|
74 |
|
|
75 |
|
|
76 |
|
|
77 |
|
|
78 |
0 |
Map<String, Map<Integer, List<String>>> groupLabels = new HashMap<String, Map<Integer, List<String>>>(); |
79 |
|
|
80 |
|
|
81 |
0 |
List<String> addedToShown = new ArrayList<String>(); |
82 |
0 |
List<String> addedToHidden = new ArrayList<String>(); |
83 |
|
|
84 |
0 |
for (AlignmentAnnotation aa : annotations) |
85 |
|
{ |
86 |
|
|
87 |
|
|
88 |
|
|
89 |
|
|
90 |
0 |
if (aa.annotations == null) |
91 |
|
{ |
92 |
0 |
continue; |
93 |
|
} |
94 |
0 |
if (forSequences != null && (aa.sequenceRef != null |
95 |
|
&& forSequences.contains(aa.sequenceRef))) |
96 |
|
{ |
97 |
0 |
String calcId = aa.getCalcId(); |
98 |
|
|
99 |
|
|
100 |
|
|
101 |
|
|
102 |
0 |
final List<String> labelAsList = new ArrayList<String>(); |
103 |
0 |
final String displayLabel = aa.label; |
104 |
0 |
labelAsList.add(displayLabel); |
105 |
0 |
if (aa.graph == AlignmentAnnotation.LINE_GRAPH |
106 |
|
&& aa.graphGroup > -1) |
107 |
|
{ |
108 |
0 |
if (!groupLabels.containsKey(calcId)) |
109 |
|
{ |
110 |
0 |
groupLabels.put(calcId, new HashMap<Integer, List<String>>()); |
111 |
|
} |
112 |
0 |
Map<Integer, List<String>> groupLabelsForCalcId = groupLabels |
113 |
|
.get(calcId); |
114 |
0 |
if (groupLabelsForCalcId.containsKey(aa.graphGroup)) |
115 |
|
{ |
116 |
0 |
if (!groupLabelsForCalcId.get(aa.graphGroup) |
117 |
|
.contains(displayLabel)) |
118 |
|
{ |
119 |
0 |
groupLabelsForCalcId.get(aa.graphGroup).add(displayLabel); |
120 |
|
} |
121 |
|
} |
122 |
|
else |
123 |
|
{ |
124 |
0 |
groupLabelsForCalcId.put(aa.graphGroup, labelAsList); |
125 |
|
} |
126 |
|
} |
127 |
|
else |
128 |
|
|
129 |
|
|
130 |
|
|
131 |
|
|
132 |
|
{ |
133 |
0 |
String rememberAs = calcId + "!" + displayLabel; |
134 |
0 |
if (aa.isForDisplay() && !addedToShown.contains(rememberAs)) |
135 |
|
{ |
136 |
0 |
if (!shownTypes.containsKey(calcId)) |
137 |
|
{ |
138 |
0 |
shownTypes.put(calcId, new ArrayList<List<String>>()); |
139 |
|
} |
140 |
0 |
shownTypes.get(calcId).add(labelAsList); |
141 |
0 |
addedToShown.add(rememberAs); |
142 |
|
} |
143 |
|
else |
144 |
|
{ |
145 |
0 |
if (!aa.visible && !addedToHidden.contains(rememberAs)) |
146 |
|
{ |
147 |
0 |
if (!hiddenTypes.containsKey(calcId)) |
148 |
|
{ |
149 |
0 |
hiddenTypes.put(calcId, new ArrayList<List<String>>()); |
150 |
|
} |
151 |
0 |
hiddenTypes.get(calcId).add(labelAsList); |
152 |
0 |
addedToHidden.add(rememberAs); |
153 |
|
} |
154 |
|
} |
155 |
|
} |
156 |
|
} |
157 |
|
} |
158 |
|
|
159 |
|
|
160 |
|
|
161 |
|
|
162 |
|
|
163 |
|
|
164 |
0 |
for (String calcId : groupLabels.keySet()) |
165 |
|
{ |
166 |
0 |
for (int group : groupLabels.get(calcId).keySet()) |
167 |
|
{ |
168 |
0 |
final List<String> groupLabel = groupLabels.get(calcId).get(group); |
169 |
|
|
170 |
0 |
Collections.sort(groupLabel); |
171 |
0 |
if (visibleGraphGroups.get(group)) |
172 |
|
{ |
173 |
0 |
if (!shownTypes.containsKey(calcId)) |
174 |
|
{ |
175 |
0 |
shownTypes.put(calcId, new ArrayList<List<String>>()); |
176 |
|
} |
177 |
0 |
if (!shownTypes.get(calcId).contains(groupLabel)) |
178 |
|
{ |
179 |
0 |
shownTypes.get(calcId).add(groupLabel); |
180 |
|
} |
181 |
|
} |
182 |
|
else |
183 |
|
{ |
184 |
0 |
if (!hiddenTypes.containsKey(calcId)) |
185 |
|
{ |
186 |
0 |
hiddenTypes.put(calcId, new ArrayList<List<String>>()); |
187 |
|
} |
188 |
0 |
if (!hiddenTypes.get(calcId).contains(groupLabel)) |
189 |
|
{ |
190 |
0 |
hiddenTypes.get(calcId).add(groupLabel); |
191 |
|
} |
192 |
|
} |
193 |
|
} |
194 |
|
} |
195 |
|
} |
196 |
|
|
197 |
|
|
198 |
|
|
199 |
|
|
200 |
|
|
201 |
|
|
202 |
|
|
203 |
|
|
204 |
|
|
205 |
|
|
206 |
|
|
207 |
|
@see |
208 |
|
@param |
209 |
|
@return |
210 |
|
|
|
|
| 0% |
Uncovered Elements: 11 (11) |
Complexity: 4 |
Complexity Density: 0.57 |
|
211 |
0 |
public static BitSet getVisibleLineGraphGroups(... |
212 |
|
List<AlignmentAnnotation> annotations) |
213 |
|
{ |
214 |
0 |
BitSet result = new BitSet(); |
215 |
0 |
for (AlignmentAnnotation ann : annotations) |
216 |
|
{ |
217 |
0 |
if (ann.graph == AlignmentAnnotation.LINE_GRAPH && ann.visible) |
218 |
|
{ |
219 |
0 |
int gg = ann.graphGroup; |
220 |
0 |
if (gg > -1) |
221 |
|
{ |
222 |
0 |
result.set(gg); |
223 |
|
} |
224 |
|
} |
225 |
|
} |
226 |
0 |
return result; |
227 |
|
} |
228 |
|
|
229 |
|
|
230 |
|
|
231 |
|
|
232 |
|
|
233 |
|
@param |
234 |
|
@return |
235 |
|
|
|
|
| 0% |
Uncovered Elements: 3 (3) |
Complexity: 2 |
Complexity Density: 2 |
|
236 |
0 |
public static List<AlignmentAnnotation> asList(AlignmentAnnotation[] anns)... |
237 |
|
{ |
238 |
|
|
239 |
0 |
return (anns == null ? Collections.<AlignmentAnnotation> emptyList() |
240 |
|
: Arrays.asList(anns)); |
241 |
|
} |
242 |
|
} |