2 * Jalview - A Sequence Alignment Editor and Viewer
3 * Copyright (C) 2007 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)
28 JnetAnnotationMaker.add_annotation(prediction, al, firstSeq, noMsa, (int[])null);
32 * adds the annotation parsed by prediction to al.
33 * @param prediction JPredFile
34 * @param al AlignmentI
35 * @param firstSeq int the index of the sequence to attach the annotation to (usually zero)
36 * @param noMsa boolean
37 * @param delMap mapping from columns in JPredFile prediction to residue number in al.getSequence(firstSeq)
39 public static void add_annotation(JPredFile prediction, AlignmentI al,
40 int firstSeq, boolean noMsa, int[] delMap)
44 SequenceI[] preds = prediction.getSeqsAsArray();
45 // in the future we could search for the query
46 // sequence in the alignment before calling this function.
47 SequenceI seqRef = al.getSequenceAt(firstSeq);
48 int width = preds[0].getSequence().length;
49 int[] gapmap = al.getSequenceAt(firstSeq).gapMap();
50 if ( (delMap != null && delMap.length > width) ||
51 (delMap == null && gapmap.length != width))
54 "Number of residues in " + (delMap == null ? "" : " mapped ") +
55 "supposed query sequence ('" +
56 al.getSequenceAt(firstSeq).getName() + "'\n" +
57 al.getSequenceAt(firstSeq).getSequenceAsString() +
58 ")\ndiffer from number of prediction sites in prediction (" + width +
62 AlignmentAnnotation annot;
63 Annotation[] annotations = null;
65 int existingAnnotations = 0;
66 if (al.getAlignmentAnnotation() != null)
68 existingAnnotations = al.getAlignmentAnnotation().length;
71 while (i < preds.length)
73 String id = preds[i].getName().toUpperCase();
75 if (id.startsWith("LUPAS") || id.startsWith("JNET") ||
76 id.startsWith("JPRED"))
78 annotations = new Annotation[al.getWidth()];
79 /* if (delMap!=null) {
80 for (int j=0; j<annotations.length; j++)
81 annotations[j] = new Annotation("","",'',0);
84 if (id.equals("JNETPRED") || id.equals("JNETPSSM") ||
85 id.equals("JNETFREQ") || id.equals("JNETHMM") ||
86 id.equals("JNETALIGN") || id.equals("JPRED"))
90 for (int j = 0; j < width; j++)
92 annotations[gapmap[j]] = new Annotation("", "",
93 preds[i].getCharAt(j), 0);
98 for (int j = 0; j < width; j++)
100 annotations[gapmap[delMap[j]]] = new Annotation("", "",
101 preds[i].getCharAt(j), 0);
105 else if (id.equals("JNETCONF"))
109 for (int j = 0; j < width; j++)
111 float value = new Float(preds[i].getCharAt(
112 j) + "").floatValue();
113 annotations[gapmap[j]] = new Annotation(preds[i].getCharAt(
114 j) + "", "", preds[i].getCharAt(j),
120 for (int j = 0; j < width; j++)
122 float value = new Float(preds[i].getCharAt(
123 j) + "").floatValue();
124 annotations[gapmap[delMap[j]]] = new Annotation(preds[i].
126 j) + "", "", preds[i].getCharAt(j),
135 for (int j = 0; j < width; j++)
137 annotations[gapmap[j]] = new Annotation(preds[i].getCharAt(
138 j) + "", "", ' ', 0);
143 for (int j = 0; j < width; j++)
145 annotations[gapmap[delMap[j]]] = new Annotation(preds[i].
147 j) + "", "", ' ', 0);
152 if (id.equals("JNETCONF"))
154 annot = new AlignmentAnnotation(preds[i].getName(),
155 "JNet Output", annotations, 0f,
157 AlignmentAnnotation.BAR_GRAPH);
161 annot = new AlignmentAnnotation(preds[i].getName(),
162 "JNet Output", annotations);
167 annot.createSequenceMapping(seqRef, 1, true);
168 seqRef.addAlignmentAnnotation(annot);
171 al.addAnnotation(annot);
172 al.setAnnotationIndex(annot,
173 al.getAlignmentAnnotation().
174 length - existingAnnotations - 1);
178 al.deleteSequence(preds[i]);
185 //Hashtable scores = prediction.getScores();
187 /* addFloatAnnotations(al, gapmap, (Vector)scores.get("JNETPROPH"),
188 "JnetpropH", "Jnet Helix Propensity", 0f,1f,1);
190 addFloatAnnotations(al, gapmap, (Vector)scores.get("JNETPROPB"),
191 "JnetpropB", "Jnet Beta Sheet Propensity", 0f,1f,1);
193 addFloatAnnotations(al, gapmap, (Vector)scores.get("JNETPROPC"),
194 "JnetpropC", "Jnet Coil Propensity", 0f,1f,1);