Merge branch 'improvement/JAL-4023_snotation_for_trees' into develop
[jalview.git] / src / jalview / datamodel / SequenceGroup.java
index 62f9fd8..5e33229 100755 (executable)
@@ -88,7 +88,7 @@ public class SequenceGroup implements AnnotatedCollectionI
   /**
    * group members
    */
-  private List<SequenceI> sequences = new ArrayList<>();
+  private List<SequenceI> sequences;
 
   /**
    * representative sequence for this group (if any)
@@ -108,7 +108,7 @@ public class SequenceGroup implements AnnotatedCollectionI
   private int startRes = 0;
 
   /**
-   *  end column (base 0)
+   * end column (base 0)
    */
   private int endRes = 0;
 
@@ -162,6 +162,7 @@ public class SequenceGroup implements AnnotatedCollectionI
   {
     groupName = "JGroup:" + this.hashCode();
     cs = new ResidueShader();
+    sequences = new ArrayList<>();
   }
 
   /**
@@ -213,7 +214,7 @@ public class SequenceGroup implements AnnotatedCollectionI
       displayBoxes = seqsel.displayBoxes;
       displayText = seqsel.displayText;
       colourText = seqsel.colourText;
-      
+
       startRes = seqsel.startRes;
       endRes = seqsel.endRes;
       cs = new ResidueShader((ResidueShader) seqsel.cs);
@@ -243,6 +244,17 @@ public class SequenceGroup implements AnnotatedCollectionI
     }
   }
 
+  /**
+   * Constructor that copies the given list of sequences
+   * 
+   * @param seqs
+   */
+  public SequenceGroup(List<SequenceI> seqs)
+  {
+    this();
+    this.sequences.addAll(seqs);
+  }
+
   public boolean isShowSequenceLogo()
   {
     return showSequenceLogo;
@@ -257,7 +269,8 @@ public class SequenceGroup implements AnnotatedCollectionI
     for (int i = 0, ipos = 0; i < inorder.length; i++)
     {
       SequenceI seq = inorder[i];
-      SequenceI seqipos = seqs[ipos] = seq.getSubSequence(startRes, endRes + 1);
+      SequenceI seqipos = seqs[ipos] = seq.getSubSequence(startRes,
+              endRes + 1);
       if (seqipos != null)
       {
         seqipos.setDescription(seq.getDescription());
@@ -761,10 +774,9 @@ public class SequenceGroup implements AnnotatedCollectionI
   public void setStartRes(int newStart)
   {
     int before = startRes;
-   startRes= Math.max(0,newStart); // sanity check for negative start column positions
-   changeSupport.firePropertyChange(SEQ_GROUP_CHANGED, before, startRes);
-    
-
+    startRes = Math.max(0, newStart); // sanity check for negative start column
+                                      // positions
+    changeSupport.firePropertyChange(SEQ_GROUP_CHANGED, before, startRes);
 
   }