2 * Jalview - A Sequence Alignment Editor and Viewer (Version 2.4)
3 * Copyright (C) 2008 AM Waterhouse, J Procter, G Barton, M Clamp, S Searle
5 * This program is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU General Public License
7 * as published by the Free Software Foundation; either version 2
8 * of the License, or (at your option) any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
19 package jalview.commands;
22 * Jalview - A Sequence Alignment Editor and Viewer
23 * Copyright (C) 2007 AM Waterhouse, J Procter, G Barton, M Clamp, S Searle
25 * This program is free software; you can redistribute it and/or
26 * modify it under the terms of the GNU General Public License
27 * as published by the Free Software Foundation; either version 2
28 * of the License, or (at your option) any later version.
30 * This program is distributed in the hope that it will be useful,
31 * but WITHOUT ANY WARRANTY; without even the implied warranty of
32 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
33 * GNU General Public License for more details.
35 * You should have received a copy of the GNU General Public License
36 * along with this program; if not, write to the Free Software
37 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
40 import jalview.datamodel.*;
42 public class RemoveGapsCommand
45 public RemoveGapsCommand(String description,
46 SequenceI[] seqs, AlignmentI al)
48 this.description = description;
50 for (int i = 0; i < seqs.length; i++)
52 if (seqs[i].getLength() > width)
54 width = seqs[i].getLength();
58 findGaps(seqs, 0, width, al);
61 public RemoveGapsCommand(String description,
63 int start, int end, AlignmentI al)
65 this.description = description;
66 findGaps(seqs, start, end, al);
69 void findGaps(SequenceI[] seqs, int start, int end, AlignmentI al)
72 int startCol = -1, endCol = -1;
79 boolean delete = true;
82 for (int s = 0; s < seqs.length; s++)
87 sequence = seqs[s].getSequence(start, end + 1);
89 jSize = sequence.length;
90 for (j = 0; j < jSize; j++)
94 if (!jalview.util.Comparison.isGap(sequence[j]))
104 if (delete && startCol == -1)
109 if (!delete && startCol > -1)
111 this.appendEdit(DELETE_GAP, new SequenceI[]
113 start + startCol - deletedCols,
118 deletedCols += (endCol - startCol);
123 if (delete && startCol > -1)
125 this.appendEdit(DELETE_GAP, new SequenceI[]
127 start + startCol - deletedCols,