beginning of implementation of new properties for hide/show groups and sequence repre...
authorjprocter <Jim Procter>
Tue, 4 Nov 2008 11:44:15 +0000 (11:44 +0000)
committerjprocter <Jim Procter>
Tue, 4 Nov 2008 11:44:15 +0000 (11:44 +0000)
help/html/features/annotationsFormat.html
src/jalview/datamodel/SequenceGroup.java
src/jalview/io/AnnotationFile.java

index afee3b8..daaca93 100755 (executable)
@@ -98,14 +98,22 @@ GRAPHLINE&#9;<em>graph_name</em>&#9;<em>value</em>&#9;<em>label</em>&#9;<em>colo
   textCol1=black<br>
   textCol2=black<br>
   textColThreshold=0<br>
-  idColour=ff3322</p>
-<em>New Features in 2.4:</em><ul><li>if the <strong>idColour</strong> property
+  idColour=ff3322<br>
+  hide=false
+  hidecols=false</p>
+<ul><li>if the <strong>idColour</strong> property
 is given without specifying a colour scheme with the <strong>colour</strong>
 property, then the idColour will also be used to colour the sequence.</li>
 <li>the <strong>colour</strong> property can take either a colour scheme name,
  or a single colour specification (either a colour name like 'red' or an RGB
  triplet like 'ff0066'). If a single colour is specified, then the group
  will be coloured with that colour.</li>
+ <li><em>New Features in 2.4.1</em></li>
+ <li>hide and hidecols instruct jalview to hide the sequences or columns covered by the group.</li>
+  <li>Sequence associated Groups<br>If a group is defined after a valid
+ <em>SEQUENCE_REF</em> sequence reference statement, the sequence representative
+ for the group will be set to the referenced sequence.<br><strong>Note:</strong> if the <em>hide</em> 
+ property is set then only the representative sequence for the group will be shown in the alignment.</li>
 </ul>
 <p> </p>
 <p>An example Annotation file is given below:
index dd842ea..bb075aa 100755 (executable)
@@ -46,12 +46,18 @@ public class SequenceGroup
   boolean displayText = true;
 
   boolean colourText = false;
-
+  /**
+   * group members
+   */
   private Vector sequences = new Vector();
-
+  /**
+   * representative sequence for this group (if any)
+   */
+  private SequenceI seqrep = null;
   int width = -1;
 
-  /** DOCUMENT ME!! */
+  /**
+   * Colourscheme applied to group if any */
   public ColourSchemeI cs;
 
   int startRes = 0;
@@ -680,4 +686,71 @@ public class SequenceGroup
   {
     this.idColour = idColour;
   }
+
+  /**
+   * @return the representative sequence for this group
+   */
+  public SequenceI getSeqrep()
+  {
+    return seqrep;
+  }
+
+  /**
+   * set the representative sequence for this group.
+   * Note - this affects the interpretation of the Hidereps attribute.
+   * @param seqrep the seqrep to set (null means no sequence representative)
+   */
+  public void setSeqrep(SequenceI seqrep)
+  {
+    this.seqrep = seqrep;
+  }
+  /**
+   * 
+   * @return true if group has a sequence representative
+   */
+  public boolean hasSeqrep()
+  {
+    return seqrep != null;
+  }
+  /**
+   * visibility of rows or represented rows covered by group
+   */
+  private boolean hidereps=false;
+  /**
+   * set visibility of sequences covered by (if no sequence representative is defined) 
+   * or represented by this group.
+   * @param visibility
+   */
+  public void setHidereps(boolean visibility)
+  {
+    hidereps = visibility;
+  }
+  /**
+   * 
+   * @return true if sequences represented (or covered) by this group should be hidden
+   */
+  public boolean isHidereps()
+  {
+    return hidereps;
+  }
+  /**
+   * visibility of columns intersecting this group
+   */
+  private boolean hidecols=false;
+  /**
+   * set intended visibility of columns covered by this group
+   * @param visibility
+   */
+  public void setHideCols(boolean visibility)
+  {
+    hidecols = visibility;
+  }
+  /**
+   * 
+   * @return true if columns covered by group should be hidden
+   */
+  public boolean isHideCols()
+  {
+    return hidecols;
+  }
 }
index d9fd871..1872f60 100755 (executable)
@@ -60,13 +60,15 @@ public class AnnotationFile
     public ColumnSelection hiddencols;\r
 \r
     public Vector visibleGroups;\r
-\r
+    public Hashtable hiddenRepSeqs;\r
+    \r
     public ViewDef(String viewname, HiddenSequences hidseqs,\r
-            ColumnSelection hiddencols)\r
+            ColumnSelection hiddencols, Hashtable hiddenRepSeqs)\r
     {\r
       this.viewname = viewname;\r
       this.hidseqs = hidseqs;\r
       this.hiddencols = hiddencols;\r
+      this.hiddenRepSeqs = hiddenRepSeqs;\r
     }\r
   }\r
 \r
@@ -268,12 +270,23 @@ public class AnnotationFile
   public void printGroups(Vector sequenceGroups)\r
   {\r
     SequenceGroup sg;\r
+    SequenceI seqrep=null;\r
     for (int i = 0; i < sequenceGroups.size(); i++)\r
     {\r
       sg = (SequenceGroup) sequenceGroups.elementAt(i);\r
-      text.append("SEQUENCE_GROUP\t" + sg.getName() + "\t"\r
-              + (sg.getStartRes() + 1) + "\t" + (sg.getEndRes() + 1) + "\t"\r
-              + "-1\t");\r
+      if (!sg.hasSeqrep())\r
+      {\r
+        text.append("SEQUENCE_GROUP\t" + sg.getName() + "\t"\r
+                + (sg.getStartRes() + 1) + "\t" + (sg.getEndRes() + 1) + "\t"\r
+                + "-1\t");\r
+        seqrep = null;\r
+      } else {\r
+        seqrep = sg.getSeqrep();\r
+        text.append("SEQUENCE_REF\t"+seqrep.getName()+"\n");\r
+        text.append("SEQUENCE_GROUP\t" + sg.getName() + "\t"\r
+                + (seqrep.findPosition(sg.getStartRes())) + "\t" + (seqrep.findPosition(sg.getEndRes())) + "\t"\r
+                + "-1\t");\r
+      }\r
       for (int s = 0; s < sg.getSize(); s++)\r
       {\r
         text.append(sg.getSequenceAt(s).getName() + "\t");\r
@@ -318,14 +331,26 @@ public class AnnotationFile
       }\r
       if (sg.thresholdTextColour != 0)\r
       {\r
-        text.append("textColThreshold=" + sg.thresholdTextColour);\r
+        text.append("textColThreshold=" + sg.thresholdTextColour+"\t");\r
       }\r
       if (sg.idColour != null)\r
       {\r
         text.append("idColour="\r
                 + jalview.util.Format.getHexString(sg.idColour) + "\t");\r
       }\r
-\r
+      if (sg.isHidereps())\r
+      {\r
+        text.append("hide=true\t");\r
+      }\r
+      if (sg.isHideCols())\r
+      {\r
+        text.append("hidecols=true\t");\r
+      }\r
+      if (seqrep!=null)\r
+      {\r
+        // terminate the last line and clear the sequence ref for the group\r
+        text.append("\nSEQUENCE_REF");\r
+      }\r
       text.append("\n\n");\r
 \r
     }\r
@@ -752,13 +777,33 @@ public class AnnotationFile
 \r
     annotation.setThreshold(new GraphLine(value, label, colour));\r
   }\r
-\r
   void addGroup(AlignmentI al, StringTokenizer st)\r
   {\r
     SequenceGroup sg = new SequenceGroup();\r
     sg.setName(st.nextToken());\r
-    sg.setStartRes(Integer.parseInt(st.nextToken()) - 1);\r
-    sg.setEndRes(Integer.parseInt(st.nextToken()) - 1);\r
+    String rng ="";\r
+    try {\r
+      rng = st.nextToken();\r
+      if (rng.length()>0 && !rng.startsWith("*"))\r
+      {\r
+        sg.setStartRes(Integer.parseInt(rng) - 1);\r
+      } else {\r
+        sg.setStartRes(0);\r
+      }\r
+      rng = st.nextToken();\r
+      if (rng.length()>0 && !rng.startsWith("*"))\r
+      {\r
+        sg.setEndRes(Integer.parseInt(rng) - 1);\r
+      } else {\r
+        sg.setEndRes(al.getWidth()-1);\r
+      }\r
+    } catch (Exception e)\r
+    {\r
+      System.err.println("Couldn't parse Group Start or End Field as '*' or a valid column or sequence index: '"+rng+"' - assuming alignment width for group.");\r
+      // assume group is full width\r
+      sg.setStartRes(0);\r
+      sg.setEndRes(al.getWidth()-1);\r
+    }\r
 \r
     String index = st.nextToken();\r
     if (index.equals("-1"))\r
@@ -810,6 +855,7 @@ public class AnnotationFile
     {\r
       sg.setStartRes(refSeq.findIndex(sg.getStartRes() + 1) - 1);\r
       sg.setEndRes(refSeq.findIndex(sg.getEndRes() + 1) - 1);\r
+      sg.setSeqrep(refSeq);\r
     }\r
 \r
     if (sg.getSize() > 0)\r
@@ -917,6 +963,16 @@ public class AnnotationFile
           sg.setIdColour((def = new UserColourScheme(value))\r
                   .findColour('A'));\r
         }\r
+        else if (key.equalsIgnoreCase("hide"))\r
+        {\r
+          // see bug https://mantis.lifesci.dundee.ac.uk/view.php?id=25847\r
+          sg.setHidereps(true);\r
+        }\r
+        else if (key.equalsIgnoreCase("hidecols"))\r
+        {\r
+          // see bug https://mantis.lifesci.dundee.ac.uk/view.php?id=25847\r
+          sg.setHideCols(true);\r
+        }\r
         sg.recalcConservation();\r
       }\r
       if (sg.cs == null)\r