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)
29 JnetAnnotationMaker.add_annotation(prediction, al, firstSeq, noMsa, (int[])null);
33 * adds the annotation parsed by prediction to al.
34 * @param prediction JPredFile
35 * @param al AlignmentI
36 * @param firstSeq int the index of the sequence to attach the annotation to (usually zero)
37 * @param noMsa boolean
38 * @param delMap mapping from columns in JPredFile prediction to residue number in al.getSequence(firstSeq)
40 public static void add_annotation(JPredFile prediction, AlignmentI al,
41 int firstSeq, boolean noMsa, int[] delMap)
45 SequenceI[] preds = prediction.getSeqsAsArray();
46 // in the future we could search for the query
47 // sequence in the alignment before calling this function.
48 SequenceI seqRef = al.getSequenceAt(firstSeq);
49 int width = preds[0].getSequence().length;
50 int[] gapmap = al.getSequenceAt(firstSeq).gapMap();
51 if ( (delMap != null && delMap.length > width) ||
52 (delMap == null && gapmap.length != width))
55 "Number of residues in " + (delMap == null ? "" : " mapped ") +
56 "supposed query sequence ('" +
57 al.getSequenceAt(firstSeq).getName() + "'\n" +
58 al.getSequenceAt(firstSeq).getSequenceAsString() +
59 ")\ndiffer from number of prediction sites in prediction (" + width +
63 AlignmentAnnotation annot;
64 Annotation[] annotations = null;
66 int existingAnnotations = 0;
67 if (al.getAlignmentAnnotation() != null)
69 existingAnnotations = al.getAlignmentAnnotation().length;
72 while (i < preds.length)
74 String id = preds[i].getName().toUpperCase();
76 if (id.startsWith("LUPAS") || id.startsWith("JNET") ||
77 id.startsWith("JPRED"))
79 annotations = new Annotation[al.getWidth()];
80 /* if (delMap!=null) {
81 for (int j=0; j<annotations.length; j++)
82 annotations[j] = new Annotation("","",'',0);
85 if (id.equals("JNETPRED") || id.equals("JNETPSSM") ||
86 id.equals("JNETFREQ") || id.equals("JNETHMM") ||
87 id.equals("JNETALIGN") || id.equals("JPRED"))
91 for (int j = 0; j < width; j++)
93 annotations[gapmap[j]] = new Annotation("", "",
94 preds[i].getCharAt(j), 0);
99 for (int j = 0; j < width; j++)
101 annotations[gapmap[delMap[j]]] = new Annotation("", "",
102 preds[i].getCharAt(j), 0);
106 else if (id.equals("JNETCONF"))
110 for (int j = 0; j < width; j++)
112 float value = new Float(preds[i].getCharAt(
113 j) + "").floatValue();
114 annotations[gapmap[j]] = new Annotation(preds[i].getCharAt(
115 j) + "", "", preds[i].getCharAt(j),
121 for (int j = 0; j < width; j++)
123 float value = new Float(preds[i].getCharAt(
124 j) + "").floatValue();
125 annotations[gapmap[delMap[j]]] = new Annotation(preds[i].
127 j) + "", "", preds[i].getCharAt(j),
136 for (int j = 0; j < width; j++)
138 annotations[gapmap[j]] = new Annotation(preds[i].getCharAt(
139 j) + "", "", ' ', 0);
144 for (int j = 0; j < width; j++)
146 annotations[gapmap[delMap[j]]] = new Annotation(preds[i].
148 j) + "", "", ' ', 0);
153 if (id.equals("JNETCONF"))
155 annot = new AlignmentAnnotation(preds[i].getName(),
156 "JNet Output", annotations, 0f,
158 AlignmentAnnotation.BAR_GRAPH);
162 annot = new AlignmentAnnotation(preds[i].getName(),
163 "JNet Output", annotations);
168 annot.createSequenceMapping(seqRef, 1, true);
169 seqRef.addAlignmentAnnotation(annot);
172 al.addAnnotation(annot);
173 al.setAnnotationIndex(annot,
174 al.getAlignmentAnnotation().
175 length - existingAnnotations - 1);
179 al.deleteSequence(preds[i]);
186 //Hashtable scores = prediction.getScores();
188 /* addFloatAnnotations(al, gapmap, (Vector)scores.get("JNETPROPH"),
189 "JnetpropH", "Jnet Helix Propensity", 0f,1f,1);
191 addFloatAnnotations(al, gapmap, (Vector)scores.get("JNETPROPB"),
192 "JnetpropB", "Jnet Beta Sheet Propensity", 0f,1f,1);
194 addFloatAnnotations(al, gapmap, (Vector)scores.get("JNETPROPC"),
195 "JnetpropC", "Jnet Coil Propensity", 0f,1f,1);