X-Git-Url: http://source.jalview.org/gitweb/?p=jalviewjs.git;a=blobdiff_plain;f=bin%2Fjalview%2Fanalysis%2FSequenceIdMatcher.js;h=adb0a5a19dbab05ccb4d5d67dd74d61e9a695c6a;hp=6e94b5f8d3aa5f8673c36e12146d2d4645d14b76;hb=7301a2415adab88038b291fc54caeeb3a5a47a44;hpb=6154cb57a6eac3bb1344b8342495f5bb701ee921 diff --git a/bin/jalview/analysis/SequenceIdMatcher.js b/bin/jalview/analysis/SequenceIdMatcher.js index 6e94b5f..adb0a5a 100644 --- a/bin/jalview/analysis/SequenceIdMatcher.js +++ b/bin/jalview/analysis/SequenceIdMatcher.js @@ -1,167 +1,167 @@ -Clazz.declarePackage ("jalview.analysis"); -Clazz.load (null, "jalview.analysis.SequenceIdMatcher", ["java.util.ArrayList", "$.Arrays", "$.HashMap", "$.Vector"], function () { -c$ = Clazz.decorateAsClass (function () { -this.names = null; -if (!Clazz.isClassDefined ("jalview.analysis.SequenceIdMatcher.SeqIdName")) { -jalview.analysis.SequenceIdMatcher.$SequenceIdMatcher$SeqIdName$ (); -} -Clazz.instantialize (this, arguments); -}, jalview.analysis, "SequenceIdMatcher"); -Clazz.makeConstructor (c$, -function (seqs) { -this.names = new java.util.HashMap (); -this.addAll (seqs); -}, "java.util.List"); -Clazz.defineMethod (c$, "addAll", -function (seqs) { -for (var seq, $seq = seqs.iterator (); $seq.hasNext () && ((seq = $seq.next ()) || true);) { -this.names.put (Clazz.innerTypeInstance (jalview.analysis.SequenceIdMatcher.SeqIdName, this, null, seq.getDisplayId (true)), seq); -var dbseq = seq; -while (dbseq.getDatasetSequence () != null) { -dbseq = dbseq.getDatasetSequence (); -} -if (dbseq.getDBRef () != null) { -var dbr = dbseq.getDBRef (); -var sid = null; -for (var r = 0; r < dbr.length; r++) { -sid = Clazz.innerTypeInstance (jalview.analysis.SequenceIdMatcher.SeqIdName, this, null, dbr[r].getAccessionId ()); -if (!this.names.containsKey (sid)) { -this.names.put (sid, seq); -}} -}} -}, "java.util.List"); -Clazz.makeConstructor (c$, -function (sequences) { -this.construct (java.util.Arrays.asList (sequences)); -}, "~A"); -Clazz.defineMethod (c$, "pickbestMatch", -($fz = function (candName, matches) { -var st = this.pickbestMatches (candName, matches); -return st == null || st.size () == 0 ? null : st.get (0); -}, $fz.isPrivate = true, $fz), "jalview.analysis.SequenceIdMatcher.SeqIdName,java.util.List"); -Clazz.defineMethod (c$, "pickbestMatches", -($fz = function (candName, matches) { -var best = new java.util.ArrayList (); -if (candName == null || matches == null || matches.size () == 0) { -return null; -}var match = matches.remove (0); -best.add (match); -this.names.put (Clazz.innerTypeInstance (jalview.analysis.SequenceIdMatcher.SeqIdName, this, null, match.getName ()), match); -var matchlen = match.getName ().length; -var namlen = candName.id.length; -while (matches.size () > 0) { -var cand = matches.remove (0); -this.names.put (Clazz.innerTypeInstance (jalview.analysis.SequenceIdMatcher.SeqIdName, this, null, cand.getName ()), cand); -var q; -var w; -var candlen = cand.getName ().length; -if ((q = Math.abs (matchlen - namlen)) > (w = Math.abs (candlen - namlen)) && candlen > matchlen) { -best.clear (); -match = cand; -matchlen = candlen; -best.add (match); -}if (q == w && candlen == matchlen) { -best.add (cand); -}} -if (best.size () == 0) { -return null; -};return best; -}, $fz.isPrivate = true, $fz), "jalview.analysis.SequenceIdMatcher.SeqIdName,java.util.List"); -Clazz.defineMethod (c$, "findIdMatch", -function (seq) { -var nam = Clazz.innerTypeInstance (jalview.analysis.SequenceIdMatcher.SeqIdName, this, null, seq.getName ()); -return this.findIdMatch (nam); -}, "jalview.datamodel.SequenceI"); -Clazz.defineMethod (c$, "findIdMatch", -function (seqnam) { -var nam = Clazz.innerTypeInstance (jalview.analysis.SequenceIdMatcher.SeqIdName, this, null, seqnam); -return this.findIdMatch (nam); -}, "~S"); -Clazz.defineMethod (c$, "findAllIdMatches", -function (seqnam) { -var nam = Clazz.innerTypeInstance (jalview.analysis.SequenceIdMatcher.SeqIdName, this, null, seqnam); -var m = this.findAllIdMatches (nam); -if (m != null) { -return m.toArray ( new Array (m.size ())); -}return null; -}, "~S"); -Clazz.defineMethod (c$, "findIdMatch", -function (seqs) { -var namedseqs = null; -var i = 0; -var nam; -if (seqs.length > 0) { -namedseqs = new Array (seqs.length); -do { -nam = Clazz.innerTypeInstance (jalview.analysis.SequenceIdMatcher.SeqIdName, this, null, seqs[i].getName ()); -if (this.names.containsKey (nam)) { -namedseqs[i] = this.findIdMatch (nam); -} else { -namedseqs[i] = null; -}} while (++i < seqs.length); -}return namedseqs; -}, "~A"); -Clazz.defineMethod (c$, "findIdMatch", -($fz = function (nam) { -var matches = new java.util.Vector (); -while (this.names.containsKey (nam)) { -matches.addElement (this.names.remove (nam)); -} -return this.pickbestMatch (nam, matches); -}, $fz.isPrivate = true, $fz), "jalview.analysis.SequenceIdMatcher.SeqIdName"); -Clazz.defineMethod (c$, "findAllIdMatches", -($fz = function (nam) { -var matches = new java.util.ArrayList (); -while (this.names.containsKey (nam)) { -matches.add (this.names.remove (nam)); -} -var r = this.pickbestMatches (nam, matches); -return r; -}, $fz.isPrivate = true, $fz), "jalview.analysis.SequenceIdMatcher.SeqIdName"); -c$.$SequenceIdMatcher$SeqIdName$ = function () { -Clazz.pu$h (); -c$ = Clazz.decorateAsClass (function () { -Clazz.prepareCallback (this, arguments); -this.id = null; -this.WORD_SEP = "~. |#\\/<>!\"\u00a4$%^*)}[@\',?_"; -Clazz.instantialize (this, arguments); -}, jalview.analysis.SequenceIdMatcher, "SeqIdName"); -Clazz.makeConstructor (c$, -function (a) { -if (a != null) { -this.id = String.instantialize (a); -} else { -this.id = ""; -}}, "~S"); -Clazz.overrideMethod (c$, "hashCode", -function () { -return ((this.id.length >= 4) ? this.id.substring (0, 4).hashCode () : this.id.hashCode ()); -}); -Clazz.defineMethod (c$, "equals", -function (a) { -if (a == null) { -return false; -}if (Clazz.instanceOf (a, jalview.analysis.SequenceIdMatcher.SeqIdName)) { -return this.equals (a); -} else { -if (Clazz.instanceOf (a, String)) { -return this.equals (a); -}}return false; -}, "~O"); -Clazz.defineMethod (c$, "equals", -function (a) { -if (this.id.length > a.id.length) { -return this.id.startsWith (a.id) ? (this.WORD_SEP.indexOf (this.id.charAt (a.id.length)) > -1) : false; -} else { -return a.id.startsWith (this.id) ? (a.id.equals (this.id) ? true : (this.WORD_SEP.indexOf (a.id.charAt (this.id.length)) > -1)) : false; -}}, "jalview.analysis.SequenceIdMatcher.SeqIdName"); -Clazz.defineMethod (c$, "equals", -function (a) { -if (this.id.length > a.length) { -return this.id.startsWith (a) ? (this.WORD_SEP.indexOf (this.id.charAt (a.length)) > -1) : false; -} else { -return a.startsWith (this.id) ? (a.equals (this.id) ? true : (this.WORD_SEP.indexOf (a.charAt (this.id.length)) > -1)) : false; -}}, "~S"); -c$ = Clazz.p0p (); -}; -}); +Clazz.declarePackage ("jalview.analysis"); +Clazz.load (null, "jalview.analysis.SequenceIdMatcher", ["java.util.ArrayList", "$.Arrays", "$.HashMap", "$.Vector"], function () { +c$ = Clazz.decorateAsClass (function () { +this.names = null; +if (!Clazz.isClassDefined ("jalview.analysis.SequenceIdMatcher.SeqIdName")) { +jalview.analysis.SequenceIdMatcher.$SequenceIdMatcher$SeqIdName$ (); +} +Clazz.instantialize (this, arguments); +}, jalview.analysis, "SequenceIdMatcher"); +Clazz.makeConstructor (c$, +function (seqs) { +this.names = new java.util.HashMap (); +this.addAll (seqs); +}, "java.util.List"); +Clazz.defineMethod (c$, "addAll", +function (seqs) { +for (var seq, $seq = seqs.iterator (); $seq.hasNext () && ((seq = $seq.next ()) || true);) { +this.names.put (Clazz.innerTypeInstance (jalview.analysis.SequenceIdMatcher.SeqIdName, this, null, seq.getDisplayId (true)), seq); +var dbseq = seq; +while (dbseq.getDatasetSequence () != null) { +dbseq = dbseq.getDatasetSequence (); +} +if (dbseq.getDBRef () != null) { +var dbr = dbseq.getDBRef (); +var sid = null; +for (var r = 0; r < dbr.length; r++) { +sid = Clazz.innerTypeInstance (jalview.analysis.SequenceIdMatcher.SeqIdName, this, null, dbr[r].getAccessionId ()); +if (!this.names.containsKey (sid)) { +this.names.put (sid, seq); +}} +}} +}, "java.util.List"); +Clazz.makeConstructor (c$, +function (sequences) { +this.construct (java.util.Arrays.asList (sequences)); +}, "~A"); +Clazz.defineMethod (c$, "pickbestMatch", +($fz = function (candName, matches) { +var st = this.pickbestMatches (candName, matches); +return st == null || st.size () == 0 ? null : st.get (0); +}, $fz.isPrivate = true, $fz), "jalview.analysis.SequenceIdMatcher.SeqIdName,java.util.List"); +Clazz.defineMethod (c$, "pickbestMatches", +($fz = function (candName, matches) { +var best = new java.util.ArrayList (); +if (candName == null || matches == null || matches.size () == 0) { +return null; +}var match = matches.remove (0); +best.add (match); +this.names.put (Clazz.innerTypeInstance (jalview.analysis.SequenceIdMatcher.SeqIdName, this, null, match.getName ()), match); +var matchlen = match.getName ().length; +var namlen = candName.id.length; +while (matches.size () > 0) { +var cand = matches.remove (0); +this.names.put (Clazz.innerTypeInstance (jalview.analysis.SequenceIdMatcher.SeqIdName, this, null, cand.getName ()), cand); +var q; +var w; +var candlen = cand.getName ().length; +if ((q = Math.abs (matchlen - namlen)) > (w = Math.abs (candlen - namlen)) && candlen > matchlen) { +best.clear (); +match = cand; +matchlen = candlen; +best.add (match); +}if (q == w && candlen == matchlen) { +best.add (cand); +}} +if (best.size () == 0) { +return null; +};return best; +}, $fz.isPrivate = true, $fz), "jalview.analysis.SequenceIdMatcher.SeqIdName,java.util.List"); +Clazz.defineMethod (c$, "findIdMatch", +function (seq) { +var nam = Clazz.innerTypeInstance (jalview.analysis.SequenceIdMatcher.SeqIdName, this, null, seq.getName ()); +return this.findIdMatch (nam); +}, "jalview.datamodel.SequenceI"); +Clazz.defineMethod (c$, "findIdMatch", +function (seqnam) { +var nam = Clazz.innerTypeInstance (jalview.analysis.SequenceIdMatcher.SeqIdName, this, null, seqnam); +return this.findIdMatch (nam); +}, "~S"); +Clazz.defineMethod (c$, "findAllIdMatches", +function (seqnam) { +var nam = Clazz.innerTypeInstance (jalview.analysis.SequenceIdMatcher.SeqIdName, this, null, seqnam); +var m = this.findAllIdMatches (nam); +if (m != null) { +return m.toArray ( new Array (m.size ())); +}return null; +}, "~S"); +Clazz.defineMethod (c$, "findIdMatch", +function (seqs) { +var namedseqs = null; +var i = 0; +var nam; +if (seqs.length > 0) { +namedseqs = new Array (seqs.length); +do { +nam = Clazz.innerTypeInstance (jalview.analysis.SequenceIdMatcher.SeqIdName, this, null, seqs[i].getName ()); +if (this.names.containsKey (nam)) { +namedseqs[i] = this.findIdMatch (nam); +} else { +namedseqs[i] = null; +}} while (++i < seqs.length); +}return namedseqs; +}, "~A"); +Clazz.defineMethod (c$, "findIdMatch", +($fz = function (nam) { +var matches = new java.util.Vector (); +while (this.names.containsKey (nam)) { +matches.addElement (this.names.remove (nam)); +} +return this.pickbestMatch (nam, matches); +}, $fz.isPrivate = true, $fz), "jalview.analysis.SequenceIdMatcher.SeqIdName"); +Clazz.defineMethod (c$, "findAllIdMatches", +($fz = function (nam) { +var matches = new java.util.ArrayList (); +while (this.names.containsKey (nam)) { +matches.add (this.names.remove (nam)); +} +var r = this.pickbestMatches (nam, matches); +return r; +}, $fz.isPrivate = true, $fz), "jalview.analysis.SequenceIdMatcher.SeqIdName"); +c$.$SequenceIdMatcher$SeqIdName$ = function () { +Clazz.pu$h (); +c$ = Clazz.decorateAsClass (function () { +Clazz.prepareCallback (this, arguments); +this.id = null; +this.WORD_SEP = "~. |#\\/<>!\"\u00a4$%^*)}[@\',?_"; +Clazz.instantialize (this, arguments); +}, jalview.analysis.SequenceIdMatcher, "SeqIdName"); +Clazz.makeConstructor (c$, +function (a) { +if (a != null) { +this.id = String.instantialize (a); +} else { +this.id = ""; +}}, "~S"); +Clazz.overrideMethod (c$, "hashCode", +function () { +return ((this.id.length >= 4) ? this.id.substring (0, 4).hashCode () : this.id.hashCode ()); +}); +Clazz.defineMethod (c$, "equals", +function (a) { +if (a == null) { +return false; +}if (Clazz.instanceOf (a, jalview.analysis.SequenceIdMatcher.SeqIdName)) { +return this.equals (a); +} else { +if (Clazz.instanceOf (a, String)) { +return this.equals (a); +}}return false; +}, "~O"); +Clazz.defineMethod (c$, "equals", +function (a) { +if (this.id.length > a.id.length) { +return this.id.startsWith (a.id) ? (this.WORD_SEP.indexOf (this.id.charAt (a.id.length)) > -1) : false; +} else { +return a.id.startsWith (this.id) ? (a.id.equals (this.id) ? true : (this.WORD_SEP.indexOf (a.id.charAt (this.id.length)) > -1)) : false; +}}, "jalview.analysis.SequenceIdMatcher.SeqIdName"); +Clazz.defineMethod (c$, "equals", +function (a) { +if (this.id.length > a.length) { +return this.id.startsWith (a) ? (this.WORD_SEP.indexOf (this.id.charAt (a.length)) > -1) : false; +} else { +return a.startsWith (this.id) ? (a.equals (this.id) ? true : (this.WORD_SEP.indexOf (a.charAt (this.id.length)) > -1)) : false; +}}, "~S"); +c$ = Clazz.p0p (); +}; +});