header updated
[jalview.git] / src / jalview / datamodel / SequenceFeature.java
index 5bf4e88..ca72942 100755 (executable)
@@ -1,6 +1,6 @@
 /*\r
  * Jalview - A Sequence Alignment Editor and Viewer\r
- * Copyright (C) 2005 AM Waterhouse, J Procter, G Barton, M Clamp, S Searle\r
+ * Copyright (C) 2006 AM Waterhouse, J Procter, G Barton, M Clamp, S Searle\r
  *\r
  * This program is free software; you can redistribute it and/or\r
  * modify it under the terms of the GNU General Public License\r
@@ -18,6 +18,8 @@
  */\r
 package jalview.datamodel;\r
 \r
+import java.util.Hashtable;\r
+\r
 /**\r
  * DOCUMENT ME!\r
  *\r
@@ -26,48 +28,79 @@ package jalview.datamodel;
  */\r
 public class SequenceFeature\r
 {\r
-    int begin;\r
-    int end;\r
-    String type;\r
-    String description;\r
-    String status;\r
+    public int begin;\r
+    public int end;\r
+    public float score;\r
+    public String type;\r
+    public String description;\r
+    public Hashtable otherDetails;\r
+    public java.util.Vector links;\r
+\r
+    // Feature group can be set from a features file\r
+    // as a group of features between STARTGROUP and ENDGROUP markers\r
+    public String featureGroup;\r
 \r
-    /**\r
-     * Creates a new SequenceFeature object.\r
-     */\r
     public SequenceFeature()\r
+    {}\r
+\r
+    public SequenceFeature(String type,\r
+                           String desc,\r
+                           String status,\r
+                           int begin, int end,\r
+                           String featureGroup)\r
     {\r
+      this.type = type;\r
+      this.description = desc;\r
+      setValue("status", status);\r
+      this.begin = begin;\r
+      this.end = end;\r
+      this.featureGroup = featureGroup;\r
     }\r
 \r
-    /**\r
-     * Creates a new SequenceFeature object.\r
-     *\r
-     * @param type DOCUMENT ME!\r
-     * @param start DOCUMENT ME!\r
-     * @param end DOCUMENT ME!\r
-     * @param description DOCUMENT ME!\r
-     * @param status DOCUMENT ME!\r
-     */\r
-    public SequenceFeature(String type, int start, int end, String description,\r
-        String status)\r
+    public SequenceFeature(String type,\r
+                           String desc,\r
+                           int begin, int end,\r
+                           float score,\r
+                           String featureGroup)\r
     {\r
-        this.type = type;\r
-        this.begin = start;\r
-        this.end = end;\r
-        this.description = description;\r
-        this.status = status;\r
+      this.type = type;\r
+      this.description = desc;\r
+      this.begin = begin;\r
+      this.end = end;\r
+      this.score = score;\r
+      this.featureGroup = featureGroup;\r
     }\r
 \r
+    public boolean equals(SequenceFeature sf)\r
+    {\r
+      if (begin != sf.begin\r
+          || end != sf.end\r
+          || score != sf.score)\r
+        return false;\r
+\r
+      if(!(type+description+featureGroup).equals\r
+         (sf.type+sf.description+sf.featureGroup))\r
+        return false;\r
+\r
+      return true;\r
+    }\r
+\r
+\r
     /**\r
      * DOCUMENT ME!\r
      *\r
      * @return DOCUMENT ME!\r
      */\r
-    public int getStart()\r
+    public int getBegin()\r
     {\r
         return begin;\r
     }\r
 \r
+    public void setBegin(int start)\r
+    {\r
+      this.begin = start;\r
+    }\r
+\r
     /**\r
      * DOCUMENT ME!\r
      *\r
@@ -78,6 +111,11 @@ public class SequenceFeature
         return end;\r
     }\r
 \r
+    public void setEnd(int end)\r
+    {\r
+      this.end = end;\r
+    }\r
+\r
     /**\r
      * DOCUMENT ME!\r
      *\r
@@ -88,6 +126,11 @@ public class SequenceFeature
         return type;\r
     }\r
 \r
+    public void setType(String type)\r
+    {\r
+      this.type = type;\r
+    }\r
+\r
     /**\r
      * DOCUMENT ME!\r
      *\r
@@ -98,52 +141,96 @@ public class SequenceFeature
         return description;\r
     }\r
 \r
+    public void setDescription(String desc)\r
+    {\r
+      description = desc;\r
+    }\r
+\r
+    public String getFeatureGroup()\r
+    {\r
+      return featureGroup;\r
+    }\r
+\r
+    public void setFeatureGroup(String featureGroup)\r
+    {\r
+      this.featureGroup = featureGroup;\r
+    }\r
+\r
+    public void addLink(String labelLink)\r
+    {\r
+      if(links==null)\r
+        links = new java.util.Vector();\r
+\r
+      links.insertElementAt(labelLink,0);\r
+    }\r
+\r
+    public float getScore()\r
+    {\r
+      return score;\r
+    }\r
+\r
+    public void setScore(float value)\r
+    {\r
+      score = value;\r
+    }\r
+\r
     /**\r
-     * DOCUMENT ME!\r
-     *\r
-     * @return DOCUMENT ME!\r
+     * Used for getting values which are not in the\r
+     * basic set. eg STRAND, FRAME for GFF file\r
+     * @param key String\r
      */\r
-    public String getStatus()\r
+    public Object getValue(String key)\r
     {\r
-        return status;\r
+      if(otherDetails==null)\r
+        return null;\r
+      else\r
+        return otherDetails.get(key);\r
     }\r
 \r
+    /**\r
+     * Used for setting values which are not in the\r
+     * basic set. eg STRAND, FRAME for GFF file\r
+     * @param key   eg STRAND\r
+     * @param value eg +\r
+     */\r
+    public void setValue(String key, Object value)\r
+    {\r
+      if(value!=null)\r
+      {\r
+        if (otherDetails == null)\r
+          otherDetails = new Hashtable();\r
+\r
+        otherDetails.put(key, value);\r
+      }\r
+    }\r
+\r
+\r
     /*\r
-          <xs:enumeration value="active site" />\r
-         <xs:enumeration value="binding site" />\r
-         <xs:enumeration value="calcium-binding region" />\r
-         <xs:enumeration value="chain" />\r
-         <xs:enumeration value="cross-link" />\r
-         <xs:enumeration value="disulfide bond" />\r
-         <xs:enumeration value="DNA-binding region" />\r
-         <xs:enumeration value="domain" />\r
-         <xs:enumeration value="glycosylation site" />\r
-         <xs:enumeration value="helix" />\r
-         <xs:enumeration value="initiator methionine" />\r
-         <xs:enumeration value="lipid moiety-binding region" />\r
-         <xs:enumeration value="metal ion-binding site" />\r
-         <xs:enumeration value="modified residue" />\r
-         <xs:enumeration value="mutagenesis site" />\r
-         <xs:enumeration value="non-consecutive residues" />\r
-         <xs:enumeration value="non-terminal residue" />\r
-         <xs:enumeration value="nucleotide phosphate-binding region" />\r
-         <xs:enumeration value="peptide" />\r
-         <xs:enumeration value="propeptide" />\r
-         <xs:enumeration value="repeat" />\r
-         <xs:enumeration value="selenocysteine" />\r
-         <xs:enumeration value="sequence conflict" />\r
-         <xs:enumeration value="sequence variant" />\r
-         <xs:enumeration value="signal peptide" />\r
-         <xs:enumeration value="similar" />\r
-         <xs:enumeration value="site" />\r
-         <xs:enumeration value="splice variant" />\r
-         <xs:enumeration value="strand" />\r
-         <xs:enumeration value="thioether bond" />\r
-         <xs:enumeration value="thiolester bond" />\r
-         <xs:enumeration value="transit peptide" />\r
-         <xs:enumeration value="transmembrane region" />\r
-         <xs:enumeration value="turn" />\r
-         <xs:enumeration value="unsure residue" />\r
-         <xs:enumeration value="zinc finger region" />\r
+     * The following methods are added to maintain\r
+     * the castor Uniprot mapping file for the moment.\r
      */\r
+    public void setStatus(String status)\r
+    {\r
+      setValue("status", status);\r
+    }\r
+\r
+    public String getStatus()\r
+    {\r
+      if (otherDetails != null)\r
+        return otherDetails.get("status").toString();\r
+      else\r
+        return null;\r
+    }\r
+\r
+    public void setPosition(int pos)\r
+    {\r
+      begin = pos;\r
+      end = pos;\r
+    }\r
+\r
+    public int getPosition()\r
+    {\r
+      return begin;\r
+    }\r
+\r
 }\r