java 1.1 compatibility
[jalview.git] / src / jalview / datamodel / Alignment.java
index 78aa015..b0b04ca 100755 (executable)
@@ -24,7 +24,6 @@ import jalview.util.*;
 \r
 import java.util.*;\r
 \r
-\r
 /** Data structure to hold and manipulate a multiple sequence alignment\r
  */\r
 public class Alignment implements AlignmentI\r
@@ -41,6 +40,9 @@ public class Alignment implements AlignmentI
     /** DOCUMENT ME!! */\r
     public AlignmentAnnotation[] annotations;\r
 \r
+    HiddenSequences hiddenSequences = new HiddenSequences(this);\r
+\r
+\r
     /** Make an alignment from an array of Sequences.\r
      *\r
      * @param sequences\r
@@ -390,47 +392,7 @@ public class Alignment implements AlignmentI
         return ret;\r
     }\r
 \r
-    /**\r
-     * DOCUMENT ME!\r
-     *\r
-     * @param sg DOCUMENT ME!\r
-     */\r
-    public void addSuperGroup(SuperGroup sg)\r
-    {\r
-        superGroup.addElement(sg);\r
-    }\r
-\r
-    /**\r
-     * DOCUMENT ME!\r
-     *\r
-     * @param sg DOCUMENT ME!\r
-     */\r
-    public void removeSuperGroup(SuperGroup sg)\r
-    {\r
-        superGroup.removeElement(sg);\r
-    }\r
-\r
-    /**\r
-     * DOCUMENT ME!\r
-     *\r
-     * @param sg DOCUMENT ME!\r
-     *\r
-     * @return DOCUMENT ME!\r
-     */\r
-    public SuperGroup getSuperGroup(SequenceGroup sg)\r
-    {\r
-        for (int i = 0; i < this.superGroup.size(); i++)\r
-        {\r
-            SuperGroup temp = (SuperGroup) superGroup.elementAt(i);\r
-\r
-            if (temp.sequenceGroups.contains(sg))\r
-            {\r
-                return temp;\r
-            }\r
-        }\r
 \r
-        return null;\r
-    }\r
 \r
     /**    */\r
     public void addGroup(SequenceGroup sg)\r
@@ -848,19 +810,48 @@ public class Alignment implements AlignmentI
 \r
     public boolean padGaps() {\r
       boolean modified=false;\r
-      int Width = getWidth();\r
+\r
+      //Remove excess gaps from the end of alignment\r
+      int maxLength = -1;\r
+\r
       SequenceI current;\r
+      for (int i = 0; i < sequences.size(); i++)\r
+      {\r
+        current = getSequenceAt(i);\r
+        for (int j = current.getLength(); j > maxLength; j--)\r
+        {\r
+          if (j > maxLength && !jalview.util.Comparison.isGap(\r
+              current.getCharAt(j)))\r
+          {\r
+            maxLength = j;\r
+            break;\r
+          }\r
+        }\r
+      }\r
+\r
+      maxLength++;\r
+\r
       for (int i = 0; i < sequences.size();\r
            i++)\r
       {\r
         current = getSequenceAt(i);\r
 \r
-        if (current.getLength() < Width)\r
+        if (current.getLength() < maxLength)\r
         {\r
-          current.insertCharAt(Width - 1, gapCharacter);\r
+          current.insertCharAt(maxLength - 1, gapCharacter);\r
           modified=true;\r
         }\r
+        else if(current.getLength() > maxLength)\r
+        {\r
+          current.deleteChars(maxLength, current.getLength());\r
+        }\r
       }\r
       return modified;\r
     }\r
+\r
+    public HiddenSequences getHiddenSequences()\r
+    {\r
+      return hiddenSequences;\r
+    }\r
+\r
 }\r