X-Git-Url: http://source.jalview.org/gitweb/?p=jalview.git;a=blobdiff_plain;f=src%2Fjalview%2Fanalysis%2FAlignmentUtils.java;h=9aaaed2fd56418160823f5b7b93f82608e24df6c;hp=5e04d31bdae19672cb2905485d932cfb008fda64;hb=2baee069f9edaef280f0115bae42d4ac7b77bb9b;hpb=a2789c98b3f5c793ee3298131ba9f18c6e065fd6 diff --git a/src/jalview/analysis/AlignmentUtils.java b/src/jalview/analysis/AlignmentUtils.java index 5e04d31..9aaaed2 100644 --- a/src/jalview/analysis/AlignmentUtils.java +++ b/src/jalview/analysis/AlignmentUtils.java @@ -867,6 +867,8 @@ public class AlignmentUtils * Realigns the given dna to match the alignment of the protein, using codon * mappings to translate aligned peptide positions to codons. * + * Always produces a padded CDS alignment. + * * @param dna * the alignment whose sequences are realigned by this method * @param protein @@ -883,6 +885,7 @@ public class AlignmentUtils // todo: implement this List mappings = protein.getCodonFrames(); int alignedCount = 0; + int width = 0; // alignment width for padding CDS for (SequenceI dnaSeq : dna.getSequences()) { if (alignCdsSequenceAsProtein(dnaSeq, protein, mappings, @@ -890,6 +893,17 @@ public class AlignmentUtils { alignedCount++; } + width = Math.max(dnaSeq.getLength(), width); + } + int oldwidth, diff; + for (SequenceI dnaSeq : dna.getSequences()) + { + oldwidth = dnaSeq.getLength(); + diff = width - oldwidth; + if (diff > 0) + { + dnaSeq.insertCharAt(oldwidth, diff, dna.getGapCharacter()); + } } return alignedCount; }