1 Clazz.declarePackage ("jalview.datamodel");
2 Clazz.load (null, "jalview.datamodel.AlignedCodonFrame", ["jalview.datamodel.Mapping", "jalview.util.MappingUtils", "java.util.ArrayList"], function () {
3 c$ = Clazz.decorateAsClass (function () {
6 Clazz.instantialize (this, arguments);
7 }, jalview.datamodel, "AlignedCodonFrame");
8 Clazz.makeConstructor (c$,
11 Clazz.defineMethod (c$, "addMap",
12 function (dnaseq, aaseq, map) {
14 if (this.dnaSeqs != null) {
15 nlen = this.dnaSeqs.length + 1;
16 }var ndna = new Array (nlen);
17 var ndtp = new Array (nlen);
18 if (this.dnaSeqs != null) {
19 System.arraycopy (this.dnaSeqs, 0, ndna, 0, this.dnaSeqs.length);
20 System.arraycopy (this.dnaToProt, 0, ndtp, 0, this.dnaSeqs.length);
22 this.dnaToProt = ndtp;
24 this.dnaSeqs[nlen] = (dnaseq.getDatasetSequence () == null) ? dnaseq : dnaseq.getDatasetSequence ();
25 var mp = new jalview.datamodel.Mapping (map);
26 mp.to = (aaseq.getDatasetSequence () == null) ? aaseq : aaseq.getDatasetSequence ();
27 this.dnaToProt[nlen] = mp;
28 }, "jalview.datamodel.SequenceI,jalview.datamodel.SequenceI,jalview.util.MapList");
29 Clazz.defineMethod (c$, "getdnaSeqs",
33 Clazz.defineMethod (c$, "getAaSeqs",
35 if (this.dnaToProt == null) {
37 }var sqs = new Array (this.dnaToProt.length);
38 for (var sz = 0; sz < this.dnaToProt.length; sz++) {
39 sqs[sz] = this.dnaToProt[sz].to;
43 Clazz.defineMethod (c$, "getdnaToProt",
45 if (this.dnaToProt == null) {
47 }var sqs = new Array (this.dnaToProt.length);
48 for (var sz = 0; sz < this.dnaToProt.length; sz++) {
49 sqs[sz] = this.dnaToProt[sz].map;
53 Clazz.defineMethod (c$, "getProtMappings",
55 return this.dnaToProt;
57 Clazz.defineMethod (c$, "getMappingForSequence",
59 if (this.dnaSeqs == null) {
61 }var seqDs = seq.getDatasetSequence ();
62 seqDs = seqDs != null ? seqDs : seq;
63 for (var ds = 0; ds < this.dnaSeqs.length; ds++) {
64 if (this.dnaSeqs[ds] === seqDs || this.dnaToProt[ds].to === seqDs) {
65 return this.dnaToProt[ds];
68 }, "jalview.datamodel.SequenceI");
69 Clazz.defineMethod (c$, "getAaForDnaSeq",
70 function (dnaSeqRef) {
71 if (this.dnaSeqs == null) {
73 }var dnads = dnaSeqRef.getDatasetSequence ();
74 for (var ds = 0; ds < this.dnaSeqs.length; ds++) {
75 if (this.dnaSeqs[ds] === dnaSeqRef || this.dnaSeqs[ds] === dnads) {
76 return this.dnaToProt[ds].to;
79 }, "jalview.datamodel.SequenceI");
80 Clazz.defineMethod (c$, "getDnaForAaSeq",
82 if (this.dnaToProt == null) {
84 }var aads = aaSeqRef.getDatasetSequence ();
85 for (var as = 0; as < this.dnaToProt.length; as++) {
86 if (this.dnaToProt[as].to === aaSeqRef || this.dnaToProt[as].to === aads) {
87 return this.dnaSeqs[as];
90 }, "jalview.datamodel.SequenceI");
91 Clazz.defineMethod (c$, "involvesSequence",
93 return this.getAaForDnaSeq (seq) != null || this.getDnaForAaSeq (seq) != null;
94 }, "jalview.datamodel.SequenceI");
95 Clazz.defineMethod (c$, "markMappedRegion",
96 function (seq, index, results) {
97 if (this.dnaToProt == null) {
100 var ds = seq.getDatasetSequence ();
101 for (var mi = 0; mi < this.dnaToProt.length; mi++) {
102 if (this.dnaSeqs[mi] === seq || this.dnaSeqs[mi] === ds) {
103 codon = this.dnaToProt[mi].map.locateInTo (index, index);
105 for (var i = 0; i < codon.length; i += 2) {
106 results.addResult (this.dnaToProt[mi].to, codon[i], codon[i + 1]);
108 }} else if (this.dnaToProt[mi].to === seq || this.dnaToProt[mi].to === ds) {
110 codon = this.dnaToProt[mi].map.locateInFrom (index, index);
112 for (var i = 0; i < codon.length; i += 2) {
113 results.addResult (this.dnaSeqs[mi], codon[i], codon[i + 1]);
116 }, "jalview.datamodel.SequenceI,~N,jalview.datamodel.SearchResults");
117 Clazz.defineMethod (c$, "getDnaPosition",
118 function (seq, aaPos) {
120 for (var i = 0; i < this.dnaToProt.length; i++) {
121 if (this.dnaSeqs[i] === seq) {
122 ml = this.getdnaToProt ()[i];
125 return ml == null ? null : ml.locateInFrom (aaPos, aaPos);
126 }, "jalview.datamodel.SequenceI,~N");
127 Clazz.defineMethod (c$, "findAlignedSequence",
129 if (this.dnaToProt != null) {
130 for (var i = 0; i < this.dnaToProt.length; i++) {
131 if (this.dnaSeqs[i] === seq) {
132 for (var sourceAligned, $sourceAligned = al.getSequences ().iterator (); $sourceAligned.hasNext () && ((sourceAligned = $sourceAligned.next ()) || true);) {
133 if (this.dnaToProt[i].to === sourceAligned.getDatasetSequence ()) {
134 return sourceAligned;
137 }if (this.dnaToProt != null) {
138 for (var i = 0; i < this.dnaToProt.length; i++) {
139 if (this.dnaToProt[i].to === seq) {
140 for (var sourceAligned, $sourceAligned = al.getSequences ().iterator (); $sourceAligned.hasNext () && ((sourceAligned = $sourceAligned.next ()) || true);) {
141 if (this.dnaSeqs[i] === sourceAligned.getDatasetSequence ()) {
142 return sourceAligned;
146 }, "jalview.datamodel.SequenceI,jalview.datamodel.AlignmentI");
147 Clazz.defineMethod (c$, "getMappedRegion",
148 function (mappedFrom, mappedTo, pos) {
149 var targetDs = mappedFrom.getDatasetSequence () == null ? mappedFrom : mappedFrom.getDatasetSequence ();
150 var sourceDs = mappedTo.getDatasetSequence () == null ? mappedTo : mappedTo.getDatasetSequence ();
151 if (targetDs == null || sourceDs == null || this.dnaToProt == null) {
153 }for (var mi = 0; mi < this.dnaToProt.length; mi++) {
154 if (this.dnaSeqs[mi] === targetDs && this.dnaToProt[mi].to === sourceDs) {
155 var codon = this.dnaToProt[mi].map.locateInFrom (pos, pos);
160 }, "jalview.datamodel.SequenceI,jalview.datamodel.SequenceI,~N");
161 Clazz.defineMethod (c$, "getMappedCodon",
162 function (protein, aaPos) {
163 if (this.dnaToProt == null) {
167 for (var i = 0; i < this.dnaToProt.length; i++) {
168 if (this.dnaToProt[i].to === protein) {
169 ml = this.getdnaToProt ()[i];
170 dnaSeq = this.dnaSeqs[i].getSequence ();
175 }var codonPos = ml.locateInFrom (aaPos, aaPos);
176 if (codonPos == null) {
178 }codonPos = jalview.util.MappingUtils.flattenRanges (codonPos);
179 return Clazz.newCharArray (-1, [dnaSeq[codonPos[0] - 1], dnaSeq[codonPos[1] - 1], dnaSeq[codonPos[2] - 1]]);
180 }, "jalview.datamodel.SequenceI,~N");
181 Clazz.defineMethod (c$, "getMappingsForSequence",
183 var result = new java.util.ArrayList ();
184 if (this.dnaSeqs == null) {
186 }var related = new java.util.ArrayList ();
187 var seqDs = seq.getDatasetSequence ();
188 seqDs = seqDs != null ? seqDs : seq;
189 for (var ds = 0; ds < this.dnaSeqs.length; ds++) {
190 var mapping = this.dnaToProt[ds];
191 if (this.dnaSeqs[ds] === seqDs || mapping.to === seqDs) {
192 if (!related.contains (mapping.to)) {
193 result.add (mapping);
194 related.add (mapping.to);
197 }, "jalview.datamodel.SequenceI");