1 |
|
|
2 |
|
|
3 |
|
|
4 |
|
|
5 |
|
|
6 |
|
|
7 |
|
|
8 |
|
|
9 |
|
|
10 |
|
|
11 |
|
|
12 |
|
|
13 |
|
|
14 |
|
|
15 |
|
|
16 |
|
|
17 |
|
|
18 |
|
|
19 |
|
|
20 |
|
|
21 |
|
package jalview.schemes; |
22 |
|
|
23 |
|
import jalview.api.AlignViewportI; |
24 |
|
import jalview.datamodel.AlignmentAnnotation; |
25 |
|
import jalview.datamodel.AlignmentI; |
26 |
|
import jalview.datamodel.AnnotatedCollectionI; |
27 |
|
import jalview.datamodel.Annotation; |
28 |
|
import jalview.datamodel.SequenceCollectionI; |
29 |
|
import jalview.datamodel.SequenceI; |
30 |
|
import jalview.io.TCoffeeScoreFile; |
31 |
|
|
32 |
|
import java.awt.Color; |
33 |
|
import java.util.ArrayList; |
34 |
|
import java.util.IdentityHashMap; |
35 |
|
import java.util.List; |
36 |
|
import java.util.Map; |
37 |
|
|
38 |
|
|
39 |
|
|
40 |
|
|
41 |
|
|
42 |
|
|
43 |
|
|
44 |
|
@author |
45 |
|
|
46 |
|
|
|
|
| 0% |
Uncovered Elements: 61 (61) |
Complexity: 20 |
Complexity Density: 0.61 |
|
47 |
|
public class TCoffeeColourScheme extends ResidueColourScheme |
48 |
|
{ |
49 |
|
IdentityHashMap<SequenceI, Color[]> seqMap; |
50 |
|
|
51 |
|
|
52 |
|
|
53 |
|
|
|
|
| - |
Uncovered Elements: 0 (0) |
Complexity: 1 |
Complexity Density: - |
|
54 |
0 |
public TCoffeeColourScheme()... |
55 |
|
{ |
56 |
|
|
57 |
|
} |
58 |
|
|
59 |
|
|
60 |
|
|
61 |
|
|
62 |
|
|
63 |
|
@param |
64 |
|
|
65 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
66 |
0 |
public TCoffeeColourScheme(AnnotatedCollectionI alignment)... |
67 |
|
{ |
68 |
0 |
alignmentChanged(alignment, null); |
69 |
|
} |
70 |
|
|
71 |
|
|
72 |
|
|
73 |
|
|
74 |
|
|
75 |
|
|
76 |
|
@see |
77 |
|
|
|
|
| 0% |
Uncovered Elements: 26 (26) |
Complexity: 7 |
Complexity Density: 0.44 |
|
78 |
0 |
@Override... |
79 |
|
public void alignmentChanged(AnnotatedCollectionI alignment, |
80 |
|
Map<SequenceI, SequenceCollectionI> hiddenReps) |
81 |
|
{ |
82 |
|
|
83 |
|
|
84 |
|
|
85 |
|
|
86 |
|
|
87 |
0 |
List<AlignmentAnnotation> annots = new ArrayList<>(); |
88 |
|
|
89 |
|
|
90 |
0 |
seqMap = new IdentityHashMap<>(); |
91 |
0 |
AnnotatedCollectionI alcontext = alignment instanceof AlignmentI |
92 |
|
? alignment |
93 |
|
: alignment.getContext(); |
94 |
0 |
if (alcontext == null) |
95 |
|
{ |
96 |
0 |
return; |
97 |
|
} |
98 |
0 |
int w = 0; |
99 |
0 |
for (AlignmentAnnotation al : alcontext |
100 |
|
.findAnnotation(TCoffeeScoreFile.TCOFFEE_SCORE)) |
101 |
|
{ |
102 |
0 |
if (al.sequenceRef != null && !al.belowAlignment) |
103 |
|
{ |
104 |
0 |
annots.add(al); |
105 |
0 |
if (w < al.annotations.length) |
106 |
|
{ |
107 |
0 |
w = al.annotations.length; |
108 |
|
} |
109 |
0 |
Color[] scores = new Color[al.annotations.length]; |
110 |
0 |
int i = 0; |
111 |
0 |
for (Annotation an : al.annotations) |
112 |
|
{ |
113 |
0 |
scores[i++] = (an != null) ? an.colour : Color.white; |
114 |
|
} |
115 |
0 |
seqMap.put(al.sequenceRef, scores); |
116 |
|
} |
117 |
|
} |
118 |
|
|
119 |
|
|
120 |
|
|
121 |
|
|
122 |
|
} |
123 |
|
|
|
|
| 0% |
Uncovered Elements: 14 (14) |
Complexity: 5 |
Complexity Density: 0.62 |
|
124 |
0 |
@Override... |
125 |
|
public Color findColour(char c, int j, SequenceI seq) |
126 |
|
{ |
127 |
0 |
if (seqMap == null) |
128 |
|
{ |
129 |
0 |
return Color.WHITE; |
130 |
|
} |
131 |
0 |
Color[] cols = seqMap.get(seq); |
132 |
0 |
if (cols == null) |
133 |
|
{ |
134 |
|
|
135 |
|
|
136 |
0 |
return Color.white; |
137 |
|
} |
138 |
|
|
139 |
0 |
if (j < 0 || j >= cols.length) |
140 |
|
{ |
141 |
0 |
return Color.white; |
142 |
|
} |
143 |
0 |
return cols[j]; |
144 |
|
} |
145 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
146 |
0 |
@Override... |
147 |
|
public ColourSchemeI getInstance(AlignViewportI view, |
148 |
|
AnnotatedCollectionI sg) |
149 |
|
{ |
150 |
0 |
return new TCoffeeColourScheme(sg); |
151 |
|
} |
152 |
|
|
153 |
|
|
154 |
|
|
155 |
|
|
|
|
| 0% |
Uncovered Elements: 9 (9) |
Complexity: 3 |
Complexity Density: 0.6 |
|
156 |
0 |
@Override... |
157 |
|
public boolean isApplicableTo(AnnotatedCollectionI ac) |
158 |
|
{ |
159 |
0 |
AnnotatedCollectionI alcontext = ac instanceof AlignmentI ? ac |
160 |
|
: ac.getContext(); |
161 |
0 |
if (alcontext == null) |
162 |
|
{ |
163 |
0 |
return false; |
164 |
|
} |
165 |
0 |
Iterable<AlignmentAnnotation> anns = alcontext |
166 |
|
.findAnnotation(TCoffeeScoreFile.TCOFFEE_SCORE); |
167 |
0 |
return anns.iterator().hasNext(); |
168 |
|
} |
169 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
170 |
0 |
@Override... |
171 |
|
public String getSchemeName() |
172 |
|
{ |
173 |
0 |
return JalviewColourScheme.TCoffee.toString(); |
174 |
|
} |
175 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
176 |
0 |
@Override... |
177 |
|
public boolean isSimple() |
178 |
|
{ |
179 |
0 |
return false; |
180 |
|
} |
181 |
|
} |