1 |
|
|
2 |
|
|
3 |
|
|
4 |
|
|
5 |
|
|
6 |
|
|
7 |
|
|
8 |
|
|
9 |
|
|
10 |
|
|
11 |
|
|
12 |
|
|
13 |
|
|
14 |
|
|
15 |
|
|
16 |
|
|
17 |
|
|
18 |
|
|
19 |
|
|
20 |
|
|
21 |
|
package jalview.io; |
22 |
|
|
23 |
|
import jalview.datamodel.AlignmentAnnotation; |
24 |
|
import jalview.datamodel.AlignmentI; |
25 |
|
import jalview.datamodel.Annotation; |
26 |
|
import jalview.datamodel.SequenceI; |
27 |
|
import jalview.util.MessageManager; |
28 |
|
|
|
|
| 0% |
Uncovered Elements: 124 (124) |
Complexity: 42 |
Complexity Density: 0.64 |
|
29 |
|
public class JnetAnnotationMaker |
30 |
|
{ |
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
31 |
0 |
public static void add_annotation(JPredFile prediction, AlignmentI al,... |
32 |
|
int firstSeq, boolean noMsa) throws Exception |
33 |
|
{ |
34 |
0 |
JnetAnnotationMaker.add_annotation(prediction, al, firstSeq, noMsa, |
35 |
|
(int[]) null); |
36 |
|
} |
37 |
|
|
38 |
|
|
39 |
|
|
40 |
|
|
41 |
|
@param |
42 |
|
|
43 |
|
@param |
44 |
|
|
45 |
|
@param |
46 |
|
|
47 |
|
|
48 |
|
@param |
49 |
|
|
50 |
|
@param |
51 |
|
|
52 |
|
|
53 |
|
|
|
|
| 0% |
Uncovered Elements: 121 (121) |
Complexity: 41 |
Complexity Density: 0.63 |
|
54 |
0 |
public static void add_annotation(JPredFile prediction, AlignmentI al,... |
55 |
|
int firstSeq, boolean noMsa, int[] delMap) throws Exception |
56 |
|
{ |
57 |
0 |
int i = 0; |
58 |
0 |
SequenceI[] preds = prediction.getSeqsAsArray(); |
59 |
|
|
60 |
|
|
61 |
0 |
SequenceI seqRef = al.getSequenceAt(firstSeq); |
62 |
0 |
int width = preds[0].getLength(); |
63 |
0 |
int[] gapmap = al.getSequenceAt(firstSeq).gapMap(); |
64 |
0 |
if ((delMap != null && delMap.length > width) |
65 |
|
|| (delMap == null && gapmap.length != width)) |
66 |
|
{ |
67 |
0 |
throw (new Exception(MessageManager.formatMessage( |
68 |
|
"exception.number_of_residues_in_query_sequence_differ_from_prediction", |
69 |
|
new String[] |
70 |
0 |
{ (delMap == null ? "" |
71 |
|
: MessageManager.getString("label.mapped")), |
72 |
|
al.getSequenceAt(firstSeq).getName(), |
73 |
|
al.getSequenceAt(firstSeq).getSequenceAsString(), |
74 |
|
Integer.valueOf(width).toString() }))); |
75 |
|
} |
76 |
|
|
77 |
0 |
AlignmentAnnotation annot; |
78 |
0 |
Annotation[] annotations = null; |
79 |
|
|
80 |
0 |
int existingAnnotations = 0; |
81 |
0 |
if (al.getAlignmentAnnotation() != null) |
82 |
|
{ |
83 |
0 |
existingAnnotations = al.getAlignmentAnnotation().length; |
84 |
|
} |
85 |
|
|
86 |
0 |
Annotation[] sol = new Annotation[al.getWidth()]; |
87 |
0 |
boolean firstsol = true; |
88 |
|
|
89 |
0 |
while (i < preds.length) |
90 |
|
{ |
91 |
0 |
String id = preds[i].getName().toUpperCase(); |
92 |
|
|
93 |
0 |
if (id.startsWith("LUPAS") || id.startsWith("JNET") |
94 |
|
|| id.startsWith("JPRED")) |
95 |
|
{ |
96 |
0 |
if (id.startsWith("JNETSOL")) |
97 |
|
{ |
98 |
0 |
float amnt = (id.endsWith("25") ? 3f |
99 |
0 |
: id.endsWith("5") ? 6f : 9f); |
100 |
0 |
for (int spos = 0; spos < width; spos++) |
101 |
|
{ |
102 |
0 |
int sposw = (delMap == null) ? gapmap[spos] |
103 |
|
: gapmap[delMap[spos]]; |
104 |
0 |
if (firstsol) |
105 |
|
{ |
106 |
0 |
sol[sposw] = new Annotation(0f); |
107 |
|
} |
108 |
0 |
if (preds[i].getCharAt(spos) == 'B' |
109 |
|
&& (sol[sposw].value == 0f || sol[sposw].value < amnt)) |
110 |
|
{ |
111 |
0 |
sol[sposw].value = amnt; |
112 |
|
} |
113 |
|
} |
114 |
0 |
firstsol = false; |
115 |
|
} |
116 |
|
else |
117 |
|
{ |
118 |
|
|
119 |
0 |
annotations = new Annotation[al.getWidth()]; |
120 |
|
|
121 |
|
|
122 |
|
|
123 |
|
|
124 |
0 |
if (id.equals("JNETPRED") || id.equals("JNETPSSM") |
125 |
|
|| id.equals("JNETFREQ") || id.equals("JNETHMM") |
126 |
|
|| id.equals("JNETALIGN") || id.equals("JPRED")) |
127 |
|
{ |
128 |
0 |
if (delMap == null) |
129 |
|
{ |
130 |
0 |
for (int j = 0; j < width; j++) |
131 |
|
{ |
132 |
0 |
annotations[gapmap[j]] = new Annotation("", "", |
133 |
|
preds[i].getCharAt(j), 0); |
134 |
|
} |
135 |
|
} |
136 |
|
else |
137 |
|
{ |
138 |
0 |
for (int j = 0; j < width; j++) |
139 |
|
{ |
140 |
0 |
annotations[gapmap[delMap[j]]] = new Annotation("", "", |
141 |
|
preds[i].getCharAt(j), 0); |
142 |
|
} |
143 |
|
} |
144 |
|
} |
145 |
0 |
else if (id.equals("JNETCONF")) |
146 |
|
{ |
147 |
0 |
if (delMap == null) |
148 |
|
{ |
149 |
0 |
for (int j = 0; j < width; j++) |
150 |
|
{ |
151 |
0 |
float value = new Float(preds[i].getCharAt(j) + "") |
152 |
|
.floatValue(); |
153 |
0 |
annotations[gapmap[j]] = new Annotation( |
154 |
|
preds[i].getCharAt(j) + "", "", |
155 |
|
preds[i].getCharAt(j), value); |
156 |
|
} |
157 |
|
} |
158 |
|
else |
159 |
|
{ |
160 |
0 |
for (int j = 0; j < width; j++) |
161 |
|
{ |
162 |
0 |
float value = new Float(preds[i].getCharAt(j) + "") |
163 |
|
.floatValue(); |
164 |
0 |
annotations[gapmap[delMap[j]]] = new Annotation( |
165 |
|
preds[i].getCharAt(j) + "", "", |
166 |
|
preds[i].getCharAt(j), value); |
167 |
|
} |
168 |
|
} |
169 |
|
} |
170 |
|
else |
171 |
|
{ |
172 |
0 |
if (delMap == null) |
173 |
|
{ |
174 |
0 |
for (int j = 0; j < width; j++) |
175 |
|
{ |
176 |
0 |
annotations[gapmap[j]] = new Annotation( |
177 |
|
preds[i].getCharAt(j) + "", "", ' ', 0); |
178 |
|
} |
179 |
|
} |
180 |
|
else |
181 |
|
{ |
182 |
0 |
for (int j = 0; j < width; j++) |
183 |
|
{ |
184 |
0 |
annotations[gapmap[delMap[j]]] = new Annotation( |
185 |
|
preds[i].getCharAt(j) + "", "", ' ', 0); |
186 |
|
} |
187 |
|
} |
188 |
|
} |
189 |
|
|
190 |
0 |
if (id.equals("JNETCONF")) |
191 |
|
{ |
192 |
0 |
annot = new AlignmentAnnotation(preds[i].getName(), |
193 |
|
"JPred Output", annotations, 0f, 10f, |
194 |
|
AlignmentAnnotation.BAR_GRAPH); |
195 |
|
} |
196 |
|
else |
197 |
|
{ |
198 |
0 |
annot = new AlignmentAnnotation(preds[i].getName(), |
199 |
|
"JPred Output", annotations); |
200 |
|
} |
201 |
|
|
202 |
0 |
if (seqRef != null) |
203 |
|
{ |
204 |
0 |
annot.createSequenceMapping(seqRef, 1, true); |
205 |
0 |
seqRef.addAlignmentAnnotation(annot); |
206 |
|
} |
207 |
|
|
208 |
0 |
al.addAnnotation(annot); |
209 |
0 |
al.setAnnotationIndex(annot, al.getAlignmentAnnotation().length |
210 |
|
- existingAnnotations - 1); |
211 |
|
} |
212 |
0 |
if (noMsa) |
213 |
|
{ |
214 |
0 |
al.deleteSequence(preds[i]); |
215 |
|
} |
216 |
|
} |
217 |
|
|
218 |
0 |
i++; |
219 |
|
} |
220 |
0 |
if (!firstsol) |
221 |
|
{ |
222 |
|
|
223 |
0 |
annot = new AlignmentAnnotation("Jnet Burial", |
224 |
|
"<html>Prediction of Solvent Accessibility<br/>levels are<ul><li>0 - Exposed</li><li>3 - 25% or more S.A. accessible</li><li>6 - 5% or more S.A. accessible</li><li>9 - Buried (<5% exposed)</li></ul>", |
225 |
|
sol, 0f, 9f, AlignmentAnnotation.BAR_GRAPH); |
226 |
|
|
227 |
0 |
annot.validateRangeAndDisplay(); |
228 |
0 |
if (seqRef != null) |
229 |
|
{ |
230 |
0 |
annot.createSequenceMapping(seqRef, 1, true); |
231 |
0 |
seqRef.addAlignmentAnnotation(annot); |
232 |
|
} |
233 |
0 |
al.addAnnotation(annot); |
234 |
0 |
al.setAnnotationIndex(annot, |
235 |
|
al.getAlignmentAnnotation().length - existingAnnotations - 1); |
236 |
|
} |
237 |
|
|
238 |
|
|
239 |
|
|
240 |
|
|
241 |
|
|
242 |
|
|
243 |
|
|
244 |
|
|
245 |
|
|
246 |
|
|
247 |
|
|
248 |
|
|
249 |
|
|
250 |
|
} |
251 |
|
} |