X-Git-Url: http://source.jalview.org/gitweb/?p=jalviewjs.git;a=blobdiff_plain;f=bin%2Fjalview%2Fdatamodel%2FMapping.js;h=a25222effe0e5651193b8df6df1186f9bf95ce68;hp=fe06fdacf30d54726e469e9d5063b0049b7eafc1;hb=8ffd05b3abe52c0b6b79b011c0966361f82d5fe6;hpb=6154cb57a6eac3bb1344b8342495f5bb701ee921 diff --git a/bin/jalview/datamodel/Mapping.js b/bin/jalview/datamodel/Mapping.js index fe06fda..a25222e 100644 --- a/bin/jalview/datamodel/Mapping.js +++ b/bin/jalview/datamodel/Mapping.js @@ -1,304 +1,304 @@ -Clazz.declarePackage ("jalview.datamodel"); -Clazz.load (["java.util.Iterator"], "jalview.datamodel.Mapping", ["jalview.datamodel.AlignedCodon", "$.IncompleteCodonException", "$.SequenceFeature", "jalview.util.MapList", "java.util.NoSuchElementException", "$.Vector"], function () { -c$ = Clazz.decorateAsClass (function () { -if (!Clazz.isClassDefined ("jalview.datamodel.Mapping.AlignedCodonIterator")) { -jalview.datamodel.Mapping.$Mapping$AlignedCodonIterator$ (); -} -this.map = null; -this.to = null; -Clazz.instantialize (this, arguments); -}, jalview.datamodel, "Mapping"); -Clazz.makeConstructor (c$, -function (map) { -this.map = map; -}, "jalview.util.MapList"); -Clazz.makeConstructor (c$, -function (to, map) { -this.construct (map); -this.to = to; -}, "jalview.datamodel.SequenceI,jalview.util.MapList"); -Clazz.makeConstructor (c$, -function (to, exon, is, i, j) { -this.construct (to, new jalview.util.MapList (exon, is, i, j)); -}, "jalview.datamodel.SequenceI,~A,~A,~N,~N"); -Clazz.makeConstructor (c$, -function (map2) { -if (map2 !== this && map2 != null) { -if (map2.map != null) { -this.map = new jalview.util.MapList (map2.map); -}this.to = map2.to; -}}, "jalview.datamodel.Mapping"); -Clazz.defineMethod (c$, "getMap", -function () { -return this.map; -}); -Clazz.defineMethod (c$, "setMap", -function (map) { -this.map = map; -}, "jalview.util.MapList"); -Clazz.overrideMethod (c$, "equals", -function (o) { -if (o == null || !(Clazz.instanceOf (o, jalview.datamodel.Mapping))) { -return false; -}var other = o; -if (other === this) { -return true; -}if (other.to !== this.to) { -return false; -}if ((this.map != null && other.map == null) || (this.map == null && other.map != null)) { -return false; -}if ((this.map == null && other.map == null) || this.map.equals (other.map)) { -return true; -}return false; -}, "~O"); -Clazz.defineMethod (c$, "getPosition", -function (mpos) { -if (this.map != null) { -var mp = this.map.shiftTo (mpos); -if (mp != null) { -return mp[0]; -}}return mpos; -}, "~N"); -Clazz.defineMethod (c$, "getWord", -function (mpos) { -if (this.map != null) { -return this.map.getToWord (mpos); -}return null; -}, "~N"); -Clazz.defineMethod (c$, "getWidth", -function () { -if (this.map != null) { -return this.map.getFromRatio (); -}return 1; -}); -Clazz.defineMethod (c$, "getMappedWidth", -function () { -if (this.map != null) { -return this.map.getToRatio (); -}return 1; -}); -Clazz.defineMethod (c$, "getMappedPosition", -function (pos) { -if (this.map != null) { -var mp = this.map.shiftFrom (pos); -if (mp != null) { -return mp[0]; -}}return pos; -}, "~N"); -Clazz.defineMethod (c$, "getMappedWord", -function (pos) { -if (this.map != null) { -var mp = this.map.shiftFrom (pos); -if (mp != null) { -return Clazz.newIntArray (-1, [mp[0], mp[0] + mp[2] * (this.map.getToRatio () - 1)]); -}}return null; -}, "~N"); -Clazz.defineMethod (c$, "locateFeature", -function (f) { -if (true) { -if (this.map != null) { -var frange = this.map.locateInFrom (f.getBegin (), f.getEnd ()); -if (frange == null) { -return null; -}var vf = new Array (Clazz.doubleToInt (frange.length / 2)); -for (var i = 0, v = 0; i < frange.length; i += 2, v++) { -vf[v] = new jalview.datamodel.SequenceFeature (f); -vf[v].setBegin (frange[i]); -vf[v].setEnd (frange[i + 1]); -if (frange.length > 2) { -vf[v].setDescription (f.getDescription () + "\nPart " + (v + 1)); -}} -return vf; -}}if (false) { -var word = this.getWord (f.getBegin ()); -if (word[0] < word[1]) { -f.setBegin (word[0]); -} else { -f.setBegin (word[1]); -}word = this.getWord (f.getEnd ()); -if (word[0] > word[1]) { -f.setEnd (word[0]); -} else { -f.setEnd (word[1]); -}}return Clazz.newArray (-1, [f]); -}, "jalview.datamodel.SequenceFeature"); -Clazz.defineMethod (c$, "locateRange", -function (from, to) { -if (this.map != null) { -if (from <= to) { -from = (this.map.getToLowest () < from) ? from : this.map.getToLowest (); -to = (this.map.getToHighest () > to) ? to : this.map.getToHighest (); -if (from > to) { -return null; -}} else { -from = (this.map.getToHighest () > from) ? from : this.map.getToHighest (); -to = (this.map.getToLowest () < to) ? to : this.map.getToLowest (); -if (from < to) { -return null; -}}return this.map.locateInFrom (from, to); -}return Clazz.newIntArray (-1, [from, to]); -}, "~N,~N"); -Clazz.defineMethod (c$, "locateMappedRange", -function (from, to) { -if (this.map != null) { -if (from <= to) { -from = (this.map.getFromLowest () < from) ? from : this.map.getFromLowest (); -to = (this.map.getFromHighest () > to) ? to : this.map.getFromHighest (); -if (from > to) { -return null; -}} else { -from = (this.map.getFromHighest () > from) ? from : this.map.getFromHighest (); -to = (this.map.getFromLowest () < to) ? to : this.map.getFromLowest (); -if (from < to) { -return null; -}}return this.map.locateInTo (from, to); -}return Clazz.newIntArray (-1, [from, to]); -}, "~N,~N"); -Clazz.defineMethod (c$, "intersectVisContigs", -function (viscontigs) { -var copy = new jalview.datamodel.Mapping (this); -if (this.map != null) { -var vpos = 0; -var apos = 0; -var toRange = new java.util.Vector (); -var fromRange = new java.util.Vector (); -for (var vc = 0; vc < viscontigs.length; vc += 2) { -var mpr = this.locateMappedRange (1 + viscontigs[vc], viscontigs[vc + 1] - 1); -if (mpr != null) { -for (var m = 0; m < mpr.length; m += 2) { -toRange.addElement ( Clazz.newIntArray (-1, [mpr[m], mpr[m + 1]])); -var xpos = this.locateRange (mpr[m], mpr[m + 1]); -for (var x = 0; x < xpos.length; x += 2) { -fromRange.addElement ( Clazz.newIntArray (-1, [xpos[x], xpos[x + 1]])); -} -} -}} -var from = Clazz.newIntArray (fromRange.size () * 2, 0); -var to = Clazz.newIntArray (toRange.size () * 2, 0); -var r; -for (var f = 0, fSize = fromRange.size (); f < fSize; f++) { -r = fromRange.elementAt (f); -from[f * 2] = r[0]; -from[f * 2 + 1] = r[1]; -} -for (var f = 0, fSize = toRange.size (); f < fSize; f++) { -r = toRange.elementAt (f); -to[f * 2] = r[0]; -to[f * 2 + 1] = r[1]; -} -copy.setMap ( new jalview.util.MapList (from, to, this.map.getFromRatio (), this.map.getToRatio ())); -}return copy; -}, "~A"); -Clazz.defineMethod (c$, "getTo", -function () { -return this.to; -}); -Clazz.defineMethod (c$, "setTo", -function (tto) { -this.to = tto; -}, "jalview.datamodel.SequenceI"); -Clazz.defineMethod (c$, "finalize", -function () { -this.map = null; -this.to = null; -Clazz.superCall (this, jalview.datamodel.Mapping, "finalize", []); -}); -Clazz.defineMethod (c$, "getCodonIterator", -function (seq, gapChar) { -return Clazz.innerTypeInstance (jalview.datamodel.Mapping.AlignedCodonIterator, this, null, seq.getSequence (), gapChar); -}, "jalview.datamodel.SequenceI,~S"); -c$.$Mapping$AlignedCodonIterator$ = function () { -Clazz.pu$h (); -c$ = Clazz.decorateAsClass (function () { -Clazz.prepareCallback (this, arguments); -this.gap = '\0'; -this.alignedSeq = null; -this.alignedColumn = 0; -this.alignedBases = 0; -this.fromRanges = null; -this.toRanges = null; -this.currentFromRange = null; -this.currentToRange = null; -this.fromPosition = 0; -this.toPosition = 0; -Clazz.instantialize (this, arguments); -}, jalview.datamodel.Mapping, "AlignedCodonIterator", null, java.util.Iterator); -Clazz.makeConstructor (c$, -function (a, b) { -this.alignedSeq = a; -this.gap = b; -this.fromRanges = this.b$["jalview.datamodel.Mapping"].map.getFromRanges ().iterator (); -this.toRanges = this.b$["jalview.datamodel.Mapping"].map.getToRanges ().iterator (); -if (this.fromRanges.hasNext ()) { -this.currentFromRange = this.fromRanges.next (); -this.fromPosition = this.currentFromRange[0]; -}if (this.toRanges.hasNext ()) { -this.currentToRange = this.toRanges.next (); -this.toPosition = this.currentToRange[0]; -}}, "~A,~S"); -Clazz.defineMethod (c$, "hasNext", -function () { -if (this.fromRanges.hasNext ()) { -return true; -}if (this.currentFromRange == null || this.fromPosition >= this.currentFromRange[1]) { -return false; -}return true; -}); -Clazz.overrideMethod (c$, "next", -function () { -if (!this.hasNext ()) { -throw new java.util.NoSuchElementException (); -}var a = this.getNextCodon (); -var b = this.getAlignedCodon (a); -var c = this.getPeptide (); -return new jalview.datamodel.AlignedCodon (b[0], b[1], b[2], c); -}); -Clazz.defineMethod (c$, "getPeptide", -($fz = function () { -if (this.toPosition <= this.currentToRange[1]) { -var a = this.b$["jalview.datamodel.Mapping"].to.getSequence ()[this.toPosition - 1]; -this.toPosition++; -return String.valueOf (a); -}if (!this.toRanges.hasNext ()) { -throw new java.util.NoSuchElementException ("Ran out of peptide at position " + this.toPosition); -}this.currentToRange = this.toRanges.next (); -this.toPosition = this.currentToRange[0]; -return this.getPeptide (); -}, $fz.isPrivate = true, $fz)); -Clazz.defineMethod (c$, "getNextCodon", -($fz = function () { -var a = Clazz.newIntArray (3, 0); -var b = 0; -while (b < 3) { -if (this.fromPosition <= this.currentFromRange[1]) { -a[b++] = this.fromPosition++; -} else { -if (!this.fromRanges.hasNext ()) { -throw new jalview.datamodel.IncompleteCodonException (); -}this.currentFromRange = this.fromRanges.next (); -this.fromPosition = this.currentFromRange[0]; -}} -return a; -}, $fz.isPrivate = true, $fz)); -Clazz.defineMethod (c$, "getAlignedCodon", -($fz = function (a) { -var b = Clazz.newIntArray (a.length, 0); -for (var c = 0; c < a.length; c++) { -b[c] = this.getAlignedColumn (a[c]); -} -return b; -}, $fz.isPrivate = true, $fz), "~A"); -Clazz.defineMethod (c$, "getAlignedColumn", -($fz = function (a) { -while (this.alignedBases < a && this.alignedColumn < this.alignedSeq.length) { -if (this.alignedSeq[this.alignedColumn++] != this.gap) { -this.alignedBases++; -}} -return this.alignedColumn - 1; -}, $fz.isPrivate = true, $fz), "~N"); -Clazz.overrideMethod (c$, "remove", -function () { -}); -c$ = Clazz.p0p (); -}; -}); +Clazz.declarePackage ("jalview.datamodel"); +Clazz.load (["java.util.Iterator"], "jalview.datamodel.Mapping", ["jalview.datamodel.AlignedCodon", "$.IncompleteCodonException", "$.SequenceFeature", "jalview.util.MapList", "java.util.NoSuchElementException", "$.Vector"], function () { +c$ = Clazz.decorateAsClass (function () { +if (!Clazz.isClassDefined ("jalview.datamodel.Mapping.AlignedCodonIterator")) { +jalview.datamodel.Mapping.$Mapping$AlignedCodonIterator$ (); +} +this.map = null; +this.to = null; +Clazz.instantialize (this, arguments); +}, jalview.datamodel, "Mapping"); +Clazz.makeConstructor (c$, +function (map) { +this.map = map; +}, "jalview.util.MapList"); +Clazz.makeConstructor (c$, +function (to, map) { +this.construct (map); +this.to = to; +}, "jalview.datamodel.SequenceI,jalview.util.MapList"); +Clazz.makeConstructor (c$, +function (to, exon, is, i, j) { +this.construct (to, new jalview.util.MapList (exon, is, i, j)); +}, "jalview.datamodel.SequenceI,~A,~A,~N,~N"); +Clazz.makeConstructor (c$, +function (map2) { +if (map2 !== this && map2 != null) { +if (map2.map != null) { +this.map = new jalview.util.MapList (map2.map); +}this.to = map2.to; +}}, "jalview.datamodel.Mapping"); +Clazz.defineMethod (c$, "getMap", +function () { +return this.map; +}); +Clazz.defineMethod (c$, "setMap", +function (map) { +this.map = map; +}, "jalview.util.MapList"); +Clazz.overrideMethod (c$, "equals", +function (o) { +if (o == null || !(Clazz.instanceOf (o, jalview.datamodel.Mapping))) { +return false; +}var other = o; +if (other === this) { +return true; +}if (other.to !== this.to) { +return false; +}if ((this.map != null && other.map == null) || (this.map == null && other.map != null)) { +return false; +}if ((this.map == null && other.map == null) || this.map.equals (other.map)) { +return true; +}return false; +}, "~O"); +Clazz.defineMethod (c$, "getPosition", +function (mpos) { +if (this.map != null) { +var mp = this.map.shiftTo (mpos); +if (mp != null) { +return mp[0]; +}}return mpos; +}, "~N"); +Clazz.defineMethod (c$, "getWord", +function (mpos) { +if (this.map != null) { +return this.map.getToWord (mpos); +}return null; +}, "~N"); +Clazz.defineMethod (c$, "getWidth", +function () { +if (this.map != null) { +return this.map.getFromRatio (); +}return 1; +}); +Clazz.defineMethod (c$, "getMappedWidth", +function () { +if (this.map != null) { +return this.map.getToRatio (); +}return 1; +}); +Clazz.defineMethod (c$, "getMappedPosition", +function (pos) { +if (this.map != null) { +var mp = this.map.shiftFrom (pos); +if (mp != null) { +return mp[0]; +}}return pos; +}, "~N"); +Clazz.defineMethod (c$, "getMappedWord", +function (pos) { +if (this.map != null) { +var mp = this.map.shiftFrom (pos); +if (mp != null) { +return Clazz.newIntArray (-1, [mp[0], mp[0] + mp[2] * (this.map.getToRatio () - 1)]); +}}return null; +}, "~N"); +Clazz.defineMethod (c$, "locateFeature", +function (f) { +if (true) { +if (this.map != null) { +var frange = this.map.locateInFrom (f.getBegin (), f.getEnd ()); +if (frange == null) { +return null; +}var vf = new Array (Clazz.doubleToInt (frange.length / 2)); +for (var i = 0, v = 0; i < frange.length; i += 2, v++) { +vf[v] = new jalview.datamodel.SequenceFeature (f); +vf[v].setBegin (frange[i]); +vf[v].setEnd (frange[i + 1]); +if (frange.length > 2) { +vf[v].setDescription (f.getDescription () + "\nPart " + (v + 1)); +}} +return vf; +}}if (false) { +var word = this.getWord (f.getBegin ()); +if (word[0] < word[1]) { +f.setBegin (word[0]); +} else { +f.setBegin (word[1]); +}word = this.getWord (f.getEnd ()); +if (word[0] > word[1]) { +f.setEnd (word[0]); +} else { +f.setEnd (word[1]); +}}return Clazz.newArray (-1, [f]); +}, "jalview.datamodel.SequenceFeature"); +Clazz.defineMethod (c$, "locateRange", +function (from, to) { +if (this.map != null) { +if (from <= to) { +from = (this.map.getToLowest () < from) ? from : this.map.getToLowest (); +to = (this.map.getToHighest () > to) ? to : this.map.getToHighest (); +if (from > to) { +return null; +}} else { +from = (this.map.getToHighest () > from) ? from : this.map.getToHighest (); +to = (this.map.getToLowest () < to) ? to : this.map.getToLowest (); +if (from < to) { +return null; +}}return this.map.locateInFrom (from, to); +}return Clazz.newIntArray (-1, [from, to]); +}, "~N,~N"); +Clazz.defineMethod (c$, "locateMappedRange", +function (from, to) { +if (this.map != null) { +if (from <= to) { +from = (this.map.getFromLowest () < from) ? from : this.map.getFromLowest (); +to = (this.map.getFromHighest () > to) ? to : this.map.getFromHighest (); +if (from > to) { +return null; +}} else { +from = (this.map.getFromHighest () > from) ? from : this.map.getFromHighest (); +to = (this.map.getFromLowest () < to) ? to : this.map.getFromLowest (); +if (from < to) { +return null; +}}return this.map.locateInTo (from, to); +}return Clazz.newIntArray (-1, [from, to]); +}, "~N,~N"); +Clazz.defineMethod (c$, "intersectVisContigs", +function (viscontigs) { +var copy = new jalview.datamodel.Mapping (this); +if (this.map != null) { +var vpos = 0; +var apos = 0; +var toRange = new java.util.Vector (); +var fromRange = new java.util.Vector (); +for (var vc = 0; vc < viscontigs.length; vc += 2) { +var mpr = this.locateMappedRange (1 + viscontigs[vc], viscontigs[vc + 1] - 1); +if (mpr != null) { +for (var m = 0; m < mpr.length; m += 2) { +toRange.addElement ( Clazz.newIntArray (-1, [mpr[m], mpr[m + 1]])); +var xpos = this.locateRange (mpr[m], mpr[m + 1]); +for (var x = 0; x < xpos.length; x += 2) { +fromRange.addElement ( Clazz.newIntArray (-1, [xpos[x], xpos[x + 1]])); +} +} +}} +var from = Clazz.newIntArray (fromRange.size () * 2, 0); +var to = Clazz.newIntArray (toRange.size () * 2, 0); +var r; +for (var f = 0, fSize = fromRange.size (); f < fSize; f++) { +r = fromRange.elementAt (f); +from[f * 2] = r[0]; +from[f * 2 + 1] = r[1]; +} +for (var f = 0, fSize = toRange.size (); f < fSize; f++) { +r = toRange.elementAt (f); +to[f * 2] = r[0]; +to[f * 2 + 1] = r[1]; +} +copy.setMap ( new jalview.util.MapList (from, to, this.map.getFromRatio (), this.map.getToRatio ())); +}return copy; +}, "~A"); +Clazz.defineMethod (c$, "getTo", +function () { +return this.to; +}); +Clazz.defineMethod (c$, "setTo", +function (tto) { +this.to = tto; +}, "jalview.datamodel.SequenceI"); +Clazz.defineMethod (c$, "finalize", +function () { +this.map = null; +this.to = null; +Clazz.superCall (this, jalview.datamodel.Mapping, "finalize", []); +}); +Clazz.defineMethod (c$, "getCodonIterator", +function (seq, gapChar) { +return Clazz.innerTypeInstance (jalview.datamodel.Mapping.AlignedCodonIterator, this, null, seq.getSequence (), gapChar); +}, "jalview.datamodel.SequenceI,~S"); +c$.$Mapping$AlignedCodonIterator$ = function () { +Clazz.pu$h (); +c$ = Clazz.decorateAsClass (function () { +Clazz.prepareCallback (this, arguments); +this.gap = '\0'; +this.alignedSeq = null; +this.alignedColumn = 0; +this.alignedBases = 0; +this.fromRanges = null; +this.toRanges = null; +this.currentFromRange = null; +this.currentToRange = null; +this.fromPosition = 0; +this.toPosition = 0; +Clazz.instantialize (this, arguments); +}, jalview.datamodel.Mapping, "AlignedCodonIterator", null, java.util.Iterator); +Clazz.makeConstructor (c$, +function (a, b) { +this.alignedSeq = a; +this.gap = b; +this.fromRanges = this.b$["jalview.datamodel.Mapping"].map.getFromRanges ().iterator (); +this.toRanges = this.b$["jalview.datamodel.Mapping"].map.getToRanges ().iterator (); +if (this.fromRanges.hasNext ()) { +this.currentFromRange = this.fromRanges.next (); +this.fromPosition = this.currentFromRange[0]; +}if (this.toRanges.hasNext ()) { +this.currentToRange = this.toRanges.next (); +this.toPosition = this.currentToRange[0]; +}}, "~A,~S"); +Clazz.defineMethod (c$, "hasNext", +function () { +if (this.fromRanges.hasNext ()) { +return true; +}if (this.currentFromRange == null || this.fromPosition >= this.currentFromRange[1]) { +return false; +}return true; +}); +Clazz.overrideMethod (c$, "next", +function () { +if (!this.hasNext ()) { +throw new java.util.NoSuchElementException (); +}var a = this.getNextCodon (); +var b = this.getAlignedCodon (a); +var c = this.getPeptide (); +return new jalview.datamodel.AlignedCodon (b[0], b[1], b[2], c); +}); +Clazz.defineMethod (c$, "getPeptide", +($fz = function () { +if (this.toPosition <= this.currentToRange[1]) { +var a = this.b$["jalview.datamodel.Mapping"].to.getSequence ()[this.toPosition - 1]; +this.toPosition++; +return String.valueOf (a); +}if (!this.toRanges.hasNext ()) { +throw new java.util.NoSuchElementException ("Ran out of peptide at position " + this.toPosition); +}this.currentToRange = this.toRanges.next (); +this.toPosition = this.currentToRange[0]; +return this.getPeptide (); +}, $fz.isPrivate = true, $fz)); +Clazz.defineMethod (c$, "getNextCodon", +($fz = function () { +var a = Clazz.newIntArray (3, 0); +var b = 0; +while (b < 3) { +if (this.fromPosition <= this.currentFromRange[1]) { +a[b++] = this.fromPosition++; +} else { +if (!this.fromRanges.hasNext ()) { +throw new jalview.datamodel.IncompleteCodonException (); +}this.currentFromRange = this.fromRanges.next (); +this.fromPosition = this.currentFromRange[0]; +}} +return a; +}, $fz.isPrivate = true, $fz)); +Clazz.defineMethod (c$, "getAlignedCodon", +($fz = function (a) { +var b = Clazz.newIntArray (a.length, 0); +for (var c = 0; c < a.length; c++) { +b[c] = this.getAlignedColumn (a[c]); +} +return b; +}, $fz.isPrivate = true, $fz), "~A"); +Clazz.defineMethod (c$, "getAlignedColumn", +($fz = function (a) { +while (this.alignedBases < a && this.alignedColumn < this.alignedSeq.length) { +if (this.alignedSeq[this.alignedColumn++] != this.gap) { +this.alignedBases++; +}} +return this.alignedColumn - 1; +}, $fz.isPrivate = true, $fz), "~N"); +Clazz.overrideMethod (c$, "remove", +function () { +}); +c$ = Clazz.p0p (); +}; +});