2 * Jalview - A Sequence Alignment Editor and Viewer
\r
3 * Copyright (C) 2005 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
19 package jalview.datamodel;
\r
26 * @version $Revision$
\r
28 public class AlignmentAnnotation
\r
30 public SequenceI sequenceRef;
\r
32 /** This annotation is the original loaded annotation
\r
33 * without any gaps. It is necessary to adjust the annotation
\r
34 * if sequences are updated */
\r
35 public AlignmentAnnotation datasetAnnotation;
\r
37 /** DOCUMENT ME!! */
\r
38 public String label;
\r
40 /** DOCUMENT ME!! */
\r
41 public String description;
\r
43 /** DOCUMENT ME!! */
\r
44 public Annotation[] annotations;
\r
47 /** DOCUMENT ME!! */
\r
48 public float graphMin;
\r
50 /** DOCUMENT ME!! */
\r
51 public float graphMax;
\r
53 public GraphLine threshold;
\r
55 // Graphical hints and tips
\r
57 /** DOCUMENT ME!! */
\r
58 public boolean editable = false;
\r
60 /** DOCUMENT ME!! */
\r
61 public boolean hasIcons; //
\r
63 /** DOCUMENT ME!! */
\r
64 public boolean hasText;
\r
66 /** DOCUMENT ME!! */
\r
67 public boolean visible = true;
\r
69 public int graphGroup = -1;
\r
71 /** DOCUMENT ME!! */
\r
72 public int height = 0;
\r
74 public int graph = 0;
\r
76 public int graphHeight = 40;
\r
78 public static final int NO_GRAPH = 0;
\r
80 public static final int BAR_GRAPH = 1;
\r
82 public static final int LINE_GRAPH = 2;
\r
84 public static int getGraphValueFromString(String string)
\r
86 if(string.equalsIgnoreCase("BAR_GRAPH"))
\r
88 else if(string.equalsIgnoreCase("LINE_GRAPH"))
\r
95 * Creates a new AlignmentAnnotation object.
\r
97 * @param label DOCUMENT ME!
\r
98 * @param description DOCUMENT ME!
\r
99 * @param annotations DOCUMENT ME!
\r
101 public AlignmentAnnotation(String label, String description,
\r
102 Annotation[] annotations)
\r
104 // always editable?
\r
106 this.label = label;
\r
107 this.description = description;
\r
108 this.annotations = annotations;
\r
110 for (int i = 0; i < annotations.length; i++)
\r
112 if ((annotations[i] != null) &&
\r
113 ((annotations[i].secondaryStructure == 'H') ||
\r
114 (annotations[i].secondaryStructure == 'E')))
\r
119 if ((annotations[i] != null) &&
\r
120 (annotations[i].displayCharacter.length() > 0))
\r
128 * Creates a new AlignmentAnnotation object.
\r
130 * @param label DOCUMENT ME!
\r
131 * @param description DOCUMENT ME!
\r
132 * @param annotations DOCUMENT ME!
\r
133 * @param min DOCUMENT ME!
\r
134 * @param max DOCUMENT ME!
\r
135 * @param winLength DOCUMENT ME!
\r
137 public AlignmentAnnotation(String label, String description,
\r
138 Annotation[] annotations, float min, float max, int graphType)
\r
140 // graphs are not editable
\r
141 this.label = label;
\r
142 this.description = description;
\r
143 this.annotations = annotations;
\r
149 for (int i = 0; i < annotations.length; i++)
\r
151 if (annotations[i] == null)
\r
156 if (annotations[i].value > max)
\r
158 max = annotations[i].value;
\r
161 if (annotations[i].value < min)
\r
163 min = annotations[i].value;
\r
171 for (int i = 0; i < annotations.length; i++)
\r
173 if ((annotations[i] != null) &&
\r
174 ((annotations[i].secondaryStructure == 'H') ||
\r
175 (annotations[i].secondaryStructure == 'E')))
\r
180 if ((annotations[i] != null) &&
\r
181 (annotations[i].displayCharacter.length() > 0))
\r
191 * @return DOCUMENT ME!
\r
193 public String toString()
\r
195 StringBuffer buffer = new StringBuffer();
\r
197 for (int i = 0; i < annotations.length; i++)
\r
199 if (annotations[i] != null)
\r
203 buffer.append(annotations[i].value);
\r
207 buffer.append(annotations[i].secondaryStructure);
\r
211 buffer.append(annotations[i].displayCharacter);
\r
215 buffer.append(", ");
\r
218 if (label.equals("Consensus"))
\r
220 buffer.append("\n");
\r
222 for (int i = 0; i < annotations.length; i++)
\r
224 if (annotations[i] != null)
\r
226 buffer.append(annotations[i].description);
\r
229 buffer.append(", ");
\r
233 return buffer.toString();
\r
236 public void setThreshold(GraphLine line)
\r
241 public GraphLine getThreshold()
\r
246 public void adjustForAlignment()
\r
248 int a=0, aSize = sequenceRef.getLength();
\r
251 Annotation[] temp = new Annotation[aSize];
\r
253 for (a = 0; a < aSize; a++)
\r
255 if (!jalview.util.Comparison.isGap(sequenceRef.getCharAt(a)))
\r
257 index = sequenceRef.findPosition(a);
\r
258 if(datasetAnnotation.annotations.length>index)
\r
259 temp[a] = datasetAnnotation.annotations[index];
\r
263 annotations = temp;
\r