2 * Jalview - A Sequence Alignment Editor and Viewer (Version 2.8)
3 * Copyright (C) 2012 J Procter, AM Waterhouse, LM Lui, J Engelhardt, G Barton, M Clamp, S Searle
5 * This file is part of Jalview.
7 * Jalview 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 3 of the License, or (at your option) any later version.
11 * Jalview is distributed in the hope that it will be useful, but
12 * WITHOUT ANY WARRANTY; without even the implied warranty
13 * of MERCHANTABILITY or FITNESS FOR A PARTICULAR
14 * PURPOSE. See the GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License along with Jalview. If not, see <http://www.gnu.org/licenses/>.
18 package jalview.commands;
21 * Jalview - A Sequence Alignment Editor and Viewer Copyright (C) 2007 AM
22 * Waterhouse, J Procter, G Barton, M Clamp, S Searle
24 * This program is free software; you can redistribute it and/or modify it under
25 * the terms of the GNU General Public License as published by the Free Software
26 * Foundation; either version 2 of the License, or (at your option) any later
29 * This program is distributed in the hope that it will be useful, but WITHOUT
30 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
31 * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
34 * You should have received a copy of the GNU General Public License along with
35 * this program; if not, write to the Free Software Foundation, Inc., 51
36 * Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
39 import jalview.datamodel.*;
41 public class RemoveGapColCommand extends EditCommand
45 public RemoveGapColCommand(String description, SequenceI[] seqs,
46 int start, int end, AlignmentI al)
48 this.description = description;
50 int j, jSize = seqs.length;
52 int startCol = -1, endCol = -1;
57 boolean delete = true;
58 for (int i = start; i <= end; i++)
62 for (j = 0; j < jSize; j++)
64 if (seqs[j].getLength() > i)
66 if (!jalview.util.Comparison.isGap(seqs[j].getCharAt(i)))
79 if (delete && startCol == -1)
84 if (!delete && startCol > -1)
86 this.appendEdit(DELETE_GAP, seqs, startCol - columnsDeleted, endCol
87 - startCol, al, false, null);
89 columnsDeleted += (endCol - startCol);
95 if (delete && startCol > -1)
97 // This is for empty columns at the
98 // end of the alignment
100 this.appendEdit(DELETE_GAP, seqs, startCol - columnsDeleted, end
101 - startCol + 1, al, false, null);
103 columnsDeleted += (end - startCol + 1);
106 performEdit(0, null);
111 // We're interested in the number of columns deleted,
112 // Not the number of sequence edits.
113 return columnsDeleted;