1 Clazz.declarePackage ("jalview.analysis");
2 Clazz.load (null, "jalview.analysis.AlignmentUtils", ["jalview.analysis.CodonComparator", "jalview.datamodel.AlignedCodonFrame", "$.Alignment", "$.AlignmentAnnotation", "$.DBRefEntry", "$.DBRefSource", "$.FeatureProperties", "$.SearchResults", "$.Sequence", "jalview.schemes.ResidueProperties", "jalview.util.DBRefUtils", "$.MapList", "$.MappingUtils", "java.lang.StringBuilder", "java.util.ArrayList", "$.Arrays", "$.HashMap", "$.HashSet", "$.LinkedHashMap", "$.LinkedHashSet", "$.TreeMap"], function () {
3 c$ = Clazz.declareType (jalview.analysis, "AlignmentUtils");
4 c$.expandContext = Clazz.defineMethod (c$, "expandContext",
5 function (core, flankSize) {
6 var sq = new java.util.ArrayList ();
8 for (var s, $s = core.getSequences ().iterator (); $s.hasNext () && ((s = $s.next ()) || true);) {
9 var newSeq = s.deriveSequence ();
10 var newSeqStart = newSeq.getStart () - 1;
11 if (newSeqStart > maxoffset && newSeq.getDatasetSequence ().getStart () < s.getStart ()) {
12 maxoffset = newSeqStart;
16 maxoffset = Math.min (maxoffset, flankSize);
17 }for (var s, $s = sq.iterator (); $s.hasNext () && ((s = $s.next ()) || true);) {
19 while (ds.getDatasetSequence () != null) {
20 ds = ds.getDatasetSequence ();
22 var s_end = s.findPosition (s.getStart () + s.getLength ());
23 var ustream_ds = s.getStart () - ds.getStart ();
24 var dstream_ds = ds.getEnd () - s_end;
25 var offset = maxoffset - ustream_ds;
27 if (flankSize < ustream_ds) {
28 offset = maxoffset - flankSize;
29 ustream_ds = flankSize;
30 }if (flankSize <= dstream_ds) {
31 dstream_ds = flankSize - 1;
32 }}var upstream = String.instantialize (ds.getSequence (s.getStart () - 1 - ustream_ds, s.getStart () - 1)).toLowerCase ().toCharArray ();
33 var downstream = String.instantialize (ds.getSequence (s_end - 1, s_end + dstream_ds)).toLowerCase ().toCharArray ();
34 var coreseq = s.getSequence ();
35 var nseq = Clazz.newCharArray (offset + upstream.length + downstream.length + coreseq.length, '\0');
36 var c = core.getGapCharacter ();
38 for (; p < offset; p++) {
41 System.arraycopy (upstream, 0, nseq, p, upstream.length);
42 System.arraycopy (coreseq, 0, nseq, p + upstream.length, coreseq.length);
43 System.arraycopy (downstream, 0, nseq, p + coreseq.length + upstream.length, downstream.length);
44 s.setSequence ( String.instantialize (nseq));
45 s.setStart (s.getStart () - ustream_ds);
46 s.setEnd (s_end + downstream.length);
48 var newAl = new jalview.datamodel.Alignment (sq.toArray ( new Array (0)));
49 for (var s, $s = sq.iterator (); $s.hasNext () && ((s = $s.next ()) || true);) {
50 if (s.getAnnotation () != null) {
51 for (var aa, $aa = 0, $$aa = s.getAnnotation (); $aa < $$aa.length && ((aa = $$aa[$aa]) || true); $aa++) {
52 aa.adjustForAlignment ();
53 newAl.addAnnotation (aa);
56 newAl.setDataset (core.getDataset ());
58 }, "jalview.datamodel.AlignmentI,~N");
59 c$.getSequenceIndex = Clazz.defineMethod (c$, "getSequenceIndex",
63 for (var alSeq, $alSeq = al.getSequences ().iterator (); $alSeq.hasNext () && ((alSeq = $alSeq.next ()) || true);) {
70 }, "jalview.datamodel.AlignmentI,jalview.datamodel.SequenceI");
71 c$.getSequencesByName = Clazz.defineMethod (c$, "getSequencesByName",
73 var theMap = new java.util.LinkedHashMap ();
74 for (var seq, $seq = al.getSequences ().iterator (); $seq.hasNext () && ((seq = $seq.next ()) || true);) {
75 var name = seq.getName ();
77 var seqs = theMap.get (name);
79 seqs = new java.util.ArrayList ();
80 theMap.put (name, seqs);
84 }, "jalview.datamodel.AlignmentI");
85 c$.mapProteinToCdna = Clazz.defineMethod (c$, "mapProteinToCdna",
86 function (proteinAlignment, cdnaAlignment) {
87 if (proteinAlignment == null || cdnaAlignment == null) {
89 }var mappedDna = new java.util.HashSet ();
90 var mappedProtein = new java.util.HashSet ();
91 var mappingPerformed = jalview.analysis.AlignmentUtils.mapProteinToCdna (proteinAlignment, cdnaAlignment, mappedDna, mappedProtein, true);
92 mappingPerformed = new Boolean (mappingPerformed | jalview.analysis.AlignmentUtils.mapProteinToCdna (proteinAlignment, cdnaAlignment, mappedDna, mappedProtein, false)).valueOf ();
93 return mappingPerformed;
94 }, "jalview.datamodel.AlignmentI,jalview.datamodel.AlignmentI");
95 c$.mapProteinToCdna = Clazz.defineMethod (c$, "mapProteinToCdna",
96 function (proteinAlignment, cdnaAlignment, mappedDna, mappedProtein, xrefsOnly) {
97 var mappingPerformed = false;
98 var thisSeqs = proteinAlignment.getSequences ();
99 for (var aaSeq, $aaSeq = thisSeqs.iterator (); $aaSeq.hasNext () && ((aaSeq = $aaSeq.next ()) || true);) {
100 var proteinMapped = false;
101 var acf = new jalview.datamodel.AlignedCodonFrame ();
102 for (var cdnaSeq, $cdnaSeq = cdnaAlignment.getSequences ().iterator (); $cdnaSeq.hasNext () && ((cdnaSeq = $cdnaSeq.next ()) || true);) {
103 if (xrefsOnly && !jalview.analysis.AlignmentUtils.haveCrossRef (aaSeq, cdnaSeq)) {
105 }if (!xrefsOnly && (mappedProtein.contains (aaSeq) || mappedDna.contains (cdnaSeq))) {
107 }if (!jalview.analysis.AlignmentUtils.mappingExists (proteinAlignment.getCodonFrames (), aaSeq.getDatasetSequence (), cdnaSeq.getDatasetSequence ())) {
108 var map = jalview.analysis.AlignmentUtils.mapProteinToCdna (aaSeq, cdnaSeq);
110 acf.addMap (cdnaSeq, aaSeq, map);
111 mappingPerformed = true;
112 proteinMapped = true;
113 mappedDna.add (cdnaSeq);
114 mappedProtein.add (aaSeq);
117 proteinAlignment.addCodonFrame (acf);
119 return mappingPerformed;
120 }, "jalview.datamodel.AlignmentI,jalview.datamodel.AlignmentI,java.util.Set,java.util.Set,~B");
121 c$.mappingExists = Clazz.defineMethod (c$, "mappingExists",
122 function (set, aaSeq, cdnaSeq) {
124 for (var acf, $acf = set.iterator (); $acf.hasNext () && ((acf = $acf.next ()) || true);) {
125 if (cdnaSeq === acf.getDnaForAaSeq (aaSeq)) {
129 }, "java.util.Set,jalview.datamodel.SequenceI,jalview.datamodel.SequenceI");
130 c$.mapProteinToCdna = Clazz.defineMethod (c$, "mapProteinToCdna",
131 function (proteinSeq, cdnaSeq) {
132 var proteinDataset = proteinSeq.getDatasetSequence ();
133 var aaSeqChars = proteinDataset != null ? proteinDataset.getSequence () : proteinSeq.getSequence ();
134 var cdnaDataset = cdnaSeq.getDatasetSequence ();
135 var cdnaSeqChars = cdnaDataset != null ? cdnaDataset.getSequence () : cdnaSeq.getSequence ();
136 if (aaSeqChars == null || cdnaSeqChars == null) {
138 }var mappedLength = 3 * aaSeqChars.length;
139 var cdnaLength = cdnaSeqChars.length;
141 var cdnaEnd = cdnaLength;
142 var proteinStart = 1;
143 var proteinEnd = aaSeqChars.length;
144 if (cdnaLength != mappedLength && cdnaLength > 2) {
145 var lastCodon = String.valueOf (cdnaSeqChars, cdnaLength - 3, 3).toUpperCase ();
146 for (var stop, $stop = jalview.schemes.ResidueProperties.STOP.iterator (); $stop.hasNext () && ((stop = $stop.next ()) || true);) {
147 if (lastCodon.equals (stop)) {
152 }if (cdnaLength != mappedLength && cdnaLength > 2 && String.valueOf (cdnaSeqChars, 0, 3).toUpperCase ().equals (jalview.schemes.ResidueProperties.START)) {
155 }if (cdnaLength != mappedLength) {
157 }if (!jalview.analysis.AlignmentUtils.translatesAs (cdnaSeqChars, cdnaStart - 1, aaSeqChars)) {
159 }var map = new jalview.util.MapList ( Clazz.newIntArray (-1, [cdnaStart, cdnaEnd]), Clazz.newIntArray (-1, [1, proteinEnd]), 3, 1);
161 }, "jalview.datamodel.SequenceI,jalview.datamodel.SequenceI");
162 c$.translatesAs = Clazz.defineMethod (c$, "translatesAs",
163 function (cdnaSeqChars, cdnaStart, aaSeqChars) {
165 for (var i = cdnaStart; i < cdnaSeqChars.length - 2 && aaResidue < aaSeqChars.length; i += 3, aaResidue++) {
166 var codon = String.valueOf (cdnaSeqChars, i, 3);
167 var translated = jalview.schemes.ResidueProperties.codonTranslate (codon);
168 var aaRes = aaSeqChars[aaResidue];
169 if ((translated == null || "STOP".equals (translated)) && aaRes == 'X') {
171 }if (translated == null || !(aaRes == translated.charAt (0))) {
174 return (aaResidue == aaSeqChars.length);
176 c$.alignSequenceAs = Clazz.defineMethod (c$, "alignSequenceAs",
177 function (seq, al, gap, preserveMappedGaps, preserveUnmappedGaps) {
178 var mappings = al.getCodonFrame (seq);
179 if (mappings == null || mappings.isEmpty ()) {
181 }var alignFrom = null;
183 for (var mp, $mp = mappings.iterator (); $mp.hasNext () && ((mp = $mp.next ()) || true);) {
184 alignFrom = mp.findAlignedSequence (seq.getDatasetSequence (), al);
185 if (alignFrom != null) {
189 if (alignFrom == null) {
191 }jalview.analysis.AlignmentUtils.alignSequenceAs (seq, alignFrom, mapping, gap, al.getGapCharacter (), preserveMappedGaps, preserveUnmappedGaps);
193 }, "jalview.datamodel.SequenceI,jalview.datamodel.AlignmentI,~S,~B,~B");
194 c$.alignSequenceAs = Clazz.defineMethod (c$, "alignSequenceAs",
195 function (alignTo, alignFrom, mapping, myGap, sourceGap, preserveMappedGaps, preserveUnmappedGaps) {
196 var thisSeq = alignTo.getSequence ();
197 var thatAligned = alignFrom.getSequence ();
198 var thisAligned = new StringBuilder (2 * thisSeq.length);
201 var basesWritten = 0;
202 var myGapChar = myGap.charAt (0);
203 var ratio = myGap.length;
204 var sourceGapMappedLength = 0;
206 for (var sourceChar, $sourceChar = 0, $$sourceChar = thatAligned; $sourceChar < $$sourceChar.length && ((sourceChar = $$sourceChar[$sourceChar]) || true); $sourceChar++) {
207 if (sourceChar == sourceGap) {
208 sourceGapMappedLength += ratio;
211 var mappedPos = mapping.getMappedRegion (alignTo, alignFrom, sourceDsPos);
212 if (mappedPos == null) {
213 System.err.println ("Can't align: no codon mapping to residue " + sourceDsPos + "(" + sourceChar + ")");
215 }var mappedCodonStart = mappedPos[0];
216 var mappedCodonEnd = mappedPos[mappedPos.length - 1];
217 var trailingCopiedGap = new StringBuilder ();
218 var intronLength = 0;
219 while (basesWritten < mappedCodonEnd && thisSeqPos < thisSeq.length) {
220 var c = thisSeq[thisSeqPos++];
221 if (c != myGapChar) {
223 if (basesWritten < mappedCodonStart) {
224 if (preserveUnmappedGaps && trailingCopiedGap.length () > 0) {
225 thisAligned.append (trailingCopiedGap.toString ());
226 intronLength += trailingCopiedGap.length ();
227 trailingCopiedGap = new StringBuilder ();
231 var startOfCodon = basesWritten == mappedCodonStart;
232 var gapsToAdd = jalview.analysis.AlignmentUtils.calculateGapsToInsert (preserveMappedGaps, preserveUnmappedGaps, sourceGapMappedLength, inExon, trailingCopiedGap.length (), intronLength, startOfCodon);
233 for (var i = 0; i < gapsToAdd; i++) {
234 thisAligned.append (myGapChar);
236 sourceGapMappedLength = 0;
238 }thisAligned.append (c);
239 trailingCopiedGap = new StringBuilder ();
241 if (inExon && preserveMappedGaps) {
242 trailingCopiedGap.append (myGapChar);
243 } else if (!inExon && preserveUnmappedGaps) {
244 trailingCopiedGap.append (myGapChar);
247 while (thisSeqPos < thisSeq.length) {
248 var c = thisSeq[thisSeqPos++];
249 if (c != myGapChar || preserveUnmappedGaps) {
250 thisAligned.append (c);
252 alignTo.setSequence ( String.instantialize (thisAligned));
253 }, "jalview.datamodel.SequenceI,jalview.datamodel.SequenceI,jalview.datamodel.AlignedCodonFrame,~S,~S,~B,~B");
254 c$.calculateGapsToInsert = Clazz.defineMethod (c$, "calculateGapsToInsert",
255 function (preserveMappedGaps, preserveUnmappedGaps, sourceGapMappedLength, inExon, trailingGapLength, intronLength, startOfCodon) {
258 if (inExon && !preserveMappedGaps) {
259 trailingGapLength = 0;
260 }if (!inExon && !(preserveMappedGaps && preserveUnmappedGaps)) {
261 trailingGapLength = 0;
263 gapsToAdd = Math.max (sourceGapMappedLength, trailingGapLength);
265 if (intronLength + trailingGapLength <= sourceGapMappedLength) {
266 gapsToAdd = sourceGapMappedLength - intronLength;
268 gapsToAdd = Math.min (intronLength + trailingGapLength - sourceGapMappedLength, trailingGapLength);
270 if (!preserveMappedGaps) {
271 trailingGapLength = 0;
272 }gapsToAdd = Math.max (sourceGapMappedLength, trailingGapLength);
274 }, "~B,~B,~N,~B,~N,~N,~B");
275 c$.getAlignedTranslation = Clazz.defineMethod (c$, "getAlignedTranslation",
276 function (sequences, gapCharacter, mappings) {
277 var alignedSeqs = new java.util.ArrayList ();
278 for (var seq, $seq = sequences.iterator (); $seq.hasNext () && ((seq = $seq.next ()) || true);) {
279 var mapped = jalview.analysis.AlignmentUtils.getAlignedTranslation (seq, gapCharacter, mappings);
280 alignedSeqs.addAll (mapped);
283 }, "java.util.List,~S,java.util.Set");
284 c$.getAlignedTranslation = Clazz.defineMethod (c$, "getAlignedTranslation",
285 function (seq, gapCharacter, mappings) {
286 var result = new java.util.ArrayList ();
287 for (var mapping, $mapping = mappings.iterator (); $mapping.hasNext () && ((mapping = $mapping.next ()) || true);) {
288 if (mapping.involvesSequence (seq)) {
289 var mapped = jalview.analysis.AlignmentUtils.getAlignedTranslation (seq, gapCharacter, mapping);
290 if (mapped != null) {
294 }, "jalview.datamodel.SequenceI,~S,java.util.Set");
295 c$.getAlignedTranslation = Clazz.defineMethod (c$, "getAlignedTranslation",
296 function (seq, gapCharacter, mapping) {
297 var gap = String.valueOf (gapCharacter);
300 var mapTo = mapping.getDnaForAaSeq (seq);
303 gap = String.valueOf ( Clazz.newCharArray (-1, [gapCharacter, gapCharacter, gapCharacter]));
305 mapTo = mapping.getAaForDnaSeq (seq);
307 }var newseq = new StringBuilder (seq.getLength () * (toDna ? 3 : 1));
309 var phrase = Clazz.newIntArray (fromRatio, 0);
310 var phraseOffset = 0;
313 var alignedSeq = new jalview.datamodel.Sequence ("", "");
314 for (var c, $c = 0, $$c = seq.getSequence (); $c < $$c.length && ((c = $$c[$c]) || true); $c++) {
315 if (c == gapCharacter) {
317 if (gapWidth >= fromRatio) {
321 phrase[phraseOffset++] = residueNo + 1;
322 if (phraseOffset == fromRatio) {
323 var sr = new jalview.datamodel.SearchResults ();
324 for (var pos, $pos = 0, $$pos = phrase; $pos < $$pos.length && ((pos = $$pos[$pos]) || true); $pos++) {
325 mapping.markMappedRegion (seq, pos, sr);
327 newseq.append (sr.toString ());
330 var mappedTo = sr.getResultSequence (0);
331 alignedSeq.setName (mappedTo.getName ());
332 alignedSeq.setDescription (mappedTo.getDescription ());
333 alignedSeq.setDatasetSequence (mappedTo);
337 alignedSeq.setSequence (newseq.toString ());
339 }, "jalview.datamodel.SequenceI,~S,jalview.datamodel.AlignedCodonFrame");
340 c$.alignProteinAsDna = Clazz.defineMethod (c$, "alignProteinAsDna",
341 function (protein, dna) {
342 var mappings = protein.getCodonFrames ();
343 var alignedCodons = new java.util.TreeMap ( new jalview.analysis.CodonComparator ());
344 for (var dnaSeq, $dnaSeq = dna.getSequences ().iterator (); $dnaSeq.hasNext () && ((dnaSeq = $dnaSeq.next ()) || true);) {
345 for (var mapping, $mapping = mappings.iterator (); $mapping.hasNext () && ((mapping = $mapping.next ()) || true);) {
346 var seqMap = mapping.getMappingForSequence (dnaSeq);
347 var prot = mapping.findAlignedSequence (dnaSeq.getDatasetSequence (), protein);
349 jalview.analysis.AlignmentUtils.addCodonPositions (dnaSeq, prot, protein.getGapCharacter (), seqMap, alignedCodons);
352 return jalview.analysis.AlignmentUtils.alignProteinAs (protein, alignedCodons);
353 }, "jalview.datamodel.AlignmentI,jalview.datamodel.AlignmentI");
354 c$.alignProteinAs = Clazz.defineMethod (c$, "alignProteinAs",
355 function (protein, alignedCodons) {
356 var alignedWidth = alignedCodons.size ();
357 var gaps = Clazz.newCharArray (alignedWidth, '\0');
358 java.util.Arrays.fill (gaps, protein.getGapCharacter ());
359 var allGaps = String.valueOf (gaps);
360 for (var seq, $seq = protein.getSequences ().iterator (); $seq.hasNext () && ((seq = $seq.next ()) || true);) {
361 seq.setSequence (allGaps);
364 for (var codon, $codon = alignedCodons.keySet ().iterator (); $codon.hasNext () && ((codon = $codon.next ()) || true);) {
365 var columnResidues = alignedCodons.get (codon);
366 for (var entry, $entry = columnResidues.entrySet ().iterator (); $entry.hasNext () && ((entry = $entry.next ()) || true);) {
367 entry.getKey ().getSequence ()[column] = entry.getValue ().charAt (0);
372 }, "jalview.datamodel.AlignmentI,java.util.Map");
373 c$.addCodonPositions = Clazz.defineMethod (c$, "addCodonPositions",
374 function (dna, protein, gapChar, seqMap, alignedCodons) {
375 var codons = seqMap.getCodonIterator (dna, gapChar);
376 while (codons.hasNext ()) {
377 var codon = codons.next ();
378 var seqProduct = alignedCodons.get (codon);
379 if (seqProduct == null) {
380 seqProduct = new java.util.HashMap ();
381 alignedCodons.put (codon, seqProduct);
382 }seqProduct.put (protein, codon.product);
384 }, "jalview.datamodel.SequenceI,jalview.datamodel.SequenceI,~S,jalview.datamodel.Mapping,java.util.Map");
385 c$.isMappable = Clazz.defineMethod (c$, "isMappable",
386 function (al1, al2) {
387 if (al1.isNucleotide () == al2.isNucleotide ()) {
389 }var dna = al1.isNucleotide () ? al1 : al2;
390 var protein = dna === al1 ? al2 : al1;
391 var mappings = protein.getCodonFrames ();
392 for (var dnaSeq, $dnaSeq = dna.getSequences ().iterator (); $dnaSeq.hasNext () && ((dnaSeq = $dnaSeq.next ()) || true);) {
393 for (var proteinSeq, $proteinSeq = protein.getSequences ().iterator (); $proteinSeq.hasNext () && ((proteinSeq = $proteinSeq.next ()) || true);) {
394 if (jalview.analysis.AlignmentUtils.isMappable (dnaSeq, proteinSeq, mappings)) {
399 }, "jalview.datamodel.AlignmentI,jalview.datamodel.AlignmentI");
400 c$.isMappable = Clazz.defineMethod (c$, "isMappable",
401 function (dnaSeq, proteinSeq, mappings) {
402 var dnaDs = dnaSeq.getDatasetSequence () == null ? dnaSeq : dnaSeq.getDatasetSequence ();
403 var proteinDs = proteinSeq.getDatasetSequence () == null ? proteinSeq : proteinSeq.getDatasetSequence ();
404 for (var mapping, $mapping = mappings.iterator (); $mapping.hasNext () && ((mapping = $mapping.next ()) || true);) {
405 if (proteinDs === mapping.getAaForDnaSeq (dnaDs)) {
408 return jalview.analysis.AlignmentUtils.mapProteinToCdna (proteinDs, dnaDs) != null;
409 }, "jalview.datamodel.SequenceI,jalview.datamodel.SequenceI,java.util.Set");
410 c$.findAddableReferenceAnnotations = Clazz.defineMethod (c$, "findAddableReferenceAnnotations",
411 function (sequenceScope, labelForCalcId, candidates, al) {
412 if (sequenceScope == null) {
414 }for (var seq, $seq = sequenceScope.iterator (); $seq.hasNext () && ((seq = $seq.next ()) || true);) {
415 var dataset = seq.getDatasetSequence ();
416 if (dataset == null) {
418 }var datasetAnnotations = dataset.getAnnotation ();
419 if (datasetAnnotations == null) {
421 }var result = new java.util.ArrayList ();
422 for (var dsann, $dsann = 0, $$dsann = datasetAnnotations; $dsann < $$dsann.length && ((dsann = $$dsann[$dsann]) || true); $dsann++) {
423 var matchedAlignmentAnnotations = al.findAnnotations (seq, dsann.getCalcId (), dsann.label);
424 if (!matchedAlignmentAnnotations.iterator ().hasNext ()) {
426 if (labelForCalcId != null) {
427 labelForCalcId.put (dsann.getCalcId (), dsann.label);
429 if (!result.isEmpty ()) {
430 candidates.put (seq, result);
432 }, "java.util.List,java.util.Map,java.util.Map,jalview.datamodel.AlignmentI");
433 c$.addReferenceAnnotations = Clazz.defineMethod (c$, "addReferenceAnnotations",
434 function (annotations, alignment, selectionGroup) {
435 for (var seq, $seq = annotations.keySet ().iterator (); $seq.hasNext () && ((seq = $seq.next ()) || true);) {
436 for (var ann, $ann = annotations.get (seq).iterator (); $ann.hasNext () && ((ann = $ann.next ()) || true);) {
437 var copyAnn = new jalview.datamodel.AlignmentAnnotation (ann);
439 var endRes = ann.annotations.length;
440 if (selectionGroup != null) {
441 startRes = selectionGroup.getStartRes ();
442 endRes = selectionGroup.getEndRes ();
443 }copyAnn.restrict (startRes, endRes);
444 if (!seq.hasAnnotation (ann)) {
445 seq.addAlignmentAnnotation (copyAnn);
446 }copyAnn.adjustForAlignment ();
447 alignment.addAnnotation (copyAnn);
448 copyAnn.visible = true;
451 }, "java.util.Map,jalview.datamodel.AlignmentI,jalview.datamodel.SequenceGroup");
452 c$.showOrHideSequenceAnnotations = Clazz.defineMethod (c$, "showOrHideSequenceAnnotations",
453 function (al, types, forSequences, anyType, doShow) {
454 for (var aa, $aa = 0, $$aa = al.getAlignmentAnnotation (); $aa < $$aa.length && ((aa = $$aa[$aa]) || true); $aa++) {
455 if (anyType || types.contains (aa.label)) {
456 if ((aa.sequenceRef != null) && (forSequences == null || forSequences.contains (aa.sequenceRef))) {
459 }, "jalview.datamodel.AlignmentI,java.util.Collection,java.util.List,~B,~B");
460 c$.haveCrossRef = Clazz.defineMethod (c$, "haveCrossRef",
461 function (seq1, seq2) {
462 return jalview.analysis.AlignmentUtils.hasCrossRef (seq1, seq2) || jalview.analysis.AlignmentUtils.hasCrossRef (seq2, seq1);
463 }, "jalview.datamodel.SequenceI,jalview.datamodel.SequenceI");
464 c$.hasCrossRef = Clazz.defineMethod (c$, "hasCrossRef",
465 function (seq1, seq2) {
466 if (seq1 == null || seq2 == null) {
468 }var name = seq2.getName ();
469 var xrefs = seq1.getDBRef ();
471 for (var xref, $xref = 0, $$xref = xrefs; $xref < $$xref.length && ((xref = $$xref[$xref]) || true); $xref++) {
472 var xrefName = xref.getSource () + "|" + xref.getAccessionId ();
473 if (xrefName.equalsIgnoreCase (name)) {
477 }, "jalview.datamodel.SequenceI,jalview.datamodel.SequenceI");
478 c$.makeExonAlignment = Clazz.defineMethod (c$, "makeExonAlignment",
479 function (dna, mappings) {
480 var newMappings = new java.util.LinkedHashSet ();
481 var exonSequences = new java.util.ArrayList ();
482 for (var dnaSeq, $dnaSeq = 0, $$dnaSeq = dna; $dnaSeq < $$dnaSeq.length && ((dnaSeq = $$dnaSeq[$dnaSeq]) || true); $dnaSeq++) {
483 var ds = dnaSeq.getDatasetSequence ();
484 var seqMappings = jalview.util.MappingUtils.findMappingsForSequence (ds, mappings);
485 for (var acf, $acf = seqMappings.iterator (); $acf.hasNext () && ((acf = $acf.next ()) || true);) {
486 var newMapping = new jalview.datamodel.AlignedCodonFrame ();
487 var mappedExons = jalview.analysis.AlignmentUtils.makeExonSequences (ds, acf, newMapping);
488 if (!mappedExons.isEmpty ()) {
489 exonSequences.addAll (mappedExons);
490 newMappings.add (newMapping);
493 var al = new jalview.datamodel.Alignment (exonSequences.toArray ( new Array (exonSequences.size ())));
494 al.setDataset (null);
496 mappings.addAll (newMappings);
498 }, "~A,java.util.Set");
499 c$.makeExonSequences = Clazz.defineMethod (c$, "makeExonSequences",
500 function (dnaSeq, mapping, newMapping) {
501 var exonSequences = new java.util.ArrayList ();
502 var seqMappings = mapping.getMappingsForSequence (dnaSeq);
503 var dna = dnaSeq.getSequence ();
504 for (var seqMapping, $seqMapping = seqMappings.iterator (); $seqMapping.hasNext () && ((seqMapping = $seqMapping.next ()) || true);) {
505 var newSequence = new StringBuilder (dnaSeq.getLength ());
506 var dnaExonRanges = seqMapping.getMap ().getFromRanges ();
507 for (var range, $range = dnaExonRanges.iterator (); $range.hasNext () && ((range = $range.next ()) || true);) {
508 for (var pos = range[0]; pos <= range[1]; pos++) {
509 newSequence.append (dna[pos - 1]);
512 var exon = new jalview.datamodel.Sequence (dnaSeq.getName (), newSequence.toString ());
513 var cdsAccId = jalview.datamodel.FeatureProperties.getCodingFeature (jalview.datamodel.DBRefSource.EMBL);
514 var cdsRefs = jalview.util.DBRefUtils.selectRefs (seqMapping.getTo ().getDBRef (), jalview.datamodel.DBRefSource.CODINGDBS);
515 if (cdsRefs != null) {
516 for (var cdsRef, $cdsRef = 0, $$cdsRef = cdsRefs; $cdsRef < $$cdsRef.length && ((cdsRef = $$cdsRef[$cdsRef]) || true); $cdsRef++) {
517 exon.addDBRef ( new jalview.datamodel.DBRefEntry (cdsRef));
518 cdsAccId = cdsRef.getAccessionId ();
520 }exon.setName (exon.getName () + "|" + cdsAccId);
521 exon.createDatasetSequence ();
522 var exonRange = new java.util.ArrayList ();
523 exonRange.add ( Clazz.newIntArray (-1, [1, newSequence.length ()]));
524 var map = new jalview.util.MapList (exonRange, seqMapping.getMap ().getToRanges (), 3, 1);
525 newMapping.addMap (exon.getDatasetSequence (), seqMapping.getTo (), map);
526 var cdsToDnaMap = new jalview.util.MapList (dnaExonRanges, exonRange, 1, 1);
527 newMapping.addMap (dnaSeq, exon.getDatasetSequence (), cdsToDnaMap);
528 exonSequences.add (exon);
530 return exonSequences;
531 }, "jalview.datamodel.SequenceI,jalview.datamodel.AlignedCodonFrame,jalview.datamodel.AlignedCodonFrame");