Status is now in otherData of feature
[jalview.git] / src / jalview / datamodel / SequenceFeature.java
1 /*\r
2  * Jalview - A Sequence Alignment Editor and Viewer\r
3  * Copyright (C) 2005 AM Waterhouse, J Procter, G Barton, M Clamp, S Searle\r
4  *\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
9  *\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
14  *\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
18  */\r
19 package jalview.datamodel;\r
20 \r
21 import java.util.Hashtable;\r
22 \r
23 /**\r
24  * DOCUMENT ME!\r
25  *\r
26  * @author $author$\r
27  * @version $Revision$\r
28  */\r
29 public class SequenceFeature\r
30 {\r
31     public int begin;\r
32     public int end;\r
33     public float score;\r
34     public String type;\r
35     public String description;\r
36     Hashtable otherDetails;\r
37     public java.util.Vector links;\r
38 \r
39     // Feature group can be set from a features file\r
40     // as a group of features between STARTGROUP and ENDGROUP markers\r
41     public String featureGroup;\r
42 \r
43     public SequenceFeature()\r
44     {}\r
45 \r
46     public SequenceFeature(String type,\r
47                            String desc,\r
48                            String status,\r
49                            int begin, int end,\r
50                            String featureGroup)\r
51     {\r
52       this.type = type;\r
53       this.description = desc;\r
54       if(status!=null)\r
55         setValue("status", status);\r
56 \r
57       this.begin = begin;\r
58       this.end = end;\r
59       this.featureGroup = featureGroup;\r
60     }\r
61 \r
62     public SequenceFeature(String type,\r
63                            String desc,\r
64                            int begin, int end,\r
65                            float score,\r
66                            String featureGroup)\r
67     {\r
68       this.type = type;\r
69       this.description = desc;\r
70       this.begin = begin;\r
71       this.end = end;\r
72       this.score = score;\r
73       this.featureGroup = featureGroup;\r
74     }\r
75 \r
76     public boolean equals(SequenceFeature sf)\r
77     {\r
78       if(begin != sf.begin\r
79       || end != sf.end)\r
80      return false;\r
81 \r
82 \r
83       if(!(type+description).equals\r
84          (sf.type+sf.description))\r
85         return false;\r
86 \r
87       return true;\r
88     }\r
89 \r
90 \r
91     /**\r
92      * DOCUMENT ME!\r
93      *\r
94      * @return DOCUMENT ME!\r
95      */\r
96     public int getBegin()\r
97     {\r
98         return begin;\r
99     }\r
100 \r
101     public void setBegin(int start)\r
102     {\r
103       this.begin = start;\r
104     }\r
105 \r
106     /**\r
107      * DOCUMENT ME!\r
108      *\r
109      * @return DOCUMENT ME!\r
110      */\r
111     public int getEnd()\r
112     {\r
113         return end;\r
114     }\r
115 \r
116     public void setEnd(int end)\r
117     {\r
118       this.end = end;\r
119     }\r
120 \r
121     /**\r
122      * DOCUMENT ME!\r
123      *\r
124      * @return DOCUMENT ME!\r
125      */\r
126     public String getType()\r
127     {\r
128         return type;\r
129     }\r
130 \r
131     public void setType(String type)\r
132     {\r
133       this.type = type;\r
134     }\r
135 \r
136     /**\r
137      * DOCUMENT ME!\r
138      *\r
139      * @return DOCUMENT ME!\r
140      */\r
141     public String getDescription()\r
142     {\r
143         return description;\r
144     }\r
145 \r
146     public void setDescription(String desc)\r
147     {\r
148       description = desc;\r
149     }\r
150 \r
151     public String getFeatureGroup()\r
152     {\r
153       return featureGroup;\r
154     }\r
155 \r
156     public void setFeatureGroup(String featureGroup)\r
157     {\r
158       this.featureGroup = featureGroup;\r
159     }\r
160 \r
161     public void addLink(String labelLink)\r
162     {\r
163       if(links==null)\r
164         links = new java.util.Vector();\r
165 \r
166       links.insertElementAt(labelLink,0);\r
167     }\r
168 \r
169     public float getScore()\r
170     {\r
171       return score;\r
172     }\r
173 \r
174     public void setScore(float value)\r
175     {\r
176       score = value;\r
177     }\r
178 \r
179     /**\r
180      * Used for getting values which are not in the\r
181      * basic set. eg STRAND, FRAME for GFF file\r
182      * @param key String\r
183      */\r
184     public Object getValue(String key)\r
185     {\r
186       if(otherDetails==null)\r
187         return null;\r
188       else\r
189         return otherDetails.get(key);\r
190     }\r
191 \r
192     /**\r
193      * Used for setting values which are not in the\r
194      * basic set. eg STRAND, FRAME for GFF file\r
195      * @param key   eg STRAND\r
196      * @param value eg +\r
197      */\r
198     public void setValue(String key, Object value)\r
199     {\r
200       if(otherDetails == null)\r
201         otherDetails = new Hashtable();\r
202 \r
203       otherDetails.put(key, value);\r
204     }\r
205 \r
206 \r
207 }\r