X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Fanalysis%2FFinder.java;h=f8cfcbfbb21501c2698be87bbcca3e3905dbb222;hb=05688ef13325c699644487ce1c08a53927f0eeb0;hp=d52e42a768a0e65db9a543e05031e5a5a164de6f;hpb=bf1fd68e2aea9ef1f5c0cbbae814b78d69f29e3a;p=jalview.git diff --git a/src/jalview/analysis/Finder.java b/src/jalview/analysis/Finder.java index d52e42a..f8cfcbf 100644 --- a/src/jalview/analysis/Finder.java +++ b/src/jalview/analysis/Finder.java @@ -20,6 +20,8 @@ */ package jalview.analysis; +import java.util.Locale; + import jalview.api.AlignViewportI; import jalview.api.FinderI; import jalview.datamodel.AlignmentI; @@ -121,7 +123,7 @@ public class Finder implements FinderI { doFind(theSearchString, matchCase, searchDescription, false, ignoreHidden); - + if (searchResults.isEmpty() && idMatches.isEmpty()) { /* @@ -148,7 +150,7 @@ public class Finder implements FinderI idMatches = new ArrayList<>(); String searchString = matchCase ? theSearchString - : theSearchString.toUpperCase(); + : theSearchString.toUpperCase(Locale.ROOT); Regex searchPattern = new Regex(searchString); searchPattern.setIgnoreCase(!matchCase); @@ -172,9 +174,9 @@ public class Finder implements FinderI } /** - * Calculates and saves the sequence string to search. The string is restricted - * to the current selection region if there is one, and is saved with all gaps - * removed. + * Calculates and saves the sequence string to search. The string is + * restricted to the current selection region if there is one, and is saved + * with all gaps removed. *

* If there are hidden columns, and option {@ignoreHidden} is selected, then * only visible positions of the sequence are included, and a mapping is also @@ -246,13 +248,14 @@ public class Finder implements FinderI } /** - * Returns a string consisting of only the visible residues of {@code seq} from - * alignment column {@ fromColumn}, restricted to the current selection region - * if there is one. + * Returns a string consisting of only the visible residues of {@code seq} + * from alignment column {@ fromColumn}, restricted to the current selection + * region if there is one. *

- * As a side-effect, also computes the mapping from the true sequence positions - * to the positions (1, 2, ...) of the returned sequence. This is to allow - * search matches in the visible sequence to be converted to sequence positions. + * As a side-effect, also computes the mapping from the true sequence + * positions to the positions (1, 2, ...) of the returned sequence. This is to + * allow search matches in the visible sequence to be converted to sequence + * positions. * * @param seq * @return @@ -312,9 +315,9 @@ public class Finder implements FinderI /** * Advances the search to the next sequence in the alignment. Sequences not in - * the current selection group (if there is one) are skipped. The (sub-)sequence - * to be searched is extracted, gaps removed, and saved, or set to null if there - * are no more sequences to search. + * the current selection group (if there is one) are skipped. The + * (sub-)sequence to be searched is extracted, gaps removed, and saved, or set + * to null if there are no more sequences to search. *

* Returns true if a sequence could be found, false if end of alignment was * reached @@ -346,9 +349,8 @@ public class Finder implements FinderI * @param ignoreHidden * @return */ - protected boolean findNextMatch(String searchString, - Regex searchPattern, boolean matchDescription, - boolean ignoreHidden) + protected boolean findNextMatch(String searchString, Regex searchPattern, + boolean matchDescription, boolean ignoreHidden) { if (residueIndex < 0) { @@ -356,8 +358,7 @@ public class Finder implements FinderI * at start of sequence; try find by residue number, in sequence id, * or (optionally) in sequence description */ - if (doNonMotifSearches(searchString, searchPattern, - matchDescription)) + if (doNonMotifSearches(searchString, searchPattern, matchDescription)) { return true; } @@ -410,14 +411,14 @@ public class Finder implements FinderI */ int offset = searchPattern.matchedFrom(); int matchStartPosition = this.searchedSequenceStartPosition + offset; - int matchEndPosition = matchStartPosition - + searchPattern.charsMatched() - 1; + int matchEndPosition = matchStartPosition + searchPattern.charsMatched() + - 1; /* * update residueIndex to next position after the start of the match * (findIndex returns a value base 1, columnIndex is held base 0) */ - residueIndex = searchPattern.matchedFrom()+1; + residueIndex = searchPattern.matchedFrom() + 1; /* * return false if the match is entirely in a hidden region @@ -445,9 +446,9 @@ public class Finder implements FinderI } /** - * Adds one match to the stored list. If hidden residues are being skipped, then - * the match may need to be split into contiguous positions of the sequence (so - * it does not include skipped residues). + * Adds one match to the stored list. If hidden residues are being skipped, + * then the match may need to be split into contiguous positions of the + * sequence (so it does not include skipped residues). * * @param seq * @param matchStartPosition @@ -550,10 +551,12 @@ public class Finder implements FinderI * @param searchPattern * @return */ - protected boolean searchSequenceDescription(SequenceI seq, Regex searchPattern) + protected boolean searchSequenceDescription(SequenceI seq, + Regex searchPattern) { String desc = seq.getDescription(); - if (desc != null && searchPattern.search(desc) && !idMatches.contains(seq)) + if (desc != null && searchPattern.search(desc) + && !idMatches.contains(seq)) { idMatches.add(seq); return true; @@ -582,7 +585,8 @@ public class Finder implements FinderI /** * If the residue position is valid for the sequence, and in a visible column, - * adds the position to the search results and returns true, else answers false. + * adds the position to the search results and returns true, else answers + * false. * * @param seq * @param resNo @@ -615,7 +619,8 @@ public class Finder implements FinderI return true; } int col = seq.findIndex(res); // base 1 - return viewport.getAlignment().getHiddenColumns().isVisible(col - 1); // base 0 + return viewport.getAlignment().getHiddenColumns().isVisible(col - 1); // base + // 0 } @Override