2 * Jalview - A Sequence Alignment Editor and Viewer
\r
3 * Copyright (C) 2007 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
27 * @version $Revision$
\r
29 public class SequenceFeature
\r
35 public String description;
\r
36 public Hashtable otherDetails;
\r
37 public java.util.Vector links;
\r
39 // Feature group can be set from a features file
\r
40 // as a group of features between STARTGROUP and ENDGROUP markers
\r
41 public String featureGroup;
\r
43 public SequenceFeature()
\r
47 * Constructs a duplicate feature.
\r
48 * Note: Uses clone on the otherDetails so only shallow copies are made
\r
49 * of additional properties and method will silently fail if unclonable
\r
50 * objects are found in the hash.
\r
53 public SequenceFeature(SequenceFeature cpy)
\r
60 if (cpy.type != null)
\r
62 type = new String(cpy.type);
\r
64 if (cpy.description != null)
\r
66 description = new String(cpy.description);
\r
68 if (cpy.featureGroup != null)
\r
70 featureGroup = new String(cpy.featureGroup);
\r
72 if (cpy.otherDetails != null)
\r
76 otherDetails = (Hashtable) cpy.otherDetails.clone();
\r
80 // Uncloneable objects in the otherDetails - don't complain
\r
83 if (cpy.links != null && cpy.links.size() > 0)
\r
85 links = new Vector();
\r
86 for (int i = 0, iSize = cpy.links.size(); i < iSize; i++)
\r
88 links.setElementAt(cpy.links.elementAt(i), i);
\r
94 public SequenceFeature(String type,
\r
98 String featureGroup)
\r
101 this.description = desc;
\r
102 setValue("status", status);
\r
103 this.begin = begin;
\r
105 this.featureGroup = featureGroup;
\r
108 public SequenceFeature(String type,
\r
110 int begin, int end,
\r
112 String featureGroup)
\r
115 this.description = desc;
\r
116 this.begin = begin;
\r
118 this.score = score;
\r
119 this.featureGroup = featureGroup;
\r
122 public boolean equals(SequenceFeature sf)
\r
124 if (begin != sf.begin
\r
126 || score != sf.score)
\r
131 if (! (type + description + featureGroup).equals
\r
132 (sf.type + sf.description + sf.featureGroup))
\r
143 * @return DOCUMENT ME!
\r
145 public int getBegin()
\r
150 public void setBegin(int start)
\r
152 this.begin = start;
\r
158 * @return DOCUMENT ME!
\r
160 public int getEnd()
\r
165 public void setEnd(int end)
\r
173 * @return DOCUMENT ME!
\r
175 public String getType()
\r
180 public void setType(String type)
\r
188 * @return DOCUMENT ME!
\r
190 public String getDescription()
\r
192 return description;
\r
195 public void setDescription(String desc)
\r
197 description = desc;
\r
200 public String getFeatureGroup()
\r
202 return featureGroup;
\r
205 public void setFeatureGroup(String featureGroup)
\r
207 this.featureGroup = featureGroup;
\r
210 public void addLink(String labelLink)
\r
214 links = new java.util.Vector();
\r
217 links.insertElementAt(labelLink, 0);
\r
220 public float getScore()
\r
225 public void setScore(float value)
\r
231 * Used for getting values which are not in the
\r
232 * basic set. eg STRAND, FRAME for GFF file
\r
233 * @param key String
\r
235 public Object getValue(String key)
\r
237 if (otherDetails == null)
\r
243 return otherDetails.get(key);
\r
248 * Used for setting values which are not in the
\r
249 * basic set. eg STRAND, FRAME for GFF file
\r
250 * @param key eg STRAND
\r
251 * @param value eg +
\r
253 public void setValue(String key, Object value)
\r
257 if (otherDetails == null)
\r
259 otherDetails = new Hashtable();
\r
262 otherDetails.put(key, value);
\r
267 * The following methods are added to maintain
\r
268 * the castor Uniprot mapping file for the moment.
\r
270 public void setStatus(String status)
\r
272 setValue("status", status);
\r
275 public String getStatus()
\r
277 if (otherDetails != null)
\r
279 return otherDetails.get("status").toString();
\r
287 public void setPosition(int pos)
\r
293 public int getPosition()
\r