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
19 package jalview.datamodel;
\r
21 import java.util.Enumeration;
\r
22 import java.util.Hashtable;
\r
23 import java.util.Vector;
\r
29 * @version $Revision$
\r
31 public class SequenceFeature
\r
37 public String description;
\r
38 public Hashtable otherDetails;
\r
39 public java.util.Vector links;
\r
41 // Feature group can be set from a features file
\r
42 // as a group of features between STARTGROUP and ENDGROUP markers
\r
43 public String featureGroup;
\r
45 public SequenceFeature()
\r
48 * Constructs a duplicate feature.
\r
49 * Note: Uses clone on the otherDetails so only shallow copies are made
\r
50 * of additional properties and method will silently fail if unclonable
\r
51 * objects are found in the hash.
\r
54 public SequenceFeature(SequenceFeature cpy) {
\r
59 if (cpy.type != null)
\r
60 type = new String(cpy.type);
\r
61 if (cpy.description != null)
\r
62 description = new String(cpy.description);
\r
63 if (cpy.featureGroup != null)
\r
64 featureGroup = new String(cpy.featureGroup);
\r
65 if (cpy.otherDetails!=null) {
\r
67 otherDetails = (Hashtable) cpy.otherDetails.clone();
\r
68 } catch (Exception e) {
\r
69 // Uncloneable objects in the otherDetails - don't complain
\r
72 if (cpy.links!=null && cpy.links.size()>0) {
\r
74 for (int i=0,iSize=cpy.links.size(); i<iSize; i++) {
\r
75 links.setElementAt(cpy.links.elementAt(i), i);
\r
80 public SequenceFeature(String type,
\r
84 String featureGroup)
\r
87 this.description = desc;
\r
88 setValue("status", status);
\r
91 this.featureGroup = featureGroup;
\r
94 public SequenceFeature(String type,
\r
98 String featureGroup)
\r
101 this.description = desc;
\r
102 this.begin = begin;
\r
104 this.score = score;
\r
105 this.featureGroup = featureGroup;
\r
108 public boolean equals(SequenceFeature sf)
\r
110 if (begin != sf.begin
\r
112 || score != sf.score)
\r
115 if(!(type+description+featureGroup).equals
\r
116 (sf.type+sf.description+sf.featureGroup))
\r
126 * @return DOCUMENT ME!
\r
128 public int getBegin()
\r
133 public void setBegin(int start)
\r
135 this.begin = start;
\r
141 * @return DOCUMENT ME!
\r
143 public int getEnd()
\r
148 public void setEnd(int end)
\r
156 * @return DOCUMENT ME!
\r
158 public String getType()
\r
163 public void setType(String type)
\r
171 * @return DOCUMENT ME!
\r
173 public String getDescription()
\r
175 return description;
\r
178 public void setDescription(String desc)
\r
180 description = desc;
\r
183 public String getFeatureGroup()
\r
185 return featureGroup;
\r
188 public void setFeatureGroup(String featureGroup)
\r
190 this.featureGroup = featureGroup;
\r
193 public void addLink(String labelLink)
\r
196 links = new java.util.Vector();
\r
198 links.insertElementAt(labelLink,0);
\r
201 public float getScore()
\r
206 public void setScore(float value)
\r
212 * Used for getting values which are not in the
\r
213 * basic set. eg STRAND, FRAME for GFF file
\r
214 * @param key String
\r
216 public Object getValue(String key)
\r
218 if(otherDetails==null)
\r
221 return otherDetails.get(key);
\r
225 * Used for setting values which are not in the
\r
226 * basic set. eg STRAND, FRAME for GFF file
\r
227 * @param key eg STRAND
\r
228 * @param value eg +
\r
230 public void setValue(String key, Object value)
\r
234 if (otherDetails == null)
\r
235 otherDetails = new Hashtable();
\r
237 otherDetails.put(key, value);
\r
243 * The following methods are added to maintain
\r
244 * the castor Uniprot mapping file for the moment.
\r
246 public void setStatus(String status)
\r
248 setValue("status", status);
\r
251 public String getStatus()
\r
253 if (otherDetails != null)
\r
254 return otherDetails.get("status").toString();
\r
259 public void setPosition(int pos)
\r
265 public int getPosition()
\r