jalview 2.5 release banner
[jalview.git] / src / jalview / io / vamsas / Sequencefeature.java
index 55db09d..360e704 100644 (file)
@@ -1,20 +1,19 @@
 /*\r
- * Jalview - A Sequence Alignment Editor and Viewer (Development Version 2.4.1)\r
- * Copyright (C) 2009 AM Waterhouse, J Procter, G Barton, M Clamp, S Searle\r
+ * Jalview - A Sequence Alignment Editor and Viewer (Version 2.5)\r
+ * Copyright (C) 2010 J Procter, AM Waterhouse, 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
- * as published by the Free Software Foundation; either version 2\r
- * of the License, or (at your option) any later version.\r
+ * This file is part of Jalview.\r
  * \r
- * This program is distributed in the hope that it will be useful,\r
- * but WITHOUT ANY WARRANTY; without even the implied warranty of\r
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\r
- * GNU General Public License for more details.\r
+ * Jalview is free software: you can redistribute it and/or\r
+ * modify it under the terms of the GNU General Public License \r
+ * as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.\r
  * \r
- * You should have received a copy of the GNU General Public License\r
- * along with this program; if not, write to the Free Software\r
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA\r
+ * Jalview is distributed in the hope that it will be useful, but \r
+ * WITHOUT ANY WARRANTY; without even the implied warranty \r
+ * of MERCHANTABILITY or FITNESS FOR A PARTICULAR \r
+ * PURPOSE.  See the GNU General Public License for more details.\r
+ * \r
+ * You should have received a copy of the GNU General Public License along with Jalview.  If not, see <http://www.gnu.org/licenses/>.\r
  */\r
 package jalview.io.vamsas;\r
 \r
@@ -64,7 +63,8 @@ public class Sequencefeature extends Rangetype
   public Sequencefeature(VamsasAppDatastore vamsasAppDatastore,\r
           DataSetAnnotations dseta, SequenceI dsSeq)\r
   {\r
-    super(vamsasAppDatastore, dseta, jalview.datamodel.SequenceFeature.class);\r
+    super(vamsasAppDatastore, dseta,\r
+            jalview.datamodel.SequenceFeature.class);\r
     this.dsSeq = dsSeq;\r
     doJvUpdate();\r
   }\r
@@ -90,9 +90,12 @@ public class Sequencefeature extends Rangetype
   public void addFromDocument()\r
   {\r
     DataSetAnnotations dsa = (DataSetAnnotations) vobj;\r
-    if (dsa.getSeqRefCount()!=1)\r
+    if (dsa.getSeqRefCount() != 1)\r
     {\r
-      Cache.log.warn("Not binding "+dsa.getVorbaId()+" to Sequence Feature - has multiple dataset sequence references.");\r
+      Cache.log\r
+              .warn("Not binding "\r
+                      + dsa.getVorbaId()\r
+                      + " to Sequence Feature - has multiple dataset sequence references.");\r
       return;\r
     }\r
     jalview.datamodel.SequenceFeature sf = (jalview.datamodel.SequenceFeature) jvobj;\r
@@ -107,9 +110,10 @@ public class Sequencefeature extends Rangetype
     DataSetAnnotations dsa = (DataSetAnnotations) vobj;\r
     jalview.datamodel.SequenceFeature feature = (jalview.datamodel.SequenceFeature) jvobj;\r
     jalview.datamodel.SequenceFeature sf = getJalviewSeqFeature(dsa);\r
-    replaceJvObjMapping(feature, sf); // switch binding of dsa from old feature to newly created feature\r
+    replaceJvObjMapping(feature, sf); // switch binding of dsa from old feature\r
+                                      // to newly created feature\r
     dsSeq.addSequenceFeature(sf); // add new imported feature\r
-    addToDocument(); // and create a new feature in the document        \r
+    addToDocument(); // and create a new feature in the document\r
   }\r
 \r
   public void updateToDoc()\r
@@ -137,6 +141,7 @@ public class Sequencefeature extends Rangetype
     }\r
 \r
   }\r
+\r
   public void updateFromDoc()\r
   {\r
     DataSetAnnotations dsa = (DataSetAnnotations) vobj;\r
@@ -146,20 +151,24 @@ public class Sequencefeature extends Rangetype
       // conflicting update from document - we cannot map this feature anymore.\r
       replaceJvObjMapping(feature, null);\r
       Cache.log\r
-              .warn("annotation ("+dsa.getVorbaId()+" bound to jalview feature cannot be mapped. Removing binding, deleting feature, and deleting feature.");\r
-       // - consider deleting the feature ?\r
+              .warn("annotation ("\r
+                      + dsa.getVorbaId()\r
+                      + " bound to jalview feature cannot be mapped. Removing binding, deleting feature, and deleting feature.");\r
+      // - consider deleting the feature ?\r
       dsSeq.deleteFeature(feature);\r
       // doSync();\r
     }\r
     else\r
     {\r
-      // Sync the features to Jalview - easiest to delete and add the feature again\r
+      // Sync the features to Jalview - easiest to delete and add the feature\r
+      // again\r
       jalview.datamodel.SequenceFeature newsf = getJalviewSeqFeature(dsa);\r
       dsSeq.deleteFeature(feature);\r
       replaceJvObjMapping(feature, newsf);\r
       dsSeq.addSequenceFeature(newsf);\r
-      if (feature.otherDetails!=null) {\r
-        // TODO later: leave this to finalise method ? \r
+      if (feature.otherDetails != null)\r
+      {\r
+        // TODO later: leave this to finalise method ?\r
         feature.otherDetails.clear();\r
       }\r
     }\r
@@ -170,10 +179,9 @@ public class Sequencefeature extends Rangetype
    * TODO: refactor to a method in jalview.io.vamsas.RangeAnnotation class\r
    * \r
    * @param dsa\r
-   *                (typically DataSetAnnotations or\r
-   *                AlignmentSequenceAnnotation)\r
+   *          (typically DataSetAnnotations or AlignmentSequenceAnnotation)\r
    * @param feature\r
-   *                (the feature to be mapped from)\r
+   *          (the feature to be mapped from)\r
    * @return\r
    */\r
   private RangeAnnotation getDSAnnotationFromJalview(RangeAnnotation dsa,\r
@@ -267,6 +275,7 @@ public class Sequencefeature extends Rangetype
     }\r
     return dsa;\r
   }\r
+\r
   private SequenceFeature getJalviewSeqFeature(RangeAnnotation dseta)\r
   {\r
     int[] se = getBounds(dseta);\r
@@ -277,12 +286,12 @@ public class Sequencefeature extends Rangetype
     {\r
       Link[] links = dseta.getLink();\r
       for (int i = 0; i < links.length; i++)\r
-      { \r
+      {\r
         // TODO: use URLLink parsing/validation here.\r
         sf.addLink(links[i].getContent() + "|" + links[i].getHref());\r
       }\r
     }\r
-    if (dseta.getScoreCount()>0)\r
+    if (dseta.getScoreCount() > 0)\r
     {\r
       Enumeration scr = dseta.enumerateScore();\r
       while (scr.hasMoreElements())\r
@@ -291,8 +300,10 @@ public class Sequencefeature extends Rangetype
         if (score.getName().equals(sf.getType()))\r
         {\r
           sf.setScore(score.getContent());\r
-        } else {\r
-          sf.setValue(score.getName(), ""+score.getContent());\r
+        }\r
+        else\r
+        {\r
+          sf.setValue(score.getName(), "" + score.getContent());\r
         }\r
       }\r
     }\r
@@ -302,36 +313,41 @@ public class Sequencefeature extends Rangetype
     {\r
       Property p = (Property) props.nextElement();\r
       Object val = null;\r
-      if (Properties.isValid(p)) \r
+      if (Properties.isValid(p))\r
       {\r
         if (Properties.isString(p))\r
         {\r
-        val = p.getContent();\r
+          val = p.getContent();\r
         }\r
         if (Properties.isBoolean(p))\r
         {\r
-          try {\r
+          try\r
+          {\r
             val = new Boolean(p.getContent());\r
-          } catch (Exception e) {}\r
+          } catch (Exception e)\r
+          {\r
+          }\r
         }\r
         if (Properties.isFloat(p))\r
         {\r
-          try {\r
-              val = new Float(p.getContent());\r
-              \r
-            } catch (Exception e)\r
-            {\r
-            }\r
+          try\r
+          {\r
+            val = new Float(p.getContent());\r
+\r
+          } catch (Exception e)\r
+          {\r
           }\r
-        if(Properties.isInteger(p))\r
+        }\r
+        if (Properties.isInteger(p))\r
         {\r
-          try {\r
-                val = new Integer(p.getContent());\r
+          try\r
+          {\r
+            val = new Integer(p.getContent());\r
           } catch (Exception e)\r
           {\r
-              } \r
+          }\r
         }\r
-        if (val!=null)\r
+        if (val != null)\r
         {\r
           sf.setValue(p.getName(), val);\r
         }\r