2 * Jalview - A Sequence Alignment Editor and Viewer
\r
3 * Copyright (C) 2006 AM Waterhouse, J Procter, G Barton, M Clamp, S Searle
\r
5 * This program is free software; you can redistribute it and/or
\r
6 * modify it under the terms of the GNU General Public License
\r
7 * as published by the Free Software Foundation; either version 2
\r
8 * of the License, or (at your option) any later version.
\r
10 * This program is distributed in the hope that it will be useful,
\r
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
\r
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
\r
13 * GNU General Public License for more details.
\r
15 * You should have received a copy of the GNU General Public License
\r
16 * along with this program; if not, write to the Free Software
\r
17 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
\r
18 */package jalview.io;
\r
20 import jalview.datamodel.*;
\r
21 import java.net.URL;
\r
22 import java.io.BufferedReader;
\r
23 import java.io.InputStreamReader;
\r
24 import java.io.FileReader;
\r
27 public class JnetAnnotationMaker
\r
30 * adds the annotation parsed by prediction to al.
\r
31 * @param prediction JPredFile
\r
32 * @param al AlignmentI
\r
33 * @param FirstSeq int -
\r
34 * @param noMsa boolean
\r
36 public static void add_annotation(JPredFile prediction, AlignmentI al,
\r
37 int FirstSeq, boolean noMsa)
\r
41 SequenceI[] preds = prediction.getSeqsAsArray();
\r
42 // in the future we could search for the query
\r
43 // sequence in the alignment before calling this function.
\r
44 SequenceI seqRef = al.getSequenceAt(FirstSeq);
\r
45 int width = preds[0].getSequence().length();
\r
46 int[] gapmap = al.getSequenceAt(FirstSeq).gapMap();
\r
47 if (gapmap.length != width)
\r
49 throw (new Exception(
\r
50 "Number of residues in supposed query sequence ('" +
\r
51 al.getSequenceAt(FirstSeq).getName() + "'\n" +
\r
52 al.getSequenceAt(FirstSeq).getSequence() +
\r
53 ")\ndiffer from number of prediction sites in prediction (" + width +
\r
57 AlignmentAnnotation annot;
\r
58 Annotation[] annotations = null;
\r
60 while (i < preds.length)
\r
62 String id = preds[i].getName().toUpperCase();
\r
64 if (id.startsWith("LUPAS") || id.startsWith("JNET") ||
\r
65 id.startsWith("JPRED"))
\r
67 annotations = new Annotation[al.getWidth()];
\r
69 if (id.equals("JNETPRED") || id.equals("JNETPSSM") ||
\r
70 id.equals("JNETFREQ") || id.equals("JNETHMM") ||
\r
71 id.equals("JNETALIGN") || id.equals("JPRED"))
\r
73 for (int j = 0; j < width; j++)
\r
75 annotations[gapmap[j]] = new Annotation("", "",
\r
76 preds[i].getCharAt(j), 0);
\r
79 else if (id.equals("JNETCONF"))
\r
81 for (int j = 0; j < width; j++)
\r
83 float value = new Float(preds[i].getCharAt(
\r
84 j) + "").floatValue();
\r
85 annotations[gapmap[j]] = new Annotation(preds[i].getCharAt(
\r
86 j) + "", "", preds[i].getCharAt(j),
\r
92 for (int j = 0; j < width; j++)
\r
94 annotations[gapmap[j]] = new Annotation(preds[i].getCharAt(
\r
95 j) + "", "", ' ', 0);
\r
99 if (id.equals("JNETCONF"))
\r
101 annot = new AlignmentAnnotation(preds[i].getName(),
\r
102 "JNet Output", annotations, 0f,
\r
104 AlignmentAnnotation.BAR_GRAPH);
\r
108 annot = new AlignmentAnnotation(preds[i].getName(),
\r
109 "JNet Output", annotations);
\r
112 if (seqRef != null)
\r
114 annot.createSequenceMapping(seqRef, 0);
\r
115 seqRef.addAlignmentAnnotation(annot);
\r
118 al.addAnnotation(annot);
\r
122 al.deleteSequence(preds[i]);
\r
129 //Hashtable scores = prediction.getScores();
\r
131 /* addFloatAnnotations(al, gapmap, (Vector)scores.get("JNETPROPH"),
\r
132 "JnetpropH", "Jnet Helix Propensity", 0f,1f,1);
\r
134 addFloatAnnotations(al, gapmap, (Vector)scores.get("JNETPROPB"),
\r
135 "JnetpropB", "Jnet Beta Sheet Propensity", 0f,1f,1);
\r
137 addFloatAnnotations(al, gapmap, (Vector)scores.get("JNETPROPC"),
\r
138 "JnetpropC", "Jnet Coil Propensity", 0f,1f,1);
\r