open each query result from an alignment datasource as a
[jalview.git] / src / jalview / datamodel / SequenceGroup.java
index be40bce..d253560 100755 (executable)
@@ -440,7 +440,9 @@ public class SequenceGroup
   }
 
   /**
-   * Add s to this sequence group
+   * Add s to this sequence group. If aligment sequence is already contained in
+   * group, it will not be added again, but recalculation may happen if the flag
+   * is set.
    * 
    * @param s
    *          alignment sequence to be added
@@ -627,10 +629,9 @@ public class SequenceGroup
   }
 
   /**
-   * DOCUMENT ME!
+   * Set the first column selected by this group. Runs from 0<=i<N_cols
    * 
    * @param i
-   *          DOCUMENT ME!
    */
   public void setStartRes(int i)
   {
@@ -638,10 +639,9 @@ public class SequenceGroup
   }
 
   /**
-   * DOCUMENT ME!
+   * Set the groups last selected column. Runs from 0<=i<N_cols
    * 
    * @param i
-   *          DOCUMENT ME!
    */
   public void setEndRes(int i)
   {
@@ -794,23 +794,42 @@ public class SequenceGroup
    */
   public SequenceI[] getSequencesInOrder(AlignmentI al)
   {
+    return getSequencesInOrder(al, true);
+  }
+
+  /**
+   * return an array representing the intersection of the group with al,
+   * optionally returning an array the size of al.getHeight() where nulls mark
+   * the non-intersected sequences
+   * 
+   * @param al
+   * @param trim
+   * @return null or array
+   */
+  public SequenceI[] getSequencesInOrder(AlignmentI al, boolean trim)
+  {
     int sSize = sequences.size();
     int alHeight = al.getHeight();
 
-    SequenceI[] seqs = new SequenceI[sSize];
+    SequenceI[] seqs = new SequenceI[(trim) ? sSize : alHeight];
 
     int index = 0;
     for (int i = 0; i < alHeight && index < sSize; i++)
     {
       if (sequences.contains(al.getSequenceAt(i)))
       {
-        seqs[index++] = al.getSequenceAt(i);
+        seqs[(trim) ? index : i] = al.getSequenceAt(i);
+        index++;
       }
     }
     if (index == 0)
     {
       return null;
     }
+    if (!trim)
+    {
+      return seqs;
+    }
     if (index < seqs.length)
     {
       SequenceI[] dummy = seqs;
@@ -979,6 +998,18 @@ public class SequenceGroup
   private boolean showConsensusHistogram;
 
   /**
+   * set this alignmentAnnotation object as the one used to render consensus annotation
+   * @param aan
+   */
+  public void setConsensus(AlignmentAnnotation aan)
+  {
+    if (consensus==null)
+    {
+      consensus=aan;
+    }
+  }
+  
+  /**
    * 
    * @return automatically calculated consensus row
    */
@@ -1007,6 +1038,17 @@ public class SequenceGroup
   }
 
   /**
+   * set this alignmentAnnotation object as the one used to render consensus annotation
+   * @param aan
+   */
+  public void setConservationRow(AlignmentAnnotation aan)
+  {
+    if (conservation==null)
+    {
+      conservation=aan;
+    }
+  }
+  /**
    * get the conservation annotation row for this group
    * 
    * @return autoCalculated annotation row