Clover icon

Coverage Report

  1. Project Clover database Thu Aug 13 2020 12:04:21 BST
  2. Package jalview.commands

File RemoveGapColCommand.java

 

Coverage histogram

../../img/srcFileCovDistChart9.png
12% of files have more coverage

Code metrics

16
27
2
1
102
60
13
0.48
13.5
2
6.5

Classes

Class Line # Actions
RemoveGapColCommand 26 27 13
0.866666786.7%
 

Contributing tests

This file is covered by 3 tests. .

Source view

1    /*
2    * Jalview - A Sequence Alignment Editor and Viewer ($$Version-Rel$$)
3    * Copyright (C) $$Year-Rel$$ The Jalview Authors
4    *
5    * This file is part of Jalview.
6    *
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.
11    *
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.
16    *
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.
20    */
21    package jalview.commands;
22   
23    import jalview.datamodel.AlignmentI;
24    import jalview.datamodel.SequenceI;
25   
 
26    public class RemoveGapColCommand extends EditCommand
27    {
28    int columnsDeleted;
29   
 
30  5 toggle public RemoveGapColCommand(String description, SequenceI[] seqs,
31    int start, int end, AlignmentI al)
32    {
33  5 this.description = description;
34   
35  5 int j, jSize = seqs.length;
36   
37  5 int startCol = -1, endCol = -1;
38  5 columnsDeleted = 0;
39   
40  5 clearEdits();
41   
42  5 boolean delete = true;
43  396474 for (int i = start; i <= end; i++)
44    {
45  396469 delete = true;
46   
47  4701521 for (j = 0; j < jSize; j++)
48    {
49  4310455 if (seqs[j].getLength() > i)
50    {
51  3541674 if (!jalview.util.Comparison.isGap(seqs[j].getCharAt(i)))
52    {
53  5403 if (delete)
54    {
55  5403 endCol = i;
56    }
57   
58  5403 delete = false;
59  5403 break;
60    }
61    }
62    }
63   
64  396469 if (delete && startCol == -1)
65    {
66  53 startCol = i;
67    }
68   
69  396469 if (!delete && startCol > -1)
70    {
71  53 this.appendEdit(Action.DELETE_GAP, seqs, startCol - columnsDeleted,
72    endCol - startCol, al, false, null);
73   
74  53 columnsDeleted += (endCol - startCol);
75  53 startCol = -1;
76  53 endCol = -1;
77    }
78    }
79   
80  5 if (delete && startCol > -1)
81    {
82    // This is for empty columns at the
83    // end of the alignment
84   
85  0 this.appendEdit(Action.DELETE_GAP, seqs, startCol - columnsDeleted,
86    end - startCol + 1, al, false, null);
87   
88  0 columnsDeleted += (end - startCol + 1);
89    }
90   
91  5 performEdit(0, null);
92    }
93   
 
94  0 toggle @Override
95    public int getSize()
96    {
97    // We're interested in the number of columns deleted,
98    // Not the number of sequence edits.
99  0 return columnsDeleted;
100    }
101   
102    }