X-Git-Url: http://source.jalview.org/gitweb/?p=jalviewjs.git;a=blobdiff_plain;f=bin%2Fjalview%2Fanalysis%2FDna.js;h=57c052feb3e0b0e667343dac3f4e310a79b9e420;hp=68086a9dd395f9804dfec6e229e4c5b540ea61f2;hb=7301a2415adab88038b291fc54caeeb3a5a47a44;hpb=6154cb57a6eac3bb1344b8342495f5bb701ee921 diff --git a/bin/jalview/analysis/Dna.js b/bin/jalview/analysis/Dna.js index 68086a9..57c052f 100644 --- a/bin/jalview/analysis/Dna.js +++ b/bin/jalview/analysis/Dna.js @@ -1,327 +1,327 @@ -Clazz.declarePackage ("jalview.analysis"); -Clazz.load (["jalview.analysis.CodonComparator"], "jalview.analysis.Dna", ["jalview.datamodel.AlignedCodon", "$.AlignedCodonFrame", "$.Alignment", "$.AlignmentAnnotation", "$.Annotation", "$.DBRefSource", "$.FeatureProperties", "$.GraphLine", "$.Sequence", "jalview.schemes.ResidueProperties", "jalview.util.Comparison", "$.DBRefUtils", "$.MapList", "$.ShiftList", "java.lang.IllegalStateException", "$.StringBuilder", "java.util.ArrayList", "$.Arrays"], function () { -c$ = Clazz.decorateAsClass (function () { -this.selection = null; -this.seqstring = null; -this.contigs = null; -this.gapChar = '\0'; -this.annotations = null; -this.dnaWidth = 0; -this.dataset = null; -this.aaWidth = 0; -this.alignedCodons = null; -Clazz.instantialize (this, arguments); -}, jalview.analysis, "Dna"); -Clazz.makeConstructor (c$, -function (viewport, visibleContigs) { -this.selection = java.util.Arrays.asList (viewport.getSequenceSelection ()); -this.seqstring = viewport.getViewAsString (true); -this.contigs = visibleContigs; -this.gapChar = viewport.getGapCharacter (); -this.annotations = viewport.getAlignment ().getAlignmentAnnotation (); -this.dnaWidth = viewport.getAlignment ().getWidth (); -this.dataset = viewport.getAlignment ().getDataset (); -}, "jalview.api.AlignViewportI,~A"); -c$.compareCodonPos = Clazz.defineMethod (c$, "compareCodonPos", -function (ac1, ac2) { -return jalview.analysis.Dna.comparator.compare (ac1, ac2); -}, "jalview.datamodel.AlignedCodon,jalview.datamodel.AlignedCodon"); -Clazz.defineMethod (c$, "translateCdna", -function () { -var acf = new jalview.datamodel.AlignedCodonFrame (); -this.alignedCodons = new Array (this.dnaWidth); -var s; -var sSize = this.selection.size (); -var pepseqs = new java.util.ArrayList (); -for (s = 0; s < sSize; s++) { -var newseq = this.translateCodingRegion (this.selection.get (s), this.seqstring[s], acf, pepseqs); -if (newseq != null) { -pepseqs.add (newseq); -var ds = newseq; -if (this.dataset != null) { -while (ds.getDatasetSequence () != null) { -ds = ds.getDatasetSequence (); -} -this.dataset.addSequence (ds); -}}} -var newseqs = pepseqs.toArray ( new Array (pepseqs.size ())); -var al = new jalview.datamodel.Alignment (newseqs); -al.padGaps (); -al.setDataset (this.dataset); -this.translateAlignedAnnotations (al, acf); -al.addCodonFrame (acf); -return al; -}); -c$.canTranslate = Clazz.defineMethod (c$, "canTranslate", -function (selection, viscontigs) { -for (var gd = 0; gd < selection.length; gd++) { -var dna = selection[gd]; -var dnarefs = jalview.util.DBRefUtils.selectRefs (dna.getDBRef (), jalview.datamodel.DBRefSource.DNACODINGDBS); -if (dnarefs != null) { -var mappedrefs = new java.util.ArrayList (); -var refs = dna.getDBRef (); -for (var d = 0; d < refs.length; d++) { -if (refs[d].getMap () != null && refs[d].getMap ().getMap () != null && refs[d].getMap ().getMap ().getFromRatio () == 3 && refs[d].getMap ().getMap ().getToRatio () == 1) { -mappedrefs.add (refs[d]); -}} -dnarefs = mappedrefs.toArray ( new Array (mappedrefs.size ())); -for (var d = 0; d < dnarefs.length; d++) { -var mp = dnarefs[d].getMap (); -if (mp != null) { -for (var vc = 0; vc < viscontigs.length; vc += 2) { -var mpr = mp.locateMappedRange (viscontigs[vc], viscontigs[vc + 1]); -if (mpr != null) { -return true; -}} -}} -}} -return false; -}, "~A,~A"); -Clazz.defineMethod (c$, "translateAlignedAnnotations", -function (al, acf) { -if (this.annotations != null) { -for (var annotation, $annotation = 0, $$annotation = this.annotations; $annotation < $$annotation.length && ((annotation = $$annotation[$annotation]) || true); $annotation++) { -if (annotation.autoCalculated || !annotation.visible || annotation.isRNA ()) { -continue; -}var aSize = this.aaWidth; -var anots = (annotation.annotations == null) ? null : new Array (aSize); -if (anots != null) { -for (var a = 0; a < aSize; a++) { -if (a < this.alignedCodons.length && this.alignedCodons[a] != null && this.alignedCodons[a].pos1 == (this.alignedCodons[a].pos3 - 2)) { -anots[a] = jalview.analysis.Dna.getCodonAnnotation (this.alignedCodons[a], annotation.annotations); -}} -}var aa = new jalview.datamodel.AlignmentAnnotation (annotation.label, annotation.description, anots); -aa.graph = annotation.graph; -aa.graphGroup = annotation.graphGroup; -aa.graphHeight = annotation.graphHeight; -if (annotation.getThreshold () != null) { -aa.setThreshold ( new jalview.datamodel.GraphLine (annotation.getThreshold ())); -}if (annotation.$hasScore) { -aa.setScore (annotation.getScore ()); -}var seqRef = annotation.sequenceRef; -if (seqRef != null) { -var aaSeq = acf.getAaForDnaSeq (seqRef); -if (aaSeq != null) { -aa.setSequenceRef (aaSeq); -aa.createSequenceMapping (aaSeq, aaSeq.getStart (), true); -aa.adjustForAlignment (); -aaSeq.addAlignmentAnnotation (aa); -}}al.addAnnotation (aa); -} -}}, "jalview.datamodel.AlignmentI,jalview.datamodel.AlignedCodonFrame"); -c$.getCodonAnnotation = Clazz.defineMethod (c$, "getCodonAnnotation", -($fz = function (is, annotations) { -var contrib = 0; -var annot = null; -for (var p = 1; p <= 3; p++) { -var dnaCol = is.getBaseColumn (p); -if (annotations[dnaCol] != null) { -if (annot == null) { -annot = new jalview.datamodel.Annotation (annotations[dnaCol]); -contrib = 1; -} else { -var cpy = new jalview.datamodel.Annotation (annotations[dnaCol]); -if (annot.colour == null) { -annot.colour = cpy.colour; -}if (annot.description == null || annot.description.length == 0) { -annot.description = cpy.description; -}if (annot.displayCharacter == null) { -annot.displayCharacter = cpy.displayCharacter; -}if (annot.secondaryStructure.charCodeAt (0) == 0) { -annot.secondaryStructure = cpy.secondaryStructure; -}annot.value += cpy.value; -contrib++; -}}} -if (contrib > 1) { -annot.value /= contrib; -}return annot; -}, $fz.isPrivate = true, $fz), "jalview.datamodel.AlignedCodon,~A"); -Clazz.defineMethod (c$, "translateCodingRegion", -function (selection, seqstring, acf, proteinSeqs) { -var skip = new java.util.ArrayList (); -var skipint = null; -var vismapping = new jalview.util.ShiftList (); -var vc; -var scontigs = Clazz.newIntArray (this.contigs.length, 0); -var npos = 0; -for (vc = 0; vc < this.contigs.length; vc += 2) { -if (vc == 0) { -vismapping.addShift (npos, this.contigs[vc]); -} else { -vismapping.addShift (npos, this.contigs[vc] - this.contigs[vc - 1] + 1); -}scontigs[vc] = this.contigs[vc]; -scontigs[vc + 1] = this.contigs[vc + 1]; -} -var protein = new StringBuilder (Clazz.doubleToInt (seqstring.length / 2)); -var seq = seqstring.$replace ('U', 'T').$replace ('u', 'T'); -var codon = Clazz.newCharArray (3, '\0'); -var cdp = Clazz.newIntArray (3, 0); -var rf = 0; -var lastnpos = 0; -var nend; -var aspos = 0; -var resSize = 0; -for (npos = 0, nend = seq.length; npos < nend; npos++) { -if (!jalview.util.Comparison.isGap (seq.charAt (npos))) { -cdp[rf] = npos; -codon[rf++] = seq.charAt (npos); -}if (rf == 3) { -var alignedCodon = new jalview.datamodel.AlignedCodon (cdp[0], cdp[1], cdp[2]); -var aa = jalview.schemes.ResidueProperties.codonTranslate ( String.instantialize (codon)); -rf = 0; -var gapString = String.valueOf (this.gapChar); -if (aa == null) { -aa = gapString; -if (skipint == null) { -skipint = Clazz.newIntArray (-1, [alignedCodon.pos1, alignedCodon.pos3]); -}skipint[1] = alignedCodon.pos3; -} else { -if (skipint != null) { -skipint[0] = vismapping.shift (skipint[0]); -skipint[1] = vismapping.shift (skipint[1]); -for (vc = 0; vc < scontigs.length; ) { -if (scontigs[vc + 1] < skipint[0]) { -vc += 2; -continue; -}if (scontigs[vc] > skipint[1]) { -break; -}var t; -if (scontigs[vc] <= skipint[0]) { -if (skipint[0] == scontigs[vc]) { -if (scontigs[vc + 1] > skipint[1]) { -scontigs[vc] = skipint[1]; -vc += 2; -} else { -if (scontigs[vc + 1] == skipint[1]) { -t = Clazz.newIntArray (scontigs.length - 2, 0); -if (vc > 0) { -System.arraycopy (scontigs, 0, t, 0, vc - 1); -}if (vc + 2 < t.length) { -System.arraycopy (scontigs, vc + 2, t, vc, t.length - vc + 2); -}scontigs = t; -} else { -scontigs[vc + 1] = skipint[0] - 1; -vc += 2; -}}} else { -if (scontigs[vc + 1] < skipint[1]) { -scontigs[vc + 1] = skipint[0] - 1; -vc += 2; -} else { -t = Clazz.newIntArray (scontigs.length + 2, 0); -System.arraycopy (scontigs, 0, t, 0, vc + 1); -t[vc + 1] = skipint[0]; -t[vc + 2] = skipint[1]; -System.arraycopy (scontigs, vc + 1, t, vc + 3, scontigs.length - (vc + 1)); -scontigs = t; -vc += 4; -}}}} -skip.add (skipint); -skipint = null; -}if (aa.equals ("STOP")) { -aa = "X"; -}resSize++; -}var findpos = true; -while (findpos) { -var compareCodonPos = jalview.analysis.Dna.compareCodonPos (alignedCodon, this.alignedCodons[aspos]); -switch (compareCodonPos) { -case -1: -this.insertAAGap (aspos, proteinSeqs); -findpos = false; -break; -case 1: -aa = gapString + aa; -aspos++; -break; -case 0: -findpos = false; -} -} -protein.append (aa); -lastnpos = npos; -if (this.alignedCodons[aspos] == null) { -this.alignedCodons[aspos] = alignedCodon; -} else if (!this.alignedCodons[aspos].equals (alignedCodon)) { -throw new IllegalStateException ("Tried to coalign " + this.alignedCodons[aspos].toString () + " with " + alignedCodon.toString ()); -}if (aspos >= this.aaWidth) { -this.aaWidth = aspos; -}aspos++; -}} -if (resSize > 0) { -var newseq = new jalview.datamodel.Sequence (selection.getName (), protein.toString ()); -if (rf != 0) { -var errMsg = "trimming contigs for incomplete terminal codon."; -System.err.println ("trimming contigs for incomplete terminal codon."); -vc = scontigs.length - 1; -lastnpos = vismapping.shift (lastnpos); -while (vc >= 0 && scontigs[vc] > lastnpos) { -if (vc > 0 && scontigs[vc - 1] > lastnpos) { -vc -= 2; -} else { -scontigs[vc] = lastnpos; -}} -if (vc > 0 && (vc + 1) < scontigs.length) { -var t = Clazz.newIntArray (vc + 1, 0); -System.arraycopy (scontigs, 0, t, 0, vc + 1); -scontigs = t; -}if (vc <= 0) { -scontigs = null; -}}if (scontigs != null) { -npos = 0; -for (vc = 0; vc < scontigs.length; vc += 2) { -scontigs[vc] = selection.findPosition (scontigs[vc]); -scontigs[vc + 1] = selection.findPosition (scontigs[vc + 1]); -if (scontigs[vc + 1] == selection.getEnd ()) { -break; -}} -if ((vc + 2) < scontigs.length) { -var t = Clazz.newIntArray (vc + 2, 0); -System.arraycopy (scontigs, 0, t, 0, vc + 2); -scontigs = t; -}var map = new jalview.util.MapList (scontigs, Clazz.newIntArray (-1, [1, resSize]), 3, 1); -jalview.analysis.Dna.transferCodedFeatures (selection, newseq, map, null, null); -var rseq = newseq.deriveSequence (); -acf.addMap (selection, rseq, map); -return rseq; -}}return null; -}, "jalview.datamodel.SequenceI,~S,jalview.datamodel.AlignedCodonFrame,java.util.List"); -Clazz.defineMethod (c$, "insertAAGap", -function (pos, proteinSeqs) { -this.aaWidth++; -for (var seq, $seq = proteinSeqs.iterator (); $seq.hasNext () && ((seq = $seq.next ()) || true);) { -seq.insertCharAt (pos, this.gapChar); -} -this.checkCodonFrameWidth (); -if (pos < this.aaWidth) { -this.aaWidth++; -System.arraycopy (this.alignedCodons, pos, this.alignedCodons, pos + 1, this.alignedCodons.length - pos - 1); -this.alignedCodons[pos] = null; -}}, "~N,java.util.List"); -Clazz.defineMethod (c$, "checkCodonFrameWidth", -function () { -if (this.alignedCodons[this.alignedCodons.length - 1] != null) { -var c = new Array (this.alignedCodons.length + 10); -System.arraycopy (this.alignedCodons, 0, c, 0, this.alignedCodons.length); -this.alignedCodons = c; -}}); -c$.transferCodedFeatures = Clazz.defineMethod (c$, "transferCodedFeatures", -($fz = function (dna, pep, map, featureTypes, featureGroups) { -var sfs = dna.getSequenceFeatures (); -var fgstate; -var dnarefs = jalview.util.DBRefUtils.selectRefs (dna.getDBRef (), jalview.datamodel.DBRefSource.DNACODINGDBS); -if (dnarefs != null) { -for (var d = 0; d < dnarefs.length; d++) { -var mp = dnarefs[d].getMap (); -if (mp != null) { -}} -}if (sfs != null) { -for (var sf, $sf = 0, $$sf = sfs; $sf < $$sf.length && ((sf = $$sf[$sf]) || true); $sf++) { -fgstate = (featureGroups == null) ? null : featureGroups.get (sf.featureGroup); -if ((featureTypes == null || featureTypes.containsKey (sf.getType ())) && (fgstate == null || fgstate.booleanValue ())) { -if (jalview.datamodel.FeatureProperties.isCodingFeature (null, sf.getType ())) { -{ -}}}} -}}, $fz.isPrivate = true, $fz), "jalview.datamodel.SequenceI,jalview.datamodel.SequenceI,jalview.util.MapList,java.util.Map,java.util.Map"); -Clazz.defineStatics (c$, -"STOP_X", "X"); -c$.comparator = c$.prototype.comparator = new jalview.analysis.CodonComparator (); -}); +Clazz.declarePackage ("jalview.analysis"); +Clazz.load (["jalview.analysis.CodonComparator"], "jalview.analysis.Dna", ["jalview.datamodel.AlignedCodon", "$.AlignedCodonFrame", "$.Alignment", "$.AlignmentAnnotation", "$.Annotation", "$.DBRefSource", "$.FeatureProperties", "$.GraphLine", "$.Sequence", "jalview.schemes.ResidueProperties", "jalview.util.Comparison", "$.DBRefUtils", "$.MapList", "$.ShiftList", "java.lang.IllegalStateException", "$.StringBuilder", "java.util.ArrayList", "$.Arrays"], function () { +c$ = Clazz.decorateAsClass (function () { +this.selection = null; +this.seqstring = null; +this.contigs = null; +this.gapChar = '\0'; +this.annotations = null; +this.dnaWidth = 0; +this.dataset = null; +this.aaWidth = 0; +this.alignedCodons = null; +Clazz.instantialize (this, arguments); +}, jalview.analysis, "Dna"); +Clazz.makeConstructor (c$, +function (viewport, visibleContigs) { +this.selection = java.util.Arrays.asList (viewport.getSequenceSelection ()); +this.seqstring = viewport.getViewAsString (true); +this.contigs = visibleContigs; +this.gapChar = viewport.getGapCharacter (); +this.annotations = viewport.getAlignment ().getAlignmentAnnotation (); +this.dnaWidth = viewport.getAlignment ().getWidth (); +this.dataset = viewport.getAlignment ().getDataset (); +}, "jalview.api.AlignViewportI,~A"); +c$.compareCodonPos = Clazz.defineMethod (c$, "compareCodonPos", +function (ac1, ac2) { +return jalview.analysis.Dna.comparator.compare (ac1, ac2); +}, "jalview.datamodel.AlignedCodon,jalview.datamodel.AlignedCodon"); +Clazz.defineMethod (c$, "translateCdna", +function () { +var acf = new jalview.datamodel.AlignedCodonFrame (); +this.alignedCodons = new Array (this.dnaWidth); +var s; +var sSize = this.selection.size (); +var pepseqs = new java.util.ArrayList (); +for (s = 0; s < sSize; s++) { +var newseq = this.translateCodingRegion (this.selection.get (s), this.seqstring[s], acf, pepseqs); +if (newseq != null) { +pepseqs.add (newseq); +var ds = newseq; +if (this.dataset != null) { +while (ds.getDatasetSequence () != null) { +ds = ds.getDatasetSequence (); +} +this.dataset.addSequence (ds); +}}} +var newseqs = pepseqs.toArray ( new Array (pepseqs.size ())); +var al = new jalview.datamodel.Alignment (newseqs); +al.padGaps (); +al.setDataset (this.dataset); +this.translateAlignedAnnotations (al, acf); +al.addCodonFrame (acf); +return al; +}); +c$.canTranslate = Clazz.defineMethod (c$, "canTranslate", +function (selection, viscontigs) { +for (var gd = 0; gd < selection.length; gd++) { +var dna = selection[gd]; +var dnarefs = jalview.util.DBRefUtils.selectRefs (dna.getDBRef (), jalview.datamodel.DBRefSource.DNACODINGDBS); +if (dnarefs != null) { +var mappedrefs = new java.util.ArrayList (); +var refs = dna.getDBRef (); +for (var d = 0; d < refs.length; d++) { +if (refs[d].getMap () != null && refs[d].getMap ().getMap () != null && refs[d].getMap ().getMap ().getFromRatio () == 3 && refs[d].getMap ().getMap ().getToRatio () == 1) { +mappedrefs.add (refs[d]); +}} +dnarefs = mappedrefs.toArray ( new Array (mappedrefs.size ())); +for (var d = 0; d < dnarefs.length; d++) { +var mp = dnarefs[d].getMap (); +if (mp != null) { +for (var vc = 0; vc < viscontigs.length; vc += 2) { +var mpr = mp.locateMappedRange (viscontigs[vc], viscontigs[vc + 1]); +if (mpr != null) { +return true; +}} +}} +}} +return false; +}, "~A,~A"); +Clazz.defineMethod (c$, "translateAlignedAnnotations", +function (al, acf) { +if (this.annotations != null) { +for (var annotation, $annotation = 0, $$annotation = this.annotations; $annotation < $$annotation.length && ((annotation = $$annotation[$annotation]) || true); $annotation++) { +if (annotation.autoCalculated || !annotation.visible || annotation.isRNA ()) { +continue; +}var aSize = this.aaWidth; +var anots = (annotation.annotations == null) ? null : new Array (aSize); +if (anots != null) { +for (var a = 0; a < aSize; a++) { +if (a < this.alignedCodons.length && this.alignedCodons[a] != null && this.alignedCodons[a].pos1 == (this.alignedCodons[a].pos3 - 2)) { +anots[a] = jalview.analysis.Dna.getCodonAnnotation (this.alignedCodons[a], annotation.annotations); +}} +}var aa = new jalview.datamodel.AlignmentAnnotation (annotation.label, annotation.description, anots); +aa.graph = annotation.graph; +aa.graphGroup = annotation.graphGroup; +aa.graphHeight = annotation.graphHeight; +if (annotation.getThreshold () != null) { +aa.setThreshold ( new jalview.datamodel.GraphLine (annotation.getThreshold ())); +}if (annotation.$hasScore) { +aa.setScore (annotation.getScore ()); +}var seqRef = annotation.sequenceRef; +if (seqRef != null) { +var aaSeq = acf.getAaForDnaSeq (seqRef); +if (aaSeq != null) { +aa.setSequenceRef (aaSeq); +aa.createSequenceMapping (aaSeq, aaSeq.getStart (), true); +aa.adjustForAlignment (); +aaSeq.addAlignmentAnnotation (aa); +}}al.addAnnotation (aa); +} +}}, "jalview.datamodel.AlignmentI,jalview.datamodel.AlignedCodonFrame"); +c$.getCodonAnnotation = Clazz.defineMethod (c$, "getCodonAnnotation", +($fz = function (is, annotations) { +var contrib = 0; +var annot = null; +for (var p = 1; p <= 3; p++) { +var dnaCol = is.getBaseColumn (p); +if (annotations[dnaCol] != null) { +if (annot == null) { +annot = new jalview.datamodel.Annotation (annotations[dnaCol]); +contrib = 1; +} else { +var cpy = new jalview.datamodel.Annotation (annotations[dnaCol]); +if (annot.colour == null) { +annot.colour = cpy.colour; +}if (annot.description == null || annot.description.length == 0) { +annot.description = cpy.description; +}if (annot.displayCharacter == null) { +annot.displayCharacter = cpy.displayCharacter; +}if (annot.secondaryStructure.charCodeAt (0) == 0) { +annot.secondaryStructure = cpy.secondaryStructure; +}annot.value += cpy.value; +contrib++; +}}} +if (contrib > 1) { +annot.value /= contrib; +}return annot; +}, $fz.isPrivate = true, $fz), "jalview.datamodel.AlignedCodon,~A"); +Clazz.defineMethod (c$, "translateCodingRegion", +function (selection, seqstring, acf, proteinSeqs) { +var skip = new java.util.ArrayList (); +var skipint = null; +var vismapping = new jalview.util.ShiftList (); +var vc; +var scontigs = Clazz.newIntArray (this.contigs.length, 0); +var npos = 0; +for (vc = 0; vc < this.contigs.length; vc += 2) { +if (vc == 0) { +vismapping.addShift (npos, this.contigs[vc]); +} else { +vismapping.addShift (npos, this.contigs[vc] - this.contigs[vc - 1] + 1); +}scontigs[vc] = this.contigs[vc]; +scontigs[vc + 1] = this.contigs[vc + 1]; +} +var protein = new StringBuilder (Clazz.doubleToInt (seqstring.length / 2)); +var seq = seqstring.$replace ('U', 'T').$replace ('u', 'T'); +var codon = Clazz.newCharArray (3, '\0'); +var cdp = Clazz.newIntArray (3, 0); +var rf = 0; +var lastnpos = 0; +var nend; +var aspos = 0; +var resSize = 0; +for (npos = 0, nend = seq.length; npos < nend; npos++) { +if (!jalview.util.Comparison.isGap (seq.charAt (npos))) { +cdp[rf] = npos; +codon[rf++] = seq.charAt (npos); +}if (rf == 3) { +var alignedCodon = new jalview.datamodel.AlignedCodon (cdp[0], cdp[1], cdp[2]); +var aa = jalview.schemes.ResidueProperties.codonTranslate ( String.instantialize (codon)); +rf = 0; +var gapString = String.valueOf (this.gapChar); +if (aa == null) { +aa = gapString; +if (skipint == null) { +skipint = Clazz.newIntArray (-1, [alignedCodon.pos1, alignedCodon.pos3]); +}skipint[1] = alignedCodon.pos3; +} else { +if (skipint != null) { +skipint[0] = vismapping.shift (skipint[0]); +skipint[1] = vismapping.shift (skipint[1]); +for (vc = 0; vc < scontigs.length; ) { +if (scontigs[vc + 1] < skipint[0]) { +vc += 2; +continue; +}if (scontigs[vc] > skipint[1]) { +break; +}var t; +if (scontigs[vc] <= skipint[0]) { +if (skipint[0] == scontigs[vc]) { +if (scontigs[vc + 1] > skipint[1]) { +scontigs[vc] = skipint[1]; +vc += 2; +} else { +if (scontigs[vc + 1] == skipint[1]) { +t = Clazz.newIntArray (scontigs.length - 2, 0); +if (vc > 0) { +System.arraycopy (scontigs, 0, t, 0, vc - 1); +}if (vc + 2 < t.length) { +System.arraycopy (scontigs, vc + 2, t, vc, t.length - vc + 2); +}scontigs = t; +} else { +scontigs[vc + 1] = skipint[0] - 1; +vc += 2; +}}} else { +if (scontigs[vc + 1] < skipint[1]) { +scontigs[vc + 1] = skipint[0] - 1; +vc += 2; +} else { +t = Clazz.newIntArray (scontigs.length + 2, 0); +System.arraycopy (scontigs, 0, t, 0, vc + 1); +t[vc + 1] = skipint[0]; +t[vc + 2] = skipint[1]; +System.arraycopy (scontigs, vc + 1, t, vc + 3, scontigs.length - (vc + 1)); +scontigs = t; +vc += 4; +}}}} +skip.add (skipint); +skipint = null; +}if (aa.equals ("STOP")) { +aa = "X"; +}resSize++; +}var findpos = true; +while (findpos) { +var compareCodonPos = jalview.analysis.Dna.compareCodonPos (alignedCodon, this.alignedCodons[aspos]); +switch (compareCodonPos) { +case -1: +this.insertAAGap (aspos, proteinSeqs); +findpos = false; +break; +case 1: +aa = gapString + aa; +aspos++; +break; +case 0: +findpos = false; +} +} +protein.append (aa); +lastnpos = npos; +if (this.alignedCodons[aspos] == null) { +this.alignedCodons[aspos] = alignedCodon; +} else if (!this.alignedCodons[aspos].equals (alignedCodon)) { +throw new IllegalStateException ("Tried to coalign " + this.alignedCodons[aspos].toString () + " with " + alignedCodon.toString ()); +}if (aspos >= this.aaWidth) { +this.aaWidth = aspos; +}aspos++; +}} +if (resSize > 0) { +var newseq = new jalview.datamodel.Sequence (selection.getName (), protein.toString ()); +if (rf != 0) { +var errMsg = "trimming contigs for incomplete terminal codon."; +System.err.println ("trimming contigs for incomplete terminal codon."); +vc = scontigs.length - 1; +lastnpos = vismapping.shift (lastnpos); +while (vc >= 0 && scontigs[vc] > lastnpos) { +if (vc > 0 && scontigs[vc - 1] > lastnpos) { +vc -= 2; +} else { +scontigs[vc] = lastnpos; +}} +if (vc > 0 && (vc + 1) < scontigs.length) { +var t = Clazz.newIntArray (vc + 1, 0); +System.arraycopy (scontigs, 0, t, 0, vc + 1); +scontigs = t; +}if (vc <= 0) { +scontigs = null; +}}if (scontigs != null) { +npos = 0; +for (vc = 0; vc < scontigs.length; vc += 2) { +scontigs[vc] = selection.findPosition (scontigs[vc]); +scontigs[vc + 1] = selection.findPosition (scontigs[vc + 1]); +if (scontigs[vc + 1] == selection.getEnd ()) { +break; +}} +if ((vc + 2) < scontigs.length) { +var t = Clazz.newIntArray (vc + 2, 0); +System.arraycopy (scontigs, 0, t, 0, vc + 2); +scontigs = t; +}var map = new jalview.util.MapList (scontigs, Clazz.newIntArray (-1, [1, resSize]), 3, 1); +jalview.analysis.Dna.transferCodedFeatures (selection, newseq, map, null, null); +var rseq = newseq.deriveSequence (); +acf.addMap (selection, rseq, map); +return rseq; +}}return null; +}, "jalview.datamodel.SequenceI,~S,jalview.datamodel.AlignedCodonFrame,java.util.List"); +Clazz.defineMethod (c$, "insertAAGap", +function (pos, proteinSeqs) { +this.aaWidth++; +for (var seq, $seq = proteinSeqs.iterator (); $seq.hasNext () && ((seq = $seq.next ()) || true);) { +seq.insertCharAt (pos, this.gapChar); +} +this.checkCodonFrameWidth (); +if (pos < this.aaWidth) { +this.aaWidth++; +System.arraycopy (this.alignedCodons, pos, this.alignedCodons, pos + 1, this.alignedCodons.length - pos - 1); +this.alignedCodons[pos] = null; +}}, "~N,java.util.List"); +Clazz.defineMethod (c$, "checkCodonFrameWidth", +function () { +if (this.alignedCodons[this.alignedCodons.length - 1] != null) { +var c = new Array (this.alignedCodons.length + 10); +System.arraycopy (this.alignedCodons, 0, c, 0, this.alignedCodons.length); +this.alignedCodons = c; +}}); +c$.transferCodedFeatures = Clazz.defineMethod (c$, "transferCodedFeatures", +($fz = function (dna, pep, map, featureTypes, featureGroups) { +var sfs = dna.getSequenceFeatures (); +var fgstate; +var dnarefs = jalview.util.DBRefUtils.selectRefs (dna.getDBRef (), jalview.datamodel.DBRefSource.DNACODINGDBS); +if (dnarefs != null) { +for (var d = 0; d < dnarefs.length; d++) { +var mp = dnarefs[d].getMap (); +if (mp != null) { +}} +}if (sfs != null) { +for (var sf, $sf = 0, $$sf = sfs; $sf < $$sf.length && ((sf = $$sf[$sf]) || true); $sf++) { +fgstate = (featureGroups == null) ? null : featureGroups.get (sf.featureGroup); +if ((featureTypes == null || featureTypes.containsKey (sf.getType ())) && (fgstate == null || fgstate.booleanValue ())) { +if (jalview.datamodel.FeatureProperties.isCodingFeature (null, sf.getType ())) { +{ +}}}} +}}, $fz.isPrivate = true, $fz), "jalview.datamodel.SequenceI,jalview.datamodel.SequenceI,jalview.util.MapList,java.util.Map,java.util.Map"); +Clazz.defineStatics (c$, +"STOP_X", "X"); +c$.comparator = c$.prototype.comparator = new jalview.analysis.CodonComparator (); +});