X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Fanalysis%2FFinder.java;h=756897c9b2fda95b4e0872dfa615790609ba32b2;hb=2253f31565d4e96edffce2fac596e2ef0578d596;hp=8bda5921ab3afda2c2571cbb0fcdc4b3505e07cd;hpb=d1f6cf53b29322601c621da9a6b3cb09dd28235e;p=jalview.git diff --git a/src/jalview/analysis/Finder.java b/src/jalview/analysis/Finder.java index 8bda592..756897c 100644 --- a/src/jalview/analysis/Finder.java +++ b/src/jalview/analysis/Finder.java @@ -28,16 +28,24 @@ public class Finder * Implements the search algorithms for the Find dialog box. */ SearchResults searchResults; + AlignmentI alignment; + jalview.datamodel.SequenceGroup selection = null; + Vector idMatch = null; + boolean caseSensitive = false; + boolean findAll = false; + com.stevesoft.pat.Regex regex = null; + /** * hold's last-searched position between calles to find(false) */ int seqIndex = 0, resIndex = 0; + public Finder(AlignmentI alignment, SequenceGroup selection) { this.alignment = alignment; @@ -45,7 +53,7 @@ public class Finder } public Finder(AlignmentI alignment, SequenceGroup selectionGroup, - int seqIndex, int resIndex) + int seqIndex, int resIndex) { this(alignment, selectionGroup); this.seqIndex = seqIndex; @@ -66,7 +74,7 @@ public class Finder String item = null; boolean found = false; - ////// is the searchString a residue number? + // //// is the searchString a residue number? try { int res = Integer.parseInt(searchString); @@ -82,19 +90,18 @@ public class Finder searchResults.addResult(seq, res, res); hasResults = true; - } - catch (NumberFormatException ex) + } catch (NumberFormatException ex) { } - /////////////////////////////////////////////// + // ///////////////////////////////////////////// int end = alignment.getHeight(); if (selection != null) { - if ( (selection.getSize() < 1) || - ( (selection.getEndRes() - selection.getStartRes()) < 2)) + if ((selection.getSize() < 1) + || ((selection.getEndRes() - selection.getStartRes()) < 2)) { selection = null; } @@ -104,7 +111,8 @@ public class Finder { seq = (Sequence) alignment.getSequenceAt(seqIndex); - if ( (selection != null) && !selection.getSequences(null).contains(seq)) + if ((selection != null) + && !selection.getSequences(null).contains(seq)) { seqIndex++; resIndex = 0; @@ -113,16 +121,16 @@ public class Finder } item = seq.getSequenceAsString(); - if(!caseSensitive) + if (!caseSensitive) item = item.toUpperCase(); - if ( (selection != null) && - (selection.getEndRes() < alignment.getWidth() - 1)) + if ((selection != null) + && (selection.getEndRes() < alignment.getWidth() - 1)) { item = item.substring(0, selection.getEndRes() + 1); } - ///Shall we ignore gaps???? - JBPNote: Add Flag for forcing this or not + // /Shall we ignore gaps???? - JBPNote: Add Flag for forcing this or not StringBuffer noGapsSB = new StringBuffer(); int insertCount = 0; Vector spaces = new Vector(); @@ -149,22 +157,21 @@ public class Finder { resIndex = regex.matchedFrom(); - if ( (selection != null) && - ( (resIndex + - Integer.parseInt(spaces.elementAt(resIndex).toString())) < - selection.getStartRes())) + if ((selection != null) + && ((resIndex + Integer.parseInt(spaces.elementAt( + resIndex).toString())) < selection.getStartRes())) { continue; } - int sres = seq.findPosition(resIndex + - Integer.parseInt(spaces.elementAt( - resIndex) - .toString())); - int eres = seq.findPosition(regex.matchedTo() - 1 + - Integer.parseInt(spaces.elementAt(regex. - matchedTo() - - 1).toString())); + int sres = seq + .findPosition(resIndex + + Integer.parseInt(spaces.elementAt(resIndex) + .toString())); + int eres = seq.findPosition(regex.matchedTo() + - 1 + + Integer.parseInt(spaces + .elementAt(regex.matchedTo() - 1).toString())); searchResults.addResult(seq, sres, eres); hasResults = true; @@ -212,7 +219,8 @@ public class Finder } /** - * @param alignment the alignment to set + * @param alignment + * the alignment to set */ public void setAlignment(AlignmentI alignment) { @@ -228,7 +236,8 @@ public class Finder } /** - * @param caseSensitive the caseSensitive to set + * @param caseSensitive + * the caseSensitive to set */ public void setCaseSensitive(boolean caseSensitive) { @@ -244,7 +253,8 @@ public class Finder } /** - * @param findAll the findAll to set + * @param findAll + * the findAll to set */ public void setFindAll(boolean findAll) { @@ -260,7 +270,8 @@ public class Finder } /** - * @param selection the selection to set + * @param selection + * the selection to set */ public void setSelection(jalview.datamodel.SequenceGroup selection) { @@ -300,7 +311,8 @@ public class Finder } /** - * @param resIndex the resIndex to set + * @param resIndex + * the resIndex to set */ public void setResIndex(int resIndex) { @@ -316,7 +328,8 @@ public class Finder } /** - * @param seqIndex the seqIndex to set + * @param seqIndex + * the seqIndex to set */ public void setSeqIndex(int seqIndex) {