JAL-3017 parse multiple variant elements for uniprot feature
[jalview.git] / src / jalview / datamodel / xdb / uniprot / UniprotFeature.java
1 /*
2  * Jalview - A Sequence Alignment Editor and Viewer ($$Version-Rel$$)
3  * Copyright (C) $$Year-Rel$$ The Jalview Authors
4  * 
5  * This file is part of Jalview.
6  * 
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.
11  *  
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.
16  * 
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.
20  */
21 package jalview.datamodel.xdb.uniprot;
22
23 import java.util.Vector;
24
25 /**
26  * A data model class for binding from Uniprot XML via uniprot_mapping.xml
27  */
28 public class UniprotFeature
29 {
30   private String type;
31
32   private String description = null;
33
34   private String original = null;
35
36   private Vector<String> variation = null;
37
38   private String status;
39
40   private int begin;
41
42   private int end;
43
44   public String getType()
45   {
46     return type;
47   }
48
49   public void setType(String t)
50   {
51     this.type = t;
52   }
53
54   public String getDescription()
55   {
56     if (description == null && variation == null && original == null)
57     {
58       return null;
59     }
60     StringBuilder sb = new StringBuilder();
61     if (description != null)
62     {
63       sb.append(description);
64     }
65     if (variation != null && variation.size() > 0)
66     {
67       int i = 0;
68       for (String var : variation)
69       {
70         if (i++ > 0)
71         {
72           sb.append(",");
73         }
74         if (sb.length() > 0)
75         {
76           sb.append(" ");
77         }
78         sb.append("Variation: '" + var + "'");
79       }
80     }
81     if (original != null)
82     {
83       if (sb.length() > 0)
84       {
85         sb.append(" ");
86       }
87       sb.append("Original: '" + original + "'");
88     }
89     return sb.toString();
90   }
91
92   public void setDescription(String d)
93   {
94     this.description = d;
95   }
96
97   public String getStatus()
98   {
99     return status;
100   }
101
102   public void setStatus(String s)
103   {
104     this.status = s;
105   }
106
107   public int getBegin()
108   {
109     return begin;
110   }
111
112   public void setBegin(int b)
113   {
114     this.begin = b;
115   }
116
117   public int getEnd()
118   {
119     return end;
120   }
121
122   public void setEnd(int e)
123   {
124     this.end = e;
125   }
126
127   public int getPosition()
128   {
129     return begin;
130   }
131
132   public void setPosition(int p)
133   {
134     this.begin = p;
135     this.end = p;
136   }
137
138   public String getOriginal()
139   {
140     return original;
141   }
142
143   public void setOriginal(String original)
144   {
145     this.original = original;
146   }
147
148   public Vector<String> getVariation()
149   {
150     return variation;
151   }
152
153   public void setVariation(Vector<String> variant)
154   {
155     this.variation = variant;
156   }
157 }