1 package jalview.commands;
\r
3 * Jalview - A Sequence Alignment Editor and Viewer
\r
4 * Copyright (C) 2006 AM Waterhouse, J Procter, G Barton, M Clamp, S Searle
\r
6 * This program is free software; you can redistribute it and/or
\r
7 * modify it under the terms of the GNU General Public License
\r
8 * as published by the Free Software Foundation; either version 2
\r
9 * of the License, or (at your option) any later version.
\r
11 * This program is distributed in the hope that it will be useful,
\r
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
\r
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
\r
14 * GNU General Public License for more details.
\r
16 * You should have received a copy of the GNU General Public License
\r
17 * along with this program; if not, write to the Free Software
\r
18 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
\r
21 import jalview.datamodel.*;
\r
23 public class RemoveGapsCommand extends EditCommand
\r
25 public RemoveGapsCommand( String description,
\r
26 SequenceI[] seqs, char gapChar)
\r
28 this.description = description;
\r
30 for(int i=0; i<seqs.length; i++)
\r
31 if(seqs[i].getLength()>width)
\r
32 width = seqs[i].getLength();
\r
34 findGaps(seqs, 0, width, gapChar);
\r
37 public RemoveGapsCommand( String description,
\r
39 int start, int end, char gapChar)
\r
41 this.description = description;
\r
42 findGaps(seqs, start, end, gapChar);
\r
45 void findGaps(SequenceI [] seqs, int start, int end, char gapChar)
\r
48 int startCol = -1, endCol = -1;
\r
49 int deletedCols = 0;
\r
53 edits = new Edit[0];
\r
55 boolean delete = true;
\r
58 for(int s=0; s<seqs.length; s++)
\r
63 sequence = seqs[s].getSequence(start, end+1).toCharArray();
\r
65 jSize = sequence.length;
\r
66 for (j=0; j<jSize; j++)
\r
71 if (!jalview.util.Comparison.isGap(sequence[j]))
\r
80 if (delete && startCol == -1)
\r
85 if (!delete && startCol > -1)
\r
87 this.appendEdit(DELETE_GAP, new SequenceI[]{seqs[s]},
\r
88 start + startCol - deletedCols,
\r
93 deletedCols += (endCol - startCol);
\r
98 if (delete && startCol > -1)
\r
100 this.appendEdit(DELETE_GAP, new SequenceI[]{seqs[s]},
\r
101 start + startCol - deletedCols,
\r