2 * Jalview - A Sequence Alignment Editor and Viewer ($$Version-Rel$$)
3 * Copyright (C) $$Year-Rel$$ The Jalview Authors
5 * This file is part of Jalview.
7 * Jalview is free software: you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License
9 * as published by the Free Software Foundation, either version 3
10 * of the License, or (at your option) any later version.
12 * Jalview is distributed in the hope that it will be useful, but
13 * WITHOUT ANY WARRANTY; without even the implied warranty
14 * of MERCHANTABILITY or FITNESS FOR A PARTICULAR
15 * PURPOSE. See the GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with Jalview. If not, see <http://www.gnu.org/licenses/>.
19 * The Jalview Authors are detailed in the 'AUTHORS' file.
21 package jalview.analysis;
23 import jalview.datamodel.AlignedCodon;
24 import jalview.datamodel.AlignedCodonFrame;
25 import jalview.datamodel.AlignmentAnnotation;
26 import jalview.datamodel.AlignmentI;
27 import jalview.datamodel.Mapping;
28 import jalview.datamodel.SearchResults;
29 import jalview.datamodel.Sequence;
30 import jalview.datamodel.SequenceI;
31 import jalview.schemes.ResidueProperties;
32 import jalview.util.MapList;
34 import java.util.ArrayList;
35 import java.util.Arrays;
36 import java.util.HashMap;
37 import java.util.Iterator;
38 import java.util.LinkedHashMap;
39 import java.util.List;
41 import java.util.Map.Entry;
43 import java.util.TreeMap;
46 * grab bag of useful alignment manipulation operations Expect these to be
47 * refactored elsewhere at some point.
52 public class AlignmentUtils
56 * Represents the 3 possible results of trying to map one alignment to
59 public enum MappingResult
61 Mapped, NotMapped, AlreadyMapped
65 * given an existing alignment, create a new alignment including all, or up to
66 * flankSize additional symbols from each sequence's dataset sequence
72 public static AlignmentI expandContext(AlignmentI core, int flankSize)
74 List<SequenceI> sq = new ArrayList<SequenceI>();
76 for (SequenceI s : core.getSequences())
78 SequenceI newSeq = s.deriveSequence();
79 if (newSeq.getStart() > maxoffset
80 && newSeq.getDatasetSequence().getStart() < s.getStart())
82 maxoffset = newSeq.getStart();
88 maxoffset = flankSize;
90 // now add offset to create a new expanded alignment
91 for (SequenceI s : sq)
94 while (ds.getDatasetSequence() != null)
96 ds = ds.getDatasetSequence();
98 int s_end = s.findPosition(s.getStart() + s.getLength());
99 // find available flanking residues for sequence
100 int ustream_ds = s.getStart() - ds.getStart(), dstream_ds = ds
103 // build new flanked sequence
105 // compute gap padding to start of flanking sequence
106 int offset = maxoffset - ustream_ds;
108 // padding is gapChar x ( maxoffset - min(ustream_ds, flank)
111 if (flankSize < ustream_ds)
113 // take up to flankSize residues
114 offset = maxoffset - flankSize;
115 ustream_ds = flankSize;
117 if (flankSize < dstream_ds)
119 dstream_ds = flankSize;
122 char[] upstream = new String(ds.getSequence(s.getStart() - 1
123 - ustream_ds, s.getStart() - 1)).toLowerCase().toCharArray();
124 char[] downstream = new String(ds.getSequence(s_end - 1, s_end + 1
125 + dstream_ds)).toLowerCase().toCharArray();
126 char[] coreseq = s.getSequence();
127 char[] nseq = new char[offset + upstream.length + downstream.length
129 char c = core.getGapCharacter();
130 // TODO could lowercase the flanking regions
132 for (; p < offset; p++)
136 // s.setSequence(new String(upstream).toLowerCase()+new String(coreseq) +
137 // new String(downstream).toLowerCase());
138 System.arraycopy(upstream, 0, nseq, p, upstream.length);
139 System.arraycopy(coreseq, 0, nseq, p + upstream.length,
141 System.arraycopy(downstream, 0, nseq, p + coreseq.length
142 + upstream.length, downstream.length);
143 s.setSequence(new String(nseq));
144 s.setStart(s.getStart() - ustream_ds);
145 s.setEnd(s_end + downstream.length);
147 AlignmentI newAl = new jalview.datamodel.Alignment(
148 sq.toArray(new SequenceI[0]));
149 for (SequenceI s : sq)
151 if (s.getAnnotation() != null)
153 for (AlignmentAnnotation aa : s.getAnnotation())
155 newAl.addAnnotation(aa);
159 newAl.setDataset(core.getDataset());
164 * Returns the index (zero-based position) of a sequence in an alignment, or
171 public static int getSequenceIndex(AlignmentI al, SequenceI seq)
175 for (SequenceI alSeq : al.getSequences())
188 * Returns a map of lists of sequences in the alignment, keyed by sequence
189 * name. For use in mapping between different alignment views of the same
192 * @see jalview.datamodel.AlignmentI#getSequencesByName()
194 public static Map<String, List<SequenceI>> getSequencesByName(
197 Map<String, List<SequenceI>> theMap = new LinkedHashMap<String, List<SequenceI>>();
198 for (SequenceI seq : al.getSequences())
200 String name = seq.getName();
203 List<SequenceI> seqs = theMap.get(name);
206 seqs = new ArrayList<SequenceI>();
207 theMap.put(name, seqs);
216 * Build mapping of protein to cDNA alignment. Mappings are made between
217 * sequences where the cDNA translates to the protein sequence. Any new
218 * mappings are added to the protein alignment. Has a 3-valued result: either
219 * Mapped (at least one sequence mapping was created), AlreadyMapped (all
220 * possible sequence mappings already exist), or NotMapped (no possible
221 * sequence mappings exist).
223 * @param proteinAlignment
224 * @param cdnaAlignment
227 public static MappingResult mapProteinToCdna(
228 final AlignmentI proteinAlignment,
229 final AlignmentI cdnaAlignment)
231 if (proteinAlignment == null || cdnaAlignment == null)
233 return MappingResult.NotMapped;
236 boolean mappingPossible = false;
237 boolean mappingPerformed = false;
239 List<SequenceI> mapped = new ArrayList<SequenceI>();
241 List<SequenceI> thisSeqs = proteinAlignment.getSequences();
243 for (SequenceI aaSeq : thisSeqs)
245 AlignedCodonFrame acf = new AlignedCodonFrame();
247 for (SequenceI cdnaSeq : cdnaAlignment.getSequences())
250 * Heuristic rule: don't map more than one AA sequence to the same cDNA;
251 * map progressively assuming that alignments have mappable sequences in
252 * the same respective order
254 if (mapped.contains(cdnaSeq))
258 if (!mappingExists(proteinAlignment.getCodonFrames(),
259 aaSeq.getDatasetSequence(), cdnaSeq.getDatasetSequence()))
261 MapList map = mapProteinToCdna(aaSeq, cdnaSeq);
264 acf.addMap(cdnaSeq, aaSeq, map);
265 mappingPerformed = true;
269 * Heuristic rule #2: don't map AA sequence to more than one cDNA
275 proteinAlignment.addCodonFrame(acf);
279 * If at least one mapping was possible but none was done, then the
280 * alignments are already as mapped as they can be.
282 if (mappingPossible && !mappingPerformed)
284 return MappingResult.AlreadyMapped;
288 return mappingPerformed ? MappingResult.Mapped
289 : MappingResult.NotMapped;
294 * Answers true if the mappings include one between the given (dataset)
297 public static boolean mappingExists(Set<AlignedCodonFrame> set,
298 SequenceI aaSeq, SequenceI cdnaSeq)
302 for (AlignedCodonFrame acf : set)
304 if (cdnaSeq == acf.getDnaForAaSeq(aaSeq))
314 * Build a mapping (if possible) of a protein to a cDNA sequence. The cDNA
315 * must be three times the length of the protein, possibly after ignoring
316 * start and/or stop codons, and must translate to the protein. Returns null
317 * if no mapping is determined.
323 public static MapList mapProteinToCdna(SequenceI proteinSeq,
327 * Here we handle either dataset sequence set (desktop) or absent (applet).
328 * Use only the char[] form of the sequence to avoid creating possibly large
331 final SequenceI proteinDataset = proteinSeq.getDatasetSequence();
332 char[] aaSeqChars = proteinDataset != null ? proteinDataset
333 .getSequence() : proteinSeq.getSequence();
334 final SequenceI cdnaDataset = cdnaSeq.getDatasetSequence();
335 char[] cdnaSeqChars = cdnaDataset != null ? cdnaDataset.getSequence()
336 : cdnaSeq.getSequence();
337 if (aaSeqChars == null || cdnaSeqChars == null)
343 * cdnaStart/End, proteinStartEnd are base 1 (for dataset sequence mapping)
345 final int mappedLength = 3 * aaSeqChars.length;
346 int cdnaLength = cdnaSeqChars.length;
348 int cdnaEnd = cdnaLength;
349 final int proteinStart = 1;
350 final int proteinEnd = aaSeqChars.length;
353 * If lengths don't match, try ignoring stop codon.
355 if (cdnaLength != mappedLength && cdnaLength > 2)
357 String lastCodon = String.valueOf(cdnaSeqChars, cdnaLength - 3, 3)
359 for (String stop : ResidueProperties.STOP)
361 if (lastCodon.equals(stop))
371 * If lengths still don't match, try ignoring start codon.
373 if (cdnaLength != mappedLength
375 && String.valueOf(cdnaSeqChars, 0, 3).toUpperCase()
377 ResidueProperties.START))
383 if (cdnaLength != mappedLength)
387 if (!translatesAs(cdnaSeqChars, cdnaStart - 1, aaSeqChars))
391 MapList map = new MapList(new int[]
392 { cdnaStart, cdnaEnd }, new int[]
393 { proteinStart, proteinEnd }, 3, 1);
398 * Test whether the given cdna sequence, starting at the given offset,
399 * translates to the given amino acid sequence, using the standard translation
400 * table. Designed to fail fast i.e. as soon as a mismatch position is found.
402 * @param cdnaSeqChars
407 protected static boolean translatesAs(char[] cdnaSeqChars, int cdnaStart,
411 for (int i = cdnaStart; i < cdnaSeqChars.length - 2
412 && aaResidue < aaSeqChars.length; i += 3)
414 String codon = String.valueOf(cdnaSeqChars, i, 3);
415 final String translated = ResidueProperties.codonTranslate(
417 if (translated == null
418 || !(aaSeqChars[aaResidue] == translated.charAt(0)))
424 // fail if we didn't match all of the aa sequence
425 return (aaResidue == aaSeqChars.length);
429 * Align sequence 'seq' to match the alignment of a mapped sequence. Note this
430 * currently assumes that we are aligning cDNA to match protein.
433 * the sequence to be realigned
435 * the alignment whose sequence alignment is to be 'copied'
437 * character string represent a gap in the realigned sequence
438 * @param preserveUnmappedGaps
439 * @param preserveMappedGaps
440 * @return true if the sequence was realigned, false if it could not be
442 public static boolean alignSequenceAs(SequenceI seq, AlignmentI al,
443 String gap, boolean preserveMappedGaps,
444 boolean preserveUnmappedGaps)
447 * Get any mappings from the source alignment to the target (dataset) sequence.
449 // TODO there may be one AlignedCodonFrame per dataset sequence, or one with
450 // all mappings. Would it help to constrain this?
451 List<AlignedCodonFrame> mappings = al.getCodonFrame(seq);
452 if (mappings == null || mappings.isEmpty())
458 * Locate the aligned source sequence whose dataset sequence is mapped. We
459 * just take the first match here (as we can't align cDNA like more than one
462 SequenceI alignFrom = null;
463 AlignedCodonFrame mapping = null;
464 for (AlignedCodonFrame mp : mappings)
466 alignFrom = mp.findAlignedSequence(seq.getDatasetSequence(), al);
467 if (alignFrom != null)
474 if (alignFrom == null)
478 alignSequenceAs(seq, alignFrom, mapping, gap, al.getGapCharacter(),
479 preserveMappedGaps, preserveUnmappedGaps);
484 * Align sequence 'alignTo' the same way as 'alignFrom', using the mapping to
485 * match residues and codons. Flags control whether existing gaps in unmapped
486 * (intron) and mapped (exon) regions are preserved or not. Gaps linking intro
487 * and exon are only retained if both flags are set.
494 * @param preserveUnmappedGaps
495 * @param preserveMappedGaps
497 public static void alignSequenceAs(SequenceI alignTo,
499 AlignedCodonFrame mapping, String myGap, char sourceGap,
500 boolean preserveMappedGaps, boolean preserveUnmappedGaps)
502 // TODO generalise to work for Protein-Protein, dna-dna, dna-protein
503 final char[] thisSeq = alignTo.getSequence();
504 final char[] thatAligned = alignFrom.getSequence();
505 StringBuilder thisAligned = new StringBuilder(2 * thisSeq.length);
507 // aligned and dataset sequence positions, all base zero
511 int basesWritten = 0;
512 char myGapChar = myGap.charAt(0);
513 int ratio = myGap.length();
516 * Traverse the aligned protein sequence.
518 int sourceGapMappedLength = 0;
519 boolean inExon = false;
520 for (char sourceChar : thatAligned)
522 if (sourceChar == sourceGap)
524 sourceGapMappedLength += ratio;
529 * Found a residue. Locate its mapped codon (start) position.
532 // Note mapping positions are base 1, our sequence positions base 0
533 int[] mappedPos = mapping.getMappedRegion(alignTo, alignFrom,
535 if (mappedPos == null)
538 * Abort realignment if unmapped protein. Or could ignore it??
540 System.err.println("Can't align: no codon mapping to residue "
541 + sourceDsPos + "(" + sourceChar + ")");
545 int mappedCodonStart = mappedPos[0]; // position (1...) of codon start
546 int mappedCodonEnd = mappedPos[mappedPos.length - 1]; // codon end pos
547 StringBuilder trailingCopiedGap = new StringBuilder();
550 * Copy dna sequence up to and including this codon. Optionally, include
551 * gaps before the codon starts (in introns) and/or after the codon starts
554 * Note this only works for 'linear' splicing, not reverse or interleaved.
555 * But then 'align dna as protein' doesn't make much sense otherwise.
557 int intronLength = 0;
558 while (basesWritten < mappedCodonEnd && thisSeqPos < thisSeq.length)
560 final char c = thisSeq[thisSeqPos++];
565 if (basesWritten < mappedCodonStart)
568 * Found an unmapped (intron) base. First add in any preceding gaps
571 if (preserveUnmappedGaps && trailingCopiedGap.length() > 0)
573 thisAligned.append(trailingCopiedGap.toString());
574 intronLength += trailingCopiedGap.length();
575 trailingCopiedGap = new StringBuilder();
582 final boolean startOfCodon = basesWritten == mappedCodonStart;
583 int gapsToAdd = calculateGapsToInsert(preserveMappedGaps,
584 preserveUnmappedGaps, sourceGapMappedLength, inExon,
585 trailingCopiedGap.length(), intronLength, startOfCodon);
586 for (int i = 0; i < gapsToAdd; i++)
588 thisAligned.append(myGapChar);
590 sourceGapMappedLength = 0;
593 thisAligned.append(c);
594 trailingCopiedGap = new StringBuilder();
598 if (inExon && preserveMappedGaps)
600 trailingCopiedGap.append(myGapChar);
602 else if (!inExon && preserveUnmappedGaps)
604 trailingCopiedGap.append(myGapChar);
611 * At end of protein sequence. Copy any remaining dna sequence, optionally
612 * including (intron) gaps. We do not copy trailing gaps in protein.
614 while (thisSeqPos < thisSeq.length)
616 final char c = thisSeq[thisSeqPos++];
617 if (c != myGapChar || preserveUnmappedGaps)
619 thisAligned.append(c);
624 * All done aligning, set the aligned sequence.
626 alignTo.setSequence(new String(thisAligned));
630 * Helper method to work out how many gaps to insert when realigning.
632 * @param preserveMappedGaps
633 * @param preserveUnmappedGaps
634 * @param sourceGapMappedLength
636 * @param trailingCopiedGap
637 * @param intronLength
638 * @param startOfCodon
641 protected static int calculateGapsToInsert(boolean preserveMappedGaps,
642 boolean preserveUnmappedGaps, int sourceGapMappedLength,
643 boolean inExon, int trailingGapLength,
644 int intronLength, final boolean startOfCodon)
650 * Reached start of codon. Ignore trailing gaps in intron unless we are
651 * preserving gaps in both exon and intron. Ignore them anyway if the
652 * protein alignment introduces a gap at least as large as the intronic
655 if (inExon && !preserveMappedGaps)
657 trailingGapLength = 0;
659 if (!inExon && !(preserveMappedGaps && preserveUnmappedGaps))
661 trailingGapLength = 0;
665 gapsToAdd = Math.max(sourceGapMappedLength, trailingGapLength);
669 if (intronLength + trailingGapLength <= sourceGapMappedLength)
671 gapsToAdd = sourceGapMappedLength - intronLength;
675 gapsToAdd = Math.min(intronLength + trailingGapLength
676 - sourceGapMappedLength, trailingGapLength);
683 * second or third base of codon; check for any gaps in dna
685 if (!preserveMappedGaps)
687 trailingGapLength = 0;
689 gapsToAdd = Math.max(sourceGapMappedLength, trailingGapLength);
695 * Returns a list of sequences mapped from the given sequences and aligned
696 * (gapped) in the same way. For example, the cDNA for aligned protein, where
697 * a single gap in protein generates three gaps in cDNA.
700 * @param gapCharacter
704 public static List<SequenceI> getAlignedTranslation(
705 List<SequenceI> sequences, char gapCharacter,
706 Set<AlignedCodonFrame> mappings)
708 List<SequenceI> alignedSeqs = new ArrayList<SequenceI>();
710 for (SequenceI seq : sequences)
712 List<SequenceI> mapped = getAlignedTranslation(seq, gapCharacter,
714 alignedSeqs.addAll(mapped);
720 * Returns sequences aligned 'like' the source sequence, as mapped by the
721 * given mappings. Normally we expect zero or one 'mapped' sequences, but this
722 * will support 1-to-many as well.
725 * @param gapCharacter
729 protected static List<SequenceI> getAlignedTranslation(SequenceI seq,
730 char gapCharacter, Set<AlignedCodonFrame> mappings)
732 List<SequenceI> result = new ArrayList<SequenceI>();
733 for (AlignedCodonFrame mapping : mappings)
735 if (mapping.involvesSequence(seq))
737 SequenceI mapped = getAlignedTranslation(seq, gapCharacter, mapping);
748 * Returns the translation of 'seq' (as held in the mapping) with
749 * corresponding alignment (gaps).
752 * @param gapCharacter
756 protected static SequenceI getAlignedTranslation(SequenceI seq,
757 char gapCharacter, AlignedCodonFrame mapping)
759 String gap = String.valueOf(gapCharacter);
760 boolean toDna = false;
762 SequenceI mapTo = mapping.getDnaForAaSeq(seq);
765 // mapping is from protein to nucleotide
767 // should ideally get gap count ratio from mapping
768 gap = String.valueOf(new char[]
769 { gapCharacter, gapCharacter, gapCharacter });
773 // mapping is from nucleotide to protein
774 mapTo = mapping.getAaForDnaSeq(seq);
777 StringBuilder newseq = new StringBuilder(seq.getLength()
780 int residueNo = 0; // in seq, base 1
781 int[] phrase = new int[fromRatio];
782 int phraseOffset = 0;
784 boolean first = true;
785 final Sequence alignedSeq = new Sequence("", "");
787 for (char c : seq.getSequence())
789 if (c == gapCharacter)
792 if (gapWidth >= fromRatio)
800 phrase[phraseOffset++] = residueNo + 1;
801 if (phraseOffset == fromRatio)
804 * Have read a whole codon (or protein residue), now translate: map
805 * source phrase to positions in target sequence add characters at
806 * these positions to newseq Note mapping positions are base 1, our
807 * sequence positions base 0.
809 SearchResults sr = new SearchResults();
810 for (int pos : phrase)
812 mapping.markMappedRegion(seq, pos, sr);
814 newseq.append(sr.toString());
818 // Hack: Copy sequence dataset, name and description from
819 // SearchResults.match[0].sequence
820 // TODO? carry over sequence names from original 'complement'
822 SequenceI mappedTo = sr.getResultSequence(0);
823 alignedSeq.setName(mappedTo.getName());
824 alignedSeq.setDescription(mappedTo.getDescription());
825 alignedSeq.setDatasetSequence(mappedTo);
832 alignedSeq.setSequence(newseq.toString());
837 * Realigns the given protein to match the alignment of the dna, using codon
838 * mappings to translate aligned codon positions to protein residues.
841 * the alignment whose sequences are realigned by this method
843 * the dna alignment whose alignment we are 'copying'
844 * @return the number of sequences that were realigned
846 public static int alignProteinAsDna(AlignmentI protein, AlignmentI dna)
848 Set<AlignedCodonFrame> mappings = protein.getCodonFrames();
851 * Map will hold, for each aligned codon position e.g. [3, 5, 6], a map of
852 * {dnaSequence, {proteinSequence, codonProduct}} at that position. The
853 * comparator keeps the codon positions ordered.
855 Map<AlignedCodon, Map<SequenceI, String>> alignedCodons = new TreeMap<AlignedCodon, Map<SequenceI, String>>(
856 new CodonComparator());
857 for (SequenceI dnaSeq : dna.getSequences())
859 for (AlignedCodonFrame mapping : mappings)
861 Mapping seqMap = mapping.getMappingForSequence(dnaSeq);
862 SequenceI prot = mapping.findAlignedSequence(
863 dnaSeq.getDatasetSequence(), protein);
866 addCodonPositions(dnaSeq, prot, protein.getGapCharacter(),
867 seqMap, alignedCodons);
871 return alignProteinAs(protein, alignedCodons);
875 * Update the aligned protein sequences to match the codon alignments given in
879 * @param alignedCodons
880 * an ordered map of codon positions (columns), with sequence/peptide
881 * values present in each column
884 protected static int alignProteinAs(AlignmentI protein,
885 Map<AlignedCodon, Map<SequenceI, String>> alignedCodons)
888 * Prefill aligned sequences with gaps before inserting aligned protein
891 int alignedWidth = alignedCodons.size();
892 char[] gaps = new char[alignedWidth];
893 Arrays.fill(gaps, protein.getGapCharacter());
894 String allGaps = String.valueOf(gaps);
895 for (SequenceI seq : protein.getSequences())
897 seq.setSequence(allGaps);
901 for (AlignedCodon codon : alignedCodons.keySet())
903 final Map<SequenceI, String> columnResidues = alignedCodons.get(codon);
904 for (Entry<SequenceI, String> entry : columnResidues
907 // place translated codon at its column position in sequence
908 entry.getKey().getSequence()[column] = entry.getValue().charAt(0);
916 * Populate the map of aligned codons by traversing the given sequence
917 * mapping, locating the aligned positions of mapped codons, and adding those
918 * positions and their translation products to the map.
921 * the aligned sequence we are mapping from
923 * the sequence to be aligned to the codons
925 * the gap character in the dna sequence
927 * a mapping to a sequence translation
928 * @param alignedCodons
929 * the map we are building up
931 static void addCodonPositions(SequenceI dna, SequenceI protein,
934 Map<AlignedCodon, Map<SequenceI, String>> alignedCodons)
936 Iterator<AlignedCodon> codons = seqMap.getCodonIterator(dna, gapChar);
937 while (codons.hasNext())
939 AlignedCodon codon = codons.next();
940 Map<SequenceI, String> seqProduct = alignedCodons.get(codon);
941 if (seqProduct == null)
943 seqProduct = new HashMap<SequenceI, String>();
944 alignedCodons.put(codon, seqProduct);
946 seqProduct.put(protein, codon.product);
951 * Returns true if a cDNA/Protein mapping either exists, or could be made,
952 * between at least one pair of sequences in the two alignments. Currently,
955 * <li>One alignment must be nucleotide, and the other protein</li>
956 * <li>At least one pair of sequences must be already mapped, or mappable</li>
957 * <li>Mappable means the nucleotide translation matches the protein sequence</li>
958 * <li>The translation may ignore start and stop codons if present in the
966 public static boolean isMappable(AlignmentI al1, AlignmentI al2)
969 * Require one nucleotide and one protein
971 if (al1.isNucleotide() == al2.isNucleotide())
975 AlignmentI dna = al1.isNucleotide() ? al1 : al2;
976 AlignmentI protein = dna == al1 ? al2 : al1;
977 Set<AlignedCodonFrame> mappings = protein.getCodonFrames();
978 for (SequenceI dnaSeq : dna.getSequences())
980 for (SequenceI proteinSeq : protein.getSequences())
982 if (isMappable(dnaSeq, proteinSeq, mappings))
992 * Returns true if the dna sequence is mapped, or could be mapped, to the
1000 public static boolean isMappable(SequenceI dnaSeq, SequenceI proteinSeq,
1001 Set<AlignedCodonFrame> mappings)
1003 SequenceI dnaDs = dnaSeq.getDatasetSequence() == null ? dnaSeq : dnaSeq.getDatasetSequence();
1004 SequenceI proteinDs = proteinSeq.getDatasetSequence() == null ? proteinSeq
1005 : proteinSeq.getDatasetSequence();
1010 for (AlignedCodonFrame mapping : mappings) {
1011 if ( proteinDs == mapping.getAaForDnaSeq(dnaDs)) {
1017 * Just try to make a mapping (it is not yet stored), test whether
1020 return mapProteinToCdna(proteinDs, dnaDs) != null;