JAL-1705 derive transcript sequences from gene sequence/GFF; handle CDS
[jalview.git] / src / jalview / datamodel / SequenceFeature.java
index e60e0c8..252f46c 100755 (executable)
@@ -32,6 +32,15 @@ import java.util.Vector;
  */
 public class SequenceFeature
 {
+  private static final String STATUS = "status";
+
+  private static final String STRAND = "STRAND";
+
+  // private key for Phase designed not to conflict with real GFF data
+  private static final String PHASE = "!Phase";
+
+  private static final String ATTRIBUTES = "ATTRIBUTES";
+
   public int begin;
 
   public int end;
@@ -107,7 +116,7 @@ public class SequenceFeature
   {
     this.type = type;
     this.description = desc;
-    setValue("status", status);
+    setValue(STATUS, status);
     this.begin = begin;
     this.end = end;
     this.featureGroup = featureGroup;
@@ -231,7 +240,7 @@ public class SequenceFeature
   }
 
   /**
-   * Used for getting values which are not in the basic set. eg STRAND, FRAME
+   * Used for getting values which are not in the basic set. eg STRAND, PHASE
    * for GFF file
    * 
    * @param key
@@ -291,20 +300,22 @@ public class SequenceFeature
    */
   public void setStatus(String status)
   {
-    setValue("status", status);
+    setValue(STATUS, status);
   }
 
   public String getStatus()
   {
-    if (otherDetails != null)
-    {
-      String stat = (String) otherDetails.get("status");
-      if (stat != null)
-      {
-        return new String(stat);
-      }
-    }
-    return null;
+    return (String) getValue(STATUS);
+  }
+
+  public void setAttributes(String attr)
+  {
+    setValue(ATTRIBUTES, attr);
+  }
+
+  public String getAttributes()
+  {
+    return (String) getValue(ATTRIBUTES);
   }
 
   public void setPosition(int pos)
@@ -329,7 +340,7 @@ public class SequenceFeature
     int strand = 0;
     if (otherDetails != null)
     {
-      Object str = otherDetails.get("STRAND");
+      Object str = otherDetails.get(STRAND);
       if ("-".equals(str))
       {
         strand = -1;
@@ -342,4 +353,29 @@ public class SequenceFeature
     return strand;
   }
 
+  public void setStrand(String strand)
+  {
+    setValue(STRAND, strand);
+  }
+
+  public void setPhase(String phase)
+  {
+    setValue(PHASE, phase);
+  }
+
+  public String getPhase()
+  {
+    return (String) getValue(PHASE);
+  }
+
+  /**
+   * Readable representation, for debug only, not guaranteed not to change
+   * between versions
+   */
+  @Override
+  public String toString()
+  {
+    return String.format("%d %d %s %s", getBegin(), getEnd(), getType(),
+            getDescription());
+  }
 }