dont add new sequences to null groups!
[jalview.git] / src / jalview / datamodel / Alignment.java
index dd02bc1..8535d84 100755 (executable)
@@ -11,7 +11,8 @@ public class Alignment implements AlignmentI
 \r
   protected Vector      sequences;\r
   protected Vector      groups = new Vector();\r
-  protected char      gapCharacter = '-';\r
+  protected ArrayList   superGroup = new ArrayList();\r
+  protected char        gapCharacter = '-';\r
 \r
   /** Make an alignment from an array of Sequences.\r
   *\r
@@ -45,8 +46,6 @@ public class Alignment implements AlignmentI
    */\r
   public void addSequence(SequenceI snew) {\r
     sequences.addElement(snew);\r
-\r
-    ((SequenceGroup)groups.lastElement()).addSequence(snew);\r
   }\r
 \r
   public void addSequence(SequenceI[] seq) {\r
@@ -328,6 +327,7 @@ public class Alignment implements AlignmentI
     for (int i = 0; i < this.groups.size();i++)\r
     {\r
       SequenceGroup sg = (SequenceGroup)groups.elementAt(i);\r
+\r
       if (sg.sequences.contains(s))\r
        temp.add(sg);\r
     }\r
@@ -356,17 +356,45 @@ public class Alignment implements AlignmentI
     }\r
   }\r
 \r
+  public void addSuperGroup(SuperGroup sg)\r
+  {\r
+    superGroup.add(sg);\r
+  }\r
+\r
+  public void removeSuperGroup(SuperGroup sg)\r
+  {\r
+    superGroup.remove(sg);\r
+  }\r
+\r
+  public SuperGroup     getSuperGroup(SequenceGroup sg)\r
+  {\r
+    for (int i = 0; i < this.superGroup.size(); i++)\r
+    {\r
+      SuperGroup temp = (SuperGroup) superGroup.get(i);\r
+      if (temp.sequenceGroups.contains(sg))\r
+        return temp;\r
+    }\r
+    return null;\r
+  }\r
+\r
   /**    */\r
   public void addGroup(SequenceGroup sg) {\r
     if(!groups.contains(sg))\r
       groups.addElement(sg);\r
   }\r
 \r
-  /**    */\r
-  public SequenceGroup addGroup() {\r
-    SequenceGroup sg = new SequenceGroup();\r
-    groups.addElement(sg);\r
-    return sg;\r
+  public void deleteAllGroups()\r
+  {\r
+    groups.clear();\r
+    superGroup.clear();\r
+   int i=0;\r
+    while (i < sequences.size()) {\r
+     SequenceI s = getSequenceAt(i);\r
+     s.setColor(java.awt.Color.white);\r
+     i++;\r
+   }\r
+\r
+\r
   }\r
 \r
   /**    */\r
@@ -470,6 +498,17 @@ public class Alignment implements AlignmentI
   {\r
     return AAFrequency.calculate(sequences, 0, getWidth());\r
   }\r
+\r
+  public boolean isAligned()\r
+  {\r
+    int width = getWidth();\r
+    for (int i = 0; i < sequences.size(); i++)\r
+      if (getSequenceAt(i).getLength() != width)\r
+        return false;\r
+\r
+    return true;\r
+\r
+  }\r
 }\r
 \r
 \r