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