X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Fanalysis%2FFinder.java;h=3d1a70c508103630f83ababa94866e7aad1a5beb;hb=370e045dad64be5b5425e75f979a6855bce4d2cd;hp=1fa15e3a88a3e6d7458b81069ba890fbb2b1b4d9;hpb=ac82513496578976d697ffd92c907138c882bec4;p=jalview.git diff --git a/src/jalview/analysis/Finder.java b/src/jalview/analysis/Finder.java index 1fa15e3..3d1a70c 100644 --- a/src/jalview/analysis/Finder.java +++ b/src/jalview/analysis/Finder.java @@ -44,7 +44,7 @@ public class Finder /** * hold's last-searched position between calles to find(false) */ - int seqIndex = 0, resIndex = 0; + int seqIndex = 0, resIndex = -1; public Finder(AlignmentI alignment, SequenceGroup selection) { @@ -52,6 +52,13 @@ public class Finder this.selection = selection; } + /** + * restart search at given sequence and residue on alignment and (optionally) contained in selection + * @param alignment + * @param selectionGroup + * @param seqIndex + * @param resIndex + */ public Finder(AlignmentI alignment, SequenceGroup selectionGroup, int seqIndex, int resIndex) { @@ -116,11 +123,24 @@ public class Finder && !selection.getSequences(null).contains(seq)) { seqIndex++; - resIndex = 0; + resIndex = -1; continue; } - + if (resIndex<0) { + resIndex=0; + if (regex.search(seq.getName())) + { + idMatch.addElement(seq); + hasResults = true; + if (!findAll) + { + // stop and return the match + found=true; + break; + } + } + } item = seq.getSequenceAsString(); if ((selection != null) @@ -194,18 +214,20 @@ public class Finder if (!found) { seqIndex++; - resIndex = 0; + resIndex = -1; } } - for (int id = 0; id < alignment.getHeight(); id++) + /** + * We now search the Id string in the main search loop. + * for (int id = 0; id < alignment.getHeight(); id++) { if (regex.search(alignment.getSequenceAt(id).getName())) { idMatch.addElement(alignment.getSequenceAt(id)); hasResults = true; } - } + } */ return hasResults; }