X-Git-Url: http://source.jalview.org/gitweb/?p=jalviewjs.git;a=blobdiff_plain;f=site%2Fj2s%2Fjalview%2Fanalysis%2FAnnotationSorter.js;h=ffaa451d5d0da0042bee44873f808beb4ee07fdc;hp=a94258515d7311f40cc8bf5bb9df47843d1fc645;hb=b9b7a352eee79b7764c3b09c9d19663075061d8c;hpb=7301a2415adab88038b291fc54caeeb3a5a47a44 diff --git a/site/j2s/jalview/analysis/AnnotationSorter.js b/site/j2s/jalview/analysis/AnnotationSorter.js index a942585..ffaa451 100644 --- a/site/j2s/jalview/analysis/AnnotationSorter.js +++ b/site/j2s/jalview/analysis/AnnotationSorter.js @@ -1,171 +1,171 @@ -Clazz.declarePackage ("jalview.analysis"); -Clazz.load (["java.lang.Enum", "java.util.HashMap"], "jalview.analysis.AnnotationSorter", ["jalview.analysis.AlignmentUtils", "java.lang.UnsupportedOperationException", "java.util.Arrays"], function () { -c$ = Clazz.decorateAsClass (function () { -this.alignment = null; -this.showAutocalcAbove = false; -this.sequenceIndices = null; -this.bySequenceAndLabel = null; -this.byLabelAndSequence = null; -this.noSort = null; -Clazz.instantialize (this, arguments); -}, jalview.analysis, "AnnotationSorter"); -Clazz.prepareFields (c$, function () { -this.sequenceIndices = new java.util.HashMap (); -this.bySequenceAndLabel = ((Clazz.isClassDefined ("jalview.analysis.AnnotationSorter$1") ? 0 : jalview.analysis.AnnotationSorter.$AnnotationSorter$1$ ()), Clazz.innerTypeInstance (jalview.analysis.AnnotationSorter$1, this, null)); -this.byLabelAndSequence = ((Clazz.isClassDefined ("jalview.analysis.AnnotationSorter$2") ? 0 : jalview.analysis.AnnotationSorter.$AnnotationSorter$2$ ()), Clazz.innerTypeInstance (jalview.analysis.AnnotationSorter$2, this, null)); -this.noSort = ((Clazz.isClassDefined ("jalview.analysis.AnnotationSorter$3") ? 0 : jalview.analysis.AnnotationSorter.$AnnotationSorter$3$ ()), Clazz.innerTypeInstance (jalview.analysis.AnnotationSorter$3, this, null)); -}); -Clazz.makeConstructor (c$, -function (alignmentI, showAutocalculatedAbove) { -this.alignment = alignmentI; -this.showAutocalcAbove = showAutocalculatedAbove; -}, "jalview.datamodel.AlignmentI,~B"); -Clazz.defineMethod (c$, "sort", -function (alignmentAnnotations, order) { -if (alignmentAnnotations == null) { -return; -}this.saveSequenceIndices (alignmentAnnotations); -var comparator = this.getComparator (order); -if (alignmentAnnotations != null) { -{ -java.util.Arrays.sort (alignmentAnnotations, comparator); -}}}, "~A,jalview.analysis.AnnotationSorter.SequenceAnnotationOrder"); -Clazz.defineMethod (c$, "saveSequenceIndices", - function (alignmentAnnotations) { -this.sequenceIndices.clear (); -for (var ann, $ann = 0, $$ann = alignmentAnnotations; $ann < $$ann.length && ((ann = $$ann[$ann]) || true); $ann++) { -var seq = ann.sequenceRef; -if (seq != null) { -var index = jalview.analysis.AlignmentUtils.getSequenceIndex (this.alignment, seq); -this.sequenceIndices.put (seq, new Integer (index)); -}} -}, "~A"); -Clazz.defineMethod (c$, "getComparator", - function (order) { -if (order == null) { -return this.noSort; -}switch (order) { -case jalview.analysis.AnnotationSorter.SequenceAnnotationOrder.NONE: -return this.noSort; -case jalview.analysis.AnnotationSorter.SequenceAnnotationOrder.SEQUENCE_AND_LABEL: -return this.bySequenceAndLabel; -case jalview.analysis.AnnotationSorter.SequenceAnnotationOrder.LABEL_AND_SEQUENCE: -return this.byLabelAndSequence; -default: -throw new UnsupportedOperationException (order.toString ()); -} -}, "jalview.analysis.AnnotationSorter.SequenceAnnotationOrder"); -Clazz.defineMethod (c$, "compareLabels", - function (o1, o2) { -if (o1 == null || o2 == null) { -return 0; -}var label1 = o1.label; -var label2 = o2.label; -if (label1 == null && label2 == null) { -return 0; -}if (label1 == null) { -return -1; -}if (label2 == null) { -return 1; -}return label1.toUpperCase ().compareTo (label2.toUpperCase ()); -}, "jalview.datamodel.AlignmentAnnotation,jalview.datamodel.AlignmentAnnotation"); -Clazz.defineMethod (c$, "compareSequences", - function (o1, o2) { -var seq1 = o1.sequenceRef; -var seq2 = o2.sequenceRef; -if (seq1 == null && seq2 == null) { -return 0; -}if (seq1 == null) { -return this.showAutocalcAbove ? -1 : 1; -}if (seq2 == null) { -return this.showAutocalcAbove ? 1 : -1; -}var index1 = (this.sequenceIndices.get (seq1)).intValue (); -var index2 = (this.sequenceIndices.get (seq2)).intValue (); -if (index1 == index2) { -return 0; -}if (index1 == -1) { -return -1; -}if (index2 == -1) { -return 1; -}return Integer.compare (index1, index2); -}, "jalview.datamodel.AlignmentAnnotation,jalview.datamodel.AlignmentAnnotation"); -c$.$AnnotationSorter$1$ = function () { -Clazz.pu$h(self.c$); -c$ = Clazz.declareAnonymous (jalview.analysis, "AnnotationSorter$1", null, java.util.Comparator); -Clazz.overrideMethod (c$, "compare", -function (o1, o2) { -if (o1 == null && o2 == null) { -return 0; -}if (o1 == null) { -return -1; -}if (o2 == null) { -return 1; -}if (o1.sequenceRef == null && o2.sequenceRef == null) { -return 0; -}var sequenceOrder = this.b$["jalview.analysis.AnnotationSorter"].compareSequences (o1, o2); -return sequenceOrder == 0 ? this.b$["jalview.analysis.AnnotationSorter"].compareLabels (o1, o2) : sequenceOrder; -}, "jalview.datamodel.AlignmentAnnotation,jalview.datamodel.AlignmentAnnotation"); -c$ = Clazz.p0p (); -}; -c$.$AnnotationSorter$2$ = function () { -Clazz.pu$h(self.c$); -c$ = Clazz.declareAnonymous (jalview.analysis, "AnnotationSorter$2", null, java.util.Comparator); -Clazz.overrideMethod (c$, "compare", -function (o1, o2) { -if (o1 == null && o2 == null) { -return 0; -}if (o1 == null) { -return -1; -}if (o2 == null) { -return 1; -}if (o1.sequenceRef == null && o2.sequenceRef == null) { -return 0; -}if (o1.sequenceRef == null) { -return this.b$["jalview.analysis.AnnotationSorter"].showAutocalcAbove ? -1 : 1; -}if (o2.sequenceRef == null) { -return this.b$["jalview.analysis.AnnotationSorter"].showAutocalcAbove ? 1 : -1; -}var labelOrder = this.b$["jalview.analysis.AnnotationSorter"].compareLabels (o1, o2); -return labelOrder == 0 ? this.b$["jalview.analysis.AnnotationSorter"].compareSequences (o1, o2) : labelOrder; -}, "jalview.datamodel.AlignmentAnnotation,jalview.datamodel.AlignmentAnnotation"); -c$ = Clazz.p0p (); -}; -c$.$AnnotationSorter$3$ = function () { -Clazz.pu$h(self.c$); -c$ = Clazz.declareAnonymous (jalview.analysis, "AnnotationSorter$3", null, java.util.Comparator); -Clazz.overrideMethod (c$, "compare", -function (o1, o2) { -if (o1 != null && o2 != null) { -if (o1.sequenceRef == null && o2.sequenceRef != null) { -return this.b$["jalview.analysis.AnnotationSorter"].showAutocalcAbove ? -1 : 1; -}if (o1.sequenceRef != null && o2.sequenceRef == null) { -return this.b$["jalview.analysis.AnnotationSorter"].showAutocalcAbove ? 1 : -1; -}}return 0; -}, "jalview.datamodel.AlignmentAnnotation,jalview.datamodel.AlignmentAnnotation"); -c$ = Clazz.p0p (); -}; -Clazz.pu$h(self.c$); -c$ = Clazz.decorateAsClass (function () { -this.description = null; -Clazz.instantialize (this, arguments); -}, jalview.analysis.AnnotationSorter, "SequenceAnnotationOrder", Enum); -Clazz.makeConstructor (c$, - function (a) { -this.description = a; -}, "~S"); -Clazz.overrideMethod (c$, "toString", -function () { -return this.description; -}); -c$.forDescription = Clazz.defineMethod (c$, "forDescription", -function (a) { -for (var order, $order = 0, $$order = jalview.analysis.AnnotationSorter.SequenceAnnotationOrder.values (); $order < $$order.length && ((order = $$order[$order]) || true); $order++) { -if (order.toString ().equals (a)) { -return order; -}} -return null; -}, "~S"); -Clazz.defineEnumConstant (c$, "SEQUENCE_AND_LABEL", 0, ["Sequence"]); -Clazz.defineEnumConstant (c$, "LABEL_AND_SEQUENCE", 1, ["Label"]); -Clazz.defineEnumConstant (c$, "NONE", 2, ["No sort"]); -c$ = Clazz.p0p (); -}); +Clazz.declarePackage ("jalview.analysis"); +Clazz.load (["java.lang.Enum", "java.util.HashMap"], "jalview.analysis.AnnotationSorter", ["jalview.analysis.AlignmentUtils", "java.lang.UnsupportedOperationException", "java.util.Arrays"], function () { +c$ = Clazz.decorateAsClass (function () { +this.alignment = null; +this.showAutocalcAbove = false; +this.sequenceIndices = null; +this.bySequenceAndLabel = null; +this.byLabelAndSequence = null; +this.noSort = null; +Clazz.instantialize (this, arguments); +}, jalview.analysis, "AnnotationSorter"); +Clazz.prepareFields (c$, function () { +this.sequenceIndices = new java.util.HashMap (); +this.bySequenceAndLabel = ((Clazz.isClassDefined ("jalview.analysis.AnnotationSorter$1") ? 0 : jalview.analysis.AnnotationSorter.$AnnotationSorter$1$ ()), Clazz.innerTypeInstance (jalview.analysis.AnnotationSorter$1, this, null)); +this.byLabelAndSequence = ((Clazz.isClassDefined ("jalview.analysis.AnnotationSorter$2") ? 0 : jalview.analysis.AnnotationSorter.$AnnotationSorter$2$ ()), Clazz.innerTypeInstance (jalview.analysis.AnnotationSorter$2, this, null)); +this.noSort = ((Clazz.isClassDefined ("jalview.analysis.AnnotationSorter$3") ? 0 : jalview.analysis.AnnotationSorter.$AnnotationSorter$3$ ()), Clazz.innerTypeInstance (jalview.analysis.AnnotationSorter$3, this, null)); +}); +Clazz.makeConstructor (c$, +function (alignmentI, showAutocalculatedAbove) { +this.alignment = alignmentI; +this.showAutocalcAbove = showAutocalculatedAbove; +}, "jalview.datamodel.AlignmentI,~B"); +Clazz.defineMethod (c$, "sort", +function (alignmentAnnotations, order) { +if (alignmentAnnotations == null) { +return; +}this.saveSequenceIndices (alignmentAnnotations); +var comparator = this.getComparator (order); +if (alignmentAnnotations != null) { +{ +java.util.Arrays.sort (alignmentAnnotations, comparator); +}}}, "~A,jalview.analysis.AnnotationSorter.SequenceAnnotationOrder"); +Clazz.defineMethod (c$, "saveSequenceIndices", + function (alignmentAnnotations) { +this.sequenceIndices.clear (); +for (var ann, $ann = 0, $$ann = alignmentAnnotations; $ann < $$ann.length && ((ann = $$ann[$ann]) || true); $ann++) { +var seq = ann.sequenceRef; +if (seq != null) { +var index = jalview.analysis.AlignmentUtils.getSequenceIndex (this.alignment, seq); +this.sequenceIndices.put (seq, new Integer (index)); +}} +}, "~A"); +Clazz.defineMethod (c$, "getComparator", + function (order) { +if (order == null) { +return this.noSort; +}switch (order) { +case jalview.analysis.AnnotationSorter.SequenceAnnotationOrder.NONE: +return this.noSort; +case jalview.analysis.AnnotationSorter.SequenceAnnotationOrder.SEQUENCE_AND_LABEL: +return this.bySequenceAndLabel; +case jalview.analysis.AnnotationSorter.SequenceAnnotationOrder.LABEL_AND_SEQUENCE: +return this.byLabelAndSequence; +default: +throw new UnsupportedOperationException (order.toString ()); +} +}, "jalview.analysis.AnnotationSorter.SequenceAnnotationOrder"); +Clazz.defineMethod (c$, "compareLabels", + function (o1, o2) { +if (o1 == null || o2 == null) { +return 0; +}var label1 = o1.label; +var label2 = o2.label; +if (label1 == null && label2 == null) { +return 0; +}if (label1 == null) { +return -1; +}if (label2 == null) { +return 1; +}return label1.toUpperCase ().compareTo (label2.toUpperCase ()); +}, "jalview.datamodel.AlignmentAnnotation,jalview.datamodel.AlignmentAnnotation"); +Clazz.defineMethod (c$, "compareSequences", + function (o1, o2) { +var seq1 = o1.sequenceRef; +var seq2 = o2.sequenceRef; +if (seq1 == null && seq2 == null) { +return 0; +}if (seq1 == null) { +return this.showAutocalcAbove ? -1 : 1; +}if (seq2 == null) { +return this.showAutocalcAbove ? 1 : -1; +}var index1 = (this.sequenceIndices.get (seq1)).intValue (); +var index2 = (this.sequenceIndices.get (seq2)).intValue (); +if (index1 == index2) { +return 0; +}if (index1 == -1) { +return -1; +}if (index2 == -1) { +return 1; +}return Integer.compare (index1, index2); +}, "jalview.datamodel.AlignmentAnnotation,jalview.datamodel.AlignmentAnnotation"); +c$.$AnnotationSorter$1$ = function () { +Clazz.pu$h(self.c$); +c$ = Clazz.declareAnonymous (jalview.analysis, "AnnotationSorter$1", null, java.util.Comparator); +Clazz.overrideMethod (c$, "compare", +function (o1, o2) { +if (o1 == null && o2 == null) { +return 0; +}if (o1 == null) { +return -1; +}if (o2 == null) { +return 1; +}if (o1.sequenceRef == null && o2.sequenceRef == null) { +return 0; +}var sequenceOrder = this.b$["jalview.analysis.AnnotationSorter"].compareSequences (o1, o2); +return sequenceOrder == 0 ? this.b$["jalview.analysis.AnnotationSorter"].compareLabels (o1, o2) : sequenceOrder; +}, "jalview.datamodel.AlignmentAnnotation,jalview.datamodel.AlignmentAnnotation"); +c$ = Clazz.p0p (); +}; +c$.$AnnotationSorter$2$ = function () { +Clazz.pu$h(self.c$); +c$ = Clazz.declareAnonymous (jalview.analysis, "AnnotationSorter$2", null, java.util.Comparator); +Clazz.overrideMethod (c$, "compare", +function (o1, o2) { +if (o1 == null && o2 == null) { +return 0; +}if (o1 == null) { +return -1; +}if (o2 == null) { +return 1; +}if (o1.sequenceRef == null && o2.sequenceRef == null) { +return 0; +}if (o1.sequenceRef == null) { +return this.b$["jalview.analysis.AnnotationSorter"].showAutocalcAbove ? -1 : 1; +}if (o2.sequenceRef == null) { +return this.b$["jalview.analysis.AnnotationSorter"].showAutocalcAbove ? 1 : -1; +}var labelOrder = this.b$["jalview.analysis.AnnotationSorter"].compareLabels (o1, o2); +return labelOrder == 0 ? this.b$["jalview.analysis.AnnotationSorter"].compareSequences (o1, o2) : labelOrder; +}, "jalview.datamodel.AlignmentAnnotation,jalview.datamodel.AlignmentAnnotation"); +c$ = Clazz.p0p (); +}; +c$.$AnnotationSorter$3$ = function () { +Clazz.pu$h(self.c$); +c$ = Clazz.declareAnonymous (jalview.analysis, "AnnotationSorter$3", null, java.util.Comparator); +Clazz.overrideMethod (c$, "compare", +function (o1, o2) { +if (o1 != null && o2 != null) { +if (o1.sequenceRef == null && o2.sequenceRef != null) { +return this.b$["jalview.analysis.AnnotationSorter"].showAutocalcAbove ? -1 : 1; +}if (o1.sequenceRef != null && o2.sequenceRef == null) { +return this.b$["jalview.analysis.AnnotationSorter"].showAutocalcAbove ? 1 : -1; +}}return 0; +}, "jalview.datamodel.AlignmentAnnotation,jalview.datamodel.AlignmentAnnotation"); +c$ = Clazz.p0p (); +}; +Clazz.pu$h(self.c$); +c$ = Clazz.decorateAsClass (function () { +this.description = null; +Clazz.instantialize (this, arguments); +}, jalview.analysis.AnnotationSorter, "SequenceAnnotationOrder", Enum); +Clazz.makeConstructor (c$, + function (a) { +this.description = a; +}, "~S"); +Clazz.overrideMethod (c$, "toString", +function () { +return this.description; +}); +c$.forDescription = Clazz.defineMethod (c$, "forDescription", +function (a) { +for (var order, $order = 0, $$order = jalview.analysis.AnnotationSorter.SequenceAnnotationOrder.values (); $order < $$order.length && ((order = $$order[$order]) || true); $order++) { +if (order.toString ().equals (a)) { +return order; +}} +return null; +}, "~S"); +Clazz.defineEnumConstant (c$, "SEQUENCE_AND_LABEL", 0, ["Sequence"]); +Clazz.defineEnumConstant (c$, "LABEL_AND_SEQUENCE", 1, ["Label"]); +Clazz.defineEnumConstant (c$, "NONE", 2, ["No sort"]); +c$ = Clazz.p0p (); +});