1 package jalview.datamodel;
4 * Holds the aligned column positions (base 0) for one codon in a nucleotide
5 * sequence. The object is immutable once created.
7 * Example: in "G-AT-C-GA" the aligned codons are (0, 2, 3) and (5, 7, 8).
12 public final class AlignedCodon
14 public final int pos1;
16 public final int pos2;
18 public final int pos3;
20 public AlignedCodon(int i, int j, int k)
28 * Returns the column position for the given base (1, 2, 3).
32 * @throws IllegalArgumentException
33 * if an argument value other than 1, 2 or 3 is supplied
35 public int getBaseColumn(int base)
37 if (base < 1 || base > 3)
39 throw new IllegalArgumentException(Integer.toString(base));
41 return base == 1 ? pos1 : (base == 2 ? pos2 : pos3);
45 * Two aligned codons are equal if all their base positions are the same.
48 public boolean equals(Object o)
51 * Equality with null value required for consistency with
58 if (!(o instanceof AlignedCodon))
62 AlignedCodon ac = (AlignedCodon) o;
63 return (pos1 == ac.pos1 && pos2 == ac.pos2 && pos3 == ac.pos3);
67 public String toString()
69 return "[" + pos1 + ", " + pos2 + ", " + pos3 + "]";