2 * Jalview - A Sequence Alignment Editor and Viewer (Version 2.8.2)
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
10 * of the License, or (at your option) any later version.
12 * Jalview is distributed in the hope that it will be useful, but
13 * WITHOUT ANY WARRANTY; without even the implied warranty
14 * of MERCHANTABILITY or FITNESS FOR A PARTICULAR
15 * PURPOSE. See the GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with Jalview. If not, see <http://www.gnu.org/licenses/>.
19 * The Jalview Authors are detailed in the 'AUTHORS' file.
23 import jalview.datamodel.*;
25 public class JnetAnnotationMaker
27 public static void add_annotation(JPredFile prediction, AlignmentI al,
28 int firstSeq, boolean noMsa) throws Exception
30 JnetAnnotationMaker.add_annotation(prediction, al, firstSeq, noMsa,
35 * adds the annotation parsed by prediction to al.
42 * int the index of the sequence to attach the annotation to (usually
47 * mapping from columns in JPredFile prediction to residue number in
48 * al.getSequence(firstSeq)
50 public static void add_annotation(JPredFile prediction, AlignmentI al,
51 int firstSeq, boolean noMsa, int[] delMap) throws Exception
54 SequenceI[] preds = prediction.getSeqsAsArray();
55 // in the future we could search for the query
56 // sequence in the alignment before calling this function.
57 SequenceI seqRef = al.getSequenceAt(firstSeq);
58 int width = preds[0].getSequence().length;
59 int[] gapmap = al.getSequenceAt(firstSeq).gapMap();
60 if ((delMap != null && delMap.length > width)
61 || (delMap == null && gapmap.length != width))
63 throw (new Exception("Number of residues in "
64 + (delMap == null ? "" : " mapped ")
65 + "supposed query sequence ('"
66 + al.getSequenceAt(firstSeq).getName() + "'\n"
67 + al.getSequenceAt(firstSeq).getSequenceAsString()
68 + ")\ndiffer from number of prediction sites in prediction ("
72 AlignmentAnnotation annot;
73 Annotation[] annotations = null;
75 int existingAnnotations = 0;
76 if (al.getAlignmentAnnotation() != null)
78 existingAnnotations = al.getAlignmentAnnotation().length;
81 while (i < preds.length)
83 String id = preds[i].getName().toUpperCase();
85 if (id.startsWith("LUPAS") || id.startsWith("JNET")
86 || id.startsWith("JPRED"))
88 annotations = new Annotation[al.getWidth()];
90 * if (delMap!=null) { for (int j=0; j<annotations.length; j++)
91 * annotations[j] = new Annotation("","",'',0); }
93 if (id.equals("JNETPRED") || id.equals("JNETPSSM")
94 || id.equals("JNETFREQ") || id.equals("JNETHMM")
95 || id.equals("JNETALIGN") || id.equals("JPRED"))
99 for (int j = 0; j < width; j++)
101 annotations[gapmap[j]] = new Annotation("", "",
102 preds[i].getCharAt(j), 0);
107 for (int j = 0; j < width; j++)
109 annotations[gapmap[delMap[j]]] = new Annotation("", "",
110 preds[i].getCharAt(j), 0);
114 else if (id.equals("JNETCONF"))
118 for (int j = 0; j < width; j++)
120 float value = new Float(preds[i].getCharAt(j) + "")
122 annotations[gapmap[j]] = new Annotation(preds[i].getCharAt(j)
123 + "", "", preds[i].getCharAt(j), value);
128 for (int j = 0; j < width; j++)
130 float value = new Float(preds[i].getCharAt(j) + "")
132 annotations[gapmap[delMap[j]]] = new Annotation(
133 preds[i].getCharAt(j) + "", "",
134 preds[i].getCharAt(j), value);
142 for (int j = 0; j < width; j++)
144 annotations[gapmap[j]] = new Annotation(preds[i].getCharAt(j)
150 for (int j = 0; j < width; j++)
152 annotations[gapmap[delMap[j]]] = new Annotation(
153 preds[i].getCharAt(j) + "", "", ' ', 0);
158 if (id.equals("JNETCONF"))
160 annot = new AlignmentAnnotation(preds[i].getName(),
161 "JNet Output", annotations, 0f, 10f,
162 AlignmentAnnotation.BAR_GRAPH);
166 annot = new AlignmentAnnotation(preds[i].getName(),
167 "JNet Output", annotations);
172 annot.createSequenceMapping(seqRef, 1, true);
173 seqRef.addAlignmentAnnotation(annot);
176 al.addAnnotation(annot);
177 al.setAnnotationIndex(annot, al.getAlignmentAnnotation().length
178 - existingAnnotations - 1);
182 al.deleteSequence(preds[i]);
189 // Hashtable scores = prediction.getScores();
192 * addFloatAnnotations(al, gapmap, (Vector)scores.get("JNETPROPH"),
193 * "JnetpropH", "Jnet Helix Propensity", 0f,1f,1);
195 * addFloatAnnotations(al, gapmap, (Vector)scores.get("JNETPROPB"),
196 * "JnetpropB", "Jnet Beta Sheet Propensity", 0f,1f,1);
198 * addFloatAnnotations(al, gapmap, (Vector)scores.get("JNETPROPC"),
199 * "JnetpropC", "Jnet Coil Propensity", 0f,1f,1);