JAL-1619 refactoring in progress for Dna translation
[jalview.git] / src / jalview / datamodel / AlignedCodonFrame.java
index f65f068..6048808 100644 (file)
@@ -33,14 +33,19 @@ public class AlignedCodonFrame
 {
 
   /**
-   * array of nucleotide positions for aligned codons at column of aligned
-   * proteins.
+   * <pre>
+   * Aligned nucleotide positions for codons mapped to column positions of of aligned
+   * proteins. e.g.
+   * codons[3] = [12, 14, 15] means:
+   *     column 4 in the protein alignment translates cols 13, 15, 16 in cDNA
+   * codons[5] = null means column 6 in the protein alignment is a gap
+   * </pre>
    */
   public int[][] codons = null;
 
   /**
-   * width of protein sequence alignement implicit assertion that codons.length
-   * >= aaWidth
+   * Width of protein sequence alignment (implicit assertion that codons.length
+   * >= aaWidth)
    */
   public int aaWidth = 0;
 
@@ -100,6 +105,11 @@ public class AlignedCodonFrame
     for (SequenceI seq : acf.a_aaSeqs)
     {
       boolean found = false;
+      // TODO may not correctly handle the case where the same sequence appears
+      // twice in the source alignment i.e. same dataset sequence
+      // the copy will reference the first aligned sequence for both
+      // ?not solvable if realignment may reorder the sequences
+      // or check on sequence name as well????
       for (SequenceI newseq : alignment)
       {
         if (seq.getDatasetSequence() == newseq.getDatasetSequence())
@@ -125,6 +135,8 @@ public class AlignedCodonFrame
    */
   public int[][] checkCodonFrameWidth(int aslen)
   {
+    // TODO why not codons.length < aslen ?
+    // should codons expand if length is 2 or 3 and aslen==2 ?
     if (codons.length <= aslen + 1)
     {
       // probably never have to do this ?
@@ -165,7 +177,6 @@ public class AlignedCodonFrame
       seq.insertCharAt(aspos, gapCharacter);
     }
 
-    checkCodonFrameWidth(aspos);
     if (aspos < aaWidth)
     {
       aaWidth++;