import javax.swing.*;\r
import javax.swing.event.*;\r
import java.util.*;\r
-import java.util.regex.*;\r
import java.awt.*;\r
\r
public class Finder extends GFinder\r
int [] allResults = null;\r
\r
Sequence seq;\r
- String item;\r
+ String item=null;\r
boolean found = false;\r
\r
/// is the searchString a residue number?\r
searchResults.add( Integer.toString( seq.findIndex(res)-1 ) );\r
searchResults.add( Integer.toString( seq.findIndex(res)-1 ) );\r
\r
-\r
- //av.getAlignment().getSequenceAt(seq).findPosition(res)\r
}catch(NumberFormatException ex){}\r
\r
jalview.schemes.UserColourScheme ucs = new jalview.schemes.UserColourScheme();\r
\r
searchGroup = new SuperGroup(searchString, ucs , true, true, false);\r
\r
- while( !found && seqIndex<av.getAlignment().getHeight())\r
+ int end = av.alignment.getHeight();\r
+\r
+\r
+ SequenceGroup rubberband = av.getRubberbandGroup();\r
+ if(rubberband!=null)\r
+ end = rubberband.getEndRes();\r
+\r
+\r
+\r
+ while( !found && seqIndex<end)\r
{\r
seq = (Sequence)av.getAlignment().getSequenceAt(seqIndex);\r
- if(av.getSelection().size()>0 && !av.getSelection().contains(seq))\r
+\r
+ if( av.getSelection().size()>0 && !av.getSelection().contains(seq)\r
+ || (rubberband!=null && !rubberband.sequences.contains(seq)) )\r
{\r
// if a selection has been made, only search within that selection\r
seqIndex++;\r
\r
item = seq.getSequence();\r
\r
+ if(rubberband!=null)\r
+ item = item.substring(0, rubberband.getEndRes()+1);\r
+\r
///Shall we ignore gaps????\r
StringBuffer noGaps = new StringBuffer();\r
int insertCount=0;\r
}\r
\r
\r
- Pattern pattern = Pattern.compile(searchString);\r
- Matcher matcher = pattern.matcher(noGaps);\r
+ com.stevesoft.pat.Regex regex = new com.stevesoft.pat.Regex(searchString);\r
\r
for(int r = resIndex; r<noGaps.length(); r++)\r
{\r
\r
- if( matcher.find( r ) )\r
+ if( regex.searchFrom( noGaps.toString(), r ) )\r
{\r
- resIndex = matcher.start();\r
+ resIndex = regex.matchedFrom();\r
+\r
+\r
+ if(rubberband!=null && ( resIndex+ Integer.parseInt(spaces.get(resIndex).toString()) )<rubberband.getStartRes())\r
+ continue;\r
\r
searchResults.add( Integer.toString( seqIndex) );\r
searchResults.add( Integer.toString( resIndex+ Integer.parseInt(spaces.get(resIndex).toString()) ) );\r
- searchResults.add( Integer.toString( matcher.end()-1 + Integer.parseInt(spaces.get(matcher.end()-1).toString()) ) );\r
+ searchResults.add( Integer.toString( regex.matchedTo()-1 + Integer.parseInt(spaces.get(regex.matchedTo()-1).toString()) ) );\r
\r
SequenceGroup sg = new SequenceGroup(searchString, ucs, true, true, false,\r
resIndex+ Integer.parseInt(spaces.get(resIndex).toString()) ,\r
- matcher.end()-1 + Integer.parseInt(spaces.get(matcher.end()-1).toString())\r
+ regex.matchedTo()-1 + Integer.parseInt(spaces.get(regex.matchedTo()-1).toString())\r
);\r
sg.addSequence((Sequence)av.getAlignment().getSequenceAt(seqIndex));\r
searchGroup.addGroup( sg );\r
break;\r
}\r
\r
- r=resIndex+1;\r
+ r=resIndex;\r
}\r
}\r
if(!found)\r
seqIndex++;\r
resIndex = 0;\r
}\r
- }\r
+ }\r
\r
if(searchResults.size()>0)\r
{\r