2 * Jalview - A Sequence Alignment Editor and Viewer
3 * Copyright (C) 2006 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
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 {
26 JnetAnnotationMaker.add_annotation(prediction, al, firstSeq, noMsa, (int[]) null);
29 * adds the annotation parsed by prediction to al.
30 * @param prediction JPredFile
31 * @param al AlignmentI
32 * @param firstSeq int -
33 * @param noMsa boolean
34 * @param delMap mapping from columns in JPredFile prediction to residue number in al.getSequence(firstSeq)
36 public static void add_annotation(JPredFile prediction, AlignmentI al,
37 int firstSeq, boolean noMsa, int[] delMap)
41 SequenceI[] preds = prediction.getSeqsAsArray();
42 // in the future we could search for the query
43 // sequence in the alignment before calling this function.
44 SequenceI seqRef = al.getSequenceAt(firstSeq);
45 int width = preds[0].getSequence().length;
46 int[] gapmap = al.getSequenceAt(firstSeq).gapMap();
47 if ((delMap!=null && delMap.length > width) || (delMap==null && gapmap.length!=width))
50 "Number of residues in "+(delMap==null ? "" : " mapped ")+"supposed query sequence ('" +
51 al.getSequenceAt(firstSeq).getName() + "'\n" +
52 al.getSequenceAt(firstSeq).getSequenceAsString() +
53 ")\ndiffer from number of prediction sites in prediction (" + width +
57 AlignmentAnnotation annot;
58 Annotation[] annotations = null;
60 int existingAnnotations = 0;
61 if(al.getAlignmentAnnotation()!=null)
62 existingAnnotations = al.getAlignmentAnnotation().length;
65 while (i < preds.length)
67 String id = preds[i].getName().toUpperCase();
69 if (id.startsWith("LUPAS") || id.startsWith("JNET") ||
70 id.startsWith("JPRED"))
72 annotations = new Annotation[al.getWidth()];
73 /* if (delMap!=null) {
74 for (int j=0; j<annotations.length; j++)
75 annotations[j] = new Annotation("","",'',0);
78 if (id.equals("JNETPRED") || id.equals("JNETPSSM") ||
79 id.equals("JNETFREQ") || id.equals("JNETHMM") ||
80 id.equals("JNETALIGN") || id.equals("JPRED"))
83 for (int j = 0; j < width; j++)
85 annotations[gapmap[j]] = new Annotation("", "",
86 preds[i].getCharAt(j), 0);
89 for (int j = 0; j < width; j++)
91 annotations[gapmap[delMap[j]]] = new Annotation("", "",
92 preds[i].getCharAt(j), 0);
96 else if (id.equals("JNETCONF"))
99 for (int j = 0; j < width; j++)
101 float value = new Float(preds[i].getCharAt(
102 j) + "").floatValue();
103 annotations[gapmap[j]] = new Annotation(preds[i].getCharAt(
104 j) + "", "", preds[i].getCharAt(j),
108 for (int j = 0; j < width; j++)
110 float value = new Float(preds[i].getCharAt(
111 j) + "").floatValue();
112 annotations[gapmap[delMap[j]]] = new Annotation(preds[i].getCharAt(
113 j) + "", "", preds[i].getCharAt(j),
121 for (int j = 0; j < width; j++)
123 annotations[gapmap[j]] = new Annotation(preds[i].getCharAt(
124 j) + "", "", ' ', 0);
127 for (int j = 0; j < width; j++)
129 annotations[gapmap[delMap[j]]] = new Annotation(preds[i].getCharAt(
130 j) + "", "", ' ', 0);
135 if (id.equals("JNETCONF"))
137 annot = new AlignmentAnnotation(preds[i].getName(),
138 "JNet Output", annotations, 0f,
140 AlignmentAnnotation.BAR_GRAPH);
144 annot = new AlignmentAnnotation(preds[i].getName(),
145 "JNet Output", annotations);
150 annot.createSequenceMapping(seqRef, 1, true);
151 seqRef.addAlignmentAnnotation(annot);
154 al.addAnnotation(annot);
155 al.setAnnotationIndex(annot,
156 al.getAlignmentAnnotation().
157 length - existingAnnotations - 1);
161 al.deleteSequence(preds[i]);
168 //Hashtable scores = prediction.getScores();
170 /* addFloatAnnotations(al, gapmap, (Vector)scores.get("JNETPROPH"),
171 "JnetpropH", "Jnet Helix Propensity", 0f,1f,1);
173 addFloatAnnotations(al, gapmap, (Vector)scores.get("JNETPROPB"),
174 "JnetpropB", "Jnet Beta Sheet Propensity", 0f,1f,1);
176 addFloatAnnotations(al, gapmap, (Vector)scores.get("JNETPROPC"),
177 "JnetpropC", "Jnet Coil Propensity", 0f,1f,1);