2 * Jalview - A Sequence Alignment Editor and Viewer ($$Version-Rel$$)
3 * Copyright (C) $$Year-Rel$$ The Jalview Authors
5 * This file is part of Jalview.
7 * Jalview is free software: you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License
9 * as published by the Free Software Foundation, either version 3
10 * of the License, or (at your option) any later version.
12 * Jalview is distributed in the hope that it will be useful, but
13 * WITHOUT ANY WARRANTY; without even the implied warranty
14 * of MERCHANTABILITY or FITNESS FOR A PARTICULAR
15 * PURPOSE. See the GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with Jalview. If not, see <http://www.gnu.org/licenses/>.
19 * The Jalview Authors are detailed in the 'AUTHORS' file.
21 package jalview.datamodel;
23 import java.util.Hashtable;
24 import java.util.Vector;
32 public class SequenceFeature
42 public String description;
44 public Hashtable otherDetails;
46 public Vector<String> links;
48 // Feature group can be set from a features file
49 // as a group of features between STARTGROUP and ENDGROUP markers
50 public String featureGroup;
52 public SequenceFeature()
57 * Constructs a duplicate feature. Note: Uses clone on the otherDetails so
58 * only shallow copies are made of additional properties and method will
59 * silently fail if unclonable objects are found in the hash.
63 public SequenceFeature(SequenceFeature cpy)
72 type = new String(cpy.type);
74 if (cpy.description != null)
76 description = new String(cpy.description);
78 if (cpy.featureGroup != null)
80 featureGroup = new String(cpy.featureGroup);
82 if (cpy.otherDetails != null)
86 otherDetails = (Hashtable) cpy.otherDetails.clone();
89 // Uncloneable objects in the otherDetails - don't complain
92 if (cpy.links != null && cpy.links.size() > 0)
94 links = new Vector<String>();
95 for (int i = 0, iSize = cpy.links.size(); i < iSize; i++)
97 links.addElement(cpy.links.elementAt(i));
103 public SequenceFeature(String type, String desc, String status,
104 int begin, int end, String featureGroup)
107 this.description = desc;
108 setValue("status", status);
111 this.featureGroup = featureGroup;
114 public SequenceFeature(String type, String desc, int begin, int end,
115 float score, String featureGroup)
118 this.description = desc;
122 this.featureGroup = featureGroup;
125 public boolean equals(SequenceFeature sf)
127 if (begin != sf.begin || end != sf.end || score != sf.score)
132 if (!(type + description + featureGroup).equals(sf.type
133 + sf.description + sf.featureGroup))
144 * @return DOCUMENT ME!
146 public int getBegin()
151 public void setBegin(int start)
159 * @return DOCUMENT ME!
166 public void setEnd(int end)
174 * @return DOCUMENT ME!
176 public String getType()
181 public void setType(String type)
189 * @return DOCUMENT ME!
191 public String getDescription()
196 public void setDescription(String desc)
201 public String getFeatureGroup()
206 public void setFeatureGroup(String featureGroup)
208 this.featureGroup = featureGroup;
211 public void addLink(String labelLink)
215 links = new Vector<String>();
218 links.insertElementAt(labelLink, 0);
221 public float getScore()
226 public void setScore(float value)
232 * Used for getting values which are not in the basic set. eg STRAND, FRAME
238 public Object getValue(String key)
240 if (otherDetails == null)
246 return otherDetails.get(key);
251 * Used for setting values which are not in the basic set. eg STRAND, FRAME
259 public void setValue(String key, Object value)
263 if (otherDetails == null)
265 otherDetails = new Hashtable();
268 otherDetails.put(key, value);
273 * The following methods are added to maintain the castor Uniprot mapping file
276 public void setStatus(String status)
278 setValue("status", status);
281 public String getStatus()
283 if (otherDetails != null)
285 String stat = (String) otherDetails.get("status");
288 return new String(stat);
294 public void setPosition(int pos)
300 public int getPosition()
305 public int getStrand()
308 if (otherDetails == null
309 || (str = otherDetails.get("STRAND").toString()) == null)