maxIdLength redundant, deleteCols, trimLeft, removeGaps moved to Commands
authoramwaterhouse <Andrew Waterhouse>
Tue, 24 Oct 2006 11:20:33 +0000 (11:20 +0000)
committeramwaterhouse <Andrew Waterhouse>
Tue, 24 Oct 2006 11:20:33 +0000 (11:20 +0000)
src/jalview/datamodel/Alignment.java
src/jalview/datamodel/AlignmentI.java

index 5f60530..4485c46 100755 (executable)
@@ -173,136 +173,6 @@ public class Alignment implements AlignmentI
     {
         return groups;
     }
-    /** Takes out columns consisting entirely of gaps (-,.," ")
-     */
-    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;
-
-        int width = 0;
-        for (int i = 0; i < jSize; i++)
-        {
-          if (seqs[i].getLength() > width)
-          {
-            width = seqs[i].getLength();
-          }
-        }
-
-        int startCol = -1, endCol = -1;
-        boolean delete = true;
-        for (int i = 0; i < width; i++)
-        {
-            delete = true;
-
-            for (j = 0; j < jSize; j++)
-            {
-                if (seqs[j].getLength() > i)
-                {
-                    if (!jalview.util.Comparison.isGap(seqs[j].getCharAt(i)))
-                    {
-                        if(delete)
-                          endCol = i;
-
-                        delete = false;
-                        break;
-                    }
-                }
-            }
-
-            if(delete && startCol==-1)
-            {
-              startCol = i;
-            }
-
-
-            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;
-              endCol = -1;
-            }
-        }
-
-        if (delete && startCol > -1)
-        {
-          deleteColumns(seqs, startCol, endCol);
-          if (shiftrecord!=null) {
-            shiftrecord.addShift(startCol, 1+endCol-startCol);
-          }
-        }
-    }
-
-    /** Removes a range of columns (start to end inclusive).
-     *
-     * @param seqs Sequences to remove columns from
-     * @param start Start column in the alignment
-     * @param end End column in the alignment
-     */
-    public void deleteColumns(SequenceI [] seqs, int start, int end)
-    {
-      for(int i=0; i<seqs.length; i++)
-        seqs[i].deleteChars(start, end);
-    }
-
-
-    /**
-     * DOCUMENT ME!
-     *
-     * @param i DOCUMENT ME!
-     */
-    public void trimLeft(int i)
-    {
-        SequenceI[] seqs = getVisibleAndRepresentedSeqs();
-        int j, jSize = seqs.length;
-        for (j = 0; j < jSize; j++)
-        {
-            int newstart = seqs[j].findPosition(i);
-
-            if(i>seqs[j].getLength())
-            {
-              sequences.removeElement(seqs[j]);
-              j--;
-              jSize--;
-            }
-            else
-            {
-              seqs[j].setStart(newstart);
-              seqs[j].setSequence(seqs[j].getSequence().substring(i));
-            }
-        }
-    }
-
-    /**
-     * DOCUMENT ME!
-     *
-     * @param i DOCUMENT ME!
-     */
-    public void trimRight(int i)
-    {
-        SequenceI[] seqs = getVisibleAndRepresentedSeqs();
-        int j, jSize = seqs.length;
-        for (j = 0; j < jSize; j++)
-        {
-            int newend = seqs[j].findPosition(i);
-
-            seqs[j].setEnd(newend);
-            if(seqs[j].getLength()>i)
-              seqs[j].setSequence(seqs[j].getSequence().substring(0, i + 1));
-        }
-    }
 
     /**
      * DOCUMENT ME!
@@ -321,8 +191,11 @@ public class Alignment implements AlignmentI
      */
     public void deleteSequence(int i)
     {
+      if(i>0 && i<getHeight())
+      {
         sequences.removeElementAt(i);
         hiddenSequences.adjustHeightSequenceDeleted(i);
+      }
     }
 
 
@@ -506,32 +379,6 @@ public class Alignment implements AlignmentI
         return maxLength;
     }
 
-    /**
-     * DOCUMENT ME!
-     *
-     * @return DOCUMENT ME!
-     */
-    public int getMaxIdLength()
-    {
-        int max = 0;
-        int i = 0;
-
-        while (i < sequences.size())
-        {
-            SequenceI seq = getSequenceAt(i);
-            String tmp = seq.getName() + "/" + seq.getStart() + "-" +
-                seq.getEnd();
-
-            if (tmp.length() > max)
-            {
-                max = tmp.length();
-            }
-
-            i++;
-        }
-
-        return max;
-    }
 
     /**
      * DOCUMENT ME!
index 71ba3e0..94dbf1b 100755 (executable)
@@ -41,12 +41,6 @@ public interface AlignmentI
      */
     public int getWidth();
 
-    /**
-     * Calculates the longest sequence Id of the alignment
-     *
-     * @return Number of characters in longest sequence Id.
-     */
-    public int getMaxIdLength();
 
     /**
      * Calculates if this set of sequences is all the same length
@@ -94,7 +88,7 @@ public interface AlignmentI
     public void setSequenceAt(int i, SequenceI seq);
 
     /**
-     * Deletes a sequence from the alignment.
+     * Deletes a sequence from the alignment
      *
      * @param s Sequence to be deleted.
      */
@@ -109,15 +103,6 @@ public interface AlignmentI
 
 
     /**
-     * Deletes all residues in every sequence of alignment within given columns.
-     *
-     * @param start Start index of columns to delete.
-     * @param end End index to columns to delete.
-     */
-    public void deleteColumns(SequenceI seqs [], int start, int end);
-
-
-    /**
      * Finds sequence in alignment using sequence name as query.
      *
      * @param name Id of sequence to search for.
@@ -137,29 +122,6 @@ public interface AlignmentI
      */
     public int findIndex(SequenceI s);
 
-    /**
-    * All sequences will be cut from beginning to given index.
-    *
-    * @param i Remove all residues in sequences up to this column.
-     */
-    public void trimLeft(int i);
-
-    /**
-     * All sequences will be cut from given index.
-     *
-     * @param i Remove all residues in sequences beyond this column.
-     */
-    public void trimRight(int i);
-
-    /**
-     * Removes all columns containing entirely gap characters.
-     */
-    public void removeGaps();
-    /**
-     * remove gaps in alignment - recording any frame shifts in shiftrecord
-     * @param shiftrecord
-     */
-    public void removeGaps(ShiftList shiftrecord);
 
     /**
      * Finds group that given sequence is part of.