HiddenSequences now array, not hashtable
[jalview.git] / src / jalview / datamodel / Alignment.java
index 86c140f..5f60530 100755 (executable)
@@ -1,6 +1,6 @@
 /*
  * Jalview - A Sequence Alignment Editor and Viewer
- * Copyright (C) 2005 AM Waterhouse, J Procter, G Barton, M Clamp, S Searle
+ * Copyright (C) 2006 AM Waterhouse, J Procter, G Barton, M Clamp, S Searle
  *
  * This program is free software; you can redistribute it and/or
  * modify it under the terms of the GNU General Public License
@@ -146,8 +146,9 @@ public class Alignment implements AlignmentI
           getDataset().addSequence(ds);
         }
       }
-
       sequences.addElement(snew);
+
+      hiddenSequences.adjustHeightSequenceAdded();
     }
 
 
@@ -172,11 +173,17 @@ public class Alignment implements AlignmentI
     {
         return groups;
     }
-
     /** Takes out columns consisting entirely of gaps (-,.," ")
      */
-    public void removeGaps()
-    {
+    public void removeGaps() {
+      removeGaps((ShiftList)null);
+    }
+    /**
+     * remove gaps in alignment - recording any frame shifts in shiftrecord
+     * intended to be passed to ColumnSelection.compensateForEdits(shiftrecord)
+     * @param shiftrecord
+     */
+    public void removeGaps(ShiftList shiftrecord) {
         SequenceI[] seqs = getVisibleAndRepresentedSeqs();
         int j, jSize = seqs.length;
 
@@ -219,6 +226,9 @@ public class Alignment implements AlignmentI
             if (!delete && startCol > -1)
             {
               deleteColumns(seqs, startCol, endCol);
+              if (shiftrecord!=null) {
+                shiftrecord.addShift(startCol, 1+endCol-startCol);
+              }
               width -= (endCol - startCol);
               i -= (endCol - startCol);
               startCol = -1;
@@ -229,6 +239,9 @@ public class Alignment implements AlignmentI
         if (delete && startCol > -1)
         {
           deleteColumns(seqs, startCol, endCol);
+          if (shiftrecord!=null) {
+            shiftrecord.addShift(startCol, 1+endCol-startCol);
+          }
         }
     }
 
@@ -298,13 +311,7 @@ public class Alignment implements AlignmentI
      */
     public void deleteSequence(SequenceI s)
     {
-        for (int i = 0; i < getHeight(); i++)
-        {
-            if (getSequenceAt(i) == s)
-            {
-                deleteSequence(i);
-            }
-        }
+      deleteSequence(findIndex(s));
     }
 
     /**
@@ -315,6 +322,7 @@ public class Alignment implements AlignmentI
     public void deleteSequence(int i)
     {
         sequences.removeElementAt(i);
+        hiddenSequences.adjustHeightSequenceDeleted(i);
     }
 
 
@@ -394,8 +402,7 @@ public class Alignment implements AlignmentI
 
         while (i < sequences.size())
         {
-            Sequence s = (Sequence)getSequenceAt(i);
-            s.hiddenSequences = null;
+            SequenceI s = getSequenceAt(i);
             s.setColor(java.awt.Color.white);
             i++;
         }
@@ -406,9 +413,6 @@ public class Alignment implements AlignmentI
     {
         if (groups.contains(g))
         {
-          //remove any hidden representatives
-        //  for(int i=0; i<g.getsiz
-         //   g.getSequences()
             groups.removeElement(g);
         }
     }
@@ -557,15 +561,6 @@ public class Alignment implements AlignmentI
         return gapCharacter;
     }
 
-    /**
-     * DOCUMENT ME!
-     *
-     * @return DOCUMENT ME!
-     */
-    public Vector getAAFrequency()
-    {
-        return AAFrequency.calculate(sequences, 0, getWidth());
-    }
 
     /**
      * DOCUMENT ME!
@@ -836,7 +831,9 @@ public class Alignment implements AlignmentI
     for (int i=0; i<sequences.size(); i++) {
       alseqs[i] = new SeqCigar((SequenceI) sequences.elementAt(i));
     }
-    return new CigarArray(alseqs);
+    CigarArray cal = new CigarArray(alseqs);
+    cal.addOperation(CigarArray.M, getWidth());
+    return cal;
   }
 
 }