boolean thatIsProtein = !al.isNucleotide();
if (!thatIsProtein && !thisIsNucleotide)
{
- System.err
- .println("Alignment of protein from cDNA not yet implemented");
- return 0;
- // todo: build it - a variant of Dna.CdnaTranslate()
+ return AlignmentUtils.alignProteinAsDna(this, al);
}
char thisGapChar = this.getGapCharacter();
}
return names;
}
+
+ /**
+ * Returns a (possibly empty) alignment whose sequences are aligned to match
+ * the current alignment, as mapped by the given codon mappings.
+ *
+ * @param codonFrames
+ * @return
+ */
+ @Override
+ public AlignmentI getAlignedComplement(Set<AlignedCodonFrame> codonFrames)
+ {
+ // Note: passing codonFrames as a parameter rather than using
+ // this.codonFrameList as more flexible. Specifically, mappings are held
+ // on the protein alignment but we might want to act on dna.
+
+ // TODO we want the gap character of the mapped alignment, not this one!
+ List<SequenceI> alignedSeqs = AlignmentUtils.getAlignedTranslation(
+ getSequences(), getGapCharacter(), codonFrames);
+ final SequenceI[] seqsAsArray = alignedSeqs
+ .toArray(new SequenceI[alignedSeqs.size()]);
+ AlignmentI al = new Alignment(seqsAsArray);
+ al.padGaps();
+ al.setDataset(null);
+ return al;
+ }
}