1 package jalview.commands;
4 * Jalview - A Sequence Alignment Editor and Viewer
5 * Copyright (C) 2007 AM Waterhouse, J Procter, G Barton, M Clamp, S Searle
7 * This program is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License
9 * as published by the Free Software Foundation; either version 2
10 * of the License, or (at your option) any later version.
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
22 import jalview.datamodel.*;
24 public class RemoveGapColCommand
28 public RemoveGapColCommand(String description,
30 int start, int end, AlignmentI al)
32 this.description = description;
34 int j, jSize = seqs.length;
36 int startCol = -1, endCol = -1;
41 boolean delete = true;
42 for (int i = start; i <= end; i++)
46 for (j = 0; j < jSize; j++)
48 if (seqs[j].getLength() > i)
50 if (!jalview.util.Comparison.isGap(seqs[j].getCharAt(i)))
63 if (delete && startCol == -1)
68 if (!delete && startCol > -1)
70 this.appendEdit(DELETE_GAP, seqs,
71 startCol - columnsDeleted,
76 columnsDeleted += (endCol - startCol);
82 if (delete && startCol > -1)
84 //This is for empty columns at the
85 //end of the alignment
87 this.appendEdit(DELETE_GAP, seqs,
88 startCol - columnsDeleted,
93 columnsDeleted += (end - startCol + 1);
101 //We're interested in the number of columns deleted,
102 //Not the number of sequence edits.
103 return columnsDeleted;