1 Clazz.declarePackage ("jalview.analysis");
2 Clazz.load (["java.lang.Enum", "java.util.HashMap"], "jalview.analysis.AnnotationSorter", ["jalview.analysis.AlignmentUtils", "java.lang.UnsupportedOperationException", "java.util.Arrays"], function () {
3 c$ = Clazz.decorateAsClass (function () {
5 this.showAutocalcAbove = false;
6 this.sequenceIndices = null;
7 this.bySequenceAndLabel = null;
8 this.byLabelAndSequence = null;
10 Clazz.instantialize (this, arguments);
11 }, jalview.analysis, "AnnotationSorter");
12 Clazz.prepareFields (c$, function () {
13 this.sequenceIndices = new java.util.HashMap ();
14 this.bySequenceAndLabel = ((Clazz.isClassDefined ("jalview.analysis.AnnotationSorter$1") ? 0 : jalview.analysis.AnnotationSorter.$AnnotationSorter$1$ ()), Clazz.innerTypeInstance (jalview.analysis.AnnotationSorter$1, this, null));
15 this.byLabelAndSequence = ((Clazz.isClassDefined ("jalview.analysis.AnnotationSorter$2") ? 0 : jalview.analysis.AnnotationSorter.$AnnotationSorter$2$ ()), Clazz.innerTypeInstance (jalview.analysis.AnnotationSorter$2, this, null));
16 this.noSort = ((Clazz.isClassDefined ("jalview.analysis.AnnotationSorter$3") ? 0 : jalview.analysis.AnnotationSorter.$AnnotationSorter$3$ ()), Clazz.innerTypeInstance (jalview.analysis.AnnotationSorter$3, this, null));
18 Clazz.makeConstructor (c$,
19 function (alignmentI, showAutocalculatedAbove) {
20 this.alignment = alignmentI;
21 this.showAutocalcAbove = showAutocalculatedAbove;
22 }, "jalview.datamodel.AlignmentI,~B");
23 Clazz.defineMethod (c$, "sort",
24 function (alignmentAnnotations, order) {
25 if (alignmentAnnotations == null) {
27 }this.saveSequenceIndices (alignmentAnnotations);
28 var comparator = this.getComparator (order);
29 if (alignmentAnnotations != null) {
31 java.util.Arrays.sort (alignmentAnnotations, comparator);
32 }}}, "~A,jalview.analysis.AnnotationSorter.SequenceAnnotationOrder");
33 Clazz.defineMethod (c$, "saveSequenceIndices",
34 function (alignmentAnnotations) {
35 this.sequenceIndices.clear ();
36 for (var ann, $ann = 0, $$ann = alignmentAnnotations; $ann < $$ann.length && ((ann = $$ann[$ann]) || true); $ann++) {
37 var seq = ann.sequenceRef;
39 var index = jalview.analysis.AlignmentUtils.getSequenceIndex (this.alignment, seq);
40 this.sequenceIndices.put (seq, new Integer (index));
43 Clazz.defineMethod (c$, "getComparator",
48 case jalview.analysis.AnnotationSorter.SequenceAnnotationOrder.NONE:
50 case jalview.analysis.AnnotationSorter.SequenceAnnotationOrder.SEQUENCE_AND_LABEL:
51 return this.bySequenceAndLabel;
52 case jalview.analysis.AnnotationSorter.SequenceAnnotationOrder.LABEL_AND_SEQUENCE:
53 return this.byLabelAndSequence;
55 throw new UnsupportedOperationException (order.toString ());
57 }, "jalview.analysis.AnnotationSorter.SequenceAnnotationOrder");
58 Clazz.defineMethod (c$, "compareLabels",
60 if (o1 == null || o2 == null) {
62 }var label1 = o1.label;
63 var label2 = o2.label;
64 if (label1 == null && label2 == null) {
66 }if (label1 == null) {
68 }if (label2 == null) {
70 }return label1.toUpperCase ().compareTo (label2.toUpperCase ());
71 }, "jalview.datamodel.AlignmentAnnotation,jalview.datamodel.AlignmentAnnotation");
72 Clazz.defineMethod (c$, "compareSequences",
74 var seq1 = o1.sequenceRef;
75 var seq2 = o2.sequenceRef;
76 if (seq1 == null && seq2 == null) {
79 return this.showAutocalcAbove ? -1 : 1;
81 return this.showAutocalcAbove ? 1 : -1;
82 }var index1 = (this.sequenceIndices.get (seq1)).intValue ();
83 var index2 = (this.sequenceIndices.get (seq2)).intValue ();
84 if (index1 == index2) {
90 }return Integer.compare (index1, index2);
91 }, "jalview.datamodel.AlignmentAnnotation,jalview.datamodel.AlignmentAnnotation");
92 c$.$AnnotationSorter$1$ = function () {
94 c$ = Clazz.declareAnonymous (jalview.analysis, "AnnotationSorter$1", null, java.util.Comparator);
95 Clazz.overrideMethod (c$, "compare",
97 if (o1 == null && o2 == null) {
103 }if (o1.sequenceRef == null && o2.sequenceRef == null) {
105 }var sequenceOrder = this.b$["jalview.analysis.AnnotationSorter"].compareSequences (o1, o2);
106 return sequenceOrder == 0 ? this.b$["jalview.analysis.AnnotationSorter"].compareLabels (o1, o2) : sequenceOrder;
107 }, "jalview.datamodel.AlignmentAnnotation,jalview.datamodel.AlignmentAnnotation");
110 c$.$AnnotationSorter$2$ = function () {
112 c$ = Clazz.declareAnonymous (jalview.analysis, "AnnotationSorter$2", null, java.util.Comparator);
113 Clazz.overrideMethod (c$, "compare",
115 if (o1 == null && o2 == null) {
121 }if (o1.sequenceRef == null && o2.sequenceRef == null) {
123 }if (o1.sequenceRef == null) {
124 return this.b$["jalview.analysis.AnnotationSorter"].showAutocalcAbove ? -1 : 1;
125 }if (o2.sequenceRef == null) {
126 return this.b$["jalview.analysis.AnnotationSorter"].showAutocalcAbove ? 1 : -1;
127 }var labelOrder = this.b$["jalview.analysis.AnnotationSorter"].compareLabels (o1, o2);
128 return labelOrder == 0 ? this.b$["jalview.analysis.AnnotationSorter"].compareSequences (o1, o2) : labelOrder;
129 }, "jalview.datamodel.AlignmentAnnotation,jalview.datamodel.AlignmentAnnotation");
132 c$.$AnnotationSorter$3$ = function () {
134 c$ = Clazz.declareAnonymous (jalview.analysis, "AnnotationSorter$3", null, java.util.Comparator);
135 Clazz.overrideMethod (c$, "compare",
137 if (o1 != null && o2 != null) {
138 if (o1.sequenceRef == null && o2.sequenceRef != null) {
139 return this.b$["jalview.analysis.AnnotationSorter"].showAutocalcAbove ? -1 : 1;
140 }if (o1.sequenceRef != null && o2.sequenceRef == null) {
141 return this.b$["jalview.analysis.AnnotationSorter"].showAutocalcAbove ? 1 : -1;
143 }, "jalview.datamodel.AlignmentAnnotation,jalview.datamodel.AlignmentAnnotation");
147 c$ = Clazz.decorateAsClass (function () {
148 this.description = null;
149 Clazz.instantialize (this, arguments);
150 }, jalview.analysis.AnnotationSorter, "SequenceAnnotationOrder", Enum);
151 Clazz.makeConstructor (c$,
153 this.description = a;
155 Clazz.overrideMethod (c$, "toString",
157 return this.description;
159 c$.forDescription = Clazz.defineMethod (c$, "forDescription",
161 for (var order, $order = 0, $$order = jalview.analysis.AnnotationSorter.SequenceAnnotationOrder.values (); $order < $$order.length && ((order = $$order[$order]) || true); $order++) {
162 if (order.toString ().equals (a)) {
167 Clazz.defineEnumConstant (c$, "SEQUENCE_AND_LABEL", 0, ["Sequence"]);
168 Clazz.defineEnumConstant (c$, "LABEL_AND_SEQUENCE", 1, ["Label"]);
169 Clazz.defineEnumConstant (c$, "NONE", 2, ["No sort"]);