2 * Jalview - A Sequence Alignment Editor and Viewer ($$Version-Rel$$)
3 * Copyright (C) $$Year-Rel$$ The Jalview Authors
5 * This file is part of Jalview.
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.
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.
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.
21 import jalview.analysis.*;
22 import jalview.datamodel.*;
23 import jalview.gui.AlignFrame;
24 import jalview.gui.AlignViewport;
25 import java.util.BitSet;
26 import javax.swing.JOptionPane;
27 import groovy.swing.SwingBuilder;
28 def toselect = getFeatureInput(); // change this to select the desired feature type
34 for (ala in Jalview.getAlignFrames()) {
35 def al = ala.viewport.alignment;
38 BitSet bs = new BitSet();
39 SequenceI[] seqs = al.getSequencesArray();
44 SequenceFeature[] sf = sq.getSequenceFeatures();
47 if (sfpos!=null && sfpos.getType().equals(toselect))
50 int i=sq.findIndex(sfpos.getBegin());
51 int ist=sq.findIndex(sq.getStart());
56 int j=sq.findIndex(sfpos.getEnd());
73 if (bs.cardinality()>0)
76 ColumnSelection cs = ala.viewport.getColumnSelection();
78 cs = new ColumnSelection();
80 for (int i = bs.nextSetBit(0); i >= 0; i = bs.nextSetBit(i+1)) {
83 ala.viewport.setColumnSelection(cs);
84 ala.alignPanel.paintAlignment(true);
85 ala.statusBar.setText("Marked "+bs.cardinality()+" columns containing features of type "+toselect)
87 ala.statusBar.setText("No features of type "+toselect+" found.");
91 return "Found a total of ${nfeat} features across ${nseq} sequences in ${nal} alignments.";
93 String getFeatureInput(){
94 def swingBuilder = new SwingBuilder();
95 def response = JvOptionPane.showInputDialog(
96 null, 'Select columns by feature by type','Enter type of feature', JvOptionPane.OK_OPTION)