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.HashMap;
25 import java.util.Vector;
33 public class SequenceFeature
43 public String description;
45 public Map<String, Object> otherDetails;
47 public Vector<String> links;
49 // Feature group can be set from a features file
50 // as a group of features between STARTGROUP and ENDGROUP markers
51 public String featureGroup;
53 public SequenceFeature()
58 * Constructs a duplicate feature. Note: Uses makes a shallow copy of the
59 * otherDetails map, so the new and original SequenceFeature may reference the
60 * same objects in the map.
64 public SequenceFeature(SequenceFeature cpy)
73 type = new String(cpy.type);
75 if (cpy.description != null)
77 description = new String(cpy.description);
79 if (cpy.featureGroup != null)
81 featureGroup = new String(cpy.featureGroup);
83 if (cpy.otherDetails != null)
87 otherDetails = (Map<String, Object>) ((HashMap<String, Object>) cpy.otherDetails)
94 if (cpy.links != null && cpy.links.size() > 0)
96 links = new Vector<String>();
97 for (int i = 0, iSize = cpy.links.size(); i < iSize; i++)
99 links.addElement(cpy.links.elementAt(i));
105 public SequenceFeature(String type, String desc, String status,
106 int begin, int end, String featureGroup)
109 this.description = desc;
110 setValue("status", status);
113 this.featureGroup = featureGroup;
116 public SequenceFeature(String type, String desc, int begin, int end,
117 float score, String featureGroup)
120 this.description = desc;
124 this.featureGroup = featureGroup;
127 public boolean equals(SequenceFeature sf)
129 if (begin != sf.begin || end != sf.end || score != sf.score)
134 if (!(type + description + featureGroup).equals(sf.type
135 + sf.description + sf.featureGroup))
146 * @return DOCUMENT ME!
148 public int getBegin()
153 public void setBegin(int start)
161 * @return DOCUMENT ME!
168 public void setEnd(int end)
176 * @return DOCUMENT ME!
178 public String getType()
183 public void setType(String type)
191 * @return DOCUMENT ME!
193 public String getDescription()
198 public void setDescription(String desc)
203 public String getFeatureGroup()
208 public void setFeatureGroup(String featureGroup)
210 this.featureGroup = featureGroup;
213 public void addLink(String labelLink)
217 links = new Vector<String>();
220 links.insertElementAt(labelLink, 0);
223 public float getScore()
228 public void setScore(float value)
234 * Used for getting values which are not in the basic set. eg STRAND, FRAME
240 public Object getValue(String key)
242 if (otherDetails == null)
248 return otherDetails.get(key);
253 * Returns a property value for the given key if known, else the specified
257 * @param defaultValue
260 public Object getValue(String key, Object defaultValue)
262 Object value = getValue(key);
263 return value == null ? defaultValue : value;
267 * Used for setting values which are not in the basic set. eg STRAND, FRAME
275 public void setValue(String key, Object value)
279 if (otherDetails == null)
281 otherDetails = new HashMap<String, Object>();
284 otherDetails.put(key, value);
289 * The following methods are added to maintain the castor Uniprot mapping file
292 public void setStatus(String status)
294 setValue("status", status);
297 public String getStatus()
299 if (otherDetails != null)
301 String stat = (String) otherDetails.get("status");
304 return new String(stat);
310 public void setPosition(int pos)
316 public int getPosition()
322 * Return 1 for forward strand ('+' in GFF), -1 for reverse strand ('-' in
323 * GFF), and 0 for unknown or not (validly) specified
327 public int getStrand()
330 if (otherDetails != null)
332 Object str = otherDetails.get("STRAND");
337 else if ("+".equals(str))