2 * Jalview - A Sequence Alignment Editor and Viewer
3 * Copyright (C) 2006 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;
21 import java.util.Enumeration;
22 import java.util.Hashtable;
23 import java.util.Vector;
31 public class SequenceFeature
37 public String description;
38 public Hashtable otherDetails;
39 public java.util.Vector links;
41 // Feature group can be set from a features file
42 // as a group of features between STARTGROUP and ENDGROUP markers
43 public String featureGroup;
45 public SequenceFeature()
48 * Constructs a duplicate feature.
49 * Note: Uses clone on the otherDetails so only shallow copies are made
50 * of additional properties and method will silently fail if unclonable
51 * objects are found in the hash.
54 public SequenceFeature(SequenceFeature cpy) {
59 type = new String(cpy.type);
60 description = new String(cpy.description);
61 featureGroup = new String(cpy.featureGroup);
62 if (cpy.otherDetails!=null) {
64 otherDetails = (Hashtable) cpy.otherDetails.clone();
65 } catch (Exception e) {
66 // Uncloneable objects in the otherDetails - don't complain
69 if (cpy.links!=null && cpy.links.size()>0) {
71 for (int i=0,iSize=cpy.links.size(); i<iSize; i++) {
72 links.setElementAt(cpy.links.elementAt(i), i);
77 public SequenceFeature(String type,
84 this.description = desc;
85 setValue("status", status);
88 this.featureGroup = featureGroup;
91 public SequenceFeature(String type,
98 this.description = desc;
102 this.featureGroup = featureGroup;
105 public boolean equals(SequenceFeature sf)
107 if (begin != sf.begin
109 || score != sf.score)
112 if(!(type+description+featureGroup).equals
113 (sf.type+sf.description+sf.featureGroup))
123 * @return DOCUMENT ME!
125 public int getBegin()
130 public void setBegin(int start)
138 * @return DOCUMENT ME!
145 public void setEnd(int end)
153 * @return DOCUMENT ME!
155 public String getType()
160 public void setType(String type)
168 * @return DOCUMENT ME!
170 public String getDescription()
175 public void setDescription(String desc)
180 public String getFeatureGroup()
185 public void setFeatureGroup(String featureGroup)
187 this.featureGroup = featureGroup;
190 public void addLink(String labelLink)
193 links = new java.util.Vector();
195 links.insertElementAt(labelLink,0);
198 public float getScore()
203 public void setScore(float value)
209 * Used for getting values which are not in the
210 * basic set. eg STRAND, FRAME for GFF file
213 public Object getValue(String key)
215 if(otherDetails==null)
218 return otherDetails.get(key);
222 * Used for setting values which are not in the
223 * basic set. eg STRAND, FRAME for GFF file
224 * @param key eg STRAND
227 public void setValue(String key, Object value)
231 if (otherDetails == null)
232 otherDetails = new Hashtable();
234 otherDetails.put(key, value);
240 * The following methods are added to maintain
241 * the castor Uniprot mapping file for the moment.
243 public void setStatus(String status)
245 setValue("status", status);
248 public String getStatus()
250 if (otherDetails != null)
251 return otherDetails.get("status").toString();
256 public void setPosition(int pos)
262 public int getPosition()