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 RemoveGapsCommand
27 public RemoveGapsCommand(String description,
28 SequenceI[] seqs, AlignmentI al)
30 this.description = description;
32 for (int i = 0; i < seqs.length; i++)
34 if (seqs[i].getLength() > width)
36 width = seqs[i].getLength();
40 findGaps(seqs, 0, width, al);
43 public RemoveGapsCommand(String description,
45 int start, int end, AlignmentI al)
47 this.description = description;
48 findGaps(seqs, start, end, al);
51 void findGaps(SequenceI[] seqs, int start, int end, AlignmentI al)
54 int startCol = -1, endCol = -1;
61 boolean delete = true;
64 for (int s = 0; s < seqs.length; s++)
69 sequence = seqs[s].getSequence(start, end + 1);
71 jSize = sequence.length;
72 for (j = 0; j < jSize; j++)
76 if (!jalview.util.Comparison.isGap(sequence[j]))
86 if (delete && startCol == -1)
91 if (!delete && startCol > -1)
93 this.appendEdit(DELETE_GAP, new SequenceI[]
95 start + startCol - deletedCols,
100 deletedCols += (endCol - startCol);
105 if (delete && startCol > -1)
107 this.appendEdit(DELETE_GAP, new SequenceI[]
109 start + startCol - deletedCols,