X-Git-Url: http://source.jalview.org/gitweb/?p=jalviewjs.git;a=blobdiff_plain;f=bin%2Fjalview%2Fdatamodel%2FAlignment.js;h=a4d45eecb48c4c8f842b93086dc14ae0e2a849c8;hp=f70f6ce701360438c95f2a73d8db2d70b06bfcd3;hb=7301a2415adab88038b291fc54caeeb3a5a47a44;hpb=6154cb57a6eac3bb1344b8342495f5bb701ee921 diff --git a/bin/jalview/datamodel/Alignment.js b/bin/jalview/datamodel/Alignment.js index f70f6ce..a4d45ee 100644 --- a/bin/jalview/datamodel/Alignment.js +++ b/bin/jalview/datamodel/Alignment.js @@ -1,815 +1,815 @@ -Clazz.declarePackage ("jalview.datamodel"); -Clazz.load (["jalview.datamodel.AlignmentI", "$.HiddenSequences", "java.util.ArrayList", "$.Collections", "$.LinkedHashSet"], "jalview.datamodel.Alignment", ["jalview.analysis.AlignmentUtils", "jalview.datamodel.AlignmentAnnotation", "$.CigarArray", "$.SeqCigar", "$.Sequence", "jalview.util.Comparison", "$.MessageManager", "java.lang.Error", "java.util.HashSet", "$.Hashtable", "$.Vector"], function () { -c$ = Clazz.decorateAsClass (function () { -this.dataset = null; -this.sequences = null; -this.groups = null; -this.gapCharacter = '-'; -this.type = 1; -this.$hasRNAStructure = false; -this.annotations = null; -this.hiddenSequences = null; -this.alignmentProperties = null; -this.codonFrameList = null; -this.alignmentRefs = 0; -this.seqrep = null; -Clazz.instantialize (this, arguments); -}, jalview.datamodel, "Alignment", null, jalview.datamodel.AlignmentI); -Clazz.prepareFields (c$, function () { -this.groups = java.util.Collections.synchronizedList ( new java.util.ArrayList ()); -this.hiddenSequences = new jalview.datamodel.HiddenSequences (this); -this.codonFrameList = new java.util.LinkedHashSet (); -}); -Clazz.defineMethod (c$, "initAlignment", -($fz = function (seqs) { -var i = 0; -if (jalview.util.Comparison.isNucleotide (seqs)) { -this.type = 1; -} else { -this.type = 0; -}this.sequences = java.util.Collections.synchronizedList ( new java.util.ArrayList ()); -for (i = 0; i < seqs.length; i++) { -this.sequences.add (seqs[i]); -} -}, $fz.isPrivate = true, $fz), "~A"); -Clazz.makeConstructor (c$, -function (al) { -var seqs = al.getSequencesArray (); -for (var i = 0; i < seqs.length; i++) { -seqs[i] = new jalview.datamodel.Sequence (seqs[i]); -} -this.codonFrameList = (al).codonFrameList; -this.initAlignment (seqs); -}, "jalview.datamodel.AlignmentI"); -Clazz.makeConstructor (c$, -function (seqs) { -this.initAlignment (seqs); -}, "~A"); -c$.createAlignment = Clazz.defineMethod (c$, "createAlignment", -function (compactAlignment) { -throw new Error (jalview.util.MessageManager.getString ("error.alignment_cigararray_not_implemented")); -}, "jalview.datamodel.CigarArray"); -Clazz.defineMethod (c$, "getSequences", -function () { -return this.sequences; -}); -Clazz.defineMethod (c$, "getSequences", -function (hiddenReps) { -return this.sequences; -}, "java.util.Map"); -Clazz.defineMethod (c$, "getSequencesArray", -function () { -if (this.sequences == null) { -return null; -}{ -return this.sequences.toArray ( new Array (this.sequences.size ())); -}}); -Clazz.overrideMethod (c$, "getSequencesByName", -function () { -return jalview.analysis.AlignmentUtils.getSequencesByName (this); -}); -Clazz.overrideMethod (c$, "getSequenceAt", -function (i) { -{ -if (i > -1 && i < this.sequences.size ()) { -return this.sequences.get (i); -}}return null; -}, "~N"); -Clazz.overrideMethod (c$, "addSequence", -function (snew) { -if (this.dataset != null) { -if (snew.getDatasetSequence () != null) { -this.getDataset ().addSequence (snew.getDatasetSequence ()); -} else { -var adding = snew.deriveSequence (); -this.getDataset ().addSequence (adding.getDatasetSequence ()); -snew = adding; -}}if (this.sequences == null) { -this.initAlignment ( Clazz.newArray (-1, [snew])); -} else { -{ -this.sequences.add (snew); -}}if (this.hiddenSequences != null) { -this.hiddenSequences.adjustHeightSequenceAdded (); -}}, "jalview.datamodel.SequenceI"); -Clazz.overrideMethod (c$, "setSequenceAt", -function (i, snew) { -{ -this.deleteSequence (i); -this.sequences.set (i, snew); -}}, "~N,jalview.datamodel.SequenceI"); -Clazz.defineMethod (c$, "getGroups", -function () { -return this.groups; -}); -Clazz.overrideMethod (c$, "finalize", -function () { -if (this.getDataset () != null) { -this.getDataset ().removeAlignmentRef (); -}this.dataset = null; -this.sequences = null; -this.groups = null; -this.annotations = null; -this.hiddenSequences = null; -}); -Clazz.defineMethod (c$, "removeAlignmentRef", -($fz = function () { -if (--this.alignmentRefs == 0) { -this.finalize (); -}}, $fz.isPrivate = true, $fz)); -Clazz.defineMethod (c$, "deleteSequence", -function (s) { -this.deleteSequence (this.findIndex (s)); -}, "jalview.datamodel.SequenceI"); -Clazz.defineMethod (c$, "deleteSequence", -function (i) { -if (i > -1 && i < this.getHeight ()) { -{ -this.sequences.remove (i); -this.hiddenSequences.adjustHeightSequenceDeleted (i); -}}}, "~N"); -Clazz.overrideMethod (c$, "findGroup", -function (s) { -{ -for (var i = 0; i < this.groups.size (); i++) { -var sg = this.groups.get (i); -if (sg.getSequences (null).contains (s)) { -return sg; -}} -}return null; -}, "jalview.datamodel.SequenceI"); -Clazz.overrideMethod (c$, "findAllGroups", -function (s) { -var temp = new java.util.ArrayList (); -{ -var gSize = this.groups.size (); -for (var i = 0; i < gSize; i++) { -var sg = this.groups.get (i); -if (sg == null || sg.getSequences () == null) { -this.deleteGroup (sg); -gSize--; -continue; -}if (sg.getSequences ().contains (s)) { -temp.add (sg); -}} -}var ret = new Array (temp.size ()); -return temp.toArray (ret); -}, "jalview.datamodel.SequenceI"); -Clazz.overrideMethod (c$, "addGroup", -function (sg) { -{ -if (!this.groups.contains (sg)) { -if (this.hiddenSequences.getSize () > 0) { -var i; -var iSize = sg.getSize (); -for (i = 0; i < iSize; i++) { -if (!this.sequences.contains (sg.getSequenceAt (i))) { -sg.deleteSequence (sg.getSequenceAt (i), false); -iSize--; -i--; -}} -if (sg.getSize () < 1) { -return; -}}sg.setContext (this); -this.groups.add (sg); -}}}, "jalview.datamodel.SequenceGroup"); -Clazz.defineMethod (c$, "removeAnnotationForGroup", -($fz = function (gp) { -if (this.annotations == null || this.annotations.length == 0) { -return; -}var t; -var todelete = new Array (this.annotations.length); -var tokeep = new Array (this.annotations.length); -var i; -var p; -var k; -if (gp == null) { -for (i = 0, p = 0, k = 0; i < this.annotations.length; i++) { -if (this.annotations[i].groupRef != null) { -todelete[p++] = this.annotations[i]; -} else { -tokeep[k++] = this.annotations[i]; -}} -} else { -for (i = 0, p = 0, k = 0; i < this.annotations.length; i++) { -if (this.annotations[i].groupRef === gp) { -todelete[p++] = this.annotations[i]; -} else { -tokeep[k++] = this.annotations[i]; -}} -}if (p > 0) { -for (i = 0; i < p; i++) { -this.unhookAnnotation (todelete[i]); -todelete[i] = null; -} -t = new Array (k); -for (i = 0; i < k; i++) { -t[i] = tokeep[i]; -} -this.annotations = t; -}}, $fz.isPrivate = true, $fz), "jalview.datamodel.SequenceGroup"); -Clazz.overrideMethod (c$, "deleteAllGroups", -function () { -{ -if (this.annotations != null) { -this.removeAnnotationForGroup (null); -}for (var sg, $sg = this.groups.iterator (); $sg.hasNext () && ((sg = $sg.next ()) || true);) { -sg.setContext (null); -} -this.groups.clear (); -}}); -Clazz.overrideMethod (c$, "deleteGroup", -function (g) { -{ -if (this.groups.contains (g)) { -this.removeAnnotationForGroup (g); -this.groups.remove (g); -g.setContext (null); -}}}, "jalview.datamodel.SequenceGroup"); -Clazz.defineMethod (c$, "findName", -function (name) { -return this.findName (name, false); -}, "~S"); -Clazz.defineMethod (c$, "findName", -function (token, b) { -return this.findName (null, token, b); -}, "~S,~B"); -Clazz.defineMethod (c$, "findName", -function (startAfter, token, b) { -var i = 0; -var sq = null; -var sqname = null; -if (startAfter != null) { -var matched = false; -while (i < this.sequences.size ()) { -if (this.getSequenceAt (i++) === startAfter) { -matched = true; -break; -}} -if (!matched) { -i = 0; -}}while (i < this.sequences.size ()) { -sq = this.getSequenceAt (i); -sqname = sq.getName (); -if (sqname.equals (token) || (b && (sqname.equalsIgnoreCase (token)))) { -return this.getSequenceAt (i); -}i++; -} -return null; -}, "jalview.datamodel.SequenceI,~S,~B"); -Clazz.overrideMethod (c$, "findSequenceMatch", -function (name) { -var matches = new java.util.Vector (); -var i = 0; -while (i < this.sequences.size ()) { -if (this.getSequenceAt (i).getName ().equals (name)) { -matches.addElement (this.getSequenceAt (i)); -}i++; -} -var result = new Array (matches.size ()); -for (i = 0; i < result.length; i++) { -result[i] = matches.elementAt (i); -} -return result; -}, "~S"); -Clazz.defineMethod (c$, "findIndex", -function (s) { -var i = 0; -while (i < this.sequences.size ()) { -if (s === this.getSequenceAt (i)) { -return i; -}i++; -} -return -1; -}, "jalview.datamodel.SequenceI"); -Clazz.defineMethod (c$, "findIndex", -function (results) { -var i = 0; -while (i < this.sequences.size ()) { -if (results.involvesSequence (this.getSequenceAt (i))) { -return i; -}i++; -} -return -1; -}, "jalview.datamodel.SearchResults"); -Clazz.overrideMethod (c$, "getHeight", -function () { -return this.sequences.size (); -}); -Clazz.overrideMethod (c$, "getWidth", -function () { -var maxLength = -1; -for (var i = 0; i < this.sequences.size (); i++) { -if (this.getSequenceAt (i).getLength () > maxLength) { -maxLength = this.getSequenceAt (i).getLength (); -}} -return maxLength; -}); -Clazz.overrideMethod (c$, "setGapCharacter", -function (gc) { -this.gapCharacter = gc; -{ -for (var seq, $seq = this.sequences.iterator (); $seq.hasNext () && ((seq = $seq.next ()) || true);) { -seq.setSequence (seq.getSequenceAsString ().$replace ('.', gc).$replace ('-', gc).$replace (' ', gc)); -} -}}, "~S"); -Clazz.defineMethod (c$, "getGapCharacter", -function () { -return this.gapCharacter; -}); -Clazz.defineMethod (c$, "isAligned", -function () { -return this.isAligned (false); -}); -Clazz.defineMethod (c$, "isAligned", -function (includeHidden) { -var width = this.getWidth (); -if (this.hiddenSequences == null || this.hiddenSequences.getSize () == 0) { -includeHidden = true; -}for (var i = 0; i < this.sequences.size (); i++) { -if (includeHidden || !this.hiddenSequences.isHidden (this.getSequenceAt (i))) { -if (this.getSequenceAt (i).getLength () != width) { -return false; -}}} -return true; -}, "~B"); -Clazz.overrideMethod (c$, "deleteAllAnnotations", -function (includingAutoCalculated) { -var result = false; -for (var alan, $alan = 0, $$alan = this.getAlignmentAnnotation (); $alan < $$alan.length && ((alan = $$alan[$alan]) || true); $alan++) { -if (!alan.autoCalculated || includingAutoCalculated) { -this.deleteAnnotation (alan); -result = true; -}} -return result; -}, "~B"); -Clazz.defineMethod (c$, "deleteAnnotation", -function (aa) { -return this.deleteAnnotation (aa, true); -}, "jalview.datamodel.AlignmentAnnotation"); -Clazz.defineMethod (c$, "deleteAnnotation", -function (aa, unhook) { -var aSize = 1; -if (this.annotations != null) { -aSize = this.annotations.length; -}if (aSize < 1) { -return false; -}var temp = new Array (aSize - 1); -var swap = false; -var tIndex = 0; -for (var i = 0; i < aSize; i++) { -if (this.annotations[i] === aa) { -swap = true; -continue; -}if (tIndex < temp.length) { -temp[tIndex++] = this.annotations[i]; -}} -if (swap) { -this.annotations = temp; -if (unhook) { -this.unhookAnnotation (aa); -}}return swap; -}, "jalview.datamodel.AlignmentAnnotation,~B"); -Clazz.defineMethod (c$, "unhookAnnotation", -($fz = function (aa) { -if (aa.sequenceRef != null) { -aa.sequenceRef.removeAlignmentAnnotation (aa); -}if (aa.groupRef != null) { -aa.groupRef = null; -}}, $fz.isPrivate = true, $fz), "jalview.datamodel.AlignmentAnnotation"); -Clazz.defineMethod (c$, "addAnnotation", -function (aa) { -this.addAnnotation (aa, -1); -}, "jalview.datamodel.AlignmentAnnotation"); -Clazz.defineMethod (c$, "addAnnotation", -function (aa, pos) { -if (aa.getRNAStruc () != null) { -this.$hasRNAStructure = true; -}var aSize = 1; -if (this.annotations != null) { -aSize = this.annotations.length + 1; -}var temp = new Array (aSize); -var i = 0; -if (pos == -1 || pos >= aSize) { -temp[aSize - 1] = aa; -} else { -temp[pos] = aa; -}if (aSize > 1) { -var p = 0; -for (i = 0; i < (aSize - 1); i++, p++) { -if (p == pos) { -p++; -}if (p < temp.length) { -temp[p] = this.annotations[i]; -}} -}this.annotations = temp; -}, "jalview.datamodel.AlignmentAnnotation,~N"); -Clazz.overrideMethod (c$, "setAnnotationIndex", -function (aa, index) { -if (aa == null || this.annotations == null || this.annotations.length - 1 < index) { -return; -}var aSize = this.annotations.length; -var temp = new Array (aSize); -temp[index] = aa; -for (var i = 0; i < aSize; i++) { -if (i == index) { -continue; -}if (i < index) { -temp[i] = this.annotations[i]; -} else { -temp[i] = this.annotations[i - 1]; -}} -this.annotations = temp; -}, "jalview.datamodel.AlignmentAnnotation,~N"); -Clazz.defineMethod (c$, "getAlignmentAnnotation", -function () { -return this.annotations; -}); -Clazz.overrideMethod (c$, "setNucleotide", -function (b) { -if (b) { -this.type = 1; -} else { -this.type = 0; -}}, "~B"); -Clazz.defineMethod (c$, "isNucleotide", -function () { -if (this.type == 1) { -return true; -} else { -return false; -}}); -Clazz.overrideMethod (c$, "hasRNAStructure", -function () { -return this.$hasRNAStructure; -}); -Clazz.overrideMethod (c$, "setDataset", -function (data) { -if (this.dataset == null && data == null) { -var seqs = new Array (this.getHeight ()); -var currentSeq; -for (var i = 0; i < this.getHeight (); i++) { -currentSeq = this.getSequenceAt (i); -if (currentSeq.getDatasetSequence () != null) { -seqs[i] = currentSeq.getDatasetSequence (); -} else { -seqs[i] = currentSeq.createDatasetSequence (); -}} -this.dataset = new jalview.datamodel.Alignment (seqs); -} else if (this.dataset == null && data != null) { -this.dataset = data; -for (var i = 0; i < this.getHeight (); i++) { -var currentSeq = this.getSequenceAt (i); -var dsq = currentSeq.getDatasetSequence (); -if (dsq == null) { -dsq = currentSeq.createDatasetSequence (); -this.dataset.addSequence (dsq); -} else { -while (dsq.getDatasetSequence () != null) { -dsq = dsq.getDatasetSequence (); -} -if (this.dataset.findIndex (dsq) == -1) { -this.dataset.addSequence (dsq); -}}} -}this.dataset.addAlignmentRef (); -}, "jalview.datamodel.Alignment"); -Clazz.defineMethod (c$, "addAlignmentRef", -($fz = function () { -this.alignmentRefs++; -}, $fz.isPrivate = true, $fz)); -Clazz.overrideMethod (c$, "getDataset", -function () { -return this.dataset; -}); -Clazz.overrideMethod (c$, "padGaps", -function () { -var modified = false; -var maxLength = -1; -var current; -for (var i = 0; i < this.sequences.size (); i++) { -current = this.getSequenceAt (i); -for (var j = current.getLength (); j > maxLength; j--) { -if (j > maxLength && !jalview.util.Comparison.isGap (current.getCharAt (j))) { -maxLength = j; -break; -}} -} -maxLength++; -var cLength; -for (var i = 0; i < this.sequences.size (); i++) { -current = this.getSequenceAt (i); -cLength = current.getLength (); -if (cLength < maxLength) { -current.insertCharAt (cLength, maxLength - cLength, this.gapCharacter); -modified = true; -} else if (current.getLength () > maxLength) { -current.deleteChars (maxLength, current.getLength ()); -}} -return modified; -}); -Clazz.overrideMethod (c$, "justify", -function (right) { -var modified = false; -var maxLength = -1; -var ends = Clazz.newIntArray (this.sequences.size () * 2, 0); -var current; -for (var i = 0; i < this.sequences.size (); i++) { -current = this.getSequenceAt (i); -ends[i * 2] = current.findIndex (current.getStart ()); -ends[i * 2 + 1] = current.findIndex (current.getStart () + current.getLength ()); -var hitres = false; -for (var j = 0, rs = 0, ssiz = current.getLength (); j < ssiz; j++) { -if (!jalview.util.Comparison.isGap (current.getCharAt (j))) { -if (!hitres) { -ends[i * 2] = j; -hitres = true; -} else { -ends[i * 2 + 1] = j; -if (j - ends[i * 2] > maxLength) { -maxLength = j - ends[i * 2]; -}}}} -} -maxLength++; -var cLength; -var extent; -var diff; -for (var i = 0; i < this.sequences.size (); i++) { -current = this.getSequenceAt (i); -cLength = 1 + ends[i * 2 + 1] - ends[i * 2]; -diff = maxLength - cLength; -extent = current.getLength (); -if (right) { -if (extent > ends[i * 2 + 1]) { -current.deleteChars (ends[i * 2 + 1] + 1, extent); -modified = true; -}if (ends[i * 2] > diff) { -current.deleteChars (0, ends[i * 2] - diff); -modified = true; -} else { -if (ends[i * 2] < diff) { -current.insertCharAt (0, diff - ends[i * 2], this.gapCharacter); -modified = true; -}}} else { -if (ends[i * 2] > 0) { -current.deleteChars (0, ends[i * 2]); -modified = true; -ends[i * 2 + 1] -= ends[i * 2]; -extent -= ends[i * 2]; -}if (extent > maxLength) { -current.deleteChars (maxLength + 1, extent); -modified = true; -} else { -if (extent < maxLength) { -current.insertCharAt (extent, maxLength - extent, this.gapCharacter); -modified = true; -}}}} -return modified; -}, "~B"); -Clazz.defineMethod (c$, "getHiddenSequences", -function () { -return this.hiddenSequences; -}); -Clazz.overrideMethod (c$, "getCompactAlignment", -function () { -{ -var alseqs = new Array (this.sequences.size ()); -var i = 0; -for (var seq, $seq = this.sequences.iterator (); $seq.hasNext () && ((seq = $seq.next ()) || true);) { -alseqs[i++] = new jalview.datamodel.SeqCigar (seq); -} -var cal = new jalview.datamodel.CigarArray (alseqs); -cal.addOperation ('M', this.getWidth ()); -return cal; -}}); -Clazz.overrideMethod (c$, "setProperty", -function (key, value) { -if (this.alignmentProperties == null) { -this.alignmentProperties = new java.util.Hashtable (); -}this.alignmentProperties.put (key, value); -}, "~O,~O"); -Clazz.defineMethod (c$, "getProperty", -function (key) { -if (this.alignmentProperties != null) { -return this.alignmentProperties.get (key); -} else { -return null; -}}, "~O"); -Clazz.defineMethod (c$, "getProperties", -function () { -return this.alignmentProperties; -}); -Clazz.overrideMethod (c$, "addCodonFrame", -function (codons) { -if (codons != null) { -this.codonFrameList.add (codons); -}}, "jalview.datamodel.AlignedCodonFrame"); -Clazz.overrideMethod (c$, "getCodonFrame", -function (seq) { -if (seq == null) { -return null; -}var cframes = new java.util.ArrayList (); -for (var acf, $acf = this.codonFrameList.iterator (); $acf.hasNext () && ((acf = $acf.next ()) || true);) { -if (acf.involvesSequence (seq)) { -cframes.add (acf); -}} -return cframes; -}, "jalview.datamodel.SequenceI"); -Clazz.overrideMethod (c$, "setCodonFrames", -function (acfs) { -this.codonFrameList = acfs; -}, "java.util.Set"); -Clazz.defineMethod (c$, "getCodonFrames", -function () { -return this.codonFrameList; -}); -Clazz.overrideMethod (c$, "removeCodonFrame", -function (codons) { -if (codons == null || this.codonFrameList == null) { -return false; -}return this.codonFrameList.remove (codons); -}, "jalview.datamodel.AlignedCodonFrame"); -Clazz.overrideMethod (c$, "append", -function (toappend) { -if (toappend === this) { -System.err.println ("Self append may cause a deadlock."); -}var samegap = toappend.getGapCharacter () == this.getGapCharacter (); -var oldc = toappend.getGapCharacter (); -var hashidden = toappend.getHiddenSequences () != null && toappend.getHiddenSequences ().hiddenSequences != null; -var sqs = (hashidden) ? toappend.getHiddenSequences ().getFullAlignment ().getSequences () : toappend.getSequences (); -if (sqs != null) { -{ -for (var addedsq, $addedsq = sqs.iterator (); $addedsq.hasNext () && ((addedsq = $addedsq.next ()) || true);) { -if (!samegap) { -var oldseq = addedsq.getSequence (); -for (var c = 0; c < oldseq.length; c++) { -if (oldseq[c] == oldc) { -oldseq[c] = this.gapCharacter; -}} -}this.addSequence (addedsq); -} -}}var alan = toappend.getAlignmentAnnotation (); -for (var a = 0; alan != null && a < alan.length; a++) { -this.addAnnotation (alan[a]); -} -this.codonFrameList.addAll (toappend.getCodonFrames ()); -var sg = toappend.getGroups (); -if (sg != null) { -for (var _sg, $_sg = sg.iterator (); $_sg.hasNext () && ((_sg = $_sg.next ()) || true);) { -this.addGroup (_sg); -} -}if (toappend.getHiddenSequences () != null) { -var hs = toappend.getHiddenSequences (); -if (this.hiddenSequences == null) { -this.hiddenSequences = new jalview.datamodel.HiddenSequences (this); -}if (hs.hiddenSequences != null) { -for (var s = 0; s < hs.hiddenSequences.length; s++) { -if (hs.hiddenSequences[s] != null) { -this.hiddenSequences.hideSequence (hs.hiddenSequences[s]); -}} -}}if (toappend.getProperties () != null) { -var key = toappend.getProperties ().keys (); -while (key.hasMoreElements ()) { -var k = key.nextElement (); -var ourval = this.getProperty (k); -var toapprop = toappend.getProperty (k); -if (ourval != null) { -if (ourval.getClass ().equals (toapprop.getClass ()) && !ourval.equals (toapprop)) { -if (Clazz.instanceOf (ourval, String)) { -this.setProperty (k, (ourval) + "; " + (toapprop)); -} else { -if (Clazz.instanceOf (ourval, java.util.Vector)) { -var theirv = (toapprop).elements (); -while (theirv.hasMoreElements ()) { -(ourval).addElement (theirv); -} -}}}} else { -this.setProperty (k, toapprop); -}} -}}, "jalview.datamodel.AlignmentI"); -Clazz.overrideMethod (c$, "findOrCreateAnnotation", -function (name, calcId, autoCalc, seqRef, groupRef) { -if (this.annotations != null) { -for (var annot, $annot = 0, $$annot = this.getAlignmentAnnotation (); $annot < $$annot.length && ((annot = $$annot[$annot]) || true); $annot++) { -if (annot.autoCalculated == autoCalc && (name.equals (annot.label)) && (calcId == null || annot.getCalcId ().equals (calcId)) && annot.sequenceRef === seqRef && annot.groupRef === groupRef) { -return annot; -}} -}var annot = new jalview.datamodel.AlignmentAnnotation (name, name, new Array (1), 0, 0, 1); -annot.hasText = false; -annot.setCalcId ( String.instantialize (calcId)); -annot.autoCalculated = autoCalc; -if (seqRef != null) { -annot.setSequenceRef (seqRef); -}annot.groupRef = groupRef; -this.addAnnotation (annot); -return annot; -}, "~S,~S,~B,jalview.datamodel.SequenceI,jalview.datamodel.SequenceGroup"); -Clazz.overrideMethod (c$, "findAnnotation", -function (calcId) { -var aa = new java.util.ArrayList (); -for (var a, $a = 0, $$a = this.getAlignmentAnnotation (); $a < $$a.length && ((a = $$a[$a]) || true); $a++) { -if (a.getCalcId () === calcId || (a.getCalcId () != null && calcId != null && a.getCalcId ().equals (calcId))) { -aa.add (a); -}} -return aa; -}, "~S"); -Clazz.overrideMethod (c$, "findAnnotations", -function (seq, calcId, label) { -var aa = new java.util.ArrayList (); -for (var ann, $ann = 0, $$ann = this.getAlignmentAnnotation (); $ann < $$ann.length && ((ann = $$ann[$ann]) || true); $ann++) { -if (ann.getCalcId () != null && ann.getCalcId ().equals (calcId) && ann.sequenceRef != null && ann.sequenceRef === seq && ann.label != null && ann.label.equals (label)) { -aa.add (ann); -}} -return aa; -}, "jalview.datamodel.SequenceI,~S,~S"); -Clazz.overrideMethod (c$, "moveSelectedSequencesByOne", -function (sg, map, up) { -{ -if (up) { -for (var i = 1, iSize = this.sequences.size (); i < iSize; i++) { -var seq = this.sequences.get (i); -if (!sg.getSequences (map).contains (seq)) { -continue; -}var temp = this.sequences.get (i - 1); -if (sg.getSequences (null).contains (temp)) { -continue; -}this.sequences.set (i, temp); -this.sequences.set (i - 1, seq); -} -} else { -for (var i = this.sequences.size () - 2; i > -1; i--) { -var seq = this.sequences.get (i); -if (!sg.getSequences (map).contains (seq)) { -continue; -}var temp = this.sequences.get (i + 1); -if (sg.getSequences (map).contains (temp)) { -continue; -}this.sequences.set (i, temp); -this.sequences.set (i + 1, seq); -} -}}}, "jalview.datamodel.SequenceGroup,java.util.Map,~B"); -Clazz.overrideMethod (c$, "validateAnnotation", -function (alignmentAnnotation) { -alignmentAnnotation.validateRangeAndDisplay (); -if (this.isNucleotide () && alignmentAnnotation.isValidStruc ()) { -this.$hasRNAStructure = true; -}}, "jalview.datamodel.AlignmentAnnotation"); -Clazz.overrideMethod (c$, "getSeqrep", -function () { -return this.seqrep; -}); -Clazz.overrideMethod (c$, "setSeqrep", -function (seqrep) { -this.seqrep = seqrep; -}, "jalview.datamodel.SequenceI"); -Clazz.overrideMethod (c$, "hasSeqrep", -function () { -return this.seqrep != null; -}); -Clazz.overrideMethod (c$, "getEndRes", -function () { -return this.getWidth () - 1; -}); -Clazz.overrideMethod (c$, "getStartRes", -function () { -return 0; -}); -Clazz.overrideMethod (c$, "getContext", -function () { -return this.dataset; -}); -Clazz.defineMethod (c$, "alignAs", -function (al) { -return this.alignAs (al, false, true); -}, "jalview.datamodel.AlignmentI"); -Clazz.defineMethod (c$, "alignAs", -function (al, preserveMappedGaps, preserveUnmappedGaps) { -var count = 0; -var thisIsNucleotide = this.isNucleotide (); -var thatIsProtein = !al.isNucleotide (); -if (!thatIsProtein && !thisIsNucleotide) { -return jalview.analysis.AlignmentUtils.alignProteinAsDna (this, al); -}var thisGapChar = this.getGapCharacter (); -var gap = thisIsNucleotide && thatIsProtein ? String.valueOf ( Clazz.newCharArray (-1, [thisGapChar, thisGapChar, thisGapChar])) : String.valueOf (thisGapChar); -for (var alignTo, $alignTo = this.getSequences ().iterator (); $alignTo.hasNext () && ((alignTo = $alignTo.next ()) || true);) { -count += jalview.analysis.AlignmentUtils.alignSequenceAs (alignTo, al, gap, preserveMappedGaps, preserveUnmappedGaps) ? 1 : 0; -} -return count; -}, "jalview.datamodel.AlignmentI,~B,~B"); -Clazz.overrideMethod (c$, "getSequenceNames", -function () { -var names = new java.util.HashSet (); -for (var seq, $seq = this.getSequences ().iterator (); $seq.hasNext () && ((seq = $seq.next ()) || true);) { -names.add (seq.getName ()); -} -return names; -}); -Clazz.overrideMethod (c$, "toString", -function () { -var seq = this.getSequencesArray (); -{ -return "" + JSON.stringify(seq); -}}); -Clazz.defineStatics (c$, -"PROTEIN", 0, -"NUCLEOTIDE", 1); -}); +Clazz.declarePackage ("jalview.datamodel"); +Clazz.load (["jalview.datamodel.AlignmentI", "$.HiddenSequences", "java.util.ArrayList", "$.Collections", "$.LinkedHashSet"], "jalview.datamodel.Alignment", ["jalview.analysis.AlignmentUtils", "jalview.datamodel.AlignmentAnnotation", "$.CigarArray", "$.SeqCigar", "$.Sequence", "jalview.util.Comparison", "$.MessageManager", "java.lang.Error", "java.util.HashSet", "$.Hashtable", "$.Vector"], function () { +c$ = Clazz.decorateAsClass (function () { +this.dataset = null; +this.sequences = null; +this.groups = null; +this.gapCharacter = '-'; +this.type = 1; +this.$hasRNAStructure = false; +this.annotations = null; +this.hiddenSequences = null; +this.alignmentProperties = null; +this.codonFrameList = null; +this.alignmentRefs = 0; +this.seqrep = null; +Clazz.instantialize (this, arguments); +}, jalview.datamodel, "Alignment", null, jalview.datamodel.AlignmentI); +Clazz.prepareFields (c$, function () { +this.groups = java.util.Collections.synchronizedList ( new java.util.ArrayList ()); +this.hiddenSequences = new jalview.datamodel.HiddenSequences (this); +this.codonFrameList = new java.util.LinkedHashSet (); +}); +Clazz.defineMethod (c$, "initAlignment", +($fz = function (seqs) { +var i = 0; +if (jalview.util.Comparison.isNucleotide (seqs)) { +this.type = 1; +} else { +this.type = 0; +}this.sequences = java.util.Collections.synchronizedList ( new java.util.ArrayList ()); +for (i = 0; i < seqs.length; i++) { +this.sequences.add (seqs[i]); +} +}, $fz.isPrivate = true, $fz), "~A"); +Clazz.makeConstructor (c$, +function (al) { +var seqs = al.getSequencesArray (); +for (var i = 0; i < seqs.length; i++) { +seqs[i] = new jalview.datamodel.Sequence (seqs[i]); +} +this.codonFrameList = (al).codonFrameList; +this.initAlignment (seqs); +}, "jalview.datamodel.AlignmentI"); +Clazz.makeConstructor (c$, +function (seqs) { +this.initAlignment (seqs); +}, "~A"); +c$.createAlignment = Clazz.defineMethod (c$, "createAlignment", +function (compactAlignment) { +throw new Error (jalview.util.MessageManager.getString ("error.alignment_cigararray_not_implemented")); +}, "jalview.datamodel.CigarArray"); +Clazz.defineMethod (c$, "getSequences", +function () { +return this.sequences; +}); +Clazz.defineMethod (c$, "getSequences", +function (hiddenReps) { +return this.sequences; +}, "java.util.Map"); +Clazz.defineMethod (c$, "getSequencesArray", +function () { +if (this.sequences == null) { +return null; +}{ +return this.sequences.toArray ( new Array (this.sequences.size ())); +}}); +Clazz.overrideMethod (c$, "getSequencesByName", +function () { +return jalview.analysis.AlignmentUtils.getSequencesByName (this); +}); +Clazz.overrideMethod (c$, "getSequenceAt", +function (i) { +{ +if (i > -1 && i < this.sequences.size ()) { +return this.sequences.get (i); +}}return null; +}, "~N"); +Clazz.overrideMethod (c$, "addSequence", +function (snew) { +if (this.dataset != null) { +if (snew.getDatasetSequence () != null) { +this.getDataset ().addSequence (snew.getDatasetSequence ()); +} else { +var adding = snew.deriveSequence (); +this.getDataset ().addSequence (adding.getDatasetSequence ()); +snew = adding; +}}if (this.sequences == null) { +this.initAlignment ( Clazz.newArray (-1, [snew])); +} else { +{ +this.sequences.add (snew); +}}if (this.hiddenSequences != null) { +this.hiddenSequences.adjustHeightSequenceAdded (); +}}, "jalview.datamodel.SequenceI"); +Clazz.overrideMethod (c$, "setSequenceAt", +function (i, snew) { +{ +this.deleteSequence (i); +this.sequences.set (i, snew); +}}, "~N,jalview.datamodel.SequenceI"); +Clazz.defineMethod (c$, "getGroups", +function () { +return this.groups; +}); +Clazz.overrideMethod (c$, "finalize", +function () { +if (this.getDataset () != null) { +this.getDataset ().removeAlignmentRef (); +}this.dataset = null; +this.sequences = null; +this.groups = null; +this.annotations = null; +this.hiddenSequences = null; +}); +Clazz.defineMethod (c$, "removeAlignmentRef", +($fz = function () { +if (--this.alignmentRefs == 0) { +this.finalize (); +}}, $fz.isPrivate = true, $fz)); +Clazz.defineMethod (c$, "deleteSequence", +function (s) { +this.deleteSequence (this.findIndex (s)); +}, "jalview.datamodel.SequenceI"); +Clazz.defineMethod (c$, "deleteSequence", +function (i) { +if (i > -1 && i < this.getHeight ()) { +{ +this.sequences.remove (i); +this.hiddenSequences.adjustHeightSequenceDeleted (i); +}}}, "~N"); +Clazz.overrideMethod (c$, "findGroup", +function (s) { +{ +for (var i = 0; i < this.groups.size (); i++) { +var sg = this.groups.get (i); +if (sg.getSequences (null).contains (s)) { +return sg; +}} +}return null; +}, "jalview.datamodel.SequenceI"); +Clazz.overrideMethod (c$, "findAllGroups", +function (s) { +var temp = new java.util.ArrayList (); +{ +var gSize = this.groups.size (); +for (var i = 0; i < gSize; i++) { +var sg = this.groups.get (i); +if (sg == null || sg.getSequences () == null) { +this.deleteGroup (sg); +gSize--; +continue; +}if (sg.getSequences ().contains (s)) { +temp.add (sg); +}} +}var ret = new Array (temp.size ()); +return temp.toArray (ret); +}, "jalview.datamodel.SequenceI"); +Clazz.overrideMethod (c$, "addGroup", +function (sg) { +{ +if (!this.groups.contains (sg)) { +if (this.hiddenSequences.getSize () > 0) { +var i; +var iSize = sg.getSize (); +for (i = 0; i < iSize; i++) { +if (!this.sequences.contains (sg.getSequenceAt (i))) { +sg.deleteSequence (sg.getSequenceAt (i), false); +iSize--; +i--; +}} +if (sg.getSize () < 1) { +return; +}}sg.setContext (this); +this.groups.add (sg); +}}}, "jalview.datamodel.SequenceGroup"); +Clazz.defineMethod (c$, "removeAnnotationForGroup", +($fz = function (gp) { +if (this.annotations == null || this.annotations.length == 0) { +return; +}var t; +var todelete = new Array (this.annotations.length); +var tokeep = new Array (this.annotations.length); +var i; +var p; +var k; +if (gp == null) { +for (i = 0, p = 0, k = 0; i < this.annotations.length; i++) { +if (this.annotations[i].groupRef != null) { +todelete[p++] = this.annotations[i]; +} else { +tokeep[k++] = this.annotations[i]; +}} +} else { +for (i = 0, p = 0, k = 0; i < this.annotations.length; i++) { +if (this.annotations[i].groupRef === gp) { +todelete[p++] = this.annotations[i]; +} else { +tokeep[k++] = this.annotations[i]; +}} +}if (p > 0) { +for (i = 0; i < p; i++) { +this.unhookAnnotation (todelete[i]); +todelete[i] = null; +} +t = new Array (k); +for (i = 0; i < k; i++) { +t[i] = tokeep[i]; +} +this.annotations = t; +}}, $fz.isPrivate = true, $fz), "jalview.datamodel.SequenceGroup"); +Clazz.overrideMethod (c$, "deleteAllGroups", +function () { +{ +if (this.annotations != null) { +this.removeAnnotationForGroup (null); +}for (var sg, $sg = this.groups.iterator (); $sg.hasNext () && ((sg = $sg.next ()) || true);) { +sg.setContext (null); +} +this.groups.clear (); +}}); +Clazz.overrideMethod (c$, "deleteGroup", +function (g) { +{ +if (this.groups.contains (g)) { +this.removeAnnotationForGroup (g); +this.groups.remove (g); +g.setContext (null); +}}}, "jalview.datamodel.SequenceGroup"); +Clazz.defineMethod (c$, "findName", +function (name) { +return this.findName (name, false); +}, "~S"); +Clazz.defineMethod (c$, "findName", +function (token, b) { +return this.findName (null, token, b); +}, "~S,~B"); +Clazz.defineMethod (c$, "findName", +function (startAfter, token, b) { +var i = 0; +var sq = null; +var sqname = null; +if (startAfter != null) { +var matched = false; +while (i < this.sequences.size ()) { +if (this.getSequenceAt (i++) === startAfter) { +matched = true; +break; +}} +if (!matched) { +i = 0; +}}while (i < this.sequences.size ()) { +sq = this.getSequenceAt (i); +sqname = sq.getName (); +if (sqname.equals (token) || (b && (sqname.equalsIgnoreCase (token)))) { +return this.getSequenceAt (i); +}i++; +} +return null; +}, "jalview.datamodel.SequenceI,~S,~B"); +Clazz.overrideMethod (c$, "findSequenceMatch", +function (name) { +var matches = new java.util.Vector (); +var i = 0; +while (i < this.sequences.size ()) { +if (this.getSequenceAt (i).getName ().equals (name)) { +matches.addElement (this.getSequenceAt (i)); +}i++; +} +var result = new Array (matches.size ()); +for (i = 0; i < result.length; i++) { +result[i] = matches.elementAt (i); +} +return result; +}, "~S"); +Clazz.defineMethod (c$, "findIndex", +function (s) { +var i = 0; +while (i < this.sequences.size ()) { +if (s === this.getSequenceAt (i)) { +return i; +}i++; +} +return -1; +}, "jalview.datamodel.SequenceI"); +Clazz.defineMethod (c$, "findIndex", +function (results) { +var i = 0; +while (i < this.sequences.size ()) { +if (results.involvesSequence (this.getSequenceAt (i))) { +return i; +}i++; +} +return -1; +}, "jalview.datamodel.SearchResults"); +Clazz.overrideMethod (c$, "getHeight", +function () { +return this.sequences.size (); +}); +Clazz.overrideMethod (c$, "getWidth", +function () { +var maxLength = -1; +for (var i = 0; i < this.sequences.size (); i++) { +if (this.getSequenceAt (i).getLength () > maxLength) { +maxLength = this.getSequenceAt (i).getLength (); +}} +return maxLength; +}); +Clazz.overrideMethod (c$, "setGapCharacter", +function (gc) { +this.gapCharacter = gc; +{ +for (var seq, $seq = this.sequences.iterator (); $seq.hasNext () && ((seq = $seq.next ()) || true);) { +seq.setSequence (seq.getSequenceAsString ().$replace ('.', gc).$replace ('-', gc).$replace (' ', gc)); +} +}}, "~S"); +Clazz.defineMethod (c$, "getGapCharacter", +function () { +return this.gapCharacter; +}); +Clazz.defineMethod (c$, "isAligned", +function () { +return this.isAligned (false); +}); +Clazz.defineMethod (c$, "isAligned", +function (includeHidden) { +var width = this.getWidth (); +if (this.hiddenSequences == null || this.hiddenSequences.getSize () == 0) { +includeHidden = true; +}for (var i = 0; i < this.sequences.size (); i++) { +if (includeHidden || !this.hiddenSequences.isHidden (this.getSequenceAt (i))) { +if (this.getSequenceAt (i).getLength () != width) { +return false; +}}} +return true; +}, "~B"); +Clazz.overrideMethod (c$, "deleteAllAnnotations", +function (includingAutoCalculated) { +var result = false; +for (var alan, $alan = 0, $$alan = this.getAlignmentAnnotation (); $alan < $$alan.length && ((alan = $$alan[$alan]) || true); $alan++) { +if (!alan.autoCalculated || includingAutoCalculated) { +this.deleteAnnotation (alan); +result = true; +}} +return result; +}, "~B"); +Clazz.defineMethod (c$, "deleteAnnotation", +function (aa) { +return this.deleteAnnotation (aa, true); +}, "jalview.datamodel.AlignmentAnnotation"); +Clazz.defineMethod (c$, "deleteAnnotation", +function (aa, unhook) { +var aSize = 1; +if (this.annotations != null) { +aSize = this.annotations.length; +}if (aSize < 1) { +return false; +}var temp = new Array (aSize - 1); +var swap = false; +var tIndex = 0; +for (var i = 0; i < aSize; i++) { +if (this.annotations[i] === aa) { +swap = true; +continue; +}if (tIndex < temp.length) { +temp[tIndex++] = this.annotations[i]; +}} +if (swap) { +this.annotations = temp; +if (unhook) { +this.unhookAnnotation (aa); +}}return swap; +}, "jalview.datamodel.AlignmentAnnotation,~B"); +Clazz.defineMethod (c$, "unhookAnnotation", +($fz = function (aa) { +if (aa.sequenceRef != null) { +aa.sequenceRef.removeAlignmentAnnotation (aa); +}if (aa.groupRef != null) { +aa.groupRef = null; +}}, $fz.isPrivate = true, $fz), "jalview.datamodel.AlignmentAnnotation"); +Clazz.defineMethod (c$, "addAnnotation", +function (aa) { +this.addAnnotation (aa, -1); +}, "jalview.datamodel.AlignmentAnnotation"); +Clazz.defineMethod (c$, "addAnnotation", +function (aa, pos) { +if (aa.getRNAStruc () != null) { +this.$hasRNAStructure = true; +}var aSize = 1; +if (this.annotations != null) { +aSize = this.annotations.length + 1; +}var temp = new Array (aSize); +var i = 0; +if (pos == -1 || pos >= aSize) { +temp[aSize - 1] = aa; +} else { +temp[pos] = aa; +}if (aSize > 1) { +var p = 0; +for (i = 0; i < (aSize - 1); i++, p++) { +if (p == pos) { +p++; +}if (p < temp.length) { +temp[p] = this.annotations[i]; +}} +}this.annotations = temp; +}, "jalview.datamodel.AlignmentAnnotation,~N"); +Clazz.overrideMethod (c$, "setAnnotationIndex", +function (aa, index) { +if (aa == null || this.annotations == null || this.annotations.length - 1 < index) { +return; +}var aSize = this.annotations.length; +var temp = new Array (aSize); +temp[index] = aa; +for (var i = 0; i < aSize; i++) { +if (i == index) { +continue; +}if (i < index) { +temp[i] = this.annotations[i]; +} else { +temp[i] = this.annotations[i - 1]; +}} +this.annotations = temp; +}, "jalview.datamodel.AlignmentAnnotation,~N"); +Clazz.defineMethod (c$, "getAlignmentAnnotation", +function () { +return this.annotations; +}); +Clazz.overrideMethod (c$, "setNucleotide", +function (b) { +if (b) { +this.type = 1; +} else { +this.type = 0; +}}, "~B"); +Clazz.defineMethod (c$, "isNucleotide", +function () { +if (this.type == 1) { +return true; +} else { +return false; +}}); +Clazz.overrideMethod (c$, "hasRNAStructure", +function () { +return this.$hasRNAStructure; +}); +Clazz.overrideMethod (c$, "setDataset", +function (data) { +if (this.dataset == null && data == null) { +var seqs = new Array (this.getHeight ()); +var currentSeq; +for (var i = 0; i < this.getHeight (); i++) { +currentSeq = this.getSequenceAt (i); +if (currentSeq.getDatasetSequence () != null) { +seqs[i] = currentSeq.getDatasetSequence (); +} else { +seqs[i] = currentSeq.createDatasetSequence (); +}} +this.dataset = new jalview.datamodel.Alignment (seqs); +} else if (this.dataset == null && data != null) { +this.dataset = data; +for (var i = 0; i < this.getHeight (); i++) { +var currentSeq = this.getSequenceAt (i); +var dsq = currentSeq.getDatasetSequence (); +if (dsq == null) { +dsq = currentSeq.createDatasetSequence (); +this.dataset.addSequence (dsq); +} else { +while (dsq.getDatasetSequence () != null) { +dsq = dsq.getDatasetSequence (); +} +if (this.dataset.findIndex (dsq) == -1) { +this.dataset.addSequence (dsq); +}}} +}this.dataset.addAlignmentRef (); +}, "jalview.datamodel.Alignment"); +Clazz.defineMethod (c$, "addAlignmentRef", +($fz = function () { +this.alignmentRefs++; +}, $fz.isPrivate = true, $fz)); +Clazz.overrideMethod (c$, "getDataset", +function () { +return this.dataset; +}); +Clazz.overrideMethod (c$, "padGaps", +function () { +var modified = false; +var maxLength = -1; +var current; +for (var i = 0; i < this.sequences.size (); i++) { +current = this.getSequenceAt (i); +for (var j = current.getLength (); j > maxLength; j--) { +if (j > maxLength && !jalview.util.Comparison.isGap (current.getCharAt (j))) { +maxLength = j; +break; +}} +} +maxLength++; +var cLength; +for (var i = 0; i < this.sequences.size (); i++) { +current = this.getSequenceAt (i); +cLength = current.getLength (); +if (cLength < maxLength) { +current.insertCharAt (cLength, maxLength - cLength, this.gapCharacter); +modified = true; +} else if (current.getLength () > maxLength) { +current.deleteChars (maxLength, current.getLength ()); +}} +return modified; +}); +Clazz.overrideMethod (c$, "justify", +function (right) { +var modified = false; +var maxLength = -1; +var ends = Clazz.newIntArray (this.sequences.size () * 2, 0); +var current; +for (var i = 0; i < this.sequences.size (); i++) { +current = this.getSequenceAt (i); +ends[i * 2] = current.findIndex (current.getStart ()); +ends[i * 2 + 1] = current.findIndex (current.getStart () + current.getLength ()); +var hitres = false; +for (var j = 0, rs = 0, ssiz = current.getLength (); j < ssiz; j++) { +if (!jalview.util.Comparison.isGap (current.getCharAt (j))) { +if (!hitres) { +ends[i * 2] = j; +hitres = true; +} else { +ends[i * 2 + 1] = j; +if (j - ends[i * 2] > maxLength) { +maxLength = j - ends[i * 2]; +}}}} +} +maxLength++; +var cLength; +var extent; +var diff; +for (var i = 0; i < this.sequences.size (); i++) { +current = this.getSequenceAt (i); +cLength = 1 + ends[i * 2 + 1] - ends[i * 2]; +diff = maxLength - cLength; +extent = current.getLength (); +if (right) { +if (extent > ends[i * 2 + 1]) { +current.deleteChars (ends[i * 2 + 1] + 1, extent); +modified = true; +}if (ends[i * 2] > diff) { +current.deleteChars (0, ends[i * 2] - diff); +modified = true; +} else { +if (ends[i * 2] < diff) { +current.insertCharAt (0, diff - ends[i * 2], this.gapCharacter); +modified = true; +}}} else { +if (ends[i * 2] > 0) { +current.deleteChars (0, ends[i * 2]); +modified = true; +ends[i * 2 + 1] -= ends[i * 2]; +extent -= ends[i * 2]; +}if (extent > maxLength) { +current.deleteChars (maxLength + 1, extent); +modified = true; +} else { +if (extent < maxLength) { +current.insertCharAt (extent, maxLength - extent, this.gapCharacter); +modified = true; +}}}} +return modified; +}, "~B"); +Clazz.defineMethod (c$, "getHiddenSequences", +function () { +return this.hiddenSequences; +}); +Clazz.overrideMethod (c$, "getCompactAlignment", +function () { +{ +var alseqs = new Array (this.sequences.size ()); +var i = 0; +for (var seq, $seq = this.sequences.iterator (); $seq.hasNext () && ((seq = $seq.next ()) || true);) { +alseqs[i++] = new jalview.datamodel.SeqCigar (seq); +} +var cal = new jalview.datamodel.CigarArray (alseqs); +cal.addOperation ('M', this.getWidth ()); +return cal; +}}); +Clazz.overrideMethod (c$, "setProperty", +function (key, value) { +if (this.alignmentProperties == null) { +this.alignmentProperties = new java.util.Hashtable (); +}this.alignmentProperties.put (key, value); +}, "~O,~O"); +Clazz.defineMethod (c$, "getProperty", +function (key) { +if (this.alignmentProperties != null) { +return this.alignmentProperties.get (key); +} else { +return null; +}}, "~O"); +Clazz.defineMethod (c$, "getProperties", +function () { +return this.alignmentProperties; +}); +Clazz.overrideMethod (c$, "addCodonFrame", +function (codons) { +if (codons != null) { +this.codonFrameList.add (codons); +}}, "jalview.datamodel.AlignedCodonFrame"); +Clazz.overrideMethod (c$, "getCodonFrame", +function (seq) { +if (seq == null) { +return null; +}var cframes = new java.util.ArrayList (); +for (var acf, $acf = this.codonFrameList.iterator (); $acf.hasNext () && ((acf = $acf.next ()) || true);) { +if (acf.involvesSequence (seq)) { +cframes.add (acf); +}} +return cframes; +}, "jalview.datamodel.SequenceI"); +Clazz.overrideMethod (c$, "setCodonFrames", +function (acfs) { +this.codonFrameList = acfs; +}, "java.util.Set"); +Clazz.defineMethod (c$, "getCodonFrames", +function () { +return this.codonFrameList; +}); +Clazz.overrideMethod (c$, "removeCodonFrame", +function (codons) { +if (codons == null || this.codonFrameList == null) { +return false; +}return this.codonFrameList.remove (codons); +}, "jalview.datamodel.AlignedCodonFrame"); +Clazz.overrideMethod (c$, "append", +function (toappend) { +if (toappend === this) { +System.err.println ("Self append may cause a deadlock."); +}var samegap = toappend.getGapCharacter () == this.getGapCharacter (); +var oldc = toappend.getGapCharacter (); +var hashidden = toappend.getHiddenSequences () != null && toappend.getHiddenSequences ().hiddenSequences != null; +var sqs = (hashidden) ? toappend.getHiddenSequences ().getFullAlignment ().getSequences () : toappend.getSequences (); +if (sqs != null) { +{ +for (var addedsq, $addedsq = sqs.iterator (); $addedsq.hasNext () && ((addedsq = $addedsq.next ()) || true);) { +if (!samegap) { +var oldseq = addedsq.getSequence (); +for (var c = 0; c < oldseq.length; c++) { +if (oldseq[c] == oldc) { +oldseq[c] = this.gapCharacter; +}} +}this.addSequence (addedsq); +} +}}var alan = toappend.getAlignmentAnnotation (); +for (var a = 0; alan != null && a < alan.length; a++) { +this.addAnnotation (alan[a]); +} +this.codonFrameList.addAll (toappend.getCodonFrames ()); +var sg = toappend.getGroups (); +if (sg != null) { +for (var _sg, $_sg = sg.iterator (); $_sg.hasNext () && ((_sg = $_sg.next ()) || true);) { +this.addGroup (_sg); +} +}if (toappend.getHiddenSequences () != null) { +var hs = toappend.getHiddenSequences (); +if (this.hiddenSequences == null) { +this.hiddenSequences = new jalview.datamodel.HiddenSequences (this); +}if (hs.hiddenSequences != null) { +for (var s = 0; s < hs.hiddenSequences.length; s++) { +if (hs.hiddenSequences[s] != null) { +this.hiddenSequences.hideSequence (hs.hiddenSequences[s]); +}} +}}if (toappend.getProperties () != null) { +var key = toappend.getProperties ().keys (); +while (key.hasMoreElements ()) { +var k = key.nextElement (); +var ourval = this.getProperty (k); +var toapprop = toappend.getProperty (k); +if (ourval != null) { +if (ourval.getClass ().equals (toapprop.getClass ()) && !ourval.equals (toapprop)) { +if (Clazz.instanceOf (ourval, String)) { +this.setProperty (k, (ourval) + "; " + (toapprop)); +} else { +if (Clazz.instanceOf (ourval, java.util.Vector)) { +var theirv = (toapprop).elements (); +while (theirv.hasMoreElements ()) { +(ourval).addElement (theirv); +} +}}}} else { +this.setProperty (k, toapprop); +}} +}}, "jalview.datamodel.AlignmentI"); +Clazz.overrideMethod (c$, "findOrCreateAnnotation", +function (name, calcId, autoCalc, seqRef, groupRef) { +if (this.annotations != null) { +for (var annot, $annot = 0, $$annot = this.getAlignmentAnnotation (); $annot < $$annot.length && ((annot = $$annot[$annot]) || true); $annot++) { +if (annot.autoCalculated == autoCalc && (name.equals (annot.label)) && (calcId == null || annot.getCalcId ().equals (calcId)) && annot.sequenceRef === seqRef && annot.groupRef === groupRef) { +return annot; +}} +}var annot = new jalview.datamodel.AlignmentAnnotation (name, name, new Array (1), 0, 0, 1); +annot.hasText = false; +annot.setCalcId ( String.instantialize (calcId)); +annot.autoCalculated = autoCalc; +if (seqRef != null) { +annot.setSequenceRef (seqRef); +}annot.groupRef = groupRef; +this.addAnnotation (annot); +return annot; +}, "~S,~S,~B,jalview.datamodel.SequenceI,jalview.datamodel.SequenceGroup"); +Clazz.overrideMethod (c$, "findAnnotation", +function (calcId) { +var aa = new java.util.ArrayList (); +for (var a, $a = 0, $$a = this.getAlignmentAnnotation (); $a < $$a.length && ((a = $$a[$a]) || true); $a++) { +if (a.getCalcId () === calcId || (a.getCalcId () != null && calcId != null && a.getCalcId ().equals (calcId))) { +aa.add (a); +}} +return aa; +}, "~S"); +Clazz.overrideMethod (c$, "findAnnotations", +function (seq, calcId, label) { +var aa = new java.util.ArrayList (); +for (var ann, $ann = 0, $$ann = this.getAlignmentAnnotation (); $ann < $$ann.length && ((ann = $$ann[$ann]) || true); $ann++) { +if (ann.getCalcId () != null && ann.getCalcId ().equals (calcId) && ann.sequenceRef != null && ann.sequenceRef === seq && ann.label != null && ann.label.equals (label)) { +aa.add (ann); +}} +return aa; +}, "jalview.datamodel.SequenceI,~S,~S"); +Clazz.overrideMethod (c$, "moveSelectedSequencesByOne", +function (sg, map, up) { +{ +if (up) { +for (var i = 1, iSize = this.sequences.size (); i < iSize; i++) { +var seq = this.sequences.get (i); +if (!sg.getSequences (map).contains (seq)) { +continue; +}var temp = this.sequences.get (i - 1); +if (sg.getSequences (null).contains (temp)) { +continue; +}this.sequences.set (i, temp); +this.sequences.set (i - 1, seq); +} +} else { +for (var i = this.sequences.size () - 2; i > -1; i--) { +var seq = this.sequences.get (i); +if (!sg.getSequences (map).contains (seq)) { +continue; +}var temp = this.sequences.get (i + 1); +if (sg.getSequences (map).contains (temp)) { +continue; +}this.sequences.set (i, temp); +this.sequences.set (i + 1, seq); +} +}}}, "jalview.datamodel.SequenceGroup,java.util.Map,~B"); +Clazz.overrideMethod (c$, "validateAnnotation", +function (alignmentAnnotation) { +alignmentAnnotation.validateRangeAndDisplay (); +if (this.isNucleotide () && alignmentAnnotation.isValidStruc ()) { +this.$hasRNAStructure = true; +}}, "jalview.datamodel.AlignmentAnnotation"); +Clazz.overrideMethod (c$, "getSeqrep", +function () { +return this.seqrep; +}); +Clazz.overrideMethod (c$, "setSeqrep", +function (seqrep) { +this.seqrep = seqrep; +}, "jalview.datamodel.SequenceI"); +Clazz.overrideMethod (c$, "hasSeqrep", +function () { +return this.seqrep != null; +}); +Clazz.overrideMethod (c$, "getEndRes", +function () { +return this.getWidth () - 1; +}); +Clazz.overrideMethod (c$, "getStartRes", +function () { +return 0; +}); +Clazz.overrideMethod (c$, "getContext", +function () { +return this.dataset; +}); +Clazz.defineMethod (c$, "alignAs", +function (al) { +return this.alignAs (al, false, true); +}, "jalview.datamodel.AlignmentI"); +Clazz.defineMethod (c$, "alignAs", +function (al, preserveMappedGaps, preserveUnmappedGaps) { +var count = 0; +var thisIsNucleotide = this.isNucleotide (); +var thatIsProtein = !al.isNucleotide (); +if (!thatIsProtein && !thisIsNucleotide) { +return jalview.analysis.AlignmentUtils.alignProteinAsDna (this, al); +}var thisGapChar = this.getGapCharacter (); +var gap = thisIsNucleotide && thatIsProtein ? String.valueOf ( Clazz.newCharArray (-1, [thisGapChar, thisGapChar, thisGapChar])) : String.valueOf (thisGapChar); +for (var alignTo, $alignTo = this.getSequences ().iterator (); $alignTo.hasNext () && ((alignTo = $alignTo.next ()) || true);) { +count += jalview.analysis.AlignmentUtils.alignSequenceAs (alignTo, al, gap, preserveMappedGaps, preserveUnmappedGaps) ? 1 : 0; +} +return count; +}, "jalview.datamodel.AlignmentI,~B,~B"); +Clazz.overrideMethod (c$, "getSequenceNames", +function () { +var names = new java.util.HashSet (); +for (var seq, $seq = this.getSequences ().iterator (); $seq.hasNext () && ((seq = $seq.next ()) || true);) { +names.add (seq.getName ()); +} +return names; +}); +Clazz.overrideMethod (c$, "toString", +function () { +var seq = this.getSequencesArray (); +{ +return "" + JSON.stringify(seq); +}}); +Clazz.defineStatics (c$, +"PROTEIN", 0, +"NUCLEOTIDE", 1); +});