import annotation file from datasource
authorjprocter <Jim Procter>
Sun, 14 Nov 2010 14:58:04 +0000 (14:58 +0000)
committerjprocter <Jim Procter>
Sun, 14 Nov 2010 14:58:04 +0000 (14:58 +0000)
src/jalview/io/AnnotationFile.java

index ef2673a..3459517 100755 (executable)
@@ -461,13 +461,9 @@ public class AnnotationFile
   public boolean readAnnotationFile(AlignmentI al, String file,\r
           String protocol)\r
   {\r
-    String groupRef = null;\r
-    Hashtable groupRefRows = new Hashtable();\r
-\r
-    Hashtable autoAnnots = new Hashtable();\r
+    BufferedReader in = null;\r
     try\r
     {\r
-      BufferedReader in = null;\r
       if (protocol.equals(AppletFormatAdapter.FILE))\r
       {\r
         in = new BufferedReader(new FileReader(file));\r
@@ -489,7 +485,28 @@ public class AnnotationFile
           in = new BufferedReader(new java.io.InputStreamReader(is));\r
         }\r
       }\r
+      if (in != null)\r
+      {\r
+        return parseAnnotationFrom(al, in);\r
+      }\r
 \r
+    } catch (Exception ex)\r
+    {\r
+      ex.printStackTrace();\r
+      System.out.println("Problem reading annotation file: " + ex);\r
+      return false;\r
+    }\r
+    return false;\r
+  }\r
+\r
+  public boolean parseAnnotationFrom(AlignmentI al, BufferedReader in)\r
+          throws Exception\r
+  {\r
+    String groupRef = null;\r
+    Hashtable groupRefRows = new Hashtable();\r
+\r
+    Hashtable autoAnnots = new Hashtable();\r
+    {\r
       String line, label, description, token;\r
       int graphStyle, index;\r
       int refSeqIndex = 1;\r
@@ -826,11 +843,6 @@ public class AnnotationFile
         }\r
         ((Vector) groupRefRows.get(groupRef)).removeAllElements();\r
       }\r
-    } catch (Exception ex)\r
-    {\r
-      ex.printStackTrace();\r
-      System.out.println("Problem reading annotation file: " + ex);\r
-      return false;\r
     }\r
     return true;\r
   }\r