Merge branch 'master' of https://source.jalview.org/git/jalviewjs.git
[jalviewjs.git] / site / j2s / jalview / analysis / Finder.js
index cf1d8f9..5d20c2c 100644 (file)
-Clazz.declarePackage ("jalview.analysis");\r
-Clazz.load (null, "jalview.analysis.Finder", ["jalview.datamodel.SearchResults", "jalview.jsdev.RegExp", "jalview.util.Comparison", "java.lang.StringBuffer", "java.util.Vector"], function () {\r
-c$ = Clazz.decorateAsClass (function () {\r
-this.searchResults = null;\r
-this.alignment = null;\r
-this.selection = null;\r
-this.idMatch = null;\r
-this.caseSensitive = false;\r
-this.includeDescription = false;\r
-this.findAll = false;\r
-this.regex = null;\r
-this.seqIndex = 0;\r
-this.resIndex = -1;\r
-Clazz.instantialize (this, arguments);\r
-}, jalview.analysis, "Finder");\r
-Clazz.makeConstructor (c$, \r
-function (alignment, selection) {\r
-this.alignment = alignment;\r
-this.selection = selection;\r
-}, "jalview.datamodel.AlignmentI,jalview.datamodel.SequenceGroup");\r
-Clazz.makeConstructor (c$, \r
-function (alignment, selectionGroup, seqIndex, resIndex) {\r
-this.construct (alignment, selectionGroup);\r
-this.seqIndex = seqIndex;\r
-this.resIndex = resIndex;\r
-}, "jalview.datamodel.AlignmentI,jalview.datamodel.SequenceGroup,~N,~N");\r
-Clazz.defineMethod (c$, "find", \r
-function (searchString) {\r
-var hasResults = false;\r
-if (!this.caseSensitive) {\r
-searchString = searchString.toUpperCase ();\r
-}this.regex = jalview.jsdev.RegExp.newRegex ([searchString]);\r
-this.regex.setIgnoreCase (!this.caseSensitive);\r
-this.searchResults =  new jalview.datamodel.SearchResults ();\r
-this.idMatch =  new java.util.Vector ();\r
-var seq;\r
-var item = null;\r
-var found = false;\r
-var end = this.alignment.getHeight ();\r
-if (this.selection != null) {\r
-if ((this.selection.getSize () < 1) || ((this.selection.getEndRes () - this.selection.getStartRes ()) < 2)) {\r
-this.selection = null;\r
-}}while (!found && (this.seqIndex < end)) {\r
-seq = this.alignment.getSequenceAt (this.seqIndex);\r
-if ((this.selection != null && this.selection.getSize () > 0) && !this.selection.getSequences (null).contains (seq)) {\r
-this.seqIndex++;\r
-this.resIndex = -1;\r
-continue;\r
-}if (this.resIndex < 0) {\r
-this.resIndex = 0;\r
-try {\r
-var res = Integer.parseInt (searchString);\r
-if (seq.getEnd () >= res) {\r
-this.searchResults.addResult (seq, res, res);\r
-hasResults = true;\r
-if (!this.findAll) {\r
-found = true;\r
-break;\r
-}}} catch (ex) {\r
-if (Clazz.exceptionOf (ex, NumberFormatException)) {\r
-} else {\r
-throw ex;\r
-}\r
-}\r
-if (this.regex.search (seq.getName ())) {\r
-this.idMatch.addElement (seq);\r
-hasResults = true;\r
-if (!this.findAll) {\r
-found = true;\r
-break;\r
-}}if (this.isIncludeDescription () && seq.getDescription () != null && this.regex.search (seq.getDescription ())) {\r
-this.idMatch.addElement (seq);\r
-hasResults = true;\r
-if (!this.findAll) {\r
-found = true;\r
-break;\r
-}}}item = seq.getSequenceAsString ();\r
-if ((this.selection != null) && (this.selection.getEndRes () < this.alignment.getWidth () - 1)) {\r
-item = item.substring (0, this.selection.getEndRes () + 1);\r
-}var noGapsSB =  new StringBuffer ();\r
-var insertCount = 0;\r
-var spaces =  new java.util.Vector ();\r
-for (var j = 0; j < item.length; j++) {\r
-if (!jalview.util.Comparison.isGap (item.charAt (j))) {\r
-noGapsSB.append (item.charAt (j));\r
-spaces.addElement ( new Integer (insertCount));\r
-} else {\r
-insertCount++;\r
-}}\r
-var noGaps = noGapsSB.toString ();\r
-for (var r = this.resIndex; r < noGaps.length; r++) {\r
-if (this.regex.searchFrom (noGaps, r)) {\r
-this.resIndex = this.regex.matchedFrom ();\r
-if ((this.selection != null && this.selection.getSize () > 0) && ((this.resIndex + Integer.parseInt (spaces.elementAt (this.resIndex).toString ())) < this.selection.getStartRes ())) {\r
-continue;\r
-}var sres = seq.findPosition (this.resIndex + Integer.parseInt (spaces.elementAt (this.resIndex).toString ()));\r
-var eres = seq.findPosition (this.regex.matchedTo () - 1 + Integer.parseInt (spaces.elementAt (this.regex.matchedTo () - 1).toString ()));\r
-this.searchResults.addResult (seq, sres, eres);\r
-hasResults = true;\r
-if (!this.findAll) {\r
-found = true;\r
-this.resIndex++;\r
-break;\r
-}r = this.resIndex;\r
-} else {\r
-break;\r
-}}\r
-if (!found) {\r
-this.seqIndex++;\r
-this.resIndex = -1;\r
-}}\r
-return hasResults;\r
-}, "~S");\r
-Clazz.defineMethod (c$, "getAlignment", \r
-function () {\r
-return this.alignment;\r
-});\r
-Clazz.defineMethod (c$, "setAlignment", \r
-function (alignment) {\r
-this.alignment = alignment;\r
-}, "jalview.datamodel.AlignmentI");\r
-Clazz.defineMethod (c$, "isCaseSensitive", \r
-function () {\r
-return this.caseSensitive;\r
-});\r
-Clazz.defineMethod (c$, "setCaseSensitive", \r
-function (caseSensitive) {\r
-this.caseSensitive = caseSensitive;\r
-}, "~B");\r
-Clazz.defineMethod (c$, "isFindAll", \r
-function () {\r
-return this.findAll;\r
-});\r
-Clazz.defineMethod (c$, "setFindAll", \r
-function (findAll) {\r
-this.findAll = findAll;\r
-}, "~B");\r
-Clazz.defineMethod (c$, "getSelection", \r
-function () {\r
-return this.selection;\r
-});\r
-Clazz.defineMethod (c$, "setSelection", \r
-function (selection) {\r
-this.selection = selection;\r
-}, "jalview.datamodel.SequenceGroup");\r
-Clazz.defineMethod (c$, "getIdMatch", \r
-function () {\r
-return this.idMatch;\r
-});\r
-Clazz.defineMethod (c$, "getRegex", \r
-function () {\r
-return this.regex;\r
-});\r
-Clazz.defineMethod (c$, "getSearchResults", \r
-function () {\r
-return this.searchResults;\r
-});\r
-Clazz.defineMethod (c$, "getResIndex", \r
-function () {\r
-return this.resIndex;\r
-});\r
-Clazz.defineMethod (c$, "setResIndex", \r
-function (resIndex) {\r
-this.resIndex = resIndex;\r
-}, "~N");\r
-Clazz.defineMethod (c$, "getSeqIndex", \r
-function () {\r
-return this.seqIndex;\r
-});\r
-Clazz.defineMethod (c$, "setSeqIndex", \r
-function (seqIndex) {\r
-this.seqIndex = seqIndex;\r
-}, "~N");\r
-Clazz.defineMethod (c$, "isIncludeDescription", \r
-function () {\r
-return this.includeDescription;\r
-});\r
-Clazz.defineMethod (c$, "setIncludeDescription", \r
-function (includeDescription) {\r
-this.includeDescription = includeDescription;\r
-}, "~B");\r
-});\r
+Clazz.declarePackage ("jalview.analysis");
+Clazz.load (null, "jalview.analysis.Finder", ["jalview.datamodel.SearchResults", "jalview.jsdev.RegExp", "jalview.util.Comparison", "java.lang.StringBuffer", "java.util.Vector"], function () {
+c$ = Clazz.decorateAsClass (function () {
+this.searchResults = null;
+this.alignment = null;
+this.selection = null;
+this.idMatch = null;
+this.caseSensitive = false;
+this.includeDescription = false;
+this.findAll = false;
+this.regex = null;
+this.seqIndex = 0;
+this.resIndex = -1;
+Clazz.instantialize (this, arguments);
+}, jalview.analysis, "Finder");
+Clazz.makeConstructor (c$, 
+function (alignment, selection) {
+this.alignment = alignment;
+this.selection = selection;
+}, "jalview.datamodel.AlignmentI,jalview.datamodel.SequenceGroup");
+Clazz.makeConstructor (c$, 
+function (alignment, selectionGroup, seqIndex, resIndex) {
+this.construct (alignment, selectionGroup);
+this.seqIndex = seqIndex;
+this.resIndex = resIndex;
+}, "jalview.datamodel.AlignmentI,jalview.datamodel.SequenceGroup,~N,~N");
+Clazz.defineMethod (c$, "find", 
+function (searchString) {
+var hasResults = false;
+if (!this.caseSensitive) {
+searchString = searchString.toUpperCase ();
+}this.regex = jalview.jsdev.RegExp.newRegex ([searchString]);
+this.regex.setIgnoreCase (!this.caseSensitive);
+this.searchResults =  new jalview.datamodel.SearchResults ();
+this.idMatch =  new java.util.Vector ();
+var seq;
+var item = null;
+var found = false;
+var end = this.alignment.getHeight ();
+if (this.selection != null) {
+if ((this.selection.getSize () < 1) || ((this.selection.getEndRes () - this.selection.getStartRes ()) < 2)) {
+this.selection = null;
+}}while (!found && (this.seqIndex < end)) {
+seq = this.alignment.getSequenceAt (this.seqIndex);
+if ((this.selection != null && this.selection.getSize () > 0) && !this.selection.getSequences (null).contains (seq)) {
+this.seqIndex++;
+this.resIndex = -1;
+continue;
+}if (this.resIndex < 0) {
+this.resIndex = 0;
+try {
+var res = Integer.parseInt (searchString);
+if (seq.getEnd () >= res) {
+this.searchResults.addResult (seq, res, res);
+hasResults = true;
+if (!this.findAll) {
+found = true;
+break;
+}}} catch (ex) {
+if (Clazz.exceptionOf (ex, NumberFormatException)) {
+} else {
+throw ex;
+}
+}
+if (this.regex.search (seq.getName ())) {
+this.idMatch.addElement (seq);
+hasResults = true;
+if (!this.findAll) {
+found = true;
+break;
+}}if (this.isIncludeDescription () && seq.getDescription () != null && this.regex.search (seq.getDescription ())) {
+this.idMatch.addElement (seq);
+hasResults = true;
+if (!this.findAll) {
+found = true;
+break;
+}}}item = seq.getSequenceAsString ();
+if ((this.selection != null) && (this.selection.getEndRes () < this.alignment.getWidth () - 1)) {
+item = item.substring (0, this.selection.getEndRes () + 1);
+}var noGapsSB =  new StringBuffer ();
+var insertCount = 0;
+var spaces =  new java.util.Vector ();
+for (var j = 0; j < item.length; j++) {
+if (!jalview.util.Comparison.isGap (item.charAt (j))) {
+noGapsSB.append (item.charAt (j));
+spaces.addElement ( new Integer (insertCount));
+} else {
+insertCount++;
+}}
+var noGaps = noGapsSB.toString ();
+for (var r = this.resIndex; r < noGaps.length; r++) {
+if (this.regex.searchFrom (noGaps, r)) {
+this.resIndex = this.regex.matchedFrom ();
+if ((this.selection != null && this.selection.getSize () > 0) && ((this.resIndex + Integer.parseInt (spaces.elementAt (this.resIndex).toString ())) < this.selection.getStartRes ())) {
+continue;
+}var sres = seq.findPosition (this.resIndex + Integer.parseInt (spaces.elementAt (this.resIndex).toString ()));
+var eres = seq.findPosition (this.regex.matchedTo () - 1 + Integer.parseInt (spaces.elementAt (this.regex.matchedTo () - 1).toString ()));
+this.searchResults.addResult (seq, sres, eres);
+hasResults = true;
+if (!this.findAll) {
+found = true;
+this.resIndex++;
+break;
+}r = this.resIndex;
+} else {
+break;
+}}
+if (!found) {
+this.seqIndex++;
+this.resIndex = -1;
+}}
+return hasResults;
+}, "~S");
+Clazz.defineMethod (c$, "getAlignment", 
+function () {
+return this.alignment;
+});
+Clazz.defineMethod (c$, "setAlignment", 
+function (alignment) {
+this.alignment = alignment;
+}, "jalview.datamodel.AlignmentI");
+Clazz.defineMethod (c$, "isCaseSensitive", 
+function () {
+return this.caseSensitive;
+});
+Clazz.defineMethod (c$, "setCaseSensitive", 
+function (caseSensitive) {
+this.caseSensitive = caseSensitive;
+}, "~B");
+Clazz.defineMethod (c$, "isFindAll", 
+function () {
+return this.findAll;
+});
+Clazz.defineMethod (c$, "setFindAll", 
+function (findAll) {
+this.findAll = findAll;
+}, "~B");
+Clazz.defineMethod (c$, "getSelection", 
+function () {
+return this.selection;
+});
+Clazz.defineMethod (c$, "setSelection", 
+function (selection) {
+this.selection = selection;
+}, "jalview.datamodel.SequenceGroup");
+Clazz.defineMethod (c$, "getIdMatch", 
+function () {
+return this.idMatch;
+});
+Clazz.defineMethod (c$, "getRegex", 
+function () {
+return this.regex;
+});
+Clazz.defineMethod (c$, "getSearchResults", 
+function () {
+return this.searchResults;
+});
+Clazz.defineMethod (c$, "getResIndex", 
+function () {
+return this.resIndex;
+});
+Clazz.defineMethod (c$, "setResIndex", 
+function (resIndex) {
+this.resIndex = resIndex;
+}, "~N");
+Clazz.defineMethod (c$, "getSeqIndex", 
+function () {
+return this.seqIndex;
+});
+Clazz.defineMethod (c$, "setSeqIndex", 
+function (seqIndex) {
+this.seqIndex = seqIndex;
+}, "~N");
+Clazz.defineMethod (c$, "isIncludeDescription", 
+function () {
+return this.includeDescription;
+});
+Clazz.defineMethod (c$, "setIncludeDescription", 
+function (includeDescription) {
+this.includeDescription = includeDescription;
+}, "~B");
+});