JAL-3017 parse multiple variant elements for uniprot feature
[jalview.git] / src / jalview / datamodel / xdb / uniprot / UniprotFeature.java
index 4a359ff..3bae87e 100644 (file)
@@ -1,5 +1,27 @@
+/*
+ * Jalview - A Sequence Alignment Editor and Viewer ($$Version-Rel$$)
+ * Copyright (C) $$Year-Rel$$ The Jalview Authors
+ * 
+ * This file is part of Jalview.
+ * 
+ * Jalview is free software: you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License 
+ * as published by the Free Software Foundation, either version 3
+ * of the License, or (at your option) any later version.
+ *  
+ * Jalview is distributed in the hope that it will be useful, but 
+ * WITHOUT ANY WARRANTY; without even the implied warranty 
+ * of MERCHANTABILITY or FITNESS FOR A PARTICULAR 
+ * PURPOSE.  See the GNU General Public License for more details.
+ * 
+ * You should have received a copy of the GNU General Public License
+ * along with Jalview.  If not, see <http://www.gnu.org/licenses/>.
+ * The Jalview Authors are detailed in the 'AUTHORS' file.
+ */
 package jalview.datamodel.xdb.uniprot;
 
+import java.util.Vector;
+
 /**
  * A data model class for binding from Uniprot XML via uniprot_mapping.xml
  */
@@ -7,7 +29,11 @@ public class UniprotFeature
 {
   private String type;
 
-  private String description;
+  private String description = null;
+
+  private String original = null;
+
+  private Vector<String> variation = null;
 
   private String status;
 
@@ -27,7 +53,40 @@ public class UniprotFeature
 
   public String getDescription()
   {
-    return description;
+    if (description == null && variation == null && original == null)
+    {
+      return null;
+    }
+    StringBuilder sb = new StringBuilder();
+    if (description != null)
+    {
+      sb.append(description);
+    }
+    if (variation != null && variation.size() > 0)
+    {
+      int i = 0;
+      for (String var : variation)
+      {
+        if (i++ > 0)
+        {
+          sb.append(",");
+        }
+        if (sb.length() > 0)
+        {
+          sb.append(" ");
+        }
+        sb.append("Variation: '" + var + "'");
+      }
+    }
+    if (original != null)
+    {
+      if (sb.length() > 0)
+      {
+        sb.append(" ");
+      }
+      sb.append("Original: '" + original + "'");
+    }
+    return sb.toString();
   }
 
   public void setDescription(String d)
@@ -75,4 +134,24 @@ public class UniprotFeature
     this.begin = p;
     this.end = p;
   }
+
+  public String getOriginal()
+  {
+    return original;
+  }
+
+  public void setOriginal(String original)
+  {
+    this.original = original;
+  }
+
+  public Vector<String> getVariation()
+  {
+    return variation;
+  }
+
+  public void setVariation(Vector<String> variant)
+  {
+    this.variation = variant;
+  }
 }