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