* @param toggle
* - rather than explicitly set, toggle selection state
* @param featureType
- * - feature type string
+ * - one or more feature types to match
* @return true if operation affected state
*/
boolean markColumnsContainingFeatures(boolean invert,
- boolean extendCurrent, boolean toggle, String featureType);
+ boolean extendCurrent, boolean toggle, String... featureType);
/**
* sort the alignment or current selection by average score over the given set
@Override
public boolean markColumnsContainingFeatures(boolean invert,
- boolean extendCurrent, boolean toggle, String featureType)
+ boolean extendCurrent, boolean toggle, String... featureType)
{
// JBPNote this routine could also mark rows, not just columns.
// need a decent query structure to allow all types of feature searches
|| extendCurrent) ? viewport.getAlignment()
: viewport.getSelectionGroup();
- int nseq = findColumnsWithFeature(featureType, sqcol, bs);
+ int nseq = findColumnsWithFeature(sqcol, bs, featureType);
ColumnSelection cs = viewport.getColumnSelection();
if (cs == null)
cs = new ColumnSelection();
}
+ String featureTypeString = featureType.length == 1 ? featureType[0]
+ : featureType.toString();
+
if (bs.cardinality() > 0 || invert)
{
boolean changed = cs.markColumns(bs, sqcol.getStartRes(),
invert ? MessageManager
.getString("label.not_containing")
: MessageManager.getString("label.containing"),
- featureType, Integer.valueOf(nseq).toString() }));
+ featureTypeString, Integer.valueOf(nseq).toString() }));
return true;
}
}
{
avcg.setStatus(MessageManager
.formatMessage("label.no_feature_of_type_found", new String[]
- { featureType }));
+ { featureTypeString }));
if (!extendCurrent)
{
cs.clear();
/**
* Sets a bit in the BitSet for each column (base 0) in the sequence
- * collection which includes a visible feature of the specified feature type.
- * Returns the number of sequences which have the feature visible in the
- * selected range.
+ * collection which includes a visible feature of the specified feature
+ * type(s). Returns the number of sequences which have the feature(s) visible
+ * in the selected range.
*
- * @param featureType
* @param sqcol
* @param bs
+ * @param featureType
+ *
* @return
*/
- int findColumnsWithFeature(String featureType,
- SequenceCollectionI sqcol, BitSet bs)
+ int findColumnsWithFeature(SequenceCollectionI sqcol,
+ BitSet bs, String... featureType)
{
FeatureRenderer fr = alignPanel == null ? null : alignPanel
.getFeatureRenderer();
boolean invertSelection = evt.isAltDown();
boolean toggleSelection = Platform.isControlDown(evt);
boolean extendSelection = evt.isShiftDown();
+ String[] terms = getTermsInScope(type);
fr.ap.alignFrame.avc.markColumnsContainingFeatures(
- invertSelection, extendSelection, toggleSelection, type);
+ invertSelection, extendSelection, toggleSelection, terms);
}
}
});
}
+ /**
+ * Answers an array consisting of the given type, and also (if 'Summary View'
+ * is selected), any child terms in the sequence ontology
+ *
+ * @param type
+ * @return
+ */
+ protected String[] getTermsInScope(String type)
+ {
+ if (!summaryView.isSelected())
+ {
+ return new String[] { type };
+ }
+
+ List<String> terms = new ArrayList<>();
+ terms.add(type);
+
+ OntologyI so = SequenceOntologyFactory.getInstance();
+
+ Object[][] data = ((FeatureTableModel) table.getModel()).getData();
+ for (Object[] row : data)
+ {
+ String type2 = (String) row[TYPE_COLUMN];
+ if (!type2.equals(type) && so.isA(type2, type))
+ {
+ terms.add(type2);
+ }
+ }
+ return terms.toArray(new String[terms.size()]);
+ }
+
protected void popupMenu(final int rowSelected, final String type,
final Object typeCol, int x, int y)
{
protected void eraseConsensus(int aWidth)
{
AlignmentAnnotation consensus = getConsensusAnnotation();
- consensus.annotations = new Annotation[aWidth];
+ if (consensus != null)
+ {
+ consensus.annotations = new Annotation[aWidth];
+ }
AlignmentAnnotation gap = getGapAnnotation();
if (gap != null)
{
af.alignPanel);
BitSet bs = new BitSet();
- int seqCount = avc.findColumnsWithFeature("Metal", sg, bs);
+ int seqCount = avc.findColumnsWithFeature(sg, bs, "Metal");
assertEquals(1, seqCount);
assertEquals(2, bs.cardinality());
assertTrue(bs.get(3)); // base 0
*/
sg.setEndRes(6);
bs.clear();
- seqCount = avc.findColumnsWithFeature("Metal", sg, bs);
+ seqCount = avc.findColumnsWithFeature(sg, bs, "Metal");
assertEquals(2, seqCount);
assertEquals(4, bs.cardinality());
assertTrue(bs.get(3));
sg.setStartRes(13);
sg.setEndRes(13);
bs.clear();
- seqCount = avc.findColumnsWithFeature("Metal", sg, bs);
+ seqCount = avc.findColumnsWithFeature(sg, bs, "Metal");
assertEquals(1, seqCount);
assertEquals(1, bs.cardinality());
assertTrue(bs.get(13));
sg.setStartRes(17);
sg.setEndRes(19);
bs.clear();
- seqCount = avc.findColumnsWithFeature("Metal", sg, bs);
+ seqCount = avc.findColumnsWithFeature(sg, bs, "Metal");
assertEquals(0, seqCount);
assertEquals(0, bs.cardinality());
sg.setStartRes(0);
sg.setEndRes(6);
bs.clear();
- seqCount = avc.findColumnsWithFeature("Metal", sg, bs);
+ seqCount = avc.findColumnsWithFeature(sg, bs, "Metal");
assertEquals(1, seqCount);
assertEquals(2, bs.cardinality());
assertTrue(bs.get(5));
sg.setStartRes(10);
sg.setEndRes(12);
bs.clear();
- seqCount = avc.findColumnsWithFeature("disulfide bond", sg, bs);
+ seqCount = avc.findColumnsWithFeature(sg, bs, "disulfide bond");
assertEquals(0, seqCount);
assertEquals(0, bs.cardinality());
sg.setStartRes(5);
sg.setEndRes(17);
bs.clear();
- seqCount = avc.findColumnsWithFeature("disulfide bond", sg, bs);
+ seqCount = avc.findColumnsWithFeature(sg, bs, "disulfide bond");
assertEquals(1, seqCount);
assertEquals(2, bs.cardinality());
assertTrue(bs.get(8));
sg.setStartRes(0);
sg.setEndRes(19);
bs.clear();
- seqCount = avc.findColumnsWithFeature("Pfam", sg, bs);
+ seqCount = avc.findColumnsWithFeature(sg, bs, "Pfam");
assertEquals(0, seqCount);
assertEquals(0, bs.cardinality());
}