+ ////// is the searchString a residue number?\r
+ try\r
+ {\r
+ int res = Integer.parseInt(searchString);\r
+ found = true;\r
+ if (av.getSelectionGroup() == null || av.getSelectionGroup().getSize() < 1)\r
+ {\r
+ seq = (Sequence) av.getAlignment().getSequenceAt(0);\r
+ }\r
+ else\r
+ {\r
+ seq = (Sequence) (av.getSelectionGroup().getSequenceAt(0));\r
+ }\r
+\r
+ searchResults.add(Integer.toString(av.getAlignment().findIndex(seq)));\r
+ searchResults.add(res+"");\r
+ searchResults.add(res+"");\r
+ }\r
+ catch (NumberFormatException ex)\r
+ {\r
+ }\r
+\r
+ ///////////////////////////////////////////////\r
+ Color[] newColors = new Color[24];\r
+\r
+ for (int i = 0; i < 24; i++)\r
+ {\r
+ newColors[i] = new Color(60, 160, 115);\r
+ }\r
+\r
+ jalview.schemes.UserColourScheme ucs = new jalview.schemes.UserColourScheme(newColors);\r
+\r
+ searchGroup = new SuperGroup(searchString, ucs, true, true, false);\r
+\r
+ int end = av.alignment.getHeight();\r
+\r
+ SequenceGroup selection = av.getSelectionGroup();\r
+\r
+ if (selection != null)\r
+ {\r
+ if ((selection.getSize() < 1) ||\r
+ ((selection.getEndRes() - selection.getStartRes()) < 2))\r
+ {\r
+ selection = null;\r
+ }\r
+ }\r
+\r
+ while (!found && (seqIndex < end))\r
+ {\r
+ seq = (Sequence) av.alignment.getSequenceAt(seqIndex);\r
+\r
+ if ((selection != null) && !selection.sequences.contains(seq))\r
+ {\r
+ seqIndex++;\r
+ resIndex = 0;\r
+\r
+ continue;\r
+ }\r
+\r
+ item = seq.getSequence().toUpperCase();\r
+\r
+ if ((selection != null) &&\r
+ (selection.getEndRes() < av.alignment.getWidth()))\r
+ {\r
+ item = item.substring(0, selection.getEndRes() + 1);\r
+ }\r
+\r
+ ///Shall we ignore gaps????\r
+ StringBuffer noGaps = new StringBuffer();\r
+ int insertCount = 0;\r
+ Vector spaces = new Vector();\r
+\r
+ for (int j = 0; j < item.length(); j++)\r
+ {\r
+ if (!jalview.util.Comparison.isGap(item.charAt(j)))\r
+ {\r
+ noGaps.append(item.charAt(j));\r
+ spaces.add(new Integer(insertCount));\r
+ }\r
+ else\r
+ {\r
+ insertCount++;\r
+ }\r
+ }\r
+\r
+ for (int r = resIndex; r < noGaps.length(); r++)\r
+ {\r
+ if (regex.searchFrom(noGaps.toString(), r))\r
+ {\r
+ resIndex = regex.matchedFrom();\r
+\r
+ if ((selection != null) &&\r
+ ((resIndex +\r
+ Integer.parseInt(spaces.get(resIndex).toString())) < selection.getStartRes()))\r
+ {\r
+ continue;\r
+ }\r
+\r
+ searchResults.add(Integer.toString(seqIndex));\r
+\r
+ int sres = seq.findPosition(resIndex +\r
+ Integer.parseInt(spaces.elementAt(resIndex)\r
+ .toString()));\r
+ int eres = seq.findPosition(regex.matchedTo() - 1 +\r
+ Integer.parseInt(spaces.elementAt(regex.matchedTo() -\r
+ 1).toString()));\r
+\r
+ searchResults.addElement(sres + "");\r
+ searchResults.addElement(eres + "");\r
+\r
+ if (!findAll)\r
+ {\r
+ // thats enough, break and display the result\r
+ found = true;\r
+ resIndex++;\r
+\r
+ break;\r
+ }\r
+\r
+ r = resIndex;\r
+ }\r
+ }\r
+\r
+ if (!found)\r
+ {\r
+ seqIndex++;\r
+ resIndex = 0;\r
+ }\r
+ }\r
+\r
+ Vector idMatch = new Vector();\r
+\r
+ for (int id = 0; id < av.alignment.getHeight(); id++)\r
+ {\r
+ if (regex.search(av.alignment.getSequenceAt(id).getName()))\r
+ {\r
+ idMatch.add(av.alignment.getSequenceAt(id));\r
+ }\r
+ }\r
+\r
+ if ((searchResults.size() == 0) && (idMatch.size() > 0))\r
+ {\r
+ ap.idPanel.highlightSearchResults(idMatch);\r
+ }\r
+\r
+ if (searchResults.size() > 0)\r
+ {\r
+ allResults = new int[searchResults.size()];\r
+\r
+ for (int i = 0; i < searchResults.size(); i++)\r
+ {\r
+ allResults[i] = Integer.parseInt(searchResults.get(i).toString());\r
+ }\r
+\r
+ createNewGroup.setEnabled(true);\r
+ }\r
+ else\r
+ {\r
+ JOptionPane.showInternalMessageDialog(this, "Finished searching",\r
+ null, JOptionPane.INFORMATION_MESSAGE);\r
+ resIndex = 0;\r
+ seqIndex = 0;\r
+ }\r
+\r
+ // if allResults is null, this effectively switches displaySearch flag in seqCanvas\r
+ ap.highlightSearchResults(allResults);\r
+\r
+ if (findAll)\r
+ {\r
+ String message = (searchResults.size() / 3) + " matches found.";\r
+ JOptionPane.showInternalMessageDialog(this, message, null,\r
+ JOptionPane.INFORMATION_MESSAGE);\r
+ }\r
+ }\r