2 * Jalview - A Sequence Alignment Editor and Viewer (Version 2.4)
3 * Copyright (C) 2008 AM Waterhouse, J Procter, G Barton, M Clamp, S Searle
5 * This program is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU General Public License
7 * as published by the Free Software Foundation; either version 2
8 * of the License, or (at your option) any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
19 package jalview.datamodel;
29 public class SequenceFeature
39 public String description;
41 public Hashtable otherDetails;
43 public java.util.Vector links;
45 // Feature group can be set from a features file
46 // as a group of features between STARTGROUP and ENDGROUP markers
47 public String featureGroup;
49 public SequenceFeature()
54 * Constructs a duplicate feature. Note: Uses clone on the otherDetails so
55 * only shallow copies are made of additional properties and method will
56 * silently fail if unclonable objects are found in the hash.
60 public SequenceFeature(SequenceFeature cpy)
69 type = new String(cpy.type);
71 if (cpy.description != null)
73 description = new String(cpy.description);
75 if (cpy.featureGroup != null)
77 featureGroup = new String(cpy.featureGroup);
79 if (cpy.otherDetails != null)
83 otherDetails = (Hashtable) cpy.otherDetails.clone();
86 // Uncloneable objects in the otherDetails - don't complain
89 if (cpy.links != null && cpy.links.size() > 0)
92 for (int i = 0, iSize = cpy.links.size(); i < iSize; i++)
94 links.addElement(cpy.links.elementAt(i));
100 public SequenceFeature(String type, String desc, String status,
101 int begin, int end, String featureGroup)
104 this.description = desc;
105 setValue("status", status);
108 this.featureGroup = featureGroup;
111 public SequenceFeature(String type, String desc, int begin, int end,
112 float score, String featureGroup)
115 this.description = desc;
119 this.featureGroup = featureGroup;
122 public boolean equals(SequenceFeature sf)
124 if (begin != sf.begin || end != sf.end || score != sf.score)
129 if (!(type + description + featureGroup).equals(sf.type
130 + sf.description + sf.featureGroup))
141 * @return DOCUMENT ME!
143 public int getBegin()
148 public void setBegin(int start)
156 * @return DOCUMENT ME!
163 public void setEnd(int end)
171 * @return DOCUMENT ME!
173 public String getType()
178 public void setType(String type)
186 * @return DOCUMENT ME!
188 public String getDescription()
193 public void setDescription(String desc)
198 public String getFeatureGroup()
203 public void setFeatureGroup(String featureGroup)
205 this.featureGroup = featureGroup;
208 public void addLink(String labelLink)
212 links = new java.util.Vector();
215 links.insertElementAt(labelLink, 0);
218 public float getScore()
223 public void setScore(float value)
229 * Used for getting values which are not in the basic set. eg STRAND, FRAME
235 public Object getValue(String key)
237 if (otherDetails == null)
243 return otherDetails.get(key);
248 * Used for setting values which are not in the basic set. eg STRAND, FRAME
256 public void setValue(String key, Object value)
260 if (otherDetails == null)
262 otherDetails = new Hashtable();
265 otherDetails.put(key, value);
270 * The following methods are added to maintain the castor Uniprot mapping file
273 public void setStatus(String status)
275 setValue("status", status);
278 public String getStatus()
280 if (otherDetails != null)
282 String stat = (String) otherDetails.get("status");
284 return new String(stat);
289 public void setPosition(int pos)
295 public int getPosition()