2 * Jalview - A Sequence Alignment Editor and Viewer (Version 2.4)
3 * Copyright (C) 2008 AM Waterhouse, J Procter, G Barton, M Clamp, S Searle
5 * This program is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU General Public License
7 * as published by the Free Software Foundation; either version 2
8 * of the License, or (at your option) any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
21 import jalview.datamodel.*;
23 public class JnetAnnotationMaker
25 public static void add_annotation(JPredFile prediction, AlignmentI al,
26 int firstSeq, boolean noMsa) throws Exception
28 JnetAnnotationMaker.add_annotation(prediction, al, firstSeq, noMsa,
33 * adds the annotation parsed by prediction to al.
40 * int the index of the sequence to attach the annotation to
45 * mapping from columns in JPredFile prediction to residue
46 * number in al.getSequence(firstSeq)
48 public static void add_annotation(JPredFile prediction, AlignmentI al,
49 int firstSeq, boolean noMsa, int[] delMap) throws Exception
52 SequenceI[] preds = prediction.getSeqsAsArray();
53 // in the future we could search for the query
54 // sequence in the alignment before calling this function.
55 SequenceI seqRef = al.getSequenceAt(firstSeq);
56 int width = preds[0].getSequence().length;
57 int[] gapmap = al.getSequenceAt(firstSeq).gapMap();
58 if ((delMap != null && delMap.length > width)
59 || (delMap == null && gapmap.length != width))
61 throw (new Exception("Number of residues in "
62 + (delMap == null ? "" : " mapped ")
63 + "supposed query sequence ('"
64 + al.getSequenceAt(firstSeq).getName() + "'\n"
65 + al.getSequenceAt(firstSeq).getSequenceAsString()
66 + ")\ndiffer from number of prediction sites in prediction ("
70 AlignmentAnnotation annot;
71 Annotation[] annotations = null;
73 int existingAnnotations = 0;
74 if (al.getAlignmentAnnotation() != null)
76 existingAnnotations = al.getAlignmentAnnotation().length;
79 while (i < preds.length)
81 String id = preds[i].getName().toUpperCase();
83 if (id.startsWith("LUPAS") || id.startsWith("JNET")
84 || id.startsWith("JPRED"))
86 annotations = new Annotation[al.getWidth()];
88 * if (delMap!=null) { for (int j=0; j<annotations.length; j++)
89 * annotations[j] = new Annotation("","",'',0); }
91 if (id.equals("JNETPRED") || id.equals("JNETPSSM")
92 || id.equals("JNETFREQ") || id.equals("JNETHMM")
93 || id.equals("JNETALIGN") || id.equals("JPRED"))
97 for (int j = 0; j < width; j++)
99 annotations[gapmap[j]] = new Annotation("", "", preds[i]
105 for (int j = 0; j < width; j++)
107 annotations[gapmap[delMap[j]]] = new Annotation("", "",
108 preds[i].getCharAt(j), 0);
112 else if (id.equals("JNETCONF"))
116 for (int j = 0; j < width; j++)
118 float value = new Float(preds[i].getCharAt(j) + "")
120 annotations[gapmap[j]] = new Annotation(preds[i].getCharAt(j)
121 + "", "", preds[i].getCharAt(j), value);
126 for (int j = 0; j < width; j++)
128 float value = new Float(preds[i].getCharAt(j) + "")
130 annotations[gapmap[delMap[j]]] = new Annotation(preds[i]
132 + "", "", preds[i].getCharAt(j), value);
140 for (int j = 0; j < width; j++)
142 annotations[gapmap[j]] = new Annotation(preds[i].getCharAt(j)
148 for (int j = 0; j < width; j++)
150 annotations[gapmap[delMap[j]]] = new Annotation(preds[i]
157 if (id.equals("JNETCONF"))
159 annot = new AlignmentAnnotation(preds[i].getName(),
160 "JNet Output", annotations, 0f, 10f,
161 AlignmentAnnotation.BAR_GRAPH);
165 annot = new AlignmentAnnotation(preds[i].getName(),
166 "JNet Output", annotations);
171 annot.createSequenceMapping(seqRef, 1, true);
172 seqRef.addAlignmentAnnotation(annot);
175 al.addAnnotation(annot);
176 al.setAnnotationIndex(annot, al.getAlignmentAnnotation().length
177 - existingAnnotations - 1);
181 al.deleteSequence(preds[i]);
188 // Hashtable scores = prediction.getScores();
191 * addFloatAnnotations(al, gapmap, (Vector)scores.get("JNETPROPH"),
192 * "JnetpropH", "Jnet Helix Propensity", 0f,1f,1);
194 * addFloatAnnotations(al, gapmap, (Vector)scores.get("JNETPROPB"),
195 * "JnetpropB", "Jnet Beta Sheet Propensity", 0f,1f,1);
197 * addFloatAnnotations(al, gapmap, (Vector)scores.get("JNETPROPC"),
198 * "JnetpropC", "Jnet Coil Propensity", 0f,1f,1);