X-Git-Url: http://source.jalview.org/gitweb/?p=jalviewjs.git;a=blobdiff_plain;f=bin%2Fjalview%2Fdatamodel%2FAlignedCodonFrame.js;h=043b032895a36b87fca9cc25a9a575dbf45d37d1;hp=8d854b47cdb6e4323538e047e11e6c8938aa67df;hb=8ffd05b3abe52c0b6b79b011c0966361f82d5fe6;hpb=6154cb57a6eac3bb1344b8342495f5bb701ee921 diff --git a/bin/jalview/datamodel/AlignedCodonFrame.js b/bin/jalview/datamodel/AlignedCodonFrame.js index 8d854b4..043b032 100644 --- a/bin/jalview/datamodel/AlignedCodonFrame.js +++ b/bin/jalview/datamodel/AlignedCodonFrame.js @@ -1,198 +1,198 @@ -Clazz.declarePackage ("jalview.datamodel"); -Clazz.load (null, "jalview.datamodel.AlignedCodonFrame", ["jalview.datamodel.Mapping", "jalview.util.MappingUtils", "java.util.ArrayList"], function () { -c$ = Clazz.decorateAsClass (function () { -this.dnaSeqs = null; -this.dnaToProt = null; -Clazz.instantialize (this, arguments); -}, jalview.datamodel, "AlignedCodonFrame"); -Clazz.makeConstructor (c$, -function () { -}); -Clazz.defineMethod (c$, "addMap", -function (dnaseq, aaseq, map) { -var nlen = 1; -if (this.dnaSeqs != null) { -nlen = this.dnaSeqs.length + 1; -}var ndna = new Array (nlen); -var ndtp = new Array (nlen); -if (this.dnaSeqs != null) { -System.arraycopy (this.dnaSeqs, 0, ndna, 0, this.dnaSeqs.length); -System.arraycopy (this.dnaToProt, 0, ndtp, 0, this.dnaSeqs.length); -}this.dnaSeqs = ndna; -this.dnaToProt = ndtp; -nlen--; -this.dnaSeqs[nlen] = (dnaseq.getDatasetSequence () == null) ? dnaseq : dnaseq.getDatasetSequence (); -var mp = new jalview.datamodel.Mapping (map); -mp.to = (aaseq.getDatasetSequence () == null) ? aaseq : aaseq.getDatasetSequence (); -this.dnaToProt[nlen] = mp; -}, "jalview.datamodel.SequenceI,jalview.datamodel.SequenceI,jalview.util.MapList"); -Clazz.defineMethod (c$, "getdnaSeqs", -function () { -return this.dnaSeqs; -}); -Clazz.defineMethod (c$, "getAaSeqs", -function () { -if (this.dnaToProt == null) { -return null; -}var sqs = new Array (this.dnaToProt.length); -for (var sz = 0; sz < this.dnaToProt.length; sz++) { -sqs[sz] = this.dnaToProt[sz].to; -} -return sqs; -}); -Clazz.defineMethod (c$, "getdnaToProt", -function () { -if (this.dnaToProt == null) { -return null; -}var sqs = new Array (this.dnaToProt.length); -for (var sz = 0; sz < this.dnaToProt.length; sz++) { -sqs[sz] = this.dnaToProt[sz].map; -} -return sqs; -}); -Clazz.defineMethod (c$, "getProtMappings", -function () { -return this.dnaToProt; -}); -Clazz.defineMethod (c$, "getMappingForSequence", -function (seq) { -if (this.dnaSeqs == null) { -return null; -}var seqDs = seq.getDatasetSequence (); -seqDs = seqDs != null ? seqDs : seq; -for (var ds = 0; ds < this.dnaSeqs.length; ds++) { -if (this.dnaSeqs[ds] === seqDs || this.dnaToProt[ds].to === seqDs) { -return this.dnaToProt[ds]; -}} -return null; -}, "jalview.datamodel.SequenceI"); -Clazz.defineMethod (c$, "getAaForDnaSeq", -function (dnaSeqRef) { -if (this.dnaSeqs == null) { -return null; -}var dnads = dnaSeqRef.getDatasetSequence (); -for (var ds = 0; ds < this.dnaSeqs.length; ds++) { -if (this.dnaSeqs[ds] === dnaSeqRef || this.dnaSeqs[ds] === dnads) { -return this.dnaToProt[ds].to; -}} -return null; -}, "jalview.datamodel.SequenceI"); -Clazz.defineMethod (c$, "getDnaForAaSeq", -function (aaSeqRef) { -if (this.dnaToProt == null) { -return null; -}var aads = aaSeqRef.getDatasetSequence (); -for (var as = 0; as < this.dnaToProt.length; as++) { -if (this.dnaToProt[as].to === aaSeqRef || this.dnaToProt[as].to === aads) { -return this.dnaSeqs[as]; -}} -return null; -}, "jalview.datamodel.SequenceI"); -Clazz.defineMethod (c$, "involvesSequence", -function (seq) { -return this.getAaForDnaSeq (seq) != null || this.getDnaForAaSeq (seq) != null; -}, "jalview.datamodel.SequenceI"); -Clazz.defineMethod (c$, "markMappedRegion", -function (seq, index, results) { -if (this.dnaToProt == null) { -return; -}var codon; -var ds = seq.getDatasetSequence (); -for (var mi = 0; mi < this.dnaToProt.length; mi++) { -if (this.dnaSeqs[mi] === seq || this.dnaSeqs[mi] === ds) { -codon = this.dnaToProt[mi].map.locateInTo (index, index); -if (codon != null) { -for (var i = 0; i < codon.length; i += 2) { -results.addResult (this.dnaToProt[mi].to, codon[i], codon[i + 1]); -} -}} else if (this.dnaToProt[mi].to === seq || this.dnaToProt[mi].to === ds) { -{ -codon = this.dnaToProt[mi].map.locateInFrom (index, index); -if (codon != null) { -for (var i = 0; i < codon.length; i += 2) { -results.addResult (this.dnaSeqs[mi], codon[i], codon[i + 1]); -} -}}}} -}, "jalview.datamodel.SequenceI,~N,jalview.datamodel.SearchResults"); -Clazz.defineMethod (c$, "getDnaPosition", -function (seq, aaPos) { -var ml = null; -for (var i = 0; i < this.dnaToProt.length; i++) { -if (this.dnaSeqs[i] === seq) { -ml = this.getdnaToProt ()[i]; -break; -}} -return ml == null ? null : ml.locateInFrom (aaPos, aaPos); -}, "jalview.datamodel.SequenceI,~N"); -Clazz.defineMethod (c$, "findAlignedSequence", -function (seq, al) { -if (this.dnaToProt != null) { -for (var i = 0; i < this.dnaToProt.length; i++) { -if (this.dnaSeqs[i] === seq) { -for (var sourceAligned, $sourceAligned = al.getSequences ().iterator (); $sourceAligned.hasNext () && ((sourceAligned = $sourceAligned.next ()) || true);) { -if (this.dnaToProt[i].to === sourceAligned.getDatasetSequence ()) { -return sourceAligned; -}} -}} -}if (this.dnaToProt != null) { -for (var i = 0; i < this.dnaToProt.length; i++) { -if (this.dnaToProt[i].to === seq) { -for (var sourceAligned, $sourceAligned = al.getSequences ().iterator (); $sourceAligned.hasNext () && ((sourceAligned = $sourceAligned.next ()) || true);) { -if (this.dnaSeqs[i] === sourceAligned.getDatasetSequence ()) { -return sourceAligned; -}} -}} -}return null; -}, "jalview.datamodel.SequenceI,jalview.datamodel.AlignmentI"); -Clazz.defineMethod (c$, "getMappedRegion", -function (mappedFrom, mappedTo, pos) { -var targetDs = mappedFrom.getDatasetSequence () == null ? mappedFrom : mappedFrom.getDatasetSequence (); -var sourceDs = mappedTo.getDatasetSequence () == null ? mappedTo : mappedTo.getDatasetSequence (); -if (targetDs == null || sourceDs == null || this.dnaToProt == null) { -return null; -}for (var mi = 0; mi < this.dnaToProt.length; mi++) { -if (this.dnaSeqs[mi] === targetDs && this.dnaToProt[mi].to === sourceDs) { -var codon = this.dnaToProt[mi].map.locateInFrom (pos, pos); -if (codon != null) { -return codon; -}}} -return null; -}, "jalview.datamodel.SequenceI,jalview.datamodel.SequenceI,~N"); -Clazz.defineMethod (c$, "getMappedCodon", -function (protein, aaPos) { -if (this.dnaToProt == null) { -return null; -}var ml = null; -var dnaSeq = null; -for (var i = 0; i < this.dnaToProt.length; i++) { -if (this.dnaToProt[i].to === protein) { -ml = this.getdnaToProt ()[i]; -dnaSeq = this.dnaSeqs[i].getSequence (); -break; -}} -if (ml == null) { -return null; -}var codonPos = ml.locateInFrom (aaPos, aaPos); -if (codonPos == null) { -return null; -}codonPos = jalview.util.MappingUtils.flattenRanges (codonPos); -return Clazz.newCharArray (-1, [dnaSeq[codonPos[0] - 1], dnaSeq[codonPos[1] - 1], dnaSeq[codonPos[2] - 1]]); -}, "jalview.datamodel.SequenceI,~N"); -Clazz.defineMethod (c$, "getMappingsForSequence", -function (seq) { -var result = new java.util.ArrayList (); -if (this.dnaSeqs == null) { -return result; -}var related = new java.util.ArrayList (); -var seqDs = seq.getDatasetSequence (); -seqDs = seqDs != null ? seqDs : seq; -for (var ds = 0; ds < this.dnaSeqs.length; ds++) { -var mapping = this.dnaToProt[ds]; -if (this.dnaSeqs[ds] === seqDs || mapping.to === seqDs) { -if (!related.contains (mapping.to)) { -result.add (mapping); -related.add (mapping.to); -}}} -return result; -}, "jalview.datamodel.SequenceI"); -}); +Clazz.declarePackage ("jalview.datamodel"); +Clazz.load (null, "jalview.datamodel.AlignedCodonFrame", ["jalview.datamodel.Mapping", "jalview.util.MappingUtils", "java.util.ArrayList"], function () { +c$ = Clazz.decorateAsClass (function () { +this.dnaSeqs = null; +this.dnaToProt = null; +Clazz.instantialize (this, arguments); +}, jalview.datamodel, "AlignedCodonFrame"); +Clazz.makeConstructor (c$, +function () { +}); +Clazz.defineMethod (c$, "addMap", +function (dnaseq, aaseq, map) { +var nlen = 1; +if (this.dnaSeqs != null) { +nlen = this.dnaSeqs.length + 1; +}var ndna = new Array (nlen); +var ndtp = new Array (nlen); +if (this.dnaSeqs != null) { +System.arraycopy (this.dnaSeqs, 0, ndna, 0, this.dnaSeqs.length); +System.arraycopy (this.dnaToProt, 0, ndtp, 0, this.dnaSeqs.length); +}this.dnaSeqs = ndna; +this.dnaToProt = ndtp; +nlen--; +this.dnaSeqs[nlen] = (dnaseq.getDatasetSequence () == null) ? dnaseq : dnaseq.getDatasetSequence (); +var mp = new jalview.datamodel.Mapping (map); +mp.to = (aaseq.getDatasetSequence () == null) ? aaseq : aaseq.getDatasetSequence (); +this.dnaToProt[nlen] = mp; +}, "jalview.datamodel.SequenceI,jalview.datamodel.SequenceI,jalview.util.MapList"); +Clazz.defineMethod (c$, "getdnaSeqs", +function () { +return this.dnaSeqs; +}); +Clazz.defineMethod (c$, "getAaSeqs", +function () { +if (this.dnaToProt == null) { +return null; +}var sqs = new Array (this.dnaToProt.length); +for (var sz = 0; sz < this.dnaToProt.length; sz++) { +sqs[sz] = this.dnaToProt[sz].to; +} +return sqs; +}); +Clazz.defineMethod (c$, "getdnaToProt", +function () { +if (this.dnaToProt == null) { +return null; +}var sqs = new Array (this.dnaToProt.length); +for (var sz = 0; sz < this.dnaToProt.length; sz++) { +sqs[sz] = this.dnaToProt[sz].map; +} +return sqs; +}); +Clazz.defineMethod (c$, "getProtMappings", +function () { +return this.dnaToProt; +}); +Clazz.defineMethod (c$, "getMappingForSequence", +function (seq) { +if (this.dnaSeqs == null) { +return null; +}var seqDs = seq.getDatasetSequence (); +seqDs = seqDs != null ? seqDs : seq; +for (var ds = 0; ds < this.dnaSeqs.length; ds++) { +if (this.dnaSeqs[ds] === seqDs || this.dnaToProt[ds].to === seqDs) { +return this.dnaToProt[ds]; +}} +return null; +}, "jalview.datamodel.SequenceI"); +Clazz.defineMethod (c$, "getAaForDnaSeq", +function (dnaSeqRef) { +if (this.dnaSeqs == null) { +return null; +}var dnads = dnaSeqRef.getDatasetSequence (); +for (var ds = 0; ds < this.dnaSeqs.length; ds++) { +if (this.dnaSeqs[ds] === dnaSeqRef || this.dnaSeqs[ds] === dnads) { +return this.dnaToProt[ds].to; +}} +return null; +}, "jalview.datamodel.SequenceI"); +Clazz.defineMethod (c$, "getDnaForAaSeq", +function (aaSeqRef) { +if (this.dnaToProt == null) { +return null; +}var aads = aaSeqRef.getDatasetSequence (); +for (var as = 0; as < this.dnaToProt.length; as++) { +if (this.dnaToProt[as].to === aaSeqRef || this.dnaToProt[as].to === aads) { +return this.dnaSeqs[as]; +}} +return null; +}, "jalview.datamodel.SequenceI"); +Clazz.defineMethod (c$, "involvesSequence", +function (seq) { +return this.getAaForDnaSeq (seq) != null || this.getDnaForAaSeq (seq) != null; +}, "jalview.datamodel.SequenceI"); +Clazz.defineMethod (c$, "markMappedRegion", +function (seq, index, results) { +if (this.dnaToProt == null) { +return; +}var codon; +var ds = seq.getDatasetSequence (); +for (var mi = 0; mi < this.dnaToProt.length; mi++) { +if (this.dnaSeqs[mi] === seq || this.dnaSeqs[mi] === ds) { +codon = this.dnaToProt[mi].map.locateInTo (index, index); +if (codon != null) { +for (var i = 0; i < codon.length; i += 2) { +results.addResult (this.dnaToProt[mi].to, codon[i], codon[i + 1]); +} +}} else if (this.dnaToProt[mi].to === seq || this.dnaToProt[mi].to === ds) { +{ +codon = this.dnaToProt[mi].map.locateInFrom (index, index); +if (codon != null) { +for (var i = 0; i < codon.length; i += 2) { +results.addResult (this.dnaSeqs[mi], codon[i], codon[i + 1]); +} +}}}} +}, "jalview.datamodel.SequenceI,~N,jalview.datamodel.SearchResults"); +Clazz.defineMethod (c$, "getDnaPosition", +function (seq, aaPos) { +var ml = null; +for (var i = 0; i < this.dnaToProt.length; i++) { +if (this.dnaSeqs[i] === seq) { +ml = this.getdnaToProt ()[i]; +break; +}} +return ml == null ? null : ml.locateInFrom (aaPos, aaPos); +}, "jalview.datamodel.SequenceI,~N"); +Clazz.defineMethod (c$, "findAlignedSequence", +function (seq, al) { +if (this.dnaToProt != null) { +for (var i = 0; i < this.dnaToProt.length; i++) { +if (this.dnaSeqs[i] === seq) { +for (var sourceAligned, $sourceAligned = al.getSequences ().iterator (); $sourceAligned.hasNext () && ((sourceAligned = $sourceAligned.next ()) || true);) { +if (this.dnaToProt[i].to === sourceAligned.getDatasetSequence ()) { +return sourceAligned; +}} +}} +}if (this.dnaToProt != null) { +for (var i = 0; i < this.dnaToProt.length; i++) { +if (this.dnaToProt[i].to === seq) { +for (var sourceAligned, $sourceAligned = al.getSequences ().iterator (); $sourceAligned.hasNext () && ((sourceAligned = $sourceAligned.next ()) || true);) { +if (this.dnaSeqs[i] === sourceAligned.getDatasetSequence ()) { +return sourceAligned; +}} +}} +}return null; +}, "jalview.datamodel.SequenceI,jalview.datamodel.AlignmentI"); +Clazz.defineMethod (c$, "getMappedRegion", +function (mappedFrom, mappedTo, pos) { +var targetDs = mappedFrom.getDatasetSequence () == null ? mappedFrom : mappedFrom.getDatasetSequence (); +var sourceDs = mappedTo.getDatasetSequence () == null ? mappedTo : mappedTo.getDatasetSequence (); +if (targetDs == null || sourceDs == null || this.dnaToProt == null) { +return null; +}for (var mi = 0; mi < this.dnaToProt.length; mi++) { +if (this.dnaSeqs[mi] === targetDs && this.dnaToProt[mi].to === sourceDs) { +var codon = this.dnaToProt[mi].map.locateInFrom (pos, pos); +if (codon != null) { +return codon; +}}} +return null; +}, "jalview.datamodel.SequenceI,jalview.datamodel.SequenceI,~N"); +Clazz.defineMethod (c$, "getMappedCodon", +function (protein, aaPos) { +if (this.dnaToProt == null) { +return null; +}var ml = null; +var dnaSeq = null; +for (var i = 0; i < this.dnaToProt.length; i++) { +if (this.dnaToProt[i].to === protein) { +ml = this.getdnaToProt ()[i]; +dnaSeq = this.dnaSeqs[i].getSequence (); +break; +}} +if (ml == null) { +return null; +}var codonPos = ml.locateInFrom (aaPos, aaPos); +if (codonPos == null) { +return null; +}codonPos = jalview.util.MappingUtils.flattenRanges (codonPos); +return Clazz.newCharArray (-1, [dnaSeq[codonPos[0] - 1], dnaSeq[codonPos[1] - 1], dnaSeq[codonPos[2] - 1]]); +}, "jalview.datamodel.SequenceI,~N"); +Clazz.defineMethod (c$, "getMappingsForSequence", +function (seq) { +var result = new java.util.ArrayList (); +if (this.dnaSeqs == null) { +return result; +}var related = new java.util.ArrayList (); +var seqDs = seq.getDatasetSequence (); +seqDs = seqDs != null ? seqDs : seq; +for (var ds = 0; ds < this.dnaSeqs.length; ds++) { +var mapping = this.dnaToProt[ds]; +if (this.dnaSeqs[ds] === seqDs || mapping.to === seqDs) { +if (!related.contains (mapping.to)) { +result.add (mapping); +related.add (mapping.to); +}}} +return result; +}, "jalview.datamodel.SequenceI"); +});