1 Clazz.declarePackage ("jalview.datamodel");
2 Clazz.load (["java.util.ArrayList"], "jalview.datamodel.SearchResults", ["java.lang.StringBuilder", "java.util.Arrays"], function () {
3 c$ = Clazz.decorateAsClass (function () {
5 if (!Clazz.isClassDefined ("jalview.datamodel.SearchResults.Match")) {
6 jalview.datamodel.SearchResults.$SearchResults$Match$ ();
8 Clazz.instantialize (this, arguments);
9 }, jalview.datamodel, "SearchResults");
10 Clazz.prepareFields (c$, function () {
11 this.matches = new java.util.ArrayList ();
13 Clazz.defineMethod (c$, "addResult",
14 function (seq, start, end) {
15 this.matches.add (Clazz.innerTypeInstance (jalview.datamodel.SearchResults.Match, this, null, seq, start, end));
16 }, "jalview.datamodel.SequenceI,~N,~N");
17 Clazz.defineMethod (c$, "involvesSequence",
19 var ds = sequence.getDatasetSequence ();
20 for (var m, $m = this.matches.iterator (); $m.hasNext () && ((m = $m.next ()) || true);) {
21 if (m.sequence != null && (m.sequence === sequence || m.sequence === ds)) {
25 }, "jalview.datamodel.SequenceI");
26 Clazz.defineMethod (c$, "getResults",
27 function (sequence, start, end) {
28 if (this.matches.isEmpty ()) {
36 for (var m, $m = this.matches.iterator (); $m.hasNext () && ((m = $m.next ()) || true);) {
38 if (m.sequence === sequence) {
40 matchStart = sequence.findIndex (m.start) - 1;
41 matchEnd = sequence.findIndex (m.end) - 1;
42 } else if (m.sequence === sequence.getDatasetSequence ()) {
44 matchStart = sequence.findIndex (m.start) - 1;
45 matchEnd = sequence.findIndex (m.end) - 1;
47 if (matchStart <= end && matchEnd >= start) {
48 if (matchStart < start) {
50 }if (matchEnd > end) {
52 }if (result == null) {
53 result = Clazz.newIntArray (-1, [matchStart, matchEnd]);
55 resultLength = result.length;
56 tmp = Clazz.newIntArray (resultLength + 2, 0);
57 System.arraycopy (result, 0, tmp, 0, resultLength);
59 result[resultLength] = matchStart;
60 result[resultLength + 1] = matchEnd;
64 }, "jalview.datamodel.SequenceI,~N,~N");
65 Clazz.defineMethod (c$, "getSize",
67 return this.matches.size ();
69 Clazz.defineMethod (c$, "getResultSequence",
71 return this.matches.get (index).sequence;
73 Clazz.defineMethod (c$, "getResultStart",
75 return this.matches.get (i).start;
77 Clazz.defineMethod (c$, "getResultEnd",
79 return this.matches.get (i).end;
81 Clazz.defineMethod (c$, "isEmpty",
83 return this.matches.isEmpty ();
85 Clazz.defineMethod (c$, "getResults",
89 Clazz.overrideMethod (c$, "toString",
91 var result = new StringBuilder (256);
92 for (var m, $m = this.matches.iterator (); $m.hasNext () && ((m = $m.next ()) || true);) {
93 result.append (m.toString ());
95 return result.toString ();
97 c$.$SearchResults$Match$ = function () {
99 c$ = Clazz.decorateAsClass (function () {
100 Clazz.prepareCallback (this, arguments);
101 this.sequence = null;
104 Clazz.instantialize (this, arguments);
105 }, jalview.datamodel.SearchResults, "Match");
106 Clazz.makeConstructor (c$,
111 }, "jalview.datamodel.SequenceI,~N,~N");
112 Clazz.defineMethod (c$, "getSequence",
114 return this.sequence;
116 Clazz.defineMethod (c$, "getStart",
120 Clazz.defineMethod (c$, "getEnd",
124 Clazz.overrideMethod (c$, "toString",
126 var a = this.sequence.getSequence ();
127 var b = Math.max (this.start - 1, 0);
128 var c = Math.min (this.end, a.length + 1);
129 return String.valueOf (java.util.Arrays.copyOfRange (a, b, c));
131 Clazz.defineMethod (c$, "setSequence",
134 }, "jalview.datamodel.SequenceI");