2 * Jalview - A Sequence Alignment Editor and Viewer ($$Version-Rel$$)
3 * Copyright (C) $$Year-Rel$$ The Jalview Authors
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
10 * of the License, or (at your option) any later version.
12 * Jalview is distributed in the hope that it will be useful, but
13 * WITHOUT ANY WARRANTY; without even the implied warranty
14 * of MERCHANTABILITY or FITNESS FOR A PARTICULAR
15 * PURPOSE. See the GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with Jalview. If not, see <http://www.gnu.org/licenses/>.
19 * The Jalview Authors are detailed in the 'AUTHORS' file.
21 package jalview.commands;
23 import jalview.datamodel.AlignmentI;
24 import jalview.datamodel.SequenceI;
26 public class RemoveGapColCommand extends EditCommand
30 public RemoveGapColCommand(String description, SequenceI[] seqs,
31 int start, int end, AlignmentI al)
33 this.description = description;
35 int j, jSize = seqs.length;
37 int startCol = -1, endCol = -1;
42 boolean delete = true;
43 for (int i = start; i <= end; i++)
47 for (j = 0; j < jSize; j++)
49 if (seqs[j].getLength() > i)
51 if (!jalview.util.Comparison.isGap(seqs[j].getCharAt(i)))
64 if (delete && startCol == -1)
69 if (!delete && startCol > -1)
71 this.appendEdit(Action.DELETE_GAP, seqs, startCol - columnsDeleted,
72 endCol - startCol, al, false, null);
74 columnsDeleted += (endCol - startCol);
80 if (delete && startCol > -1)
82 // This is for empty columns at the
83 // end of the alignment
85 this.appendEdit(Action.DELETE_GAP, seqs, startCol - columnsDeleted,
86 end - startCol + 1, al, false, null);
88 columnsDeleted += (end - startCol + 1);
97 // We're interested in the number of columns deleted,
98 // Not the number of sequence edits.
99 return columnsDeleted;