formatting
[jalview.git] / src / jalview / io / StockholmFile.java
index 2e0fea7..a9124d9 100644 (file)
@@ -1,6 +1,6 @@
 /*\r
- * Jalview - A Sequence Alignment Editor and Viewer (Version 2.6)\r
- * Copyright (C) 2010 J Procter, AM Waterhouse, G Barton, M Clamp, S Searle\r
+ * Jalview - A Sequence Alignment Editor and Viewer (Version 2.7)\r
+ * Copyright (C) 2011 J Procter, AM Waterhouse, J Engelhardt, LM Lui, G Barton, M Clamp, S Searle\r
  * \r
  * This file is part of Jalview.\r
  * \r
@@ -149,12 +149,16 @@ public class StockholmFile extends AlignFile
           int start = 1;\r
           int end = -1;\r
           String sid = acc;\r
-          // Retrieve hash of annotations for this accession\r
+          /*\r
+           * Retrieve hash of annotations for this accession Associate\r
+           * Annotation with accession\r
+           */\r
           Hashtable accAnnotations = null;\r
 \r
           if (seqAnn != null && seqAnn.containsKey(acc))\r
           {\r
             accAnnotations = (Hashtable) seqAnn.remove(acc);\r
+            // TODO: add structures to sequence\r
           }\r
 \r
           // Split accession in id and from/to\r
@@ -185,6 +189,18 @@ public class StockholmFile extends AlignFile
               // seqO.addDBRef(dbref);\r
             }\r
           }\r
+          if (accAnnotations != null && accAnnotations.containsKey("SS"))\r
+          {\r
+            Vector v = (Vector) accAnnotations.get("SS");\r
+\r
+            for (int i = 0; i < v.size(); i++)\r
+            {\r
+              AlignmentAnnotation an = (AlignmentAnnotation) v.elementAt(i);\r
+              seqO.addAlignmentAnnotation(an);\r
+              // annotations.add(an);\r
+            }\r
+          }\r
+\r
           Hashtable features = null;\r
           // We need to adjust the positions of all features to account for gaps\r
           try\r
@@ -426,7 +442,8 @@ public class StockholmFile extends AlignFile
               ann = new Hashtable();\r
               seqAnn.put(acc, ann);\r
             }\r
-\r
+            // TODO test structure, call parseAnnotationRow with vector from\r
+            // hashtable for specific sequence\r
             Hashtable features;\r
             // Get an object with all the content for an annotation\r
             if (ann.containsKey("features"))\r
@@ -461,6 +478,25 @@ public class StockholmFile extends AlignFile
             }\r
             ns += seq;\r
             content.put(description, ns);\r
+\r
+            if (type.equals("SS"))\r
+            {\r
+              Hashtable strucAnn;\r
+              if (seqAnn.containsKey(acc))\r
+              {\r
+                strucAnn = (Hashtable) seqAnn.get(acc);\r
+              }\r
+              else\r
+              {\r
+                strucAnn = new Hashtable();\r
+              }\r
+\r
+              Vector newStruc = new Vector();\r
+              parseAnnotationRow(newStruc, type, ns);\r
+\r
+              strucAnn.put(type, newStruc);\r
+              seqAnn.put(acc, strucAnn);\r
+            }\r
           }\r
           else\r
           {\r
@@ -487,8 +523,8 @@ public class StockholmFile extends AlignFile
     }\r
   }\r
 \r
-  private AlignmentAnnotation parseAnnotationRow(Vector annotation,\r
-          String label, String annots)\r
+  protected static AlignmentAnnotation parseAnnotationRow(\r
+          Vector annotation, String label, String annots)\r
   {\r
     String convert1, convert2 = null;\r
 \r
@@ -566,6 +602,7 @@ public class StockholmFile extends AlignFile
               annot.annotations.length);\r
       System.arraycopy(els, 0, anns, annot.annotations.length, els.length);\r
       annot.annotations = anns;\r
+      // System.out.println("else: ");\r
     }\r
     return annot;\r
   }\r
@@ -605,7 +642,7 @@ public class StockholmFile extends AlignFile
     }\r
   }\r
 \r
-  private String id2type(String id)\r
+  protected static String id2type(String id)\r
   {\r
     if (typeIds.containsKey(id))\r
     {\r