1 package jalview.commands;
\r
4 * Jalview - A Sequence Alignment Editor and Viewer
\r
5 * Copyright (C) 2007 AM Waterhouse, J Procter, G Barton, M Clamp, S Searle
\r
7 * This program is free software; you can redistribute it and/or
\r
8 * modify it under the terms of the GNU General Public License
\r
9 * as published by the Free Software Foundation; either version 2
\r
10 * of the License, or (at your option) any later version.
\r
12 * This program is distributed in the hope that it will be useful,
\r
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
\r
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
\r
15 * GNU General Public License for more details.
\r
17 * You should have received a copy of the GNU General Public License
\r
18 * along with this program; if not, write to the Free Software
\r
19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
\r
22 import jalview.datamodel.*;
\r
24 public class RemoveGapsCommand
\r
27 public RemoveGapsCommand(String description,
\r
28 SequenceI[] seqs, AlignmentI al)
\r
30 this.description = description;
\r
32 for (int i = 0; i < seqs.length; i++)
\r
34 if (seqs[i].getLength() > width)
\r
36 width = seqs[i].getLength();
\r
40 findGaps(seqs, 0, width, al);
\r
43 public RemoveGapsCommand(String description,
\r
45 int start, int end, AlignmentI al)
\r
47 this.description = description;
\r
48 findGaps(seqs, start, end, al);
\r
51 void findGaps(SequenceI[] seqs, int start, int end, AlignmentI al)
\r
54 int startCol = -1, endCol = -1;
\r
55 int deletedCols = 0;
\r
59 edits = new Edit[0];
\r
61 boolean delete = true;
\r
64 for (int s = 0; s < seqs.length; s++)
\r
69 sequence = seqs[s].getSequence(start, end + 1);
\r
71 jSize = sequence.length;
\r
72 for (j = 0; j < jSize; j++)
\r
76 if (!jalview.util.Comparison.isGap(sequence[j]))
\r
86 if (delete && startCol == -1)
\r
91 if (!delete && startCol > -1)
\r
93 this.appendEdit(DELETE_GAP, new SequenceI[]
\r
95 start + startCol - deletedCols,
\r
100 deletedCols += (endCol - startCol);
\r
105 if (delete && startCol > -1)
\r
107 this.appendEdit(DELETE_GAP, new SequenceI[]
\r
109 start + startCol - deletedCols,
\r