/**
* Holds the aligned column positions (base 0) for one codon in a nucleotide
- * sequence. The object is immutable once created.
+ * sequence, and (optionally) its peptide translation. The object is immutable
+ * once created.
*
* Example: in "G-AT-C-GA" the aligned codons are (0, 2, 3) and (5, 7, 8).
*
public final int pos3;
+ public final String product;
+
public AlignedCodon(int i, int j, int k)
{
+ this(i, j, k, null);
+ }
+
+ public AlignedCodon(int i, int j, int k, String prod)
+ {
pos1 = i;
pos2 = j;
pos3 = k;
+ product = prod;
}
/**
}
/**
- * Two aligned codons are equal if all their base positions are the same.
+ * Two aligned codons are equal if all their base positions are the same. We
+ * don't care about the protein product. This test is required for correct
+ * alignment of translated gapped dna alignments (the same codon positions in
+ * different sequences occupy the same column in the translated alignment).
*/
@Override
public boolean equals(Object o)
@Override
public String toString()
{
- return "[" + pos1 + ", " + pos2 + ", " + pos3 + "]";
+ StringBuilder sb = new StringBuilder();
+ sb.append("[").append(pos1).append(", ").append(pos2).append(", ")
+ .append(pos3).append("]");
+ return sb.toString();
}
}