*/
package jalview.analysis;
+import jalview.api.AlignViewportI;
import jalview.api.FinderI;
import jalview.datamodel.AlignmentI;
import jalview.datamodel.Range;
private Vector<SequenceI> idMatches;
/*
- * the alignment to search over
+ * the viewport to search over
*/
- private AlignmentI alignment;
-
- /*
- * (optional) selection to restrict search to
- */
- private SequenceGroup selection;
+ private AlignViewportI viewport;
/*
* sequence index in alignment to search from
private int columnIndex;
/**
- * Constructor for searching an alignment
+ * Constructor for searching a viewport
*
- * @param al
+ * @param av
*/
- public Finder(AlignmentI al)
+ public Finder(AlignViewportI av)
{
- this.alignment = al;
+ this.viewport = av;
this.sequenceIndex = 0;
this.columnIndex = -1;
}
@Override
- public void findAll(String theSearchString, SequenceGroup sg,
- boolean matchCase, boolean searchDescription)
+ public void findAll(String theSearchString, boolean matchCase,
+ boolean searchDescription)
{
/*
* search from the start
sequenceIndex = 0;
columnIndex = -1;
- doFind(theSearchString, sg, matchCase, searchDescription, true);
+ doFind(theSearchString, matchCase, searchDescription, true);
/*
* reset to start for next search
}
@Override
- public void findNext(String theSearchString, SequenceGroup sg,
- boolean matchCase, boolean searchDescription)
+ public void findNext(String theSearchString, boolean matchCase,
+ boolean searchDescription)
{
- doFind(theSearchString, sg, matchCase, searchDescription, false);
+ doFind(theSearchString, matchCase, searchDescription, false);
if (searchResults.isEmpty() && idMatches.isEmpty())
{
}
/**
- * Performs a 'find next' or 'find all', optionally restricted to the
- * specified selection region
+ * Performs a 'find next' or 'find all'
*
* @param theSearchString
- * @param selectionRegion
* @param matchCase
* @param searchDescription
* @param findAll
*/
- protected void doFind(String theSearchString, SequenceGroup selectionRegion,
- boolean matchCase, boolean searchDescription, boolean findAll)
+ protected void doFind(String theSearchString, boolean matchCase,
+ boolean searchDescription, boolean findAll)
{
- this.selection = selectionRegion;
String searchString = matchCase ? theSearchString
: theSearchString.toUpperCase();
Regex searchPattern = new Regex(searchString);
searchResults = new SearchResults();
idMatches = new Vector<>();
+ SequenceGroup selection = viewport.getSelectionGroup();
if (selection != null && selection.getSize() < 1)
{
selection = null; // ? ignore column-only selection
}
+ AlignmentI alignment = viewport.getAlignment();
int end = alignment.getHeight();
while (sequenceIndex < end)
* restrict search to (next) visible column region,
* in case there are hidden columns
*/
+ AlignmentI alignment = viewport.getAlignment();
VisibleContigsIterator visibleRegions = alignment.getHiddenColumns()
.getVisContigsIterator(column, alignment.getWidth(),
false);
/*
* restrict search to selected region if there is one
*/
+ SequenceGroup selection = viewport.getSelectionGroup();
if (selection != null)
{
int selectionStart = selection.getStartRes();
protected boolean findNextMatch(SequenceI seq, String searchString,
Regex searchPattern, boolean matchDescription)
{
+ SequenceGroup selection = viewport.getSelectionGroup();
if (selection != null && !selection.contains(seq))
{
/*