Clover icon

Coverage Report

  1. Project Clover database Thu Nov 28 2024 18:06:40 GMT
  2. Package jalview.io

File JnetAnnotationMaker.java

 

Coverage histogram

../../img/srcFileCovDistChart0.png
63% of files have more coverage

Code metrics

56
66
2
1
253
182
42
0.64
33
2
21

Classes

Class Line # Actions
JnetAnnotationMaker 31 66 42
0.00%
 

Contributing tests

No tests hitting this source file were found.

Source view

1    /*
2    * Jalview - A Sequence Alignment Editor and Viewer ($$Version-Rel$$)
3    * Copyright (C) $$Year-Rel$$ The Jalview Authors
4    *
5    * This file is part of Jalview.
6    *
7    * Jalview is free software: you can redistribute it and/or
8    * modify it under the terms of the GNU General Public License
9    * as published by the Free Software Foundation, either version 3
10    * of the License, or (at your option) any later version.
11    *
12    * Jalview is distributed in the hope that it will be useful, but
13    * WITHOUT ANY WARRANTY; without even the implied warranty
14    * of MERCHANTABILITY or FITNESS FOR A PARTICULAR
15    * PURPOSE. See the GNU General Public License for more details.
16    *
17    * You should have received a copy of the GNU General Public License
18    * along with Jalview. If not, see <http://www.gnu.org/licenses/>.
19    * The Jalview Authors are detailed in the 'AUTHORS' file.
20    */
21    package jalview.io;
22   
23    import java.util.Locale;
24   
25    import jalview.datamodel.AlignmentAnnotation;
26    import jalview.datamodel.AlignmentI;
27    import jalview.datamodel.Annotation;
28    import jalview.datamodel.SequenceI;
29    import jalview.util.MessageManager;
30   
 
31    public class JnetAnnotationMaker
32    {
 
33  0 toggle public static void add_annotation(JPredFile prediction, AlignmentI al,
34    int firstSeq, boolean noMsa) throws Exception
35    {
36  0 JnetAnnotationMaker.add_annotation(prediction, al, firstSeq, noMsa,
37    (int[]) null);
38    }
39   
40    /**
41    * adds the annotation parsed by prediction to al.
42    *
43    * @param prediction
44    * JPredFile
45    * @param al
46    * AlignmentI
47    * @param firstSeq
48    * int the index of the sequence to attach the annotation to (usually
49    * zero)
50    * @param noMsa
51    * boolean
52    * @param delMap
53    * mapping from columns in JPredFile prediction to residue number in
54    * al.getSequence(firstSeq)
55    */
 
56  0 toggle public static void add_annotation(JPredFile prediction, AlignmentI al,
57    int firstSeq, boolean noMsa, int[] delMap) throws Exception
58    {
59  0 int i = 0;
60  0 SequenceI[] preds = prediction.getSeqsAsArray();
61    // in the future we could search for the query
62    // sequence in the alignment before calling this function.
63  0 SequenceI seqRef = al.getSequenceAt(firstSeq);
64  0 int width = preds[0].getLength();
65  0 int[] gapmap = al.getSequenceAt(firstSeq).gapMap();
66  0 if ((delMap != null && delMap.length > width)
67    || (delMap == null && gapmap.length != width))
68    {
69  0 throw (new Exception(MessageManager.formatMessage(
70    "exception.number_of_residues_in_query_sequence_differ_from_prediction",
71    new String[]
72  0 { (delMap == null ? ""
73    : MessageManager.getString("label.mapped")),
74    al.getSequenceAt(firstSeq).getName(),
75    al.getSequenceAt(firstSeq).getSequenceAsString(),
76    Integer.valueOf(width).toString() })));
77    }
78   
79  0 AlignmentAnnotation annot;
80  0 Annotation[] annotations = null;
81   
82  0 int existingAnnotations = 0;
83  0 if (al.getAlignmentAnnotation() != null)
84    {
85  0 existingAnnotations = al.getAlignmentAnnotation().length;
86    }
87   
88  0 Annotation[] sol = new Annotation[al.getWidth()];
89  0 boolean firstsol = true;
90   
91  0 while (i < preds.length)
92    {
93  0 String id = preds[i].getName().toUpperCase(Locale.ROOT);
94   
95  0 if (id.startsWith("LUPAS") || id.startsWith("JNET")
96    || id.startsWith("JPRED"))
97    {
98  0 if (id.startsWith("JNETSOL"))
99    {
100  0 float amnt = (id.endsWith("25") ? 3f
101  0 : id.endsWith("5") ? 6f : 9f);
102  0 for (int spos = 0; spos < width; spos++)
103    {
104  0 int sposw = (delMap == null) ? gapmap[spos]
105    : gapmap[delMap[spos]];
106  0 if (firstsol)
107    {
108  0 sol[sposw] = new Annotation(0f);
109    }
110  0 if (preds[i].getCharAt(spos) == 'B'
111    && (sol[sposw].value == 0f || sol[sposw].value < amnt))
112    {
113  0 sol[sposw].value = amnt;
114    }
115    }
116  0 firstsol = false;
117    }
118    else
119    {
120    // some other kind of annotation
121  0 annotations = new Annotation[al.getWidth()];
122    /*
123    * if (delMap!=null) { for (int j=0; j<annotations.length; j++)
124    * annotations[j] = new Annotation("","",'',0); }
125    */
126  0 if (id.equals("JNETPRED") || id.equals("JNETPSSM")
127    || id.equals("JNETFREQ") || id.equals("JNETHMM")
128    || id.equals("JNETALIGN") || id.equals("JPRED"))
129    {
130  0 if (delMap == null)
131    {
132  0 for (int j = 0; j < width; j++)
133    {
134  0 annotations[gapmap[j]] = new Annotation("", "",
135    preds[i].getCharAt(j), 0);
136    }
137    }
138    else
139    {
140  0 for (int j = 0; j < width; j++)
141    {
142  0 annotations[gapmap[delMap[j]]] = new Annotation("", "",
143    preds[i].getCharAt(j), 0);
144    }
145    }
146    }
147  0 else if (id.equals("JNETCONF"))
148    {
149  0 if (delMap == null)
150    {
151  0 for (int j = 0; j < width; j++)
152    {
153  0 float value = Float.valueOf(preds[i].getCharAt(j) + "")
154    .floatValue();
155  0 annotations[gapmap[j]] = new Annotation(
156    preds[i].getCharAt(j) + "", "",
157    preds[i].getCharAt(j), value);
158    }
159    }
160    else
161    {
162  0 for (int j = 0; j < width; j++)
163    {
164  0 float value = Float.valueOf(preds[i].getCharAt(j) + "")
165    .floatValue();
166  0 annotations[gapmap[delMap[j]]] = new Annotation(
167    preds[i].getCharAt(j) + "", "",
168    preds[i].getCharAt(j), value);
169    }
170    }
171    }
172    else
173    {
174  0 if (delMap == null)
175    {
176  0 for (int j = 0; j < width; j++)
177    {
178  0 annotations[gapmap[j]] = new Annotation(
179    preds[i].getCharAt(j) + "", "", ' ', 0);
180    }
181    }
182    else
183    {
184  0 for (int j = 0; j < width; j++)
185    {
186  0 annotations[gapmap[delMap[j]]] = new Annotation(
187    preds[i].getCharAt(j) + "", "", ' ', 0);
188    }
189    }
190    }
191   
192  0 if (id.equals("JNETCONF"))
193    {
194  0 annot = new AlignmentAnnotation(preds[i].getName(),
195    "JPred Output", annotations, 0f, 10f,
196    AlignmentAnnotation.BAR_GRAPH);
197    }
198    else
199    {
200  0 annot = new AlignmentAnnotation(preds[i].getName(),
201    "JPred Output", annotations);
202    }
203   
204  0 if (seqRef != null)
205    {
206  0 annot.createSequenceMapping(seqRef, 1, true);
207  0 seqRef.addAlignmentAnnotation(annot);
208    }
209   
210  0 al.addAnnotation(annot);
211  0 al.setAnnotationIndex(annot, al.getAlignmentAnnotation().length
212    - existingAnnotations - 1);
213    }
214  0 if (noMsa)
215    {
216  0 al.deleteSequence(preds[i]);
217    }
218    }
219   
220  0 i++;
221    }
222  0 if (!firstsol)
223    {
224    // add the solvent accessibility
225  0 annot = new AlignmentAnnotation("Jnet Burial",
226    "<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>",
227    sol, 0f, 9f, AlignmentAnnotation.BAR_GRAPH);
228   
229  0 annot.validateRangeAndDisplay();
230  0 if (seqRef != null)
231    {
232  0 annot.createSequenceMapping(seqRef, 1, true);
233  0 seqRef.addAlignmentAnnotation(annot);
234    }
235  0 al.addAnnotation(annot);
236  0 al.setAnnotationIndex(annot,
237    al.getAlignmentAnnotation().length - existingAnnotations - 1);
238    }
239    // Hashtable scores = prediction.getScores();
240   
241    /*
242    * addFloatAnnotations(al, gapmap, (Vector)scores.get("JNETPROPH"),
243    * "JnetpropH", "Jnet Helix Propensity", 0f,1f,1);
244    *
245    * addFloatAnnotations(al, gapmap, (Vector)scores.get("JNETPROPB"),
246    * "JnetpropB", "Jnet Beta Sheet Propensity", 0f,1f,1);
247    *
248    * addFloatAnnotations(al, gapmap, (Vector)scores.get("JNETPROPC"),
249    * "JnetpropC", "Jnet Coil Propensity", 0f,1f,1);
250    */
251   
252    }
253    }