From: Jim Procter Date: Fri, 28 Oct 2016 16:11:39 +0000 (+0100) Subject: JAL-966 JAL-1738 JAL-345 interfaces for SearchResults and SearchResults.Match X-Git-Tag: Release_2_10_1~10^2~6^2~1^2~23 X-Git-Url: http://source.jalview.org/gitweb/?a=commitdiff_plain;h=52402128d98c6744eb6348dd788fe6e8cd34575c;p=jalview.git JAL-966 JAL-1738 JAL-345 interfaces for SearchResults and SearchResults.Match --- diff --git a/src/jalview/analysis/Finder.java b/src/jalview/analysis/Finder.java index 72097e0..086765c 100644 --- a/src/jalview/analysis/Finder.java +++ b/src/jalview/analysis/Finder.java @@ -22,6 +22,7 @@ package jalview.analysis; import jalview.datamodel.AlignmentI; import jalview.datamodel.SearchResults; +import jalview.datamodel.SearchResultsI; import jalview.datamodel.Sequence; import jalview.datamodel.SequenceGroup; @@ -32,7 +33,7 @@ public class Finder /** * Implements the search algorithms for the Find dialog box. */ - SearchResults searchResults; + SearchResultsI searchResults; AlignmentI alignment; @@ -338,7 +339,7 @@ public class Finder /** * @return the searchResults */ - public SearchResults getSearchResults() + public SearchResultsI getSearchResults() { return searchResults; } diff --git a/src/jalview/appletgui/AlignViewport.java b/src/jalview/appletgui/AlignViewport.java index e5178cb..4bd77b6 100644 --- a/src/jalview/appletgui/AlignViewport.java +++ b/src/jalview/appletgui/AlignViewport.java @@ -28,6 +28,7 @@ import jalview.commands.CommandI; import jalview.datamodel.AlignmentI; import jalview.datamodel.ColumnSelection; import jalview.datamodel.SearchResults; +import jalview.datamodel.SearchResultsI; import jalview.datamodel.Sequence; import jalview.datamodel.SequenceGroup; import jalview.datamodel.SequenceI; @@ -433,7 +434,7 @@ public class AlignViewport extends AlignmentViewport implements * there is no complement, or it is not following highlights, or no mapping * is found, the result will be empty. */ - SearchResults sr = new SearchResults(); + SearchResultsI sr = new SearchResults(); int seqOffset = findComplementScrollTarget(sr); if (!sr.isEmpty()) { diff --git a/src/jalview/appletgui/AlignmentPanel.java b/src/jalview/appletgui/AlignmentPanel.java index 813ab84..4198960 100644 --- a/src/jalview/appletgui/AlignmentPanel.java +++ b/src/jalview/appletgui/AlignmentPanel.java @@ -25,7 +25,7 @@ import jalview.api.AlignViewportI; import jalview.api.AlignmentViewPanel; import jalview.bin.JalviewLite; import jalview.datamodel.AlignmentI; -import jalview.datamodel.SearchResults; +import jalview.datamodel.SearchResultsI; import jalview.datamodel.SequenceI; import jalview.structure.StructureSelectionManager; @@ -293,7 +293,7 @@ public class AlignmentPanel extends Panel implements AdjustmentListener, * Highlight the given results on the alignment. * */ - public void highlightSearchResults(SearchResults results) + public void highlightSearchResults(SearchResultsI results) { scrollToPosition(results); seqPanel.seqCanvas.highlightSearchResults(results); @@ -306,7 +306,7 @@ public class AlignmentPanel extends Panel implements AdjustmentListener, * @param results * @return false if results were not found */ - public boolean scrollToPosition(SearchResults results) + public boolean scrollToPosition(SearchResultsI results) { return scrollToPosition(results, true); } @@ -320,7 +320,7 @@ public class AlignmentPanel extends Panel implements AdjustmentListener, * - when set, the overview will be recalculated (takes longer) * @return false if results were not found */ - public boolean scrollToPosition(SearchResults results, + public boolean scrollToPosition(SearchResultsI results, boolean redrawOverview) { return scrollToPosition(results, redrawOverview, false); @@ -335,7 +335,7 @@ public class AlignmentPanel extends Panel implements AdjustmentListener, * - when set, the overview will be recalculated (takes longer) * @return false if results were not found */ - public boolean scrollToPosition(SearchResults results, + public boolean scrollToPosition(SearchResultsI results, boolean redrawOverview, boolean centre) { // do we need to scroll the panel? @@ -902,7 +902,7 @@ public class AlignmentPanel extends Panel implements AdjustmentListener, * @param seqOffset * the number of visible sequences to show above the mapped region */ - protected void scrollToCentre(SearchResults sr, int seqOffset) + protected void scrollToCentre(SearchResultsI sr, int seqOffset) { /* * To avoid jumpy vertical scrolling (if some sequences are gapped or not diff --git a/src/jalview/appletgui/FeatureRenderer.java b/src/jalview/appletgui/FeatureRenderer.java index 82736d7..2fca07d 100644 --- a/src/jalview/appletgui/FeatureRenderer.java +++ b/src/jalview/appletgui/FeatureRenderer.java @@ -22,6 +22,7 @@ package jalview.appletgui; import jalview.api.FeatureColourI; import jalview.datamodel.SearchResults; +import jalview.datamodel.SearchResultsI; import jalview.datamodel.SequenceFeature; import jalview.datamodel.SequenceI; import jalview.io.FeaturesFile; @@ -225,7 +226,7 @@ public class FeatureRenderer extends start.setText(features[index].getBegin() + ""); end.setText(features[index].getEnd() + ""); - SearchResults highlight = new SearchResults(); + SearchResultsI highlight = new SearchResults(); highlight.addResult(sequences[0], features[index].getBegin(), features[index].getEnd()); diff --git a/src/jalview/appletgui/Finder.java b/src/jalview/appletgui/Finder.java index 75d9b9e..fdfc00f 100644 --- a/src/jalview/appletgui/Finder.java +++ b/src/jalview/appletgui/Finder.java @@ -20,7 +20,7 @@ */ package jalview.appletgui; -import jalview.datamodel.SearchResults; +import jalview.datamodel.SearchResultsI; import jalview.datamodel.SequenceFeature; import jalview.datamodel.SequenceI; import jalview.util.MessageManager; @@ -50,7 +50,7 @@ public class Finder extends Panel implements ActionListener Frame frame; - SearchResults searchResults; + SearchResultsI searchResults; int seqIndex = 0; diff --git a/src/jalview/appletgui/SeqCanvas.java b/src/jalview/appletgui/SeqCanvas.java index 7216bfe..477f1d6 100755 --- a/src/jalview/appletgui/SeqCanvas.java +++ b/src/jalview/appletgui/SeqCanvas.java @@ -21,7 +21,7 @@ package jalview.appletgui; import jalview.datamodel.AlignmentI; -import jalview.datamodel.SearchResults; +import jalview.datamodel.SearchResultsI; import jalview.datamodel.SequenceGroup; import jalview.datamodel.SequenceI; import jalview.renderer.ScaleRenderer; @@ -50,7 +50,7 @@ public class SeqCanvas extends Panel AlignViewport av; - SearchResults searchResults = null; + SearchResultsI searchResults = null; boolean fastPaint = false; @@ -843,7 +843,7 @@ public class SeqCanvas extends Panel } } - public void highlightSearchResults(SearchResults results) + public void highlightSearchResults(SearchResultsI results) { searchResults = results; diff --git a/src/jalview/appletgui/SeqPanel.java b/src/jalview/appletgui/SeqPanel.java index 6ca9499..8d6e683 100644 --- a/src/jalview/appletgui/SeqPanel.java +++ b/src/jalview/appletgui/SeqPanel.java @@ -25,8 +25,9 @@ import jalview.commands.EditCommand; import jalview.commands.EditCommand.Action; import jalview.datamodel.AlignmentI; import jalview.datamodel.ColumnSelection; +import jalview.datamodel.SearchResultMatchI; import jalview.datamodel.SearchResults; -import jalview.datamodel.SearchResults.Match; +import jalview.datamodel.SearchResultsI; import jalview.datamodel.Sequence; import jalview.datamodel.SequenceFeature; import jalview.datamodel.SequenceGroup; @@ -458,7 +459,7 @@ public class SeqPanel extends Panel implements MouseMotionListener, * @param results * @return true if results were matched, false if not */ - private boolean setStatusMessage(SearchResults results) + private boolean setStatusMessage(SearchResultsI results) { AlignmentI al = this.av.getAlignment(); int sequenceIndex = al.findIndex(results); @@ -467,7 +468,7 @@ public class SeqPanel extends Panel implements MouseMotionListener, return false; } SequenceI ds = al.getSequenceAt(sequenceIndex).getDatasetSequence(); - for (Match m : results.getResults()) + for (SearchResultMatchI m : results.getResults()) { SequenceI seq = m.getSequence(); if (seq.getDatasetSequence() != null) @@ -559,7 +560,7 @@ public class SeqPanel extends Panel implements MouseMotionListener, if (features != null && features.length > 0) { - SearchResults highlight = new SearchResults(); + SearchResultsI highlight = new SearchResults(); highlight.addResult(sequence, features[0].getBegin(), features[0].getEnd()); seqCanvas.highlightSearchResults(highlight); @@ -731,7 +732,7 @@ public class SeqPanel extends Panel implements MouseMotionListener, } @Override - public void highlightSequence(SearchResults results) + public void highlightSequence(SearchResultsI results) { if (av.isFollowHighlight()) { diff --git a/src/jalview/datamodel/AlignedCodonFrame.java b/src/jalview/datamodel/AlignedCodonFrame.java index c5204eb..4fbfd62 100644 --- a/src/jalview/datamodel/AlignedCodonFrame.java +++ b/src/jalview/datamodel/AlignedCodonFrame.java @@ -301,7 +301,7 @@ public class AlignedCodonFrame * where highlighted regions go */ public void markMappedRegion(SequenceI seq, int index, - SearchResults results) + SearchResultsI results) { int[] codon; SequenceI ds = seq.getDatasetSequence(); diff --git a/src/jalview/datamodel/Alignment.java b/src/jalview/datamodel/Alignment.java index 2289ac6..bd78827 100755 --- a/src/jalview/datamodel/Alignment.java +++ b/src/jalview/datamodel/Alignment.java @@ -661,7 +661,7 @@ public class Alignment implements AlignmentI * jalview.datamodel.AlignmentI#findIndex(jalview.datamodel.SearchResults) */ @Override - public int findIndex(SearchResults results) + public int findIndex(SearchResultsI results) { int i = 0; diff --git a/src/jalview/datamodel/AlignmentI.java b/src/jalview/datamodel/AlignmentI.java index 1d37fa6..7274e5f 100755 --- a/src/jalview/datamodel/AlignmentI.java +++ b/src/jalview/datamodel/AlignmentI.java @@ -426,7 +426,7 @@ public interface AlignmentI extends AnnotatedCollectionI * @param results * @return -1 or index of sequence in alignment */ - int findIndex(SearchResults results); + int findIndex(SearchResultsI results); /** * append sequences and annotation from another alignment object to this one. diff --git a/src/jalview/datamodel/SearchResultMatchI.java b/src/jalview/datamodel/SearchResultMatchI.java new file mode 100644 index 0000000..e886bed --- /dev/null +++ b/src/jalview/datamodel/SearchResultMatchI.java @@ -0,0 +1,17 @@ +package jalview.datamodel; + +public interface SearchResultMatchI +{ + + public abstract SequenceI getSequence(); + + public abstract int getStart(); + + public abstract int getEnd(); + + /** + * Returns the string of characters in the matched region. + */ + public abstract String getCharacters(); + +} \ No newline at end of file diff --git a/src/jalview/datamodel/SearchResults.java b/src/jalview/datamodel/SearchResults.java index b9db461..2f62991 100755 --- a/src/jalview/datamodel/SearchResults.java +++ b/src/jalview/datamodel/SearchResults.java @@ -28,10 +28,10 @@ import java.util.List; * Holds a list of search result matches, where each match is a contiguous * stretch of a single sequence. * - * @author gmcarstairs + * @author gmcarstairs amwaterhouse * */ -public class SearchResults +public class SearchResults implements SearchResultsI { private List matches = new ArrayList(); @@ -40,7 +40,7 @@ public class SearchResults * One match consists of a sequence reference, start and end positions. * Discontiguous ranges in a sequence require two or more Match objects. */ - public class Match + public class Match implements SearchResultMatchI { SequenceI sequence; @@ -85,16 +85,28 @@ public class SearchResults } } + /* (non-Javadoc) + * @see jalview.datamodel.SearchResultMatchI#getSequence() + */ + @Override public SequenceI getSequence() { return sequence; } + /* (non-Javadoc) + * @see jalview.datamodel.SearchResultMatchI#getStart() + */ + @Override public int getStart() { return start; } + /* (non-Javadoc) + * @see jalview.datamodel.SearchResultMatchI#getEnd() + */ + @Override public int getEnd() { return end; @@ -112,9 +124,10 @@ public class SearchResults return startPosition + getCharacters(); } - /** - * Returns the string of characters in the matched region. + /* (non-Javadoc) + * @see jalview.datamodel.SearchResultMatchI#getCharacters() */ + @Override public String getCharacters() { char[] chars = sequence.getSequence(); @@ -159,30 +172,19 @@ public class SearchResults } } - /** - * 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 - * - * @param seq - * Sequence - * @param start - * int - * @param end - * int + /* (non-Javadoc) + * @see jalview.datamodel.SearchResultsI#addResult(jalview.datamodel.SequenceI, int, int) */ + @Override public void addResult(SequenceI seq, int start, int end) { matches.add(new Match(seq, start, end)); } - /** - * Quickly check if the given sequence is referred to in the search results - * - * @param sequence - * (specific alignment sequence or a dataset sequence) - * @return true if the results involve sequence + /* (non-Javadoc) + * @see jalview.datamodel.SearchResultsI#involvesSequence(jalview.datamodel.SequenceI) */ + @Override public boolean involvesSequence(SequenceI sequence) { SequenceI ds = sequence.getDatasetSequence(); @@ -197,11 +199,10 @@ public class SearchResults return false; } - /** - * 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 + /* (non-Javadoc) + * @see jalview.datamodel.SearchResultsI#getResults(jalview.datamodel.SequenceI, int, int) */ + @Override public int[] getResults(SequenceI sequence, int start, int end) { if (matches.isEmpty()) @@ -269,53 +270,55 @@ public class SearchResults return result; } + /* (non-Javadoc) + * @see jalview.datamodel.SearchResultsI#getSize() + */ + @Override public int getSize() { return matches.size(); } + /* (non-Javadoc) + * @see jalview.datamodel.SearchResultsI#getResultSequence(int) + */ + @Override public SequenceI getResultSequence(int index) { return matches.get(index).sequence; } - /** - * Returns the start position of the i'th match in the search results. - * - * @param i - * @return + /* (non-Javadoc) + * @see jalview.datamodel.SearchResultsI#getResultStart(int) */ + @Override public int getResultStart(int i) { return matches.get(i).start; } - /** - * Returns the end position of the i'th match in the search results. - * - * @param i - * @return + /* (non-Javadoc) + * @see jalview.datamodel.SearchResultsI#getResultEnd(int) */ + @Override public int getResultEnd(int i) { return matches.get(i).end; } - /** - * Returns true if no search result matches are held. - * - * @return + /* (non-Javadoc) + * @see jalview.datamodel.SearchResultsI#isEmpty() */ + @Override public boolean isEmpty() { return matches.isEmpty(); } - /** - * Returns the list of matches. - * - * @return + /* (non-Javadoc) + * @see jalview.datamodel.SearchResultsI#getResults() */ + @Override public List getResults() { return matches; @@ -332,7 +335,7 @@ public class SearchResults public String toString() { StringBuilder result = new StringBuilder(256); - for (Match m : matches) + for (SearchResultMatchI m : matches) { result.append(m.toString()); } @@ -349,7 +352,7 @@ public class SearchResults public String getCharacters() { StringBuilder result = new StringBuilder(256); - for (Match m : matches) + for (SearchResultMatchI m : matches) { result.append(m.getCharacters()); } diff --git a/src/jalview/datamodel/SearchResultsI.java b/src/jalview/datamodel/SearchResultsI.java new file mode 100644 index 0000000..f7d3468 --- /dev/null +++ b/src/jalview/datamodel/SearchResultsI.java @@ -0,0 +1,74 @@ +package jalview.datamodel; + +import jalview.datamodel.SearchResults.Match; + +import java.util.List; + +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 + * + * @param seq + * Sequence + * @param start + * int + * @param end + * int + */ + public abstract void addResult(SequenceI seq, int start, int end); + + /** + * Quickly check if the given sequence is referred to in the search results + * + * @param sequence + * (specific alignment sequence or a dataset sequence) + * @return true if the results involve sequence + */ + public abstract boolean involvesSequence(SequenceI sequence); + + /** + * 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 + */ + public abstract int[] getResults(SequenceI sequence, int start, int end); + + public abstract int getSize(); + + public abstract SequenceI getResultSequence(int index); + + /** + * Returns the start position of the i'th match in the search results. + * + * @param i + * @return + */ + public abstract int getResultStart(int i); + + /** + * Returns the end position of the i'th match in the search results. + * + * @param i + * @return + */ + public abstract int getResultEnd(int i); + + /** + * Returns true if no search result matches are held. + * + * @return + */ + public abstract boolean isEmpty(); + + /** + * Returns the list of matches. + * + * @return + */ + public abstract List getResults(); + +} \ No newline at end of file diff --git a/src/jalview/gui/AlignViewport.java b/src/jalview/gui/AlignViewport.java index d0a0f11..03aee5d 100644 --- a/src/jalview/gui/AlignViewport.java +++ b/src/jalview/gui/AlignViewport.java @@ -37,6 +37,7 @@ import jalview.datamodel.AlignmentI; import jalview.datamodel.ColumnSelection; import jalview.datamodel.PDBEntry; import jalview.datamodel.SearchResults; +import jalview.datamodel.SearchResultsI; import jalview.datamodel.Sequence; import jalview.datamodel.SequenceGroup; import jalview.datamodel.SequenceI; @@ -1042,7 +1043,7 @@ public class AlignViewport extends AlignmentViewport implements * there is no complement, or it is not following highlights, or no mapping * is found, the result will be empty. */ - SearchResults sr = new SearchResults(); + SearchResultsI sr = new SearchResults(); int verticalOffset = findComplementScrollTarget(sr); if (!sr.isEmpty()) { diff --git a/src/jalview/gui/AlignmentPanel.java b/src/jalview/gui/AlignmentPanel.java index 4db029c..26e0baa 100644 --- a/src/jalview/gui/AlignmentPanel.java +++ b/src/jalview/gui/AlignmentPanel.java @@ -25,7 +25,7 @@ import jalview.api.AlignViewportI; import jalview.api.AlignmentViewPanel; import jalview.bin.Cache; import jalview.datamodel.AlignmentI; -import jalview.datamodel.SearchResults; +import jalview.datamodel.SearchResultsI; import jalview.datamodel.SequenceFeature; import jalview.datamodel.SequenceGroup; import jalview.datamodel.SequenceI; @@ -297,7 +297,7 @@ public class AlignmentPanel extends GAlignmentPanel implements * Highlight the given results on the alignment. * */ - public void highlightSearchResults(SearchResults results) + public void highlightSearchResults(SearchResultsI results) { scrollToPosition(results); getSeqPanel().seqCanvas.highlightSearchResults(results); @@ -309,7 +309,7 @@ public class AlignmentPanel extends GAlignmentPanel implements * * @param results */ - public boolean scrollToPosition(SearchResults results) + public boolean scrollToPosition(SearchResultsI results) { return scrollToPosition(results, 0, true, false); } @@ -322,7 +322,7 @@ public class AlignmentPanel extends GAlignmentPanel implements * @param redrawOverview * @return */ - public boolean scrollToPosition(SearchResults searchResults, + public boolean scrollToPosition(SearchResultsI searchResults, boolean redrawOverview) { return scrollToPosition(searchResults, 0, redrawOverview, false); @@ -342,7 +342,7 @@ public class AlignmentPanel extends GAlignmentPanel implements * if true, try to centre the search results horizontally in the view * @return false if results were not found */ - public boolean scrollToPosition(SearchResults results, + public boolean scrollToPosition(SearchResultsI results, int verticalOffset, boolean redrawOverview, boolean centre) { int startv, endv, starts, ends; @@ -1788,7 +1788,7 @@ public class AlignmentPanel extends GAlignmentPanel implements * @param verticalOffset * the number of visible sequences to show above the mapped region */ - public void scrollToCentre(SearchResults sr, int verticalOffset) + public void scrollToCentre(SearchResultsI sr, int verticalOffset) { /* * To avoid jumpy vertical scrolling (if some sequences are gapped or not diff --git a/src/jalview/gui/FeatureRenderer.java b/src/jalview/gui/FeatureRenderer.java index 426ea32..83d1612 100644 --- a/src/jalview/gui/FeatureRenderer.java +++ b/src/jalview/gui/FeatureRenderer.java @@ -22,6 +22,7 @@ package jalview.gui; import jalview.api.FeatureColourI; import jalview.datamodel.SearchResults; +import jalview.datamodel.SearchResultsI; import jalview.datamodel.SequenceFeature; import jalview.datamodel.SequenceI; import jalview.schemes.FeatureColour; @@ -200,7 +201,7 @@ public class FeatureRenderer extends start.setValue(new Integer(features[index].getBegin())); end.setValue(new Integer(features[index].getEnd())); - SearchResults highlight = new SearchResults(); + SearchResultsI highlight = new SearchResults(); highlight.addResult(sequences[0], features[index].getBegin(), features[index].getEnd()); diff --git a/src/jalview/gui/Finder.java b/src/jalview/gui/Finder.java index 6bff69a..a73728a 100755 --- a/src/jalview/gui/Finder.java +++ b/src/jalview/gui/Finder.java @@ -20,7 +20,7 @@ */ package jalview.gui; -import jalview.datamodel.SearchResults; +import jalview.datamodel.SearchResultsI; import jalview.datamodel.SequenceFeature; import jalview.datamodel.SequenceI; import jalview.jbgui.GFinder; @@ -67,7 +67,7 @@ public class Finder extends GFinder int resIndex = -1; - SearchResults searchResults; + SearchResultsI searchResults; /** * Creates a new Finder object with no associated viewport or panel. diff --git a/src/jalview/gui/SeqCanvas.java b/src/jalview/gui/SeqCanvas.java index 760ece0..a621989 100755 --- a/src/jalview/gui/SeqCanvas.java +++ b/src/jalview/gui/SeqCanvas.java @@ -21,7 +21,7 @@ package jalview.gui; import jalview.datamodel.AlignmentI; -import jalview.datamodel.SearchResults; +import jalview.datamodel.SearchResultsI; import jalview.datamodel.SequenceGroup; import jalview.datamodel.SequenceI; import jalview.renderer.ScaleRenderer; @@ -62,7 +62,7 @@ public class SeqCanvas extends JComponent AlignViewport av; - SearchResults searchResults = null; + SearchResultsI searchResults = null; boolean fastPaint = false; @@ -965,7 +965,7 @@ public class SeqCanvas extends JComponent * @param results * DOCUMENT ME! */ - public void highlightSearchResults(SearchResults results) + public void highlightSearchResults(SearchResultsI results) { img = null; diff --git a/src/jalview/gui/SeqPanel.java b/src/jalview/gui/SeqPanel.java index 3266fab..10face8 100644 --- a/src/jalview/gui/SeqPanel.java +++ b/src/jalview/gui/SeqPanel.java @@ -27,8 +27,9 @@ import jalview.commands.EditCommand.Action; import jalview.commands.EditCommand.Edit; import jalview.datamodel.AlignmentI; import jalview.datamodel.ColumnSelection; +import jalview.datamodel.SearchResultMatchI; import jalview.datamodel.SearchResults; -import jalview.datamodel.SearchResults.Match; +import jalview.datamodel.SearchResultsI; import jalview.datamodel.Sequence; import jalview.datamodel.SequenceFeature; import jalview.datamodel.SequenceGroup; @@ -132,7 +133,7 @@ public class SeqPanel extends JPanel implements MouseListener, StructureSelectionManager ssm; - SearchResults lastSearchResults; + SearchResultsI lastSearchResults; /** * Creates a new SeqPanel object. @@ -676,7 +677,7 @@ public class SeqPanel extends JPanel implements MouseListener, * the start of the highlighted region. */ @Override - public void highlightSequence(SearchResults results) + public void highlightSequence(SearchResultsI results) { if (results == null || results.equals(lastSearchResults)) { @@ -910,7 +911,7 @@ public class SeqPanel extends JPanel implements MouseListener, * * @param results */ - private void setStatusMessage(SearchResults results) + private void setStatusMessage(SearchResultsI results) { AlignmentI al = this.av.getAlignment(); int sequenceIndex = al.findIndex(results); @@ -919,7 +920,7 @@ public class SeqPanel extends JPanel implements MouseListener, return; } SequenceI ds = al.getSequenceAt(sequenceIndex).getDatasetSequence(); - for (Match m : results.getResults()) + for (SearchResultMatchI m : results.getResults()) { SequenceI seq = m.getSequence(); if (seq.getDatasetSequence() != null) @@ -1501,7 +1502,7 @@ public class SeqPanel extends JPanel implements MouseListener, if (features != null && features.size() > 0) { - SearchResults highlight = new SearchResults(); + SearchResultsI highlight = new SearchResults(); highlight.addResult(sequence, features.get(0).getBegin(), features .get(0).getEnd()); seqCanvas.highlightSearchResults(highlight); diff --git a/src/jalview/structure/SequenceListener.java b/src/jalview/structure/SequenceListener.java index 771b8a0..81ff739 100644 --- a/src/jalview/structure/SequenceListener.java +++ b/src/jalview/structure/SequenceListener.java @@ -20,6 +20,7 @@ */ package jalview.structure; +import jalview.datamodel.SearchResultsI; import jalview.datamodel.SequenceI; public interface SequenceListener @@ -27,7 +28,7 @@ public interface SequenceListener // TODO remove this? never called on SequenceListener type public void mouseOverSequence(SequenceI sequence, int index, int pos); - public void highlightSequence(jalview.datamodel.SearchResults results); + public void highlightSequence(SearchResultsI results); // TODO remove this? never called public void updateColours(SequenceI sequence, int index); diff --git a/src/jalview/structure/StructureSelectionManager.java b/src/jalview/structure/StructureSelectionManager.java index 7e691be..6912836 100644 --- a/src/jalview/structure/StructureSelectionManager.java +++ b/src/jalview/structure/StructureSelectionManager.java @@ -31,6 +31,7 @@ import jalview.datamodel.AlignmentI; import jalview.datamodel.Annotation; import jalview.datamodel.PDBEntry; import jalview.datamodel.SearchResults; +import jalview.datamodel.SearchResultsI; import jalview.datamodel.SequenceI; import jalview.ext.jmol.JmolParser; import jalview.gui.IProgressIndicator; @@ -805,7 +806,7 @@ public class StructureSelectionManager return; } - SearchResults results = new SearchResults(); + SearchResultsI results = new SearchResults(); for (AtomSpec atom : atoms) { SequenceI lastseq = null; @@ -855,7 +856,7 @@ public class StructureSelectionManager { boolean hasSequenceListeners = handlingVamsasMo || !seqmappings.isEmpty(); - SearchResults results = null; + SearchResultsI results = null; if (seqPos == -1) { seqPos = seq.findPosition(indexpos); diff --git a/src/jalview/util/MappingUtils.java b/src/jalview/util/MappingUtils.java index 1fe452d..f35339c 100644 --- a/src/jalview/util/MappingUtils.java +++ b/src/jalview/util/MappingUtils.java @@ -31,8 +31,9 @@ import jalview.datamodel.AlignedCodonFrame; import jalview.datamodel.AlignmentI; import jalview.datamodel.AlignmentOrder; import jalview.datamodel.ColumnSelection; +import jalview.datamodel.SearchResultMatchI; import jalview.datamodel.SearchResults; -import jalview.datamodel.SearchResults.Match; +import jalview.datamodel.SearchResultsI; import jalview.datamodel.Sequence; import jalview.datamodel.SequenceGroup; import jalview.datamodel.SequenceI; @@ -194,7 +195,7 @@ public final class MappingUtils /* * Determine all mappings from this position to mapped sequences. */ - SearchResults sr = buildSearchResults(seq, seqpos, mappings); + SearchResultsI sr = buildSearchResults(seq, seqpos, mappings); if (!sr.isEmpty()) { @@ -266,10 +267,10 @@ public final class MappingUtils * @param seqmappings * @return */ - public static SearchResults buildSearchResults(SequenceI seq, int index, + public static SearchResultsI buildSearchResults(SequenceI seq, int index, List seqmappings) { - SearchResults results = new SearchResults(); + SearchResultsI results = new SearchResults(); addSearchResults(results, seq, index, seqmappings); return results; } @@ -283,7 +284,7 @@ public final class MappingUtils * @param index * @param seqmappings */ - public static void addSearchResults(SearchResults results, SequenceI seq, + public static void addSearchResults(SearchResultsI results, SequenceI seq, int index, List seqmappings) { if (index >= seq.getStart() && index <= seq.getEnd()) @@ -376,15 +377,15 @@ public final class MappingUtils */ List mapping = Arrays .asList(new AlignedCodonFrame[] { acf }); - SearchResults sr = buildSearchResults(selected, + SearchResultsI sr = buildSearchResults(selected, startResiduePos, mapping); - for (Match m : sr.getResults()) + for (SearchResultMatchI m : sr.getResults()) { mappedStartResidue = m.getStart(); mappedEndResidue = m.getEnd(); } sr = buildSearchResults(selected, endResiduePos, mapping); - for (Match m : sr.getResults()) + for (SearchResultMatchI m : sr.getResults()) { mappedStartResidue = Math.min(mappedStartResidue, m.getStart()); @@ -647,8 +648,8 @@ public final class MappingUtils * Get the residue position and find the mapped position. */ int residuePos = fromSeq.findPosition(col); - SearchResults sr = buildSearchResults(fromSeq, residuePos, mappings); - for (Match m : sr.getResults()) + SearchResultsI sr = buildSearchResults(fromSeq, residuePos, mappings); + for (SearchResultMatchI m : sr.getResults()) { int mappedStartResidue = m.getStart(); int mappedEndResidue = m.getEnd(); diff --git a/src/jalview/viewmodel/AlignmentViewport.java b/src/jalview/viewmodel/AlignmentViewport.java index c1c88c1..2f733ed 100644 --- a/src/jalview/viewmodel/AlignmentViewport.java +++ b/src/jalview/viewmodel/AlignmentViewport.java @@ -36,7 +36,7 @@ import jalview.datamodel.Annotation; import jalview.datamodel.CigarArray; import jalview.datamodel.ColumnSelection; import jalview.datamodel.HiddenSequences; -import jalview.datamodel.SearchResults; +import jalview.datamodel.SearchResultsI; import jalview.datamodel.Sequence; import jalview.datamodel.SequenceCollectionI; import jalview.datamodel.SequenceGroup; @@ -2715,7 +2715,7 @@ public abstract class AlignmentViewport implements AlignViewportI, * the SearchResults to add to * @return the offset (below top of visible region) of the matched sequence */ - protected int findComplementScrollTarget(SearchResults sr) + protected int findComplementScrollTarget(SearchResultsI sr) { final AlignViewportI complement = getCodingComplement(); if (complement == null || !complement.isFollowHighlight()) diff --git a/test/jalview/analysis/AlignmentUtilsTests.java b/test/jalview/analysis/AlignmentUtilsTests.java index 4aed7e7..449514a 100644 --- a/test/jalview/analysis/AlignmentUtilsTests.java +++ b/test/jalview/analysis/AlignmentUtilsTests.java @@ -35,8 +35,8 @@ import jalview.datamodel.AlignmentI; import jalview.datamodel.Annotation; import jalview.datamodel.DBRefEntry; import jalview.datamodel.Mapping; -import jalview.datamodel.SearchResults; -import jalview.datamodel.SearchResults.Match; +import jalview.datamodel.SearchResultMatchI; +import jalview.datamodel.SearchResultsI; import jalview.datamodel.Sequence; import jalview.datamodel.SequenceFeature; import jalview.datamodel.SequenceI; @@ -1119,9 +1119,9 @@ public class AlignmentUtilsTests assertEquals(1, mappings.size()); // map G to GGG - SearchResults sr = MappingUtils.buildSearchResults(pep1, 1, mappings); + SearchResultsI sr = MappingUtils.buildSearchResults(pep1, 1, mappings); assertEquals(1, sr.getResults().size()); - Match m = sr.getResults().get(0); + SearchResultMatchI m = sr.getResults().get(0); assertSame(cds1Dss, m.getSequence()); assertEquals(1, m.getStart()); assertEquals(3, m.getEnd()); @@ -1650,10 +1650,10 @@ public class AlignmentUtilsTests List pep1CdsMappings = MappingUtils .findMappingsForSequence(cds.getSequenceAt(0), pep1Mappings); assertEquals(1, pep1CdsMappings.size()); - SearchResults sr = MappingUtils.buildSearchResults(pep1, 1, + SearchResultsI sr = MappingUtils.buildSearchResults(pep1, 1, pep1CdsMappings); assertEquals(1, sr.getResults().size()); - Match m = sr.getResults().get(0); + SearchResultMatchI m = sr.getResults().get(0); assertEquals(cds.getSequenceAt(0).getDatasetSequence(), m.getSequence()); assertEquals(1, m.getStart()); assertEquals(3, m.getEnd()); @@ -2388,9 +2388,9 @@ public class AlignmentUtilsTests assertEquals(1, mappings.size()); // map G to GGG - SearchResults sr = MappingUtils.buildSearchResults(pep3, 1, mappings); + SearchResultsI sr = MappingUtils.buildSearchResults(pep3, 1, mappings); assertEquals(1, sr.getResults().size()); - Match m = sr.getResults().get(0); + SearchResultMatchI m = sr.getResults().get(0); assertSame(cds.getSequenceAt(0).getDatasetSequence(), m.getSequence()); assertEquals(1, m.getStart()); assertEquals(3, m.getEnd()); diff --git a/test/jalview/datamodel/MatchTest.java b/test/jalview/datamodel/MatchTest.java index 6f3c7a9..65c894f 100644 --- a/test/jalview/datamodel/MatchTest.java +++ b/test/jalview/datamodel/MatchTest.java @@ -35,7 +35,7 @@ public class MatchTest public void testToString() { SequenceI seq = new Sequence("", "abcdefghijklm"); - Match m = new SearchResults().new Match(seq, 3, 5); + SearchResultMatchI m = new SearchResults().new Match(seq, 3, 5); assertEquals("2cde", m.toString()); } @@ -43,7 +43,7 @@ public class MatchTest public void testGetCharacters() { SequenceI seq = new Sequence("", "abcdefghijklm"); - Match m = new SearchResults().new Match(seq, 3, 5); + SearchResultMatchI m = new SearchResults().new Match(seq, 3, 5); assertEquals("cde", m.getCharacters()); } @@ -52,8 +52,8 @@ public class MatchTest { SequenceI seq1 = new Sequence("", "abcdefghijklm"); SequenceI seq2 = new Sequence("", "abcdefghijklm"); - SearchResults sr1 = new SearchResults(); - SearchResults sr2 = new SearchResults(); + SearchResultsI sr1 = new SearchResults(); + SearchResultsI sr2 = new SearchResults(); assertFalse(sr1.equals(null)); assertFalse(sr1.equals(seq1)); @@ -72,7 +72,7 @@ public class MatchTest /* * same match but on different sequences - not equal */ - SearchResults sr3 = new SearchResults(); + SearchResultsI sr3 = new SearchResults(); sr3.addResult(seq2, 1, 1); assertFalse(sr1.equals(sr3)); assertFalse(sr3.equals(sr1)); diff --git a/test/jalview/datamodel/SearchResultsTest.java b/test/jalview/datamodel/SearchResultsTest.java index f9a0a4f..e3cbb00 100644 --- a/test/jalview/datamodel/SearchResultsTest.java +++ b/test/jalview/datamodel/SearchResultsTest.java @@ -36,7 +36,7 @@ public class SearchResultsTest public void testToString() { SequenceI seq = new Sequence("", "abcdefghijklm"); - SearchResults sr = new SearchResults(); + SearchResultsI sr = new SearchResults(); sr.addResult(seq, 1, 1); assertEquals("0a", sr.toString()); sr.addResult(seq, 3, 5); @@ -66,8 +66,8 @@ public class SearchResultsTest public void testEquals() { SequenceI seq1 = new Sequence("", "abcdefghijklm"); - SearchResults sr1 = new SearchResults(); - SearchResults sr2 = new SearchResults(); + SearchResultsI sr1 = new SearchResults(); + SearchResultsI sr2 = new SearchResults(); assertFalse(sr1.equals(null)); // null object assertFalse(sr1.equals(seq1)); // wrong type @@ -111,8 +111,8 @@ public class SearchResultsTest { SequenceI seq1 = new Sequence("", "abcdefghijklm"); SequenceI seq2 = new Sequence("", "abcdefghijklm"); - SearchResults sr1 = new SearchResults(); - SearchResults sr2 = new SearchResults(); + SearchResultsI sr1 = new SearchResults(); + SearchResultsI sr2 = new SearchResults(); sr1.addResult(seq1, 1, 1); sr2.addResult(seq2, 1, 1); @@ -127,8 +127,8 @@ public class SearchResultsTest public void testEquals_orderDiffers() { SequenceI seq1 = new Sequence("", "abcdefghijklm"); - SearchResults sr1 = new SearchResults(); - SearchResults sr2 = new SearchResults(); + SearchResultsI sr1 = new SearchResults(); + SearchResultsI sr2 = new SearchResults(); sr1.addResult(seq1, 1, 1); sr1.addResult(seq1, 2, 2); @@ -145,8 +145,8 @@ public class SearchResultsTest public void testHashcode() { SequenceI seq1 = new Sequence("", "abcdefghijklm"); - SearchResults sr1 = new SearchResults(); - SearchResults sr2 = new SearchResults(); + SearchResultsI sr1 = new SearchResults(); + SearchResultsI sr2 = new SearchResults(); /* * both empty @@ -178,7 +178,7 @@ public class SearchResultsTest public void testMatchConstructor() { SequenceI seq1 = new Sequence("", "abcdefghijklm"); - Match m = new SearchResults().new Match(seq1, 2, 5); + SearchResultMatchI m = new SearchResults().new Match(seq1, 2, 5); assertSame(seq1, m.getSequence()); assertEquals(2, m.getStart()); assertEquals(5, m.getEnd()); diff --git a/test/jalview/util/MappingUtilsTest.java b/test/jalview/util/MappingUtilsTest.java index 655aa2a..6d04661 100644 --- a/test/jalview/util/MappingUtilsTest.java +++ b/test/jalview/util/MappingUtilsTest.java @@ -33,8 +33,8 @@ import jalview.datamodel.AlignedCodonFrame; import jalview.datamodel.Alignment; import jalview.datamodel.AlignmentI; import jalview.datamodel.ColumnSelection; -import jalview.datamodel.SearchResults; -import jalview.datamodel.SearchResults.Match; +import jalview.datamodel.SearchResultMatchI; +import jalview.datamodel.SearchResultsI; import jalview.datamodel.Sequence; import jalview.datamodel.SequenceGroup; import jalview.datamodel.SequenceI; @@ -81,9 +81,9 @@ public class MappingUtilsTest /* * Check protein residue 12 maps to codon 5-7, 13 to codon 8-10 */ - SearchResults sr = MappingUtils.buildSearchResults(aseq1, 12, acfList); + SearchResultsI sr = MappingUtils.buildSearchResults(aseq1, 12, acfList); assertEquals(1, sr.getResults().size()); - Match m = sr.getResults().get(0); + SearchResultMatchI m = sr.getResults().get(0); assertEquals(seq1.getDatasetSequence(), m.getSequence()); assertEquals(5, m.getStart()); assertEquals(7, m.getEnd()); @@ -134,9 +134,9 @@ public class MappingUtilsTest /* * Check protein residue 8 maps to [6, 8, 9] */ - SearchResults sr = MappingUtils.buildSearchResults(aseq1, 8, acfList); + SearchResultsI sr = MappingUtils.buildSearchResults(aseq1, 8, acfList); assertEquals(2, sr.getResults().size()); - Match m = sr.getResults().get(0); + SearchResultMatchI m = sr.getResults().get(0); assertEquals(seq1.getDatasetSequence(), m.getSequence()); assertEquals(6, m.getStart()); assertEquals(6, m.getEnd());