JAL-1628 new entry point for reading annotation files that modify column visibility...
[jalview.git] / src / jalview / io / AnnotationFile.java
index 849f633..c25d7af 100755 (executable)
@@ -619,9 +619,33 @@ public class AnnotationFile
 
   String refSeqId = null;
 
+  public boolean annotateAlignmentView(AlignViewportI viewport,
+          String file, String protocol)
+  {
+    ColumnSelection colSel = viewport.getColumnSelection();
+    if (colSel == null)
+    {
+      colSel = new ColumnSelection();
+    }
+    boolean rslt = readAnnotationFile(viewport.getAlignment(), colSel,
+            file, protocol);
+    if (rslt
+            && (colSel.hasSelectedColumns() || colSel.hasHiddenColumns()))
+    {
+      viewport.setColumnSelection(colSel);
+    }
+
+    return rslt;
+  }
   public boolean readAnnotationFile(AlignmentI al, String file,
           String protocol)
   {
+    return readAnnotationFile(al, null, file, protocol);
+  }
+
+  public boolean readAnnotationFile(AlignmentI al, ColumnSelection colSel,
+          String file, String protocol)
+  {
     BufferedReader in = null;
     try
     {
@@ -864,6 +888,39 @@ public class AnnotationFile
           modified = true;
           continue;
         }
+        else if (token.equalsIgnoreCase("VIEW_SETREF"))
+        {
+          if (refSeq != null)
+          {
+            al.setSeqrep(refSeq);
+          }
+          modified = true;
+          continue;
+        }
+        else if (token.equalsIgnoreCase("HIDE_INSERTIONS"))
+        {
+          SequenceI sr = refSeq == null ? al.getSeqrep() : refSeq;
+          if (sr == null)
+          {
+            sr = al.getSequenceAt(0);
+          }
+          if (sr != null)
+          {
+            if (colSel == null)
+            {
+              System.err
+                      .println("Cannot process HIDE_INSERTIONS without an alignment view: Ignoring line: "
+                              + line);
+            }
+            else
+            {
+              // consider deferring this till after the file has been parsed ?
+              colSel.hideInsertionsFor(sr);
+            }
+          }
+          modified = true;
+          continue;
+        }
 
         // Parse out the annotation row
         graphStyle = AlignmentAnnotation.getGraphValueFromString(token);