From e936ffd014e4762cc2637c7a708bb06a6611ff5d Mon Sep 17 00:00:00 2001 From: Jim Procter Date: Thu, 15 Sep 2022 18:56:41 +0100 Subject: [PATCH] =?utf8?q?JAL-4061=20use=20alignment=20panel=E2=80=99s=20fea?= =?utf8?q?ture=20renderer=20to=20limit=20search=20to=20just=20the=20=20visib?= =?utf8?q?le=20features?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- src/jalview/analysis/Finder.java | 31 +++++++++++++++++++++++++++++-- src/jalview/api/FinderI.java | 2 ++ src/jalview/gui/Finder.java | 1 + 3 files changed, 32 insertions(+), 2 deletions(-) diff --git a/src/jalview/analysis/Finder.java b/src/jalview/analysis/Finder.java index 6061d76..21fa2f1 100644 --- a/src/jalview/analysis/Finder.java +++ b/src/jalview/analysis/Finder.java @@ -29,6 +29,7 @@ import java.util.Locale; import com.stevesoft.pat.Regex; import jalview.api.AlignViewportI; +import jalview.api.FeatureRenderer; import jalview.api.FinderI; import jalview.datamodel.AlignmentI; import jalview.datamodel.SearchResultMatchI; @@ -62,6 +63,11 @@ public class Finder implements FinderI private AlignViewportI viewport; /* + * feature renderer model - if available + */ + FeatureRenderer frm = null; + + /* * sequence index in alignment to search from */ private int sequenceIndex; @@ -589,9 +595,23 @@ public class Finder implements FinderI lastFeature = null; } SequenceI seq = viewport.getAlignment().getSequenceAt(sequenceIndex); - long fpos = 0; SequenceFeaturesI sf = seq.getFeatures(); - for (SequenceFeature feature : sf.getAllFeatures(null)) + + // TODO - stash feature list and search incrementally + List allFeatures = null; + if (frm != null) + { + allFeatures = frm.findFeaturesAtResidue(seq, seq.getStart(), + seq.getEnd()); + } + else + { + allFeatures = sf.getAllFeatures(null); + } + // so we can check we are advancing when debugging + long fpos = 0; + + for (SequenceFeature feature : allFeatures) { fpos++; if (lastFeature != null) @@ -607,6 +627,7 @@ public class Finder implements FinderI continue; } } + if (searchPattern.search(feature.type) || (feature.description != null && searchPattern.search(feature.description))) { @@ -712,4 +733,10 @@ public class Finder implements FinderI { return searchResults; } + + @Override + public void setFeatureRenderer(FeatureRenderer featureRenderer) + { + frm = featureRenderer; + } } diff --git a/src/jalview/api/FinderI.java b/src/jalview/api/FinderI.java index 967bd5c..697072b 100644 --- a/src/jalview/api/FinderI.java +++ b/src/jalview/api/FinderI.java @@ -96,4 +96,6 @@ public interface FinderI */ SearchResultsI getSearchResults(); + void setFeatureRenderer(FeatureRenderer featureRenderer); + } \ No newline at end of file diff --git a/src/jalview/gui/Finder.java b/src/jalview/gui/Finder.java index 6527cdc..c40b958 100755 --- a/src/jalview/gui/Finder.java +++ b/src/jalview/gui/Finder.java @@ -294,6 +294,7 @@ public class Finder extends GFinder finder = new jalview.analysis.Finder(av); finders.put(av, finder); } + finder.setFeatureRenderer(ap.getFeatureRenderer()); boolean isCaseSensitive = caseSensitive.isSelected(); boolean doSearchDescription = searchDescription.isSelected(); -- 1.7.10.2