2 * Jalview - A Sequence Alignment Editor and Viewer (Version 2.8.0b1)
3 * Copyright (C) 2014 The Jalview Authors
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/>.
17 * The Jalview Authors are detailed in the 'AUTHORS' file.
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 (usually
45 * mapping from columns in JPredFile prediction to residue number in
46 * 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("", "",
100 preds[i].getCharAt(j), 0);
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(
131 preds[i].getCharAt(j) + "", "",
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(
151 preds[i].getCharAt(j) + "", "", ' ', 0);
156 if (id.equals("JNETCONF"))
158 annot = new AlignmentAnnotation(preds[i].getName(),
159 "JNet Output", annotations, 0f, 10f,
160 AlignmentAnnotation.BAR_GRAPH);
164 annot = new AlignmentAnnotation(preds[i].getName(),
165 "JNet Output", annotations);
170 annot.createSequenceMapping(seqRef, 1, true);
171 seqRef.addAlignmentAnnotation(annot);
174 al.addAnnotation(annot);
175 al.setAnnotationIndex(annot, al.getAlignmentAnnotation().length
176 - existingAnnotations - 1);
180 al.deleteSequence(preds[i]);
187 // Hashtable scores = prediction.getScores();
190 * addFloatAnnotations(al, gapmap, (Vector)scores.get("JNETPROPH"),
191 * "JnetpropH", "Jnet Helix Propensity", 0f,1f,1);
193 * addFloatAnnotations(al, gapmap, (Vector)scores.get("JNETPROPB"),
194 * "JnetpropB", "Jnet Beta Sheet Propensity", 0f,1f,1);
196 * addFloatAnnotations(al, gapmap, (Vector)scores.get("JNETPROPC"),
197 * "JnetpropC", "Jnet Coil Propensity", 0f,1f,1);