X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Fdatamodel%2FSearchResultsI.java;h=794682412897ea634ba901595a832119749adaf8;hb=a7169b1c72607f3c9357195b4999869650a2a891;hp=bc62a666c37d9c7362886e3bc1df67cd227b2ebc;hpb=435792460e417edc981c308f917f2ff5a7829971;p=jalview.git
diff --git a/src/jalview/datamodel/SearchResultsI.java b/src/jalview/datamodel/SearchResultsI.java
index bc62a66..7946824 100644
--- a/src/jalview/datamodel/SearchResultsI.java
+++ b/src/jalview/datamodel/SearchResultsI.java
@@ -1,83 +1,111 @@
+/*
+ * Jalview - A Sequence Alignment Editor and Viewer ($$Version-Rel$$)
+ * Copyright (C) $$Year-Rel$$ The Jalview Authors
+ *
+ * This file is part of Jalview.
+ *
+ * Jalview is free software: you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation, either version 3
+ * of the License, or (at your option) any later version.
+ *
+ * Jalview is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty
+ * of MERCHANTABILITY or FITNESS FOR A PARTICULAR
+ * PURPOSE. See the GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with Jalview. If not, see .
+ * The Jalview Authors are detailed in the 'AUTHORS' file.
+ */
package jalview.datamodel;
-
import java.util.BitSet;
import java.util.List;
+/**
+ * An interface describing the result of a search or other operation which
+ * highlights matched regions of an alignment
+ */
public interface SearchResultsI
{
/**
- * This method replaces the old search results which merely held an alignment
- * index of search matches. This broke when sequences were moved around the
- * alignment
+ * Adds one region to the results (unless already added, to avoid duplicates)
*
* @param seq
- * Sequence
* @param start
- * int
* @param end
- * int
+ * @return
*/
- public abstract void addResult(SequenceI seq, int start, int end);
+ SearchResultMatchI addResult(SequenceI seq, int start, int end);
/**
- * Quickly check if the given sequence is referred to in the search results
+ * Adds one ore more [start, end] ranges to the results (unless already added
+ * to avoid duplicates). This method only increments the match count by 1.
+ * This is for the case where a match spans ignored hidden residues - it is
+ * formally two or more contiguous matches, but only counted as one match.
*
- * @param sequence
- * (specific alignment sequence or a dataset sequence)
- * @return true if the results involve sequence
+ * @param seq
+ * @param positions
*/
- public abstract boolean involvesSequence(SequenceI sequence);
+ void addResult(SequenceI seq, int[] positions);
/**
- * This Method returns the search matches which lie between the start and end
- * points of the sequence in question . It is optimised for returning objects
- * for drawing on SequenceCanvas
+ * adds all match results in the argument to this set
*
- * @param sequence
- * sequence to highlight columns according to matches
- * @param start
- * - first column of visible region
- * @param end
- * - last column of visible region
- * @return int[] ranges within start/end index on sequence
+ * @param toAdd
*/
- public abstract int[] getResults(SequenceI sequence, int start, int end);
-
- public abstract int getSize();
-
- public abstract SequenceI getResultSequence(int index);
+ void addSearchResults(SearchResultsI toAdd);
/**
- * Returns the start position of the i'th match in the search results.
+ * Answers true if the search results include the given sequence (or its
+ * dataset sequence), else false
*
- * @param i
+ * @param sequence
* @return
*/
- public abstract int getResultStart(int i);
+ boolean involvesSequence(SequenceI sequence);
/**
- * Returns the end position of the i'th match in the search results.
+ * Returns an array of [from, to, from, to..] matched columns (base 0) between
+ * the given start and end columns of the given sequence. Returns null if no
+ * matches overlap the specified region.
+ *
+ * Implementations should provide an optimised method to return locations to
+ * highlight on a visible portion of an alignment.
+ *
+ * @param sequence
+ * @param start
+ * first column of range (base 0, inclusive)
+ * @param end
+ * last column of range base 0, inclusive)
+ * @return int[]
+ */
+ int[] getResults(SequenceI sequence, int start, int end);
+
+ /**
+ * Returns the number of matches found. Note that if a match straddles ignored
+ * hidden residues, it is counted as one match, although formally recorded as
+ * two (or more) contiguous matched sequence regions
*
- * @param i
* @return
*/
- public abstract int getResultEnd(int i);
+ int getCount();
/**
* Returns true if no search result matches are held.
*
* @return
*/
- public abstract boolean isEmpty();
+ boolean isEmpty();
/**
* Returns the list of matches.
*
* @return
*/
- public abstract List getResults();
+ List getResults();
/**
* Set bits in a bitfield for all columns in the given sequence collection
@@ -89,5 +117,13 @@ public interface SearchResultsI
* bitset to set
* @return number of bits set
*/
- public abstract int markColumns(SequenceCollectionI sqcol, BitSet bs);
+ int markColumns(SequenceCollectionI sqcol, BitSet bs);
+
+ /**
+ * Return sub-sequences corresponding to distinct contiguous ranges in the
+ * matching set
+ *
+ * @return list of sequence objects
+ */
+ List getMatchingSubSequences();
}
\ No newline at end of file