2 * Jalview - A Sequence Alignment Editor and Viewer (Version 2.6)
3 * Copyright (C) 2010 J Procter, AM Waterhouse, G Barton, M Clamp, S Searle
5 * This file is part of Jalview.
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 of the License, or (at your option) any later version.
11 * Jalview is distributed in the hope that it will be useful, but
12 * WITHOUT ANY WARRANTY; without even the implied warranty
13 * of MERCHANTABILITY or FITNESS FOR A PARTICULAR
14 * PURPOSE. See the GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License along with Jalview. If not, see <http://www.gnu.org/licenses/>.
20 import jalview.datamodel.*;
22 public class JnetAnnotationMaker
24 public static void add_annotation(JPredFile prediction, AlignmentI al,
25 int firstSeq, boolean noMsa) throws Exception
27 JnetAnnotationMaker.add_annotation(prediction, al, firstSeq, noMsa,
32 * adds the annotation parsed by prediction to al.
39 * int the index of the sequence to attach the annotation to (usually
44 * mapping from columns in JPredFile prediction to residue number in
45 * al.getSequence(firstSeq)
47 public static void add_annotation(JPredFile prediction, AlignmentI al,
48 int firstSeq, boolean noMsa, int[] delMap) throws Exception
51 SequenceI[] preds = prediction.getSeqsAsArray();
52 // in the future we could search for the query
53 // sequence in the alignment before calling this function.
54 SequenceI seqRef = al.getSequenceAt(firstSeq);
55 int width = preds[0].getSequence().length;
56 int[] gapmap = al.getSequenceAt(firstSeq).gapMap();
57 if ((delMap != null && delMap.length > width)
58 || (delMap == null && gapmap.length != width))
60 throw (new Exception("Number of residues in "
61 + (delMap == null ? "" : " mapped ")
62 + "supposed query sequence ('"
63 + al.getSequenceAt(firstSeq).getName() + "'\n"
64 + al.getSequenceAt(firstSeq).getSequenceAsString()
65 + ")\ndiffer from number of prediction sites in prediction ("
69 AlignmentAnnotation annot;
70 Annotation[] annotations = null;
72 int existingAnnotations = 0;
73 if (al.getAlignmentAnnotation() != null)
75 existingAnnotations = al.getAlignmentAnnotation().length;
78 while (i < preds.length)
80 String id = preds[i].getName().toUpperCase();
82 if (id.startsWith("LUPAS") || id.startsWith("JNET")
83 || id.startsWith("JPRED"))
85 annotations = new Annotation[al.getWidth()];
87 * if (delMap!=null) { for (int j=0; j<annotations.length; j++)
88 * annotations[j] = new Annotation("","",'',0); }
90 if (id.equals("JNETPRED") || id.equals("JNETPSSM")
91 || id.equals("JNETFREQ") || id.equals("JNETHMM")
92 || id.equals("JNETALIGN") || id.equals("JPRED"))
96 for (int j = 0; j < width; j++)
98 annotations[gapmap[j]] = new Annotation("", "",
99 preds[i].getCharAt(j), 0);
104 for (int j = 0; j < width; j++)
106 annotations[gapmap[delMap[j]]] = new Annotation("", "",
107 preds[i].getCharAt(j), 0);
111 else if (id.equals("JNETCONF"))
115 for (int j = 0; j < width; j++)
117 float value = new Float(preds[i].getCharAt(j) + "")
119 annotations[gapmap[j]] = new Annotation(preds[i].getCharAt(j)
120 + "", "", preds[i].getCharAt(j), value);
125 for (int j = 0; j < width; j++)
127 float value = new Float(preds[i].getCharAt(j) + "")
129 annotations[gapmap[delMap[j]]] = new Annotation(
130 preds[i].getCharAt(j) + "", "",
131 preds[i].getCharAt(j), value);
139 for (int j = 0; j < width; j++)
141 annotations[gapmap[j]] = new Annotation(preds[i].getCharAt(j)
147 for (int j = 0; j < width; j++)
149 annotations[gapmap[delMap[j]]] = new Annotation(
150 preds[i].getCharAt(j) + "", "", ' ', 0);
155 if (id.equals("JNETCONF"))
157 annot = new AlignmentAnnotation(preds[i].getName(),
158 "JNet Output", annotations, 0f, 10f,
159 AlignmentAnnotation.BAR_GRAPH);
163 annot = new AlignmentAnnotation(preds[i].getName(),
164 "JNet Output", annotations);
169 annot.createSequenceMapping(seqRef, 1, true);
170 seqRef.addAlignmentAnnotation(annot);
173 al.addAnnotation(annot);
174 al.setAnnotationIndex(annot, al.getAlignmentAnnotation().length
175 - existingAnnotations - 1);
179 al.deleteSequence(preds[i]);
186 // Hashtable scores = prediction.getScores();
189 * addFloatAnnotations(al, gapmap, (Vector)scores.get("JNETPROPH"),
190 * "JnetpropH", "Jnet Helix Propensity", 0f,1f,1);
192 * addFloatAnnotations(al, gapmap, (Vector)scores.get("JNETPROPB"),
193 * "JnetpropB", "Jnet Beta Sheet Propensity", 0f,1f,1);
195 * addFloatAnnotations(al, gapmap, (Vector)scores.get("JNETPROPC"),
196 * "JnetpropC", "Jnet Coil Propensity", 0f,1f,1);